Safe Haskell | None |
---|---|
Language | Haskell2010 |
Blocking operations such as
readMVar v
may throw an exception such as
thread blocked indefinitely in an MVar operation
Unfortunately, this exception does not give any information of _where_ in the code we are blocked indefinitely. Compiling with profiling info and running with +RTC -xc can address this to some extent, but (1) it requires that all profiling libraries are installed and (2) when we are running multithreaded code the resulting stack trace is often difficult to read (and still does not include line numbers). With this module you can replace the above code with
$readMVar v
and the exception that will be thrown is
YourModule:lineNumber: thread blocked indefinitely in an MVar operation
which is a lot more informative. When the CPP flag DEBUGGING is turned off
then $readMVar
just turns into readMVar
.
NOTE: The type of the exception changes when using DEBUGGING mode -- in order to be able to add the line number, all exceptions are turned into IOExceptions.
- lineNumber :: ExpQ
- traceOnException :: String -> IO a -> IO a
- mapExceptionIO :: (Exception e1, Exception e2) => (e1 -> e2) -> IO a -> IO a
- mapExceptionShow :: (String -> String) -> IO a -> IO a
- putMVar :: ExpQ
- takeMVar :: ExpQ
- modifyMVar :: ExpQ
- modifyMVar_ :: ExpQ
- withMVar :: ExpQ
- readMVar :: ExpQ
- swapMVar :: ExpQ
- putStrictMVar :: ExpQ
- takeStrictMVar :: ExpQ
- modifyStrictMVar :: ExpQ
- modifyStrictMVar_ :: ExpQ
- withStrictMVar :: ExpQ
- readStrictMVar :: ExpQ
- swapStrictMVar :: ExpQ
- readChan :: ExpQ
- wait :: ExpQ
- waitCatch :: ExpQ
- waitAny :: ExpQ
- waitAnyCatchCancel :: ExpQ
Generic debugging utilities
lineNumber :: ExpQ Source
traceOnException :: String -> IO a -> IO a Source
Blocking MVar ops
modifyMVar :: ExpQ Source