From 711a51adcf8b32801289478443549947eedd49a2 Mon Sep 17 00:00:00 2001 From: Peter Wortmann Date: Tue, 14 Oct 2014 01:14:14 +0200 Subject: Add unwind information to Cmm Unwind information allows the debugger to discover more information about a program state, by allowing it to "reconstruct" other states of the program. In practice, this means that we explain to the debugger how to unravel stack frames, which comes down mostly to explaining how to find their Sp and Ip register values. * We declare yet another new constructor for CmmNode - and this time there's actually little choice, as unwind information can and will change mid-block. We don't actually make use of these capabilities, and back-end support would be tricky (generate new labels?), but it feels like the right way to do it. * Even though we only use it for Sp so far, we allow CmmUnwind to specify unwind information for any register. This is pretty cheap and could come in useful in future. * We allow full CmmExpr expressions for specifying unwind values. The advantage here is that we don't have to make up new syntax, and can e.g. use the WDS macro directly. On the other hand, the back-end will now have to simplify the expression until it can sensibly be converted into DWARF byte code - a process which might fail, yielding NCG panics. On the other hand, when you're writing Cmm by hand you really ought to know what you're doing. (From Phabricator D169) --- rts/Exception.cmm | 1 + rts/StgMiscClosures.cmm | 1 + 2 files changed, 2 insertions(+) (limited to 'rts') diff --git a/rts/Exception.cmm b/rts/Exception.cmm index e03d53e1d5..5007ef3c0c 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -58,6 +58,7 @@ import ghczmprim_GHCziTypes_True_closure; INFO_TABLE_RET(stg_unmaskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr) /* explicit stack */ { + unwind Sp = Sp + WDS(1); CInt r; P_ ret; diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index f57fc04263..dd2570617d 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -47,6 +47,7 @@ INFO_TABLE_RET (stg_stack_underflow_frame, UNDERFLOW_FRAME, INFO_TABLE_RET (stg_restore_cccs, RET_SMALL, W_ info_ptr, W_ cccs) { + unwind Sp = Sp + WDS(2); #if defined(PROFILING) CCCS = Sp(1); #endif -- cgit v1.2.1