Commit c1ad0509 authored by Rob Pike's avatar Rob Pike

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

compiler doesn't generate them any more

R=ken
OCL=15309
CL=15309
parent ddc7bc5a
...@@ -130,37 +130,6 @@ typedef struct sigaction { ...@@ -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,13 +139,11 @@ sighandler(int32 sig, siginfo *info, void *context) ...@@ -170,13 +139,11 @@ 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);
......
...@@ -129,41 +129,11 @@ typedef struct sigaction { ...@@ -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,13 +142,11 @@ sighandler(int32 sig, siginfo* info, void** context) ...@@ -172,13 +142,11 @@ 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment