mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 02:49:21 +02:00
* fixed unwinding from signal handlers, the approach used now is very simple and clean
git-svn-id: branches/debug_eh@41414 -
This commit is contained in:
parent
18fb53e012
commit
8db9b211d5
@ -975,32 +975,9 @@ procedure FPC_psabieh_ExceptionCleanUp(reason: FPC_Unwind_Reason_Code; exc:PFPC_
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function PushExceptObject(Obj : TObject; AnAddr : CodePointer; AFrame : Pointer): PExceptObject; forward;
|
function PushExceptObject(Obj : TObject; AnAddr : CodePointer; AFrame : Pointer): PExceptObject; forward;
|
||||||
procedure fpc_RaiseException_Internal(Obj: TObject; AnAddr: CodePointer; AFrame: Pointer); forward;
|
|
||||||
|
|
||||||
{$ifdef CPUI386}
|
|
||||||
{ tweak stack, so we get the correct context, this requires assembly }
|
|
||||||
procedure fpc_RaiseException(Obj: TObject; AnAddr: CodePointer; AFrame: Pointer); compilerproc;assembler; nostackframe;
|
|
||||||
asm
|
|
||||||
{ loading the address makes only sense if a frame is passed, else unwinding is completly mixed up }
|
|
||||||
orl AFrame,AFrame
|
|
||||||
je .L1
|
|
||||||
movl AFrame,%ebp
|
|
||||||
orl AnAddr,AnAddr
|
|
||||||
je .L1
|
|
||||||
movl AnAddr,(%esp)
|
|
||||||
.L1:
|
|
||||||
jmpl fpc_RaiseException_Internal
|
|
||||||
end;
|
|
||||||
{$define PSABI_HANDLESCONTEXT}
|
|
||||||
{$endif CPUI386}
|
|
||||||
|
|
||||||
{$define FPC_SYSTEM_HAS_RAISEEXCEPTION}
|
{$define FPC_SYSTEM_HAS_RAISEEXCEPTION}
|
||||||
procedure fpc_RaiseException_Internal(Obj: TObject; AnAddr: CodePointer; AFrame: Pointer);
|
|
||||||
{$ifndef PSABI_HANDLESCONTEXT}
|
|
||||||
begin
|
|
||||||
end;
|
|
||||||
procedure fpc_RaiseException(Obj: TObject; AnAddr: CodePointer; AFrame: Pointer); compilerproc;
|
procedure fpc_RaiseException(Obj: TObject; AnAddr: CodePointer; AFrame: Pointer); compilerproc;
|
||||||
{$endif PSABI_HANDLESCONTEXT}
|
|
||||||
var
|
var
|
||||||
_ExceptObjectStack : PExceptObject;
|
_ExceptObjectStack : PExceptObject;
|
||||||
_ExceptAddrstack : PExceptAddr;
|
_ExceptAddrstack : PExceptAddr;
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
|
|
||||||
|
{ use a trampoline which pushes the return address for proper unwinding }
|
||||||
|
Procedure SignalToHandleErrorAddrFrame (Errno : longint;addr : CodePointer; frame : Pointer); nostackframe; assembler;
|
||||||
|
asm
|
||||||
|
pushl addr
|
||||||
|
jmp HandleErrorAddrFrame
|
||||||
|
end;
|
||||||
|
|
||||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; UContext: Pucontext);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
|
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; UContext: Pucontext);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
|
||||||
var
|
var
|
||||||
res,fpustate : word;
|
res,fpustate : word;
|
||||||
@ -82,7 +89,7 @@ begin
|
|||||||
ucontext^.uc_mcontext.eax := res;
|
ucontext^.uc_mcontext.eax := res;
|
||||||
ucontext^.uc_mcontext.edx := ucontext^.uc_mcontext.eip;
|
ucontext^.uc_mcontext.edx := ucontext^.uc_mcontext.eip;
|
||||||
ucontext^.uc_mcontext.ecx := ucontext^.uc_mcontext.ebp;
|
ucontext^.uc_mcontext.ecx := ucontext^.uc_mcontext.ebp;
|
||||||
ucontext^.uc_mcontext.eip := ptruint(@HandleErrorAddrFrame);
|
ucontext^.uc_mcontext.eip := ptruint(@SignalToHandleErrorAddrFrame);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user