Sof*_*mur 4 debugging emacs ocaml traceback
我正在Ocaml中编写一个编译器.当我make在终端中编译和测试它时,tracback运行良好,例如:
export OCAMLRUNPARAM=b
./Simpler-Basic test.sib
Fatal error: exception Match_failure("interp.ml", 45, 21)
Called from file "interp.ml", line 97, characters 72-86
Called from file "list.ml", line 74, characters 24-34
Called from file "interp.ml", line 108, characters 9-35
Called from file "main.ml", line 54, characters 4-17
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
但是当我在我的Emacs中编译并测试它Meta-x compile后make,它没有显示缓冲区中的回溯部分:
make
export OCAMLRUNPARAM=b
./Simpler-Basic test.sib
Fatal error: exception Match_failure("interp.ml", 45, 21)
make: *** [all] Error 2
Compilation exited abnormally with code 2 at Sat Jun 18 19:03:04
Run Code Online (Sandbox Code Playgroud)
.emacs我从朋友那里复制了一部分我做的追溯:http://paste.ubuntu.com/628838/
任何人都可以告诉我如何修改我,.emacs以便它显示在终端中的追溯?非常感谢你
你在哪里写的export OCAMLRUNPARAM=b?
如果你在makefile中写了这个(↹代表一个标签):
?export OCAMLRUNPARAM=b
?./Simpler-Basic test.sib
Run Code Online (Sandbox Code Playgroud)
然后它不起作用,因为每个makefile命令都在一个单独的shell中执行,因此环境变量赋值在第一行完成后消失.您可以将两条线组合在一条逻辑线中:
?export OCAMLRUNPARAM=b; \
?./Simpler-Basic test.sib
Run Code Online (Sandbox Code Playgroud)
如果您在Emacs中运行Ocaml程序时总是想要回溯,请在以下位置设置环境变量.emacs:
(setenv "OCAMLRUNPARAM" "b")
Run Code Online (Sandbox Code Playgroud)
为了让Emacs将回溯消息识别为具有位置的错误消息,您需要将其注册到compilation-regexp-alist.把这样的东西放在你的.emacs(未经测试的)中:
(eval-after-load "caml"
(add-to-list 'compilation-regexp-alist
'("\\(^Raised at\\|Called from\\) file \"\\([^"\n]+\\)\", line \\([0-9]+\\)"
2 3)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
900 次 |
| 最近记录: |