From abef064786ef636712807dd95b7cdd4dd2d330c5 Mon Sep 17 00:00:00 2001 From: pierre Date: Thu, 27 Sep 2012 15:49:13 +0000 Subject: [PATCH] Adapt TSigContext to structure found by debugging git-svn-id: trunk@22482 - --- rtl/linux/sparc/sighnd.inc | 51 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/rtl/linux/sparc/sighnd.inc b/rtl/linux/sparc/sighnd.inc index 5182920cfe..85696ebe28 100644 --- a/rtl/linux/sparc/sighnd.inc +++ b/rtl/linux/sparc/sighnd.inc @@ -18,38 +18,44 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);public name '_FPC_DEFAULTSIGHANDLER';cdecl; var res : word; - addr : pointer; + addr, framebp : pointer; begin res:=0; addr:=nil; + framebp:=nil; case sig of SIGFPE : begin - addr := siginfo^._sifields._sigfault._addr; - case siginfo^.si_code of - FPE_INTDIV: - res:=200; - FPE_INTOVF: - res:=215; - FPE_FLTDIV: - res:=200; - FPE_FLTOVF: - res:=205; - FPE_FLTUND: - res:=206; - else - res:=207; - end; + if assigned(siginfo) then + begin + addr := siginfo^._sifields._sigfault._addr; + case siginfo^.si_code of + FPE_INTDIV: + res:=200; + FPE_INTOVF: + res:=215; + FPE_FLTDIV: + res:=200; + FPE_FLTOVF: + res:=205; + FPE_FLTUND: + res:=206; + else + res:=207; + end; + end; end; SIGBUS : begin - addr := siginfo^._sifields._sigfault._addr; + if assigned(siginfo) then + addr := siginfo^._sifields._sigfault._addr; res:=214; end; SIGILL, SIGSEGV : begin - addr := siginfo^._sifields._sigfault._addr; + if assigned(siginfo) then + addr := siginfo^._sifields._sigfault._addr; res:=216; end; SIGINT: @@ -58,9 +64,16 @@ begin res:=233; end; reenable_signal(sig); + + if assigned(sigcontext) then + begin + addr:=pointer(sigcontext^.sigc_pc); + framebp:=pointer(sigcontext^.sigc_gregs[SIG_SP]); + end; + { give runtime error at the position where the signal was raised } if res<>0 then - HandleErrorAddrFrame(res,addr,nil); + HandleErrorAddrFrame(res,addr,framebp); end;