summaryrefslogtreecommitdiff
path: root/rts/StgStartup.cmm
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2018-05-12 07:31:20 -0700
committerBartosz Nitka <niteria@gmail.com>2018-05-12 07:31:20 -0700
commitbec2e71e9869815c058dda9ebb6eb483352aa480 (patch)
tree54a09f6462d0fe2355256af60191a874e3f9d16e /rts/StgStartup.cmm
parent2323ffdd552327a8954de8ac37908029ec7cad38 (diff)
downloadhaskell-bec2e71e9869815c058dda9ebb6eb483352aa480.tar.gz
Revert "Fix unwinding of C -> Haskell FFI calls with -threaded"
This reverts commit cb5c2fe875965b7aedbc189012803fc62e48fb3f. It appears to have broken OSX and Windows builds.
Diffstat (limited to 'rts/StgStartup.cmm')
-rw-r--r--rts/StgStartup.cmm18
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);