summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/traceback_arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/traceback_arm.c')
-rw-r--r--src/pkg/runtime/traceback_arm.c103
1 files changed, 44 insertions, 59 deletions
diff --git a/src/pkg/runtime/traceback_arm.c b/src/pkg/runtime/traceback_arm.c
index 22e0bc3a6..dd85cc02c 100644
--- a/src/pkg/runtime/traceback_arm.c
+++ b/src/pkg/runtime/traceback_arm.c
@@ -17,23 +17,23 @@ void _divu(void);
void _modu(void);
int32
-runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, int32 max)
+runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *gp, int32 skip, uintptr *pcbuf, int32 max)
{
int32 i, n, iter;
uintptr pc, lr, tracepc, x;
- byte *fp, *p;
+ byte *fp;
bool waspanic;
Stktop *stk;
Func *f;
-
+
pc = (uintptr)pc0;
lr = (uintptr)lr0;
fp = nil;
waspanic = false;
// If the PC is goexit, the goroutine hasn't started yet.
- if(pc == (uintptr)runtime·goexit) {
- pc = (uintptr)g->entry;
+ if(pc == (uintptr)runtime·goexit && gp->fnstart != nil) {
+ pc = (uintptr)gp->fnstart->fn;
lr = (uintptr)runtime·goexit;
}
@@ -45,7 +45,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
n = 0;
- stk = (Stktop*)g->stackbase;
+ stk = (Stktop*)gp->stackbase;
for(iter = 0; iter < 100 && n < max; iter++) { // iter avoids looping forever
// Typically:
// pc is the PC of the running function.
@@ -57,52 +57,17 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
if(pc == (uintptr)runtime·lessstack) {
// Hit top of stack segment. Unwind to next segment.
pc = (uintptr)stk->gobuf.pc;
- sp = stk->gobuf.sp;
+ sp = (byte*)stk->gobuf.sp;
lr = 0;
fp = nil;
- if(pcbuf == nil)
+ if(pcbuf == nil && runtime·showframe(nil, gp == m->curg))
runtime·printf("----- stack segment boundary -----\n");
stk = (Stktop*)stk->stackbase;
continue;
}
- if(pc <= 0x1000 || (f = runtime·findfunc(pc)) == nil) {
- // Dangerous, but worthwhile: see if this is a closure by
- // decoding the instruction stream.
- //
- // We check p < p+4 to avoid wrapping and faulting if
- // we have lost track of where we are.
- p = (byte*)pc;
- if((pc&3) == 0 && p < p+4 &&
- runtime·mheap.arena_start < p &&
- p+4 < runtime·mheap.arena_used) {
- x = *(uintptr*)p;
- if((x&0xfffff000) == 0xe49df000) {
- // End of closure:
- // MOVW.P frame(R13), R15
- pc = *(uintptr*)sp;
- lr = 0;
- sp += x & 0xfff;
- fp = nil;
- continue;
- }
- if((x&0xfffff000) == 0xe52de000 && lr == (uintptr)runtime·goexit) {
- // Beginning of closure.
- // Closure at top of stack, not yet started.
- p += 5*4;
- if((x&0xfff) != 4) {
- // argument copying
- p += 7*4;
- }
- if((byte*)pc < p && p < p+4 && p+4 < runtime·mheap.arena_used) {
- pc = *(uintptr*)p;
- fp = nil;
- continue;
- }
- }
- }
+ if(pc <= 0x1000 || (f = runtime·findfunc(pc)) == nil)
break;
- }
// Found an actual function.
if(lr == 0)
@@ -118,15 +83,17 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
else if(pcbuf != nil)
pcbuf[n++] = pc;
else {
- if(runtime·showframe(f)) {
+ if(runtime·showframe(f, gp == m->curg)) {
// Print during crash.
// main(0x1, 0x2, 0x3)
// /home/rsc/go/src/runtime/x.go:23 +0xf
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry && !waspanic)
tracepc -= sizeof(uintptr);
+ if(m->throwing && gp == m->curg)
+ runtime·printf("[fp=%p] ", fp);
runtime·printf("%S(", f->name);
- for(i = 0; i < f->args; i++) {
+ for(i = 0; i < f->args/sizeof(uintptr); i++) {
if(i != 0)
runtime·prints(", ");
runtime·printhex(((uintptr*)fp)[1+i]);
@@ -146,22 +113,22 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
waspanic = f->entry == (uintptr)runtime·sigpanic;
- if(pcbuf == nil && f->entry == (uintptr)runtime·newstack && g == m->g0) {
- runtime·printf("----- newstack called from goroutine %d -----\n", m->curg->goid);
+ if(pcbuf == nil && f->entry == (uintptr)runtime·newstack && gp == m->g0) {
+ runtime·printf("----- newstack called from goroutine %D -----\n", m->curg->goid);
pc = (uintptr)m->morepc;
sp = (byte*)m->moreargp - sizeof(void*);
lr = (uintptr)m->morebuf.pc;
- fp = m->morebuf.sp;
- g = m->curg;
- stk = (Stktop*)g->stackbase;
+ fp = (byte*)m->morebuf.sp;
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
continue;
}
- if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && g == m->g0) {
- runtime·printf("----- lessstack called from goroutine %d -----\n", m->curg->goid);
- g = m->curg;
- stk = (Stktop*)g->stackbase;
- sp = stk->gobuf.sp;
+ if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && gp == m->g0) {
+ runtime·printf("----- lessstack called from goroutine %D -----\n", m->curg->goid);
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
+ sp = (byte*)stk->gobuf.sp;
pc = (uintptr)stk->gobuf.pc;
fp = nil;
lr = 0;
@@ -182,9 +149,21 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
// If this was deferproc or newproc, the caller had an extra 12.
if(f->entry == (uintptr)runtime·deferproc || f->entry == (uintptr)runtime·newproc)
sp += 12;
+
+ // sighandler saves the lr on stack before faking a call to sigpanic
+ if(waspanic) {
+ x = *(uintptr *)sp;
+ sp += 4;
+ f = runtime·findfunc(pc);
+ if (f == nil) {
+ pc = x;
+ } else if (f->frame == 0)
+ lr = x;
+ }
}
- if(pcbuf == nil && (pc = g->gopc) != 0 && (f = runtime·findfunc(pc)) != nil && g->goid != 1) {
+ if(pcbuf == nil && (pc = gp->gopc) != 0 && (f = runtime·findfunc(pc)) != nil
+ && runtime·showframe(f, gp == m->curg) && gp->goid != 1) {
runtime·printf("created by %S\n", f->name);
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry)
@@ -199,9 +178,15 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
void
-runtime·traceback(byte *pc0, byte *sp, byte *lr, G *g)
+runtime·traceback(byte *pc0, byte *sp, byte *lr, G *gp)
{
- runtime·gentraceback(pc0, sp, lr, g, 0, nil, 100);
+ if(gp->status == Gsyscall) {
+ // Override signal registers if blocked in system call.
+ pc0 = gp->sched.pc;
+ sp = (byte*)gp->sched.sp;
+ lr = nil;
+ }
+ runtime·gentraceback(pc0, sp, lr, gp, 0, nil, 100);
}
// func caller(n int) (pc uintptr, file string, line int, ok bool)