2009-06-10 12:53:07 -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.
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-12-16 13:33:58 -07:00
|
|
|
#include "arch_GOARCH.h"
|
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
|
|
|
#include "malloc.h"
|
|
|
|
|
|
|
|
void runtime·deferproc(void);
|
|
|
|
void runtime·newproc(void);
|
|
|
|
void runtime·newstack(void);
|
|
|
|
void runtime·morestack(void);
|
2011-07-25 22:52:46 -06:00
|
|
|
void runtime·sigpanic(void);
|
2011-02-18 11:30:29 -07:00
|
|
|
void _div(void);
|
|
|
|
void _mod(void);
|
|
|
|
void _divu(void);
|
|
|
|
void _modu(void);
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2011-03-25 10:30:49 -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)
|
2010-04-05 13:51:09 -06:00
|
|
|
{
|
2013-03-28 15:36:23 -06:00
|
|
|
int32 i, n;
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr x, tracepc;
|
|
|
|
bool waspanic, printing;
|
|
|
|
Func *f, *f2;
|
|
|
|
Stkframe frame;
|
2010-04-05 13:51:09 -06:00
|
|
|
Stktop *stk;
|
2013-01-29 03:57:11 -07:00
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·memclr((byte*)&frame, sizeof frame);
|
|
|
|
frame.pc = pc0;
|
|
|
|
frame.lr = lr0;
|
|
|
|
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
|
|
|
|
|
|
|
// If the PC is goexit, the goroutine hasn't started yet.
|
2013-06-12 06:49:38 -06:00
|
|
|
if(frame.pc == (uintptr)runtime·goexit && gp->fnstart != nil) {
|
|
|
|
frame.pc = (uintptr)gp->fnstart->fn;
|
|
|
|
frame.lr = (uintptr)runtime·goexit;
|
2010-05-21 15:40:21 -06:00
|
|
|
}
|
2010-04-05 13:51:09 -06: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 = frame.lr;
|
|
|
|
frame.lr = 0;
|
2010-04-05 13:51:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
n = 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-04-05 13:51:09 -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");
|
2010-04-05 13:51:09 -06:00
|
|
|
stk = (Stktop*)stk->stackbase;
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
|
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-04-05 13:51:09 -06:00
|
|
|
break;
|
2013-03-28 15:36:23 -06:00
|
|
|
}
|
2010-04-05 13:51:09 -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.lr == 0)
|
|
|
|
frame.lr = *(uintptr*)frame.sp;
|
|
|
|
if(frame.fp == 0) {
|
|
|
|
frame.fp = frame.sp;
|
|
|
|
if(frame.pc > f->entry && f->frame >= sizeof(uintptr))
|
|
|
|
frame.fp += f->frame;
|
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
|
|
|
}
|
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
// Derive size of arguments.
|
|
|
|
frame.argp = (byte*)frame.fp + sizeof(uintptr);
|
|
|
|
frame.arglen = 0;
|
|
|
|
if(f->args != ArgsSizeUnknown)
|
|
|
|
frame.arglen = f->args;
|
|
|
|
else if(frame.pc == (uintptr)runtime·goexit || f->entry == (uintptr)runtime·mcall || f->entry == (uintptr)runtime·mstart || f->entry == (uintptr)_rt0_go)
|
|
|
|
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)
|
|
|
|
frame.arglen = 2*sizeof(uintptr) + ((uintptr*)frame.argp)[1];
|
|
|
|
else if((f2 = runtime·findfunc(frame.lr)) != nil && f2->frame >= sizeof(uintptr))
|
|
|
|
frame.arglen = f2->frame; // conservative overestimate
|
2010-04-05 13:51:09 -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.
|
|
|
|
if(frame.fp == frame.sp) {
|
|
|
|
// 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 - frame.sp;
|
|
|
|
} else {
|
|
|
|
if(f->locals > frame.fp - 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 - 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 -= sizeof(uintptr);
|
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-04-05 13:51:09 -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");
|
2010-04-05 13:51:09 -06:00
|
|
|
}
|
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
n++;
|
2011-07-25 22:52:46 -06:00
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
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
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
if(printing && f->entry == (uintptr)runtime·newstack && gp == m->g0) {
|
2012-10-26 00:13:06 -06:00
|
|
|
runtime·printf("----- newstack called from goroutine %D -----\n", m->curg->goid);
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.pc = (uintptr)m->morepc;
|
|
|
|
frame.sp = (uintptr)m->moreargp - sizeof(void*);
|
|
|
|
frame.lr = m->morebuf.pc;
|
|
|
|
frame.fp = m->morebuf.sp;
|
2012-12-18 09:30:29 -07:00
|
|
|
gp = m->curg;
|
|
|
|
stk = (Stktop*)gp->stackbase;
|
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
|
|
|
continue;
|
|
|
|
}
|
2010-04-05 13:51:09 -06:00
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
if(printing && f->entry == (uintptr)runtime·lessstack && gp == m->g0) {
|
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;
|
2011-02-18 11:30:29 -07:00
|
|
|
|
|
|
|
// If this was div or divu or mod or modu, the caller had
|
|
|
|
// an extra 8 bytes on its stack. Adjust sp.
|
|
|
|
if(f->entry == (uintptr)_div || f->entry == (uintptr)_divu || f->entry == (uintptr)_mod || f->entry == (uintptr)_modu)
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.sp += 8;
|
2011-02-18 11:30:29 -07:00
|
|
|
|
|
|
|
// If this was deferproc or newproc, the caller had an extra 12.
|
|
|
|
if(f->entry == (uintptr)runtime·deferproc || f->entry == (uintptr)runtime·newproc)
|
2013-06-12 06:49:38 -06:00
|
|
|
frame.sp += 12;
|
2013-02-05 10:18:37 -07:00
|
|
|
|
2013-02-07 22:24:38 -07:00
|
|
|
// sighandler saves the lr on stack before faking a call to sigpanic
|
2013-02-05 10:18:37 -07:00
|
|
|
if(waspanic) {
|
2013-06-12 06:49:38 -06:00
|
|
|
x = *(uintptr*)frame.sp;
|
|
|
|
frame.sp += 4;
|
|
|
|
frame.fn = f = runtime·findfunc(frame.pc);
|
|
|
|
if(f == nil)
|
|
|
|
frame.pc = x;
|
|
|
|
else if (f->frame == 0)
|
|
|
|
frame.lr = x;
|
2013-02-05 10:18:37 -07:00
|
|
|
}
|
2010-04-05 13:51:09 -06:00
|
|
|
}
|
2011-03-02 11:42:02 -07:00
|
|
|
|
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 -= sizeof(uintptr);
|
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
|
|
|
}
|
|
|
|
|
2010-04-05 13:51:09 -06:00
|
|
|
return n;
|
|
|
|
}
|
2009-06-10 12:53:07 -06:00
|
|
|
|
|
|
|
void
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
|
2009-06-10 12:53:07 -06:00
|
|
|
{
|
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;
|
|
|
|
lr = 0;
|
2013-02-01 09:34:41 -07:00
|
|
|
}
|
2013-06-12 06:49:38 -06:00
|
|
|
runtime·gentraceback(pc, sp, lr, gp, 0, nil, 100, nil, nil);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// func caller(n int) (pc uintptr, file string, line int, ok bool)
|
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)
|
2009-06-10 12:53:07 -06:00
|
|
|
{
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr pc, sp;
|
2010-04-05 13:51:09 -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
|
|
|
sp = runtime·getcallersp(&skip);
|
2013-06-12 06:49:38 -06:00
|
|
|
pc = (uintptr)runtime·getcallerpc(&skip);
|
2010-04-05 13:51:09 -06:00
|
|
|
|
2013-03-28 15:36:23 -06:00
|
|
|
return runtime·gentraceback(pc, sp, 0, g, skip, pcbuf, m, nil, nil);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|