diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2015-08-30 14:11:56 +0200 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-01 15:19:47 +0100 |
| commit | d9f886282c605e5f4b74126b3af8f23771ef03f1 (patch) | |
| tree | 5a0ed5ca4c1776b2ad7f06bebe8f43342c88ddde | |
| parent | 159a1a2b7501b149fadfc0cd1940fab6bf030691 (diff) | |
| download | haskell-d9f886282c605e5f4b74126b3af8f23771ef03f1.tar.gz | |
StgStartup: Setup unwinding for stg_stop_thread
This is a bit ugly as we need to assume the structure of the C stack as
left by StgRun. Nevertheless, it allows us to unwind all the way back to
`_start` on my machine.
```
Stack trace:
set_initial_registers (rts/Libdw.c:272.0)
dwfl_thread_getframes
dwfl_getthreads
dwfl_getthread_frames
libdw_get_backtrace (rts/Libdw.c:243.0)
base_GHCziExecutionStack_getStackTrace1_info
(libraries/base/GHC/ExecutionStack.hs:43.1)
base_GHCziExecutionStack_showStackTrace1_info
(libraries/base/GHC/ExecutionStack.hs:47.1)
base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1085.1)
base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
stg_catch_frame_info (rts/Exception.cmm:370.1)
stg_stop_thread_info (rts/StgStartup.cmm:42.1)
scheduleWaitThread (rts/Schedule.c:465.0)
hs_main (rts/RtsMain.c:65.0)
__libc_start_main (/tmp/buildd/glibc-2.19/csu/libc-start.c:321.0)
_start
```
| -rw-r--r-- | rts/StgCRun.c | 2 | ||||
| -rw-r--r-- | rts/StgStartup.cmm | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 644850988e..0a010d464e 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -159,6 +159,8 @@ StgWord8 *win32AllocStack(void) * stack isn't aligned, and calling exitWith from Haskell invokes * shutdownHaskellAndExit using a C call. * + * If you edit the sequence below be sure to update the unwinding information + * for stg_stop_thread in StgStartup.cmm. */ static void GNUC3_ATTRIBUTE(used) diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index 2a245b059d..aad4fab139 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -62,6 +62,18 @@ INFO_TABLE_RET(stg_stop_thread, STOP_FRAME, be an info table on top of the stack). */ + /* + 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. + */ +#ifdef x86_64_HOST_ARCH + unwind MachSp = MachSp + RESERVED_C_STACK_BYTES + 0x38 + 8 + unwind UnwindReturnReg = W_[MachSp + RESERVED_C_STACK_BYTES + 0x38] +#endif + Sp = Sp + SIZEOF_StgStopFrame - WDS(2); Sp(1) = R1; Sp(0) = stg_enter_info; |
