[commit: ghc] wip/libdw-prof: Add test for DWARF unwinding through C stack (d8b6ca8)
git at git.haskell.org
git at git.haskell.org
Sat May 6 22:40:16 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/libdw-prof
Link : http://ghc.haskell.org/trac/ghc/changeset/d8b6ca8009fec92611eedf3ea3a196c4da34988f/ghc
>---------------------------------------------------------------
commit d8b6ca8009fec92611eedf3ea3a196c4da34988f
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri Oct 23 11:37:36 2015 +0200
Add test for DWARF unwinding through C stack
>---------------------------------------------------------------
d8b6ca8009fec92611eedf3ea3a196c4da34988f
.../tests/codeGen/should_run/DwarfUnwindToC.hs | 21 +++++++++
.../tests/codeGen/should_run/DwarfUnwindToC.stdout | 52 ++++++++++++++++++++++
testsuite/tests/codeGen/should_run/all.T | 1 +
3 files changed, 74 insertions(+)
diff --git a/testsuite/tests/codeGen/should_run/DwarfUnwindToC.hs b/testsuite/tests/codeGen/should_run/DwarfUnwindToC.hs
new file mode 100644
index 0000000..52db325
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/DwarfUnwindToC.hs
@@ -0,0 +1,21 @@
+import GHC.ExecutionStack
+
+-- | Trim object file names
+cleanUpBacktrace :: String -> String
+cleanUpBacktrace = unlines . map trimLine . lines
+ where
+ trimLine (' ':'i':'n':' ':_) = ""
+ trimLine (x:xs) = x : trimLine xs
+ trimLine [] = []
+
+test :: Int -> IO ()
+test 0 = return ()
+test i = do
+ print i
+ showStackTrace >>= putStrLn . cleanUpBacktrace
+ test (i-1)
+ return ()
+
+main = do
+ test 3
+ print "Hello"
diff --git a/testsuite/tests/codeGen/should_run/DwarfUnwindToC.stdout b/testsuite/tests/codeGen/should_run/DwarfUnwindToC.stdout
new file mode 100644
index 0000000..11c0967
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/DwarfUnwindToC.stdout
@@ -0,0 +1,52 @@
+3
+Stack trace:
+ set_initial_registers (rts/Libdw.c:278.0)
+ dwfl_thread_getframes
+
+ dwfl_getthreads
+ dwfl_getthread_frames
+ libdw_get_backtrace (rts/Libdw.c:249.0)
+ base_GHCziExecutionStackziInternal_collectStackTrace1_info (libraries/base/GHC/ExecutionStack/Internal.hsc:194.1)
+ base_GHCziExecutionStack_showStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:47.1)
+ base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1081.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ stg_catch_frame_info (rts/Exception.cmm:370.1)
+ stg_stop_thread_info (rts/StgStartup.cmm:42.1)
+
+2
+Stack trace:
+ set_initial_registers (rts/Libdw.c:278.0)
+ dwfl_thread_getframes
+
+ dwfl_getthreads
+ dwfl_getthread_frames
+ libdw_get_backtrace (rts/Libdw.c:249.0)
+ base_GHCziExecutionStackziInternal_collectStackTrace1_info (libraries/base/GHC/ExecutionStack/Internal.hsc:194.1)
+ base_GHCziExecutionStack_showStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:47.1)
+ base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1081.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ stg_catch_frame_info (rts/Exception.cmm:370.1)
+ stg_stop_thread_info (rts/StgStartup.cmm:42.1)
+
+1
+Stack trace:
+ set_initial_registers (rts/Libdw.c:278.0)
+ dwfl_thread_getframes
+
+ dwfl_getthreads
+ dwfl_getthread_frames
+ libdw_get_backtrace (rts/Libdw.c:249.0)
+ base_GHCziExecutionStackziInternal_collectStackTrace1_info (libraries/base/GHC/ExecutionStack/Internal.hsc:194.1)
+ base_GHCziExecutionStack_showStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:47.1)
+ base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1081.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1084.1)
+ stg_catch_frame_info (rts/Exception.cmm:370.1)
+ stg_stop_thread_info (rts/StgStartup.cmm:42.1)
+
+"Hello"
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 6318341..7f66f08 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -158,3 +158,4 @@ test('T9577', [ unless(arch('x86_64') or arch('i386'),skip),
test('T13425', normal, compile_and_run, ['-O'])
test('castFloatWord', normal, compile_and_run, ['-dcmm-lint'])
+test('DwarfUnwindToC', [when(not rts_with_libdw() or not libs_have_debug_info(), skip)], compile_and_run, [''])
More information about the ghc-commits
mailing list