diff options
Diffstat (limited to 'rts/StgStartup.cmm')
-rw-r--r-- | rts/StgStartup.cmm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index 571e0637fc..f67373031b 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -62,12 +62,24 @@ INFO_TABLE_RET(stg_stop_thread, STOP_FRAME, be an info table on top of the stack). */ - // See Note [Unwinding foreign exports on x86-64]. + /* + Here we setup the stack unwinding annotation necessary to allow + debuggers to find their way back to the C stack. + + This is a bit fiddly as we assume the layout of the stack prepared + for us by StgRun. Note that in most cases StgRun is written in assembler + and therefore has no associated unwind information. For this reason we + need to identify the platform stack pointer and return address values for + the StgRun's caller. + */ #if defined(x86_64_HOST_ARCH) - unwind UnwindReturnReg = STG_RUN_JMP; + // offset of 8 in MachSp value due to return address + unwind MachSp = MachSp + RESERVED_C_STACK_BYTES + STG_RUN_STACK_FRAME_SIZE + 8, + UnwindReturnReg = W_[MachSp + RESERVED_C_STACK_BYTES + STG_RUN_STACK_FRAME_SIZE]; #else // FIXME: Fill in for other platforms - unwind UnwindReturnReg = return; + unwind MachSp = return, + UnwindReturnReg = return; #endif Sp = Sp + SIZEOF_StgStopFrame - WDS(2); |