1
0
mirror of https://github.com/golang/go synced 2024-11-24 20:50:11 -07:00

runtime: better trace for fault due to nil pointer call

R=r
CC=golang-dev
https://golang.org/cl/854048
This commit is contained in:
Russ Cox 2010-04-13 22:31:47 -07:00
parent 035265975f
commit c3e54f0988
7 changed files with 72 additions and 20 deletions

View File

@ -66,10 +66,18 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->eip != 0.
// If r->eip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->eip != 0) {
sp = (uintptr*)r->esp;
*--sp = r->eip;
r->eip = (uintptr)sigpanic;
r->esp = (uintptr)sp;
}
r->eip = (uintptr)sigpanic;
return;
}

View File

@ -75,10 +75,18 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->rip != 0.
// If r->rip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->rip != 0) {
sp = (uintptr*)r->rsp;
*--sp = r->rip;
r->rip = (uintptr)sigpanic;
r->rsp = (uintptr)sp;
}
r->rip = (uintptr)sigpanic;
return;
}

View File

@ -64,10 +64,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->mc_eip != 0.
// If r->mc_eip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->mc_eip != 0) {
sp = (uintptr*)r->mc_esp;
*--sp = r->mc_eip;
r->mc_eip = (uintptr)sigpanic;
r->mc_esp = (uintptr)sp;
}
r->mc_eip = (uintptr)sigpanic;
return;
}

View File

@ -72,10 +72,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->mc_rip != 0.
// If r->mc_rip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->mc_rip != 0) {
sp = (uintptr*)r->mc_rsp;
*--sp = r->mc_rip;
r->mc_rip = (uintptr)sigpanic;
r->mc_rsp = (uintptr)sp;
}
r->mc_rip = (uintptr)sigpanic;
return;
}

View File

@ -61,10 +61,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = ((uintptr*)info)[3];
// Only push sigpanic if r->eip != 0.
// If r->eip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->eip != 0) {
sp = (uintptr*)r->esp;
*--sp = r->eip;
r->eip = (uintptr)sigpanic;
r->esp = (uintptr)sp;
}
r->eip = (uintptr)sigpanic;
return;
}

View File

@ -71,10 +71,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = ((uintptr*)info)[2];
// Only push sigpanic if r->rip != 0.
// If r->rip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// won't get to see who faulted.)
if(r->rip != 0) {
sp = (uintptr*)r->rsp;
*--sp = r->rip;
r->rip = (uintptr)sigpanic;
r->rsp = (uintptr)sp;
}
r->rip = (uintptr)sigpanic;
return;
}

View File

@ -70,6 +70,10 @@ sighandler(int32 sig, Siginfo *info, void *context)
// If this is a leaf function, we do smash LR,
// but we're not going back there anyway.
// Don't bother smashing if r->arm_pc is 0,
// which is probably a call to a nil func: the
// old link register is more useful in the stack trace.
if(r->arm_pc != 0)
r->arm_lr = r->arm_pc;
r->arm_pc = (uintptr)sigpanic;
return;