1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:34:40 -07:00

remove special trap-handling code for array out of bounds -

compiler doesn't generate them any more

R=ken
OCL=15309
CL=15309
This commit is contained in:
Rob Pike 2008-09-13 13:13:36 -07:00
parent ddc7bc5aba
commit c1ad0509ee
2 changed files with 11 additions and 76 deletions

View File

@ -130,37 +130,6 @@ typedef struct sigaction {
int32 sa_flags; /* see signal options below */ int32 sa_flags; /* see signal options below */
} sigaction; } sigaction;
/*
* For trace traps, disassemble instruction to see if it's INTB of known type.
*/
int32
inlinetrap(int32 sig, byte* pc)
{
extern void etext();
extern void _rt0_amd64_darwin();
if(sig != 5) /* INTB 5 looks like TRAP */
return 0;
pc -= 2; // mac steps across INTB
if(pc < (byte*)_rt0_amd64_darwin || pc+2 >= (byte*)etext)
return 0;
if(pc[0] != 0xcd) /* INTB */
return 0;
switch(pc[1]) {
case 5:
prints("\nTRAP: array out of bounds\n");
break;
case 6:
prints("\nTRAP: leaving function with returning a value\n");
break;
default:
prints("\nTRAP: unknown run-time trap ");
sys·printint(pc[1]);
prints("\n");
}
return 1;
}
void void
sighandler(int32 sig, siginfo *info, void *context) sighandler(int32 sig, siginfo *info, void *context)
{ {
@ -170,14 +139,12 @@ sighandler(int32 sig, siginfo *info, void *context)
_STRUCT_MCONTEXT64 *uc_mcontext = get_uc_mcontext(context); _STRUCT_MCONTEXT64 *uc_mcontext = get_uc_mcontext(context);
_STRUCT_X86_THREAD_STATE64 *ss = get___ss(uc_mcontext); _STRUCT_X86_THREAD_STATE64 *ss = get___ss(uc_mcontext);
if(!inlinetrap(sig, (byte *)ss->__rip)) {
if(sig < 0 || sig >= NSIG){ if(sig < 0 || sig >= NSIG){
prints("Signal "); prints("Signal ");
sys·printint(sig); sys·printint(sig);
}else{ }else{
prints(sigtab[sig].name); prints(sigtab[sig].name);
} }
}
prints("\nFaulting address: 0x"); sys·printpointer(info->si_addr); prints("\nFaulting address: 0x"); sys·printpointer(info->si_addr);
prints("\npc: 0x"); sys·printpointer((void *)ss->__rip); prints("\npc: 0x"); sys·printpointer((void *)ss->__rip);

View File

@ -129,41 +129,11 @@ typedef struct sigaction {
void (*sa_handler)(int32); void (*sa_handler)(int32);
void (*sa_sigaction)(int32, siginfo *, void *); void (*sa_sigaction)(int32, siginfo *, void *);
} u; /* signal handler */ } u; /* signal handler */
uint8 sa_mask[128]; /* signal mask to apply. 128? are they MORONS? */ uint8 sa_mask[128]; /* signal mask to apply. 128? are they KIDDING? */
int32 sa_flags; /* see signal options below */ int32 sa_flags; /* see signal options below */
void (*sa_restorer) (void); /* unused here; needed to return from trap? */ void (*sa_restorer) (void); /* unused here; needed to return from trap? */
} sigaction; } sigaction;
/*
* For trace traps, disassemble instruction to see if it's INTB of known type.
*/
int32
inlinetrap(int32 sig, byte* pc)
{
extern void etext();
extern void _rt0_amd64_linux();
if(sig != 5 && sig != 11) /* 5 is for trap, but INTB 5 looks like SEGV */
return 0;
if(pc < (byte*)_rt0_amd64_linux || pc+2 >= (byte*)etext)
return 0;
if(pc[0] != 0xcd) /* INTB */
return 0;
switch(pc[1]) {
case 5:
prints("\nTRAP: array out of bounds\n");
break;
case 6:
prints("\nTRAP: leaving function with returning a value\n");
break;
default:
prints("\nTRAP: unknown run-time trap ");
sys·printint(pc[1]);
prints("\n");
}
return 1;
}
void void
sighandler(int32 sig, siginfo* info, void** context) sighandler(int32 sig, siginfo* info, void** context)
{ {
@ -172,14 +142,12 @@ sighandler(int32 sig, siginfo* info, void** context)
struct sigcontext *sc = &(((struct ucontext *)context)->uc_mcontext); struct sigcontext *sc = &(((struct ucontext *)context)->uc_mcontext);
if(!inlinetrap(sig, (byte *)sc->rip)) {
if(sig < 0 || sig >= NSIG){ if(sig < 0 || sig >= NSIG){
prints("Signal "); prints("Signal ");
sys·printint(sig); sys·printint(sig);
}else{ }else{
prints(sigtab[sig].name); prints(sigtab[sig].name);
} }
}
prints("\nFaulting address: 0x"); sys·printpointer(info->si_addr); prints("\nFaulting address: 0x"); sys·printpointer(info->si_addr);
prints("\npc: 0x"); sys·printpointer((void *)sc->rip); prints("\npc: 0x"); sys·printpointer((void *)sc->rip);