Re: Stack trace on error (and packages)
Hi,
Is it possible to persuade ghc/RTS to provide a stack trace (or something similar) when an error occurs? I have some code that is generating a runtime error (appears to be due to division by almost-zero, provoking very large numbers and then a NaN in a case statement when coerced to Double) in a function that is used throughout my code - it would be a big help to know which function called the function that is generating the error.
Yes. Compile your program with -prof -auto-all (you need at least -prof on all modules for the link to work, but -auto-all is only necessary on modules containing functions you want to trace). This turns on automatic profiling. Now run your program with the option `+RTS -xc' . This will turn on a cost-centre stack trace, displayed each time your program throws an exception (including runtime errors). This gives not the program stack (which function demanded which value), but the cost-centre stack (which function called which function which failed), which may or may not be more useful. The former is only available under `gdb' at the moment, with a very hairy user interface. You can read about cost centres in chapter 4 of the manual. My apologies for not having put this properly in the manual yet! HTH.. --KW 8-) -- Keith Wansbrough <kw217@cl.cam.ac.uk> http://www.cl.cam.ac.uk/users/kw217/ Cambridge University Computer Laboratory.
participants (1)
-
Keith Wansbrough