From 5b9a51eaa84c8f0ddb010becf4b57beb874ec2c0 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 19 Dec 2006 15:15:39 +0000 Subject: [PATCH] * fixed extracting stack pointer and program counter from signal context git-svn-id: trunk@5650 - --- rtl/solaris/sparc/sighnd.inc | 23 ++++++++--- rtl/solaris/sparc/sighndh.inc | 78 ++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 7 deletions(-) diff --git a/rtl/solaris/sparc/sighnd.inc b/rtl/solaris/sparc/sighnd.inc index 36b410a027..975017c3ed 100644 --- a/rtl/solaris/sparc/sighnd.inc +++ b/rtl/solaris/sparc/sighnd.inc @@ -15,6 +15,12 @@ **********************************************************************} +const + REG_PC = 1; + REG_nPC = 2; + REG_O6 = 17; + REG_SP = REG_O6; + const FPE_INTDIV = 1; FPE_INTOVF = 2; @@ -30,13 +36,22 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigCon var res : word; addr : pointer; + frame : pointer; begin res:=0; - addr:=nil; + if assigned(sigcontext) then + begin + addr := pointer(sigcontext^.uc_mcontext.gregs[REG_PC]); + frame := pointer(sigcontext^.uc_mcontext.gregs[REG_SP]) + end + else + begin + addr := nil; + frame := nil; + end; case sig of SIGFPE : begin - addr := siginfo^._sifields._sigfault._addr; res := 207; case siginfo^.si_code of FPE_INTDIV: @@ -60,19 +75,17 @@ begin SIGILL, SIGSEGV : begin - addr := siginfo^._sifields._sigfault._addr; res:=216; end; SIGBUS : begin - addr := siginfo^._sifields._sigfault._addr; res:=214; end; end; reenable_signal(sig); { give runtime error at the position where the signal was raised } if res<>0 then - HandleErrorAddrFrame(res,addr,nil); + HandleErrorAddrFrame(res,addr,frame); end; diff --git a/rtl/solaris/sparc/sighndh.inc b/rtl/solaris/sparc/sighndh.inc index e8a498aa9e..e9a96eb5c2 100644 --- a/rtl/solaris/sparc/sighndh.inc +++ b/rtl/solaris/sparc/sighndh.inc @@ -16,9 +16,83 @@ {$packrecords C} +{ sparc v8 definition } + +const + SPARC_MAXREGWINDOW = 31; + _NGREG = 19; + type - PSigContext = ^TSigContext; - TSigContext = record +{$ifdef cpu64} + TGReg = clong; +{$else} + TGReg = cint; +{$endif} + + TGRegSet = array[0.._NGREG-1] of TGReg; + + PSPBuf = ^TSPBuf; + TSPBuf = array[0..SPARC_MAXREGWINDOW-1] of TGReg; + + TRWindow = record + rw_local : array[0..7] of TGReg; + rw_in : array[0..7] of TGReg; end; + PGWindows = ^TGWindows; + TGWindows = record + wbcnt : cint; + spbuf : PSPBuf; + rwindow : array[0..SPARC_MAXREGWINDOW-1] of TRWindow; + end; + TFPURegs = record + case longint of + 0: ( fpuregs: array[0..31] of cardinal); + 1: ( fpudregs: array[0..15] of double); + end; + + PFQ = ^TFQ; + TFQ = record + fpq_addr : ^cuint; + fpq_instr : cuint; + end; + + TFPU = record + fpu_fr : TFPURegs; + fq: PFQ; + fpu_fsr: cardinal; + fpu_qcnt : byte; + fpu_q_entrysize : byte; + fpu_e : byte; + end; + TFPRegSet = TFPU; + + TXRS = record + xrs_id : cuint; + xrs_ptr : pointer; + end; + + TMContext = record + gregs : TGRegSet; + gwins : PGWindows; + fpregs : TFPRegSet; + xrs : TXRS; + __filler : array[0..19-1] of clong; + end; + + TStack = record + ss_sp : pointer; + ss_size : size_t; + ss_flags : cint; + end; + + PSigContext = ^TSigContext; + TSigContext = record + uc_flags : cuint; + uc_link : PSigContext; + uc_sigmask : sigset_t; + uc_stack : TStack; + uc_mcontext : TMContext; + __uc_filler : array[0..23-1] of clong; + end;