mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 18:29:28 +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;
|
||||
|
||||
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}
|
||||
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;
|
||||
{$endif PSABI_HANDLESCONTEXT}
|
||||
var
|
||||
_ExceptObjectStack : PExceptObject;
|
||||
_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;
|
||||
var
|
||||
res,fpustate : word;
|
||||
@ -82,7 +89,7 @@ begin
|
||||
ucontext^.uc_mcontext.eax := res;
|
||||
ucontext^.uc_mcontext.edx := ucontext^.uc_mcontext.eip;
|
||||
ucontext^.uc_mcontext.ecx := ucontext^.uc_mcontext.ebp;
|
||||
ucontext^.uc_mcontext.eip := ptruint(@HandleErrorAddrFrame);
|
||||
ucontext^.uc_mcontext.eip := ptruint(@SignalToHandleErrorAddrFrame);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user