我如何获得错误被调用的位置? [英] How can I get the position where error was called?
问题描述
我正在寻找替代 loch (及其预处理器)的内容,因为它没有使用ghc编译7.
具体来说,如果调用 error
,那么我想弄清楚,就像(行号和堆栈跟踪会很好)。
您可以使用 -xc
RTS选项,详见本页;你需要使用分析支持来编译你的程序,并且输出非常难看,但是它很有用。
这应该是这样做的:
$ ghc --make -prof -auto-all myprog.hs
$ ./myprog + RTS -xc
$ c $从技术上讲,这只能给出一个成本中心堆栈,而不是真正的堆栈跟踪。改进的堆栈跟踪支持来自GHC 7.4 。
I am looking for something to replace loch (and its preprocessor) since it doesn't compile with ghc 7.
Specifically, if error
is called then I would like to figure out, as conveniently as possible, where it was called from (line number and stack trace would be nice).
解决方案 You can use the -xc
RTS option, as described on this page; you need to compile your program with profiling support, and the output is pretty ugly, but it works.
This should do it:
$ ghc --make -prof -auto-all myprog.hs
$ ./myprog +RTS -xc
Technically this only gives a cost centre stack, not a true stack trace. Improved stack trace support is coming in GHC 7.4.
这篇关于我如何获得错误被调用的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!