mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 09:50:22 +02:00
* fix #41004: correctly determine the instruction pointer for leaf functions and set the CONTEXT_UNWOUND_TO_CALL context flag
This commit is contained in:
parent
ee6bfa357a
commit
1b44d17899
@ -18,6 +18,8 @@ const
|
|||||||
EXCEPTION_UNWIND = EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND or
|
EXCEPTION_UNWIND = EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND or
|
||||||
EXCEPTION_TARGET_UNWIND or EXCEPTION_COLLIDED_UNWIND;
|
EXCEPTION_TARGET_UNWIND or EXCEPTION_COLLIDED_UNWIND;
|
||||||
|
|
||||||
|
CONTEXT_UNWOUND_TO_CALL = $20000000;
|
||||||
|
|
||||||
UNWIND_HISTORY_TABLE_SIZE = 12;
|
UNWIND_HISTORY_TABLE_SIZE = 12;
|
||||||
|
|
||||||
UNW_FLAG_NHANDLER = 0;
|
UNW_FLAG_NHANDLER = 0;
|
||||||
@ -346,9 +348,12 @@ begin
|
|||||||
Context.Rip:=PQWord(Context.Rsp)^;
|
Context.Rip:=PQWord(Context.Rsp)^;
|
||||||
Inc(Context.Rsp, sizeof(Pointer));
|
Inc(Context.Rsp, sizeof(Pointer));
|
||||||
{$elseif defined(CPUAARCH64)}
|
{$elseif defined(CPUAARCH64)}
|
||||||
{ ToDo }
|
{ For leaf function on Windows ARM64, return address is at LR(X30). Add
|
||||||
//Context.Pc:=Context.Lr;
|
CONTEXT_UNWOUND_TO_CALL flag to avoid unwind ambiguity for tailcall on
|
||||||
ContextSetIP(Context,0);
|
ARM64, because padding after tailcall is not guaranteed.
|
||||||
|
Source: https://chromium.googlesource.com/chromium/src/base/+/master/profiler/win32_stack_frame_unwinder.cc#116 }
|
||||||
|
Context.Pc:=Context.Lr;
|
||||||
|
Context.ContextFlags := Context.ContextFlags or CONTEXT_UNWOUND_TO_CALL;
|
||||||
{$else}
|
{$else}
|
||||||
ContextSetIP(Context,0);
|
ContextSetIP(Context,0);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
Loading…
Reference in New Issue
Block a user