mirror of
https://github.com/golang/go
synced 2024-11-25 05:38:01 -07:00
FreeBSD's mcontext isn't exactly the same as sigcontext, so
we can't use them interchangably. R=rsc, wjosephson CC=golang-dev https://golang.org/cl/156113
This commit is contained in:
parent
7763345379
commit
7ada6018a7
@ -124,37 +124,4 @@ struct Ucontext {
|
|||||||
int32 __spare__[4];
|
int32 __spare__[4];
|
||||||
byte pad0[12];
|
byte pad0[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Sigcontext Sigcontext;
|
|
||||||
struct Sigcontext {
|
|
||||||
Sigset sc_mask;
|
|
||||||
int32 sc_onstack;
|
|
||||||
int32 sc_gs;
|
|
||||||
int32 sc_fs;
|
|
||||||
int32 sc_es;
|
|
||||||
int32 sc_ds;
|
|
||||||
int32 sc_edi;
|
|
||||||
int32 sc_esi;
|
|
||||||
int32 sc_ebp;
|
|
||||||
int32 sc_isp;
|
|
||||||
int32 sc_ebx;
|
|
||||||
int32 sc_edx;
|
|
||||||
int32 sc_ecx;
|
|
||||||
int32 sc_eax;
|
|
||||||
int32 sc_trapno;
|
|
||||||
int32 sc_err;
|
|
||||||
int32 sc_eip;
|
|
||||||
int32 sc_cs;
|
|
||||||
int32 sc_efl;
|
|
||||||
int32 sc_esp;
|
|
||||||
int32 sc_ss;
|
|
||||||
int32 sc_len;
|
|
||||||
int32 sc_fpformat;
|
|
||||||
int32 sc_ownedfp;
|
|
||||||
int32 sc_spare1[1];
|
|
||||||
int32 sc_fpstate[128];
|
|
||||||
int32 sc_fsbase;
|
|
||||||
int32 sc_gsbase;
|
|
||||||
int32 sc_spare2[6];
|
|
||||||
};
|
|
||||||
#pragma pack off
|
#pragma pack off
|
||||||
|
@ -15,21 +15,21 @@ typedef struct sigaction {
|
|||||||
} Sigaction;
|
} Sigaction;
|
||||||
|
|
||||||
void
|
void
|
||||||
dumpregs(Sigcontext *r)
|
dumpregs(Mcontext *r)
|
||||||
{
|
{
|
||||||
printf("eax %x\n", r->sc_eax);
|
printf("eax %x\n", r->mc_eax);
|
||||||
printf("ebx %x\n", r->sc_ebx);
|
printf("ebx %x\n", r->mc_ebx);
|
||||||
printf("ecx %x\n", r->sc_ecx);
|
printf("ecx %x\n", r->mc_ecx);
|
||||||
printf("edx %x\n", r->sc_edx);
|
printf("edx %x\n", r->mc_edx);
|
||||||
printf("edi %x\n", r->sc_edi);
|
printf("edi %x\n", r->mc_edi);
|
||||||
printf("esi %x\n", r->sc_esi);
|
printf("esi %x\n", r->mc_esi);
|
||||||
printf("ebp %x\n", r->sc_ebp);
|
printf("ebp %x\n", r->mc_ebp);
|
||||||
printf("esp %x\n", r->sc_esp);
|
printf("esp %x\n", r->mc_esp);
|
||||||
printf("eip %x\n", r->sc_eip);
|
printf("eip %x\n", r->mc_eip);
|
||||||
printf("eflags %x\n", r->sc_efl);
|
printf("eflags %x\n", r->mc_eflags);
|
||||||
printf("cs %x\n", r->sc_cs);
|
printf("cs %x\n", r->mc_cs);
|
||||||
printf("fs %x\n", r->sc_fsbase);
|
printf("fs %x\n", r->mc_fs);
|
||||||
printf("gs %x\n", r->sc_gsbase);
|
printf("gs %x\n", r->mc_gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -37,7 +37,6 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
{
|
{
|
||||||
Ucontext *uc;
|
Ucontext *uc;
|
||||||
Mcontext *mc;
|
Mcontext *mc;
|
||||||
Sigcontext *sc;
|
|
||||||
|
|
||||||
if(panicking) // traceback already printed
|
if(panicking) // traceback already printed
|
||||||
exit(2);
|
exit(2);
|
||||||
@ -45,7 +44,6 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
|
|
||||||
uc = context;
|
uc = context;
|
||||||
mc = &uc->uc_mcontext;
|
mc = &uc->uc_mcontext;
|
||||||
sc = (Sigcontext*)mc; // same layout, more conveient names
|
|
||||||
|
|
||||||
if(sig < 0 || sig >= NSIG)
|
if(sig < 0 || sig >= NSIG)
|
||||||
printf("Signal %d\n", sig);
|
printf("Signal %d\n", sig);
|
||||||
@ -53,13 +51,13 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
printf("%s\n", sigtab[sig].name);
|
printf("%s\n", sigtab[sig].name);
|
||||||
|
|
||||||
printf("Faulting address: %p\n", info->si_addr);
|
printf("Faulting address: %p\n", info->si_addr);
|
||||||
printf("PC=%X\n", sc->sc_eip);
|
printf("PC=%X\n", mc->mc_eip);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if(gotraceback()){
|
if(gotraceback()){
|
||||||
traceback((void*)sc->sc_eip, (void*)sc->sc_esp, m->curg);
|
traceback((void*)sc->sc_eip, (void*)mc->mc_esp, m->curg);
|
||||||
tracebackothers(m->curg);
|
tracebackothers(m->curg);
|
||||||
dumpregs(sc);
|
dumpregs(mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
breakpoint();
|
breakpoint();
|
||||||
|
@ -135,45 +135,4 @@ struct Ucontext {
|
|||||||
int32 __spare__[4];
|
int32 __spare__[4];
|
||||||
byte pad0[12];
|
byte pad0[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Sigcontext Sigcontext;
|
|
||||||
struct Sigcontext {
|
|
||||||
Sigset sc_mask;
|
|
||||||
int64 sc_onstack;
|
|
||||||
int64 sc_rdi;
|
|
||||||
int64 sc_rsi;
|
|
||||||
int64 sc_rdx;
|
|
||||||
int64 sc_rcx;
|
|
||||||
int64 sc_r8;
|
|
||||||
int64 sc_r9;
|
|
||||||
int64 sc_rax;
|
|
||||||
int64 sc_rbx;
|
|
||||||
int64 sc_rbp;
|
|
||||||
int64 sc_r10;
|
|
||||||
int64 sc_r11;
|
|
||||||
int64 sc_r12;
|
|
||||||
int64 sc_r13;
|
|
||||||
int64 sc_r14;
|
|
||||||
int64 sc_r15;
|
|
||||||
int32 sc_trapno;
|
|
||||||
int16 sc_fs;
|
|
||||||
int16 sc_gs;
|
|
||||||
int64 sc_addr;
|
|
||||||
int32 sc_flags;
|
|
||||||
int16 sc_es;
|
|
||||||
int16 sc_ds;
|
|
||||||
int64 sc_err;
|
|
||||||
int64 sc_rip;
|
|
||||||
int64 sc_cs;
|
|
||||||
int64 sc_rflags;
|
|
||||||
int64 sc_rsp;
|
|
||||||
int64 sc_ss;
|
|
||||||
int64 sc_len;
|
|
||||||
int64 sc_fpformat;
|
|
||||||
int64 sc_ownedfp;
|
|
||||||
int64 sc_fpstate[64];
|
|
||||||
int64 sc_fsbase;
|
|
||||||
int64 sc_gsbase;
|
|
||||||
int64 sc_spare[6];
|
|
||||||
};
|
|
||||||
#pragma pack off
|
#pragma pack off
|
||||||
|
@ -15,29 +15,29 @@ typedef struct sigaction {
|
|||||||
} Sigaction;
|
} Sigaction;
|
||||||
|
|
||||||
void
|
void
|
||||||
dumpregs(Sigcontext *r)
|
dumpregs(Mcontext *r)
|
||||||
{
|
{
|
||||||
printf("rax %X\n", r->sc_rax);
|
printf("rax %X\n", r->mc_rax);
|
||||||
printf("rbx %X\n", r->sc_rbx);
|
printf("rbx %X\n", r->mc_rbx);
|
||||||
printf("rcx %X\n", r->sc_rcx);
|
printf("rcx %X\n", r->mc_rcx);
|
||||||
printf("rdx %X\n", r->sc_rdx);
|
printf("rdx %X\n", r->mc_rdx);
|
||||||
printf("rdi %X\n", r->sc_rdi);
|
printf("rdi %X\n", r->mc_rdi);
|
||||||
printf("rsi %X\n", r->sc_rsi);
|
printf("rsi %X\n", r->mc_rsi);
|
||||||
printf("rbp %X\n", r->sc_rbp);
|
printf("rbp %X\n", r->mc_rbp);
|
||||||
printf("rsp %X\n", r->sc_rsp);
|
printf("rsp %X\n", r->mc_rsp);
|
||||||
printf("r8 %X\n", r->sc_r8 );
|
printf("r8 %X\n", r->mc_r8 );
|
||||||
printf("r9 %X\n", r->sc_r9 );
|
printf("r9 %X\n", r->mc_r9 );
|
||||||
printf("r10 %X\n", r->sc_r10);
|
printf("r10 %X\n", r->mc_r10);
|
||||||
printf("r11 %X\n", r->sc_r11);
|
printf("r11 %X\n", r->mc_r11);
|
||||||
printf("r12 %X\n", r->sc_r12);
|
printf("r12 %X\n", r->mc_r12);
|
||||||
printf("r13 %X\n", r->sc_r13);
|
printf("r13 %X\n", r->mc_r13);
|
||||||
printf("r14 %X\n", r->sc_r14);
|
printf("r14 %X\n", r->mc_r14);
|
||||||
printf("r15 %X\n", r->sc_r15);
|
printf("r15 %X\n", r->mc_r15);
|
||||||
printf("rip %X\n", r->sc_rip);
|
printf("rip %X\n", r->mc_rip);
|
||||||
printf("rflags %X\n", r->sc_flags);
|
printf("rflags %X\n", r->mc_flags);
|
||||||
printf("cs %X\n", (uint64)r->sc_cs);
|
printf("cs %X\n", r->mc_cs);
|
||||||
printf("fs %X\n", (uint64)r->sc_fsbase);
|
printf("fs %X\n", r->mc_fs);
|
||||||
printf("gs %X\n", (uint64)r->sc_gsbase);
|
printf("gs %X\n", r->mc_gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -45,7 +45,6 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
{
|
{
|
||||||
Ucontext *uc;
|
Ucontext *uc;
|
||||||
Mcontext *mc;
|
Mcontext *mc;
|
||||||
Sigcontext *sc;
|
|
||||||
|
|
||||||
if(panicking) // traceback already printed
|
if(panicking) // traceback already printed
|
||||||
exit(2);
|
exit(2);
|
||||||
@ -53,7 +52,6 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
|
|
||||||
uc = context;
|
uc = context;
|
||||||
mc = &uc->uc_mcontext;
|
mc = &uc->uc_mcontext;
|
||||||
sc = (Sigcontext*)mc; // same layout, more conveient names
|
|
||||||
|
|
||||||
if(sig < 0 || sig >= NSIG)
|
if(sig < 0 || sig >= NSIG)
|
||||||
printf("Signal %d\n", sig);
|
printf("Signal %d\n", sig);
|
||||||
@ -61,13 +59,13 @@ sighandler(int32 sig, Siginfo* info, void* context)
|
|||||||
printf("%s\n", sigtab[sig].name);
|
printf("%s\n", sigtab[sig].name);
|
||||||
|
|
||||||
printf("Faulting address: %p\n", info->si_addr);
|
printf("Faulting address: %p\n", info->si_addr);
|
||||||
printf("PC=%X\n", sc->sc_rip);
|
printf("PC=%X\n", mc->mc_rip);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if(gotraceback()){
|
if(gotraceback()){
|
||||||
traceback((void*)sc->sc_rip, (void*)sc->sc_rsp, (void*)sc->sc_r15);
|
traceback((void*)mc->mc_rip, (void*)mc->mc_rsp, (void*)mc->mc_r15);
|
||||||
tracebackothers((void*)sc->sc_r15);
|
tracebackothers((void*)mc->mc_r15);
|
||||||
dumpregs(sc);
|
dumpregs(mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
breakpoint();
|
breakpoint();
|
||||||
|
@ -50,4 +50,3 @@ typedef siginfo_t $Siginfo;
|
|||||||
|
|
||||||
typedef mcontext_t $Mcontext;
|
typedef mcontext_t $Mcontext;
|
||||||
typedef ucontext_t $Ucontext;
|
typedef ucontext_t $Ucontext;
|
||||||
typedef struct sigcontext $Sigcontext;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user