* fixed extracting stack pointer and program counter from

signal context

git-svn-id: trunk@5650 -
This commit is contained in:
Jonas Maebe 2006-12-19 15:15:39 +00:00
parent df03c25daf
commit 5b9a51eaa8
2 changed files with 94 additions and 7 deletions

View File

@ -15,6 +15,12 @@
**********************************************************************} **********************************************************************}
const
REG_PC = 1;
REG_nPC = 2;
REG_O6 = 17;
REG_SP = REG_O6;
const const
FPE_INTDIV = 1; FPE_INTDIV = 1;
FPE_INTOVF = 2; FPE_INTOVF = 2;
@ -30,13 +36,22 @@ procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigCon
var var
res : word; res : word;
addr : pointer; addr : pointer;
frame : pointer;
begin begin
res:=0; 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 case sig of
SIGFPE : SIGFPE :
begin begin
addr := siginfo^._sifields._sigfault._addr;
res := 207; res := 207;
case siginfo^.si_code of case siginfo^.si_code of
FPE_INTDIV: FPE_INTDIV:
@ -60,19 +75,17 @@ begin
SIGILL, SIGILL,
SIGSEGV : SIGSEGV :
begin begin
addr := siginfo^._sifields._sigfault._addr;
res:=216; res:=216;
end; end;
SIGBUS : SIGBUS :
begin begin
addr := siginfo^._sifields._sigfault._addr;
res:=214; res:=214;
end; end;
end; end;
reenable_signal(sig); reenable_signal(sig);
{ give runtime error at the position where the signal was raised } { give runtime error at the position where the signal was raised }
if res<>0 then if res<>0 then
HandleErrorAddrFrame(res,addr,nil); HandleErrorAddrFrame(res,addr,frame);
end; end;

View File

@ -16,9 +16,83 @@
{$packrecords C} {$packrecords C}
{ sparc v8 definition }
const
SPARC_MAXREGWINDOW = 31;
_NGREG = 19;
type type
PSigContext = ^TSigContext; {$ifdef cpu64}
TSigContext = record 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; 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;