1
0
mirror of https://github.com/golang/go synced 2024-11-25 12:57:58 -07:00

safety checks, waiting for gri's real tracking of PC and SP

extant code is too fragile

SVN=124223
This commit is contained in:
Rob Pike 2008-06-23 20:12:39 -07:00
parent 7b409b30f2
commit d4c2da409b
2 changed files with 9 additions and 4 deletions

View File

@ -64,7 +64,7 @@ TEXT sys_sigaction(SB),1,$-8
CALL notok(SB)
RET
TEXT sigtramp(SB),1,$-24
TEXT sigtramp(SB),1,$24
MOVL DX,0(SP)
MOVQ CX,8(SP)
MOVQ R8,16(SP)

View File

@ -39,6 +39,7 @@ typedef struct sigaction {
void
sighandler(int32 sig, siginfo* info, void** context) {
int32 i;
void *pc, *sp;
if(sig < 0 || sig >= NSIG){
prints("Signal ");
@ -46,14 +47,18 @@ sighandler(int32 sig, siginfo* info, void** context) {
}else{
prints(sigtab[sig].name);
}
prints("\nFaulting address: 0x");
sys_printpointer(info->si_addr);
prints("\nPC: 0x");
sys_printpointer(((void**)((&sig)+1))[22]);
pc = ((void**)((&sig)+1))[22];
sys_printpointer(pc);
prints("\nSP: 0x");
sys_printpointer(((void**)((&sig)+1))[13]);
sp = ((void**)((&sig)+1))[13];
sys_printpointer(sp);
prints("\n");
traceback(((void**)((&sig)+1))[22], ((void**)((&sig)+1))[13]); /* empirically discovered locations */
if (pc != 0 && sp != 0)
traceback(pc, sp); /* empirically discovered locations */
sys_exit(2);
}