Skip to content

Instantly share code, notes, and snippets.

@Tarrasch
Created November 18, 2013 16:13
Show Gist options
  • Save Tarrasch/7530508 to your computer and use it in GitHub Desktop.
Save Tarrasch/7530508 to your computer and use it in GitHub Desktop.
Ideal (but unrealizeible) API for haskell stack traces

Haskell API for stack traces

– what we have:

catch# :: (State# RealWorld -> (# State# RealWorld, a #) ) -> (b -> ByteArray# -> State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #)

dumpStack :: ByteArray# -> State# RealWorld -> State# RealWorld

– what we want (high level) – See also: GHC.Stack (a similar API for cost-centre stacks)

getStack :: IO Stack

stackContents :: Stack -> [ [StackItem] ]

data StackItem = StackItem { { fileName :: String , functionName :: String , startLint :: Int , startColumn :: Int , endLine :: Int , endColumn :: Int }

prettyPrintStack :: Stack -> [String]

errorWithStackTrace :: String -> a

throw :: Exception e => e -> a

– what we want (low level)

data Stack = Stack ByteArray#

getStack# :: State# RealWorld -> (# State# RealWorld, ByteArray# #)

stackItemElems :: Addr# -> Int# – gets the number of ticks for this address – the first tick should always be the one that was chosen to appear – in the DWARF info, according to the heuristic that chooses the – “best” tick.

inspectStackItem# :: Addr# -> Int# -> (# ByteArray# , ByteArray# , Int# , Int# , Int# , Int# #)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment