如何跟踪“失败” Emacs中的错误? [英] How to trace "failwith" error in Emacs?
问题描述
make -k
给超级链接发出警告。但是对于 failwith
提出的错误,它不能提供超链接,例如: analyze(ZONE)...
致命错误:异常失败(做)
在文件pervasives.ml上引发22行字符22-33
从文件list.ml中调用,第69行,字符12-15
make:*** [all]错误2
编译异常退出代码2在Fri Jan 27 18: 44:10
我有很多 failwith做
在我的代码,需要知道哪一个引发错误,有没有人知道如何让Emacs找到这种错误?
请参阅以下错误报告中的一些elisp添加到您的.emacs,以便编译主要模式知道如何解析OCaml回溯报告。
以下是建议的代码(加图形模式钩子):
(defun caml-change-error- alist-for-backtraces()
Hook将编译错误 - regexp-alist变量更改为
搜索错误位置的ocaml回溯
(interactive)
progn
(setq compilation-error-regexp-alist-alist
(附加
'((caml-backtrace
^ * \\(? \ |从\\中调用文件\\(\?\\)\\([^,\\\\
\t] + \\\ \\)\\1,\
行? \\([0-9] + \\) - ?\\([0-9] + \\)?\\(?:$ \\ |,\\ \\
\\(?: characters?\\([0-9] + \\) - ?\\([0-9] + \\)?: ?\\)
2(3..4)(.6)))
compilation-error-regexp-alist-alist))
( setq compilation-error-regexp-alist
(附加编译错误 - regexp-alist'(caml-backtrace)))))
(add-hook'caml-mode-hook'
(add-hook'tuareg-mode-hook'caml-change-error-alist-for-backtraces)
(defun caml-change-error-alist-for-assert-failure()
Hook将编译错误 - regexp-alist变量更改为
搜索错误位置的断言失败消息
(interactive)
(progn
(setq compilation-error-regexp-alist-alist
(append
'((caml-assert-failure
Assert_fail ure(\\\([^,\\\\
\t]] \\ \\)\,\\([0-9] + \\\ \\),\\([0-9] + \\))
1 2 3))
compilation-error-regexp-alist-alist))
setq compilation-error-regexp-alist
(append-compiler-regexp-alist'(caml-assert-failure)))))
(add-hook'caml-mode-钩子'caml-change-error-alist-for-assert-failure)
(add-hook'tuareg-mode-hook'caml-change-error-alist-for-assert-failure)
I am writing OCaml under Emacs. I have already configured Emacs so that Meta-x compile
and make -k
gives warnings with hyperlink. But for errors raised by failwith
, it can not give a hyperlink, for instance:
analyzing (ZONE)...
Fatal error: exception Failure("to do")
Raised at file "pervasives.ml", line 22, characters 22-33
Called from file "list.ml", line 69, characters 12-15
make: *** [all] Error 2
Compilation exited abnormally with code 2 at Fri Jan 27 18:44:10
I have many failwith "to do"
in my code, and need to know which one raises the error, does anyone know how to let Emacs locate this kind of error?
See the following bug report for some elisp to add to your .emacs, so that the compilation major mode knows how to parse OCaml backtrace reports.
Here is the suggested code (plus tuareg-mode hooks):
(defun caml-change-error-alist-for-backtraces ()
"Hook to change the compilation-error-regexp-alist variable, to
search the ocaml backtraces for error locations"
(interactive)
(progn
(setq compilation-error-regexp-alist-alist
(append
'((caml-backtrace
"^ *\\(?:Raised at\\|Called from\\) file \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1,\
lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:?\\)?\\)"
2 (3 . 4) (5 . 6)))
compilation-error-regexp-alist-alist))
(setq compilation-error-regexp-alist
(append compilation-error-regexp-alist '(caml-backtrace)))))
(add-hook 'caml-mode-hook 'caml-change-error-alist-for-backtraces)
(add-hook 'tuareg-mode-hook 'caml-change-error-alist-for-backtraces)
(defun caml-change-error-alist-for-assert-failure ()
"Hook to change the compilation-error-regexp-alist variable, to
search the assert failure messages for error locations"
(interactive)
(progn
(setq compilation-error-regexp-alist-alist
(append
'((caml-assert-failure
"Assert_failure(\"\\([^,\" \n\t<>]+\\)\", \\([0-9]+\\), \\([0-9]+\\))"
1 2 3))
compilation-error-regexp-alist-alist))
(setq compilation-error-regexp-alist
(append compilation-error-regexp-alist '(caml-assert-failure)))))
(add-hook 'caml-mode-hook 'caml-change-error-alist-for-assert-failure)
(add-hook 'tuareg-mode-hook 'caml-change-error-alist-for-assert-failure)
这篇关于如何跟踪“失败” Emacs中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!