diff options
Diffstat (limited to 'testsuite/tests/rts/decodeMyStack.hs')
-rw-r--r-- | testsuite/tests/rts/decodeMyStack.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/rts/decodeMyStack.hs b/testsuite/tests/rts/decodeMyStack.hs new file mode 100644 index 0000000000..b0c330ee34 --- /dev/null +++ b/testsuite/tests/rts/decodeMyStack.hs @@ -0,0 +1,23 @@ +module Main where + +import GHC.Stack.CloneStack +import System.IO.Unsafe + +getDeepStack :: Int -> (Int, [StackEntry]) +getDeepStack deepness = case getDeepStackCase deepness of + [] -> (0, []) + s -> (deepness, s) + where + getDeepStackCase :: Int -> [StackEntry] + getDeepStackCase 0 = + unsafePerformIO $ + ( do + stack <- cloneMyStack + GHC.Stack.CloneStack.decode stack + ) + getDeepStackCase n = snd $ getDeepStack $ n - 1 + +main :: IO () +main = do + let (_, stackEntries) = getDeepStack 10 + mapM_ (putStrLn . show) stackEntries |