我如何获得错误被调用的位置? [英] How can I get the position where error was called?

查看:57
本文介绍了我如何获得错误被调用的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找替代 loch (及其预处理器)的内容,因为它没有使用ghc编译7.



具体来说,如果调用 error ,那么我想弄清楚,就像(行号和堆栈跟踪会很好)。

解决方案

您可以使用 -xc RTS选项,详见本页;你需要使用分析支持来编译你的程序,并且输出非常难看,但是它很有用。



这应该是这样做的:

  $ ghc --make -prof -auto-all myprog.hs 
$ ./myprog + RTS -xc
成本中心堆栈,而不是真正的堆栈跟踪。改进的堆栈跟踪支持来自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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆