2008-06-21 16:36:23 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2011-12-16 13:46:25 -07:00
|
|
|
// +build amd64 386
|
|
|
|
|
2008-06-21 16:36:23 -06:00
|
|
|
#include "runtime.h"
|
2011-12-16 13:33:58 -07:00
|
|
|
#include "arch_GOARCH.h"
|
2010-03-23 18:01:17 -06:00
|
|
|
#include "malloc.h"
|
2008-06-21 16:36:23 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·deferproc(void);
|
|
|
|
void runtime·newproc(void);
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
void runtime·newstack(void);
|
|
|
|
void runtime·morestack(void);
|
2011-07-25 22:52:46 -06:00
|
|
|
void runtime·sigpanic(void);
|
2010-05-21 15:40:21 -06:00
|
|
|
|
2010-03-23 18:01:17 -06:00
|
|
|
// This code is also used for the 386 tracebacks.
|
|
|
|
// Use uintptr for an appropriate word-sized integer.
|
|
|
|
|
2013-03-28 15:36:23 -06:00
|
|
|
// Generic traceback. Handles runtime stack prints (pcbuf == nil),
|
|
|
|
// the runtime.Callers function (pcbuf != nil), as well as the garbage
|
2013-06-12 06:49:38 -06:00
|
|
|
// collector (callback != nil). A little clunky to merge these, but avoids
|
2013-03-28 15:36:23 -06:00
|
|
|
// duplicating the code and all its subtlety.
|
2011-03-23 09:43:37 -06:00
|
|
|
int32
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·gentraceback(uintptr pc0, uintptr sp0, uintptr lr0, G *gp, int32 skip, uintptr *pcbuf, int32 max, void (*callback)(Stkframe*, void*), void *v)
|
2008-06-21 16:36:23 -06:00
|
|
|
{
|
2013-03-28 15:36:23 -06:00
|
|
|
int32 i, n, sawnewstack;
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr tracepc;
|
|
|
|
bool waspanic, printing;
|
|
|
|
Func *f, *f2;
|
|
|
|
Stkframe frame;
|
clean stack trace code.
format is unchanged but shows all frames
(old loop stopped one frame early).
wreck=; 6.out
cannot convert type *main.S·interface2 to interface main.I·interface2: missing method Foo
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
pc: 0x256d
throw+0x46 /home/rsc/go/src/runtime/runtime.c:68
throw(0x863a, 0x0)
hashmap+0x188 /home/rsc/go/src/runtime/iface.c:167
hashmap(0x8760, 0x0, 0x85b0, 0x0, 0x0, ...)
sys·ifaceT2I+0xa8 /home/rsc/go/src/runtime/iface.c:201
sys·ifaceT2I(0x8760, 0x0, 0x85b0, 0x0, 0x0, ...)
main·main+0x4e /home/rsc/go/src/runtime/rt0_amd64_darwin.s:87
main·main()
mainstart+0xf /home/rsc/go/src/runtime/rt0_amd64.s:70
mainstart()
sys·goexit /home/rsc/go/src/runtime/proc.c:110
sys·goexit()
R=r
DELTA=44 (5 added, 15 deleted, 24 changed)
OCL=20358
CL=20368
2008-12-03 15:20:23 -07:00
|
|
|
Stktop *stk;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
|
2011-03-23 09:43:37 -06:00
|
|
|
USED(lr0);
|
2013-06-12 06:49:38 -06:00
|
|
|
|
|
|
|
runtime·memclr((byte*)&frame, sizeof frame);
|
|
|
|
frame.pc = pc0;
|
|
|
|
frame.sp = sp0;
|
2011-07-25 22:52:46 -06:00
|
|
|
waspanic = false;
|
2013-06-12 06:49:38 -06:00
|
|
|
printing = pcbuf==nil && callback==nil;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
|
clean stack trace code.
format is unchanged but shows all frames
(old loop stopped one frame early).
wreck=; 6.out
cannot convert type *main.S·interface2 to interface main.I·interface2: missing method Foo
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
pc: 0x256d
throw+0x46 /home/rsc/go/src/runtime/runtime.c:68
throw(0x863a, 0x0)
hashmap+0x188 /home/rsc/go/src/runtime/iface.c:167
hashmap(0x8760, 0x0, 0x85b0, 0x0, 0x0, ...)
sys·ifaceT2I+0xa8 /home/rsc/go/src/runtime/iface.c:201
sys·ifaceT2I(0x8760, 0x0, 0x85b0, 0x0, 0x0, ...)
main·main+0x4e /home/rsc/go/src/runtime/rt0_amd64_darwin.s:87
main·main()
mainstart+0xf /home/rsc/go/src/runtime/rt0_amd64.s:70
mainstart()
sys·goexit /home/rsc/go/src/runtime/proc.c:110
sys·goexit()
R=r
DELTA=44 (5 added, 15 deleted, 24 changed)
OCL=20358
CL=20368
2008-12-03 15:20:23 -07:00
|
|
|
// If the PC is zero, it's likely a nil function call.
|
|
|
|
// Start in the caller's frame.
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc == 0) {
|
|
|
|
frame.pc = *(uintptr*)frame.sp;
|
|
|
|
frame.sp += sizeof(uintptr);
|
2008-11-03 16:22:15 -07:00
|
|
|
}
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
|
2010-03-23 18:01:17 -06:00
|
|
|
n = 0;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
sawnewstack = 0;
|
2012-12-18 09:30:29 -07:00
|
|
|
stk = (Stktop*)gp->stackbase;
|
2013-03-28 15:36:23 -06:00
|
|
|
while(n < max) {
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
// Typically:
|
|
|
|
// pc is the PC of the running function.
|
|
|
|
// sp is the stack pointer at that program counter.
|
|
|
|
// fp is the frame pointer (caller's stack pointer) at that program counter, or nil if unknown.
|
|
|
|
// stk is the stack containing sp.
|
|
|
|
// The caller's program counter is lr, unless lr is zero, in which case it is *(uintptr*)sp.
|
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc == (uintptr)runtime·lessstack) {
|
2010-03-23 18:01:17 -06:00
|
|
|
// Hit top of stack segment. Unwind to next segment.
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.pc = stk->gobuf.pc;
|
|
|
|
frame.sp = stk->gobuf.sp;
|
|
|
|
frame.lr = 0;
|
|
|
|
frame.fp = 0;
|
|
|
|
if(printing && runtime·showframe(nil, gp == m->curg))
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
runtime·printf("----- stack segment boundary -----\n");
|
2009-06-17 16:12:16 -06:00
|
|
|
stk = (Stktop*)stk->stackbase;
|
2010-03-23 18:01:17 -06:00
|
|
|
continue;
|
2008-06-30 15:39:47 -06:00
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc <= 0x1000 || (frame.fn = f = runtime·findfunc(frame.pc)) == nil) {
|
|
|
|
if(callback != nil)
|
2013-03-28 15:36:23 -06:00
|
|
|
runtime·throw("unknown pc");
|
2010-03-23 18:01:17 -06:00
|
|
|
break;
|
2013-03-28 15:36:23 -06:00
|
|
|
}
|
2008-06-30 15:39:47 -06:00
|
|
|
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
// Found an actual function.
|
2013-06-12 06:49:38 -06:00
|
|
|
// Derive frame pointer and link register.
|
|
|
|
if(frame.fp == 0) {
|
|
|
|
frame.fp = frame.sp;
|
|
|
|
if(frame.pc > f->entry && f->frame >= sizeof(uintptr))
|
|
|
|
frame.fp += f->frame;
|
|
|
|
else
|
|
|
|
frame.fp += sizeof(uintptr);
|
|
|
|
}
|
|
|
|
if(frame.lr == 0)
|
|
|
|
frame.lr = ((uintptr*)frame.fp)[-1];
|
|
|
|
|
|
|
|
// Derive size of arguments.
|
|
|
|
frame.argp = (byte*)frame.fp;
|
|
|
|
frame.arglen = 0;
|
|
|
|
if(f->args != ArgsSizeUnknown)
|
|
|
|
frame.arglen = f->args;
|
2013-06-12 13:22:26 -06:00
|
|
|
else if(runtime·haszeroargs(f->entry))
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.arglen = 0;
|
|
|
|
else if(frame.lr == (uintptr)runtime·lessstack)
|
|
|
|
frame.arglen = stk->argsize;
|
|
|
|
else if(f->entry == (uintptr)runtime·deferproc || f->entry == (uintptr)runtime·newproc)
|
2013-06-12 13:22:26 -06:00
|
|
|
frame.arglen = 2*sizeof(uintptr) + *(int32*)frame.argp;
|
2013-06-12 06:49:38 -06:00
|
|
|
else if((f2 = runtime·findfunc(frame.lr)) != nil && f2->frame >= sizeof(uintptr))
|
|
|
|
frame.arglen = f2->frame; // conservative overestimate
|
2010-03-23 18:01:17 -06:00
|
|
|
else {
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·printf("runtime: unknown argument frame size for %S\n", f->name);
|
|
|
|
runtime·throw("invalid stack");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Derive location and size of local variables.
|
2013-06-12 07:06:28 -06:00
|
|
|
if(frame.fp == frame.sp + sizeof(uintptr)) {
|
2013-06-12 06:49:38 -06:00
|
|
|
// Function has not created a frame for itself yet.
|
|
|
|
frame.varp = nil;
|
|
|
|
frame.varlen = 0;
|
|
|
|
} else if(f->locals == 0) {
|
|
|
|
// Assume no information, so use whole frame.
|
|
|
|
// TODO: Distinguish local==0 from local==unknown.
|
|
|
|
frame.varp = (byte*)frame.sp;
|
|
|
|
frame.varlen = frame.fp - sizeof(uintptr) - frame.sp;
|
|
|
|
} else {
|
|
|
|
if(f->locals > frame.fp - sizeof(uintptr) - frame.sp) {
|
|
|
|
runtime·printf("runtime: inconsistent locals=%p frame=%p fp=%p sp=%p for %S\n", (uintptr)f->locals, (uintptr)f->frame, frame.fp, frame.sp, f->name);
|
|
|
|
runtime·throw("invalid stack");
|
|
|
|
}
|
|
|
|
frame.varp = (byte*)frame.fp - sizeof(uintptr) - f->locals;
|
|
|
|
frame.varlen = f->locals;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(skip > 0) {
|
|
|
|
skip--;
|
|
|
|
goto skipped;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pcbuf != nil)
|
|
|
|
pcbuf[n] = frame.pc;
|
|
|
|
if(callback != nil)
|
|
|
|
callback(&frame, v);
|
|
|
|
if(printing) {
|
2013-01-29 03:57:11 -07:00
|
|
|
if(runtime·showframe(f, gp == m->curg)) {
|
2011-08-22 21:26:39 -06:00
|
|
|
// Print during crash.
|
|
|
|
// main(0x1, 0x2, 0x3)
|
|
|
|
// /home/rsc/go/src/runtime/x.go:23 +0xf
|
|
|
|
//
|
2013-06-12 06:49:38 -06:00
|
|
|
tracepc = frame.pc; // back up to CALL instruction for funcline.
|
|
|
|
if(n > 0 && frame.pc > f->entry && !waspanic)
|
2011-08-22 21:26:39 -06:00
|
|
|
tracepc--;
|
2013-02-15 12:48:47 -07:00
|
|
|
if(m->throwing && gp == m->curg)
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·printf("[fp=%p] ", frame.fp);
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("%S(", f->name);
|
cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information
Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.
This change populates the func structure with args and locals
values computed by the compiler. The number of args was
already available in the ATEXT instruction. The number of
locals is now passed through in the new ALOCALS instruction.
This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.
R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045
2013-02-21 13:52:26 -07:00
|
|
|
for(i = 0; i < f->args/sizeof(uintptr); i++) {
|
2011-08-22 21:26:39 -06:00
|
|
|
if(i != 0)
|
|
|
|
runtime·prints(", ");
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·printhex(((uintptr*)frame.argp)[i]);
|
2011-08-22 21:26:39 -06:00
|
|
|
if(i >= 4) {
|
|
|
|
runtime·prints(", ...");
|
|
|
|
break;
|
|
|
|
}
|
2010-03-23 18:01:17 -06:00
|
|
|
}
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·prints(")\n");
|
|
|
|
runtime·printf("\t%S:%d", f->src, runtime·funcline(f, tracepc));
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc > f->entry)
|
|
|
|
runtime·printf(" +%p", (uintptr)(frame.pc - f->entry));
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("\n");
|
2008-11-25 18:17:54 -07:00
|
|
|
}
|
2008-06-21 16:36:23 -06:00
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
n++;
|
|
|
|
|
|
|
|
skipped:
|
2011-07-25 22:52:46 -06:00
|
|
|
waspanic = f->entry == (uintptr)runtime·sigpanic;
|
|
|
|
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
if(f->entry == (uintptr)runtime·deferproc || f->entry == (uintptr)runtime·newproc)
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.fp += 2*sizeof(uintptr);
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
|
|
|
|
if(f->entry == (uintptr)runtime·newstack)
|
|
|
|
sawnewstack = 1;
|
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
if(printing && f->entry == (uintptr)runtime·morestack && gp == m->g0 && sawnewstack) {
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
// The fact that we saw newstack means that morestack
|
|
|
|
// has managed to record its information in m, so we can
|
|
|
|
// use it to keep unwinding the stack.
|
2012-10-26 00:13:06 -06:00
|
|
|
runtime·printf("----- morestack called from goroutine %D -----\n", m->curg->goid);
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.pc = (uintptr)m->morepc;
|
|
|
|
frame.sp = m->morebuf.sp - sizeof(void*);
|
|
|
|
frame.lr = m->morebuf.pc;
|
|
|
|
frame.fp = m->morebuf.sp;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
sawnewstack = 0;
|
2012-12-18 09:30:29 -07:00
|
|
|
gp = m->curg;
|
|
|
|
stk = (Stktop*)gp->stackbase;
|
2010-05-21 15:40:21 -06:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
if(printing && f->entry == (uintptr)runtime·lessstack && gp == m->g0) {
|
2011-02-23 12:47:22 -07:00
|
|
|
// Lessstack is running on scheduler stack. Switch to original goroutine.
|
2012-10-26 00:13:06 -06:00
|
|
|
runtime·printf("----- lessstack called from goroutine %D -----\n", m->curg->goid);
|
2012-12-18 09:30:29 -07:00
|
|
|
gp = m->curg;
|
|
|
|
stk = (Stktop*)gp->stackbase;
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.sp = stk->gobuf.sp;
|
|
|
|
frame.pc = stk->gobuf.pc;
|
|
|
|
frame.fp = 0;
|
|
|
|
frame.lr = 0;
|
2011-02-23 12:47:22 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-28 15:36:23 -06:00
|
|
|
// Do not unwind past the bottom of the stack.
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc == (uintptr)runtime·goexit || f->entry == (uintptr)runtime·mstart || f->entry == (uintptr)_rt0_go)
|
2013-03-28 15:36:23 -06:00
|
|
|
break;
|
|
|
|
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
// Unwind to next frame.
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.pc = frame.lr;
|
|
|
|
frame.lr = 0;
|
|
|
|
frame.sp = frame.fp;
|
|
|
|
frame.fp = 0;
|
2008-06-21 16:36:23 -06:00
|
|
|
}
|
2011-03-02 11:42:02 -07:00
|
|
|
|
2011-08-22 21:26:39 -06:00
|
|
|
// Show what created goroutine, except main goroutine (goid 1).
|
2013-06-12 06:49:38 -06:00
|
|
|
if(printing && (frame.pc = gp->gopc) != 0 && (f = runtime·findfunc(frame.pc)) != nil
|
2013-01-29 03:57:11 -07:00
|
|
|
&& runtime·showframe(f, gp == m->curg) && gp->goid != 1) {
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("created by %S\n", f->name);
|
2013-06-12 06:49:38 -06:00
|
|
|
tracepc = frame.pc; // back up to CALL instruction for funcline.
|
|
|
|
if(n > 0 && frame.pc > f->entry)
|
2011-03-02 11:42:02 -07:00
|
|
|
tracepc--;
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("\t%S:%d", f->src, runtime·funcline(f, tracepc));
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc > f->entry)
|
|
|
|
runtime·printf(" +%p", (uintptr)(frame.pc - f->entry));
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("\n");
|
2011-03-02 11:42:02 -07:00
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
|
2010-03-23 18:01:17 -06:00
|
|
|
return n;
|
2008-06-21 16:36:23 -06:00
|
|
|
}
|
2009-01-09 16:52:43 -07:00
|
|
|
|
|
|
|
void
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
|
2009-01-09 16:52:43 -07:00
|
|
|
{
|
2013-06-12 06:49:38 -06:00
|
|
|
USED(lr);
|
|
|
|
|
2013-02-01 09:34:41 -07:00
|
|
|
if(gp->status == Gsyscall) {
|
|
|
|
// Override signal registers if blocked in system call.
|
2013-06-12 06:49:38 -06:00
|
|
|
pc = gp->sched.pc;
|
|
|
|
sp = gp->sched.sp;
|
2013-02-01 09:34:41 -07:00
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·gentraceback(pc, sp, 0, gp, 0, nil, 100, nil, nil);
|
2010-03-23 18:01:17 -06:00
|
|
|
}
|
2009-01-09 16:52:43 -07:00
|
|
|
|
2010-03-23 18:01:17 -06:00
|
|
|
int32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·callers(int32 skip, uintptr *pcbuf, int32 m)
|
2010-03-23 18:01:17 -06:00
|
|
|
{
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr pc, sp;
|
2009-01-09 16:52:43 -07:00
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
sp = runtime·getcallersp(&skip);
|
|
|
|
pc = (uintptr)runtime·getcallerpc(&skip);
|
2009-01-09 16:52:43 -07:00
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
return runtime·gentraceback(pc, sp, 0, g, skip, pcbuf, m, nil, nil);
|
2009-01-09 16:52:43 -07:00
|
|
|
}
|