【问题标题】:elisp debugging, show backtrace when function failselisp 调试,当函数失败时显示回溯
【发布时间】:2016-07-05 03:54:09
【问题描述】:

我想在运行此代码时查看错误的回溯。

 (make-network-process :name (dbgp-make-listner-name 10004)
                       :server 1
                       :service 10004
                       :family 'ipv4
                       :nowait t
                       :noquery t
                       :filter 'dbgp-comint-setup
                       :sentinel 'dbgp-listener-sentinel
                       :log 'dbgp-listener-log)

https://github.com/gregsexton/ob-ipython/issues/4
这表明我可以看到make-network-process 下发生了什么。

Debugger entered--Lisp error: (file-error "make client process failed" "connection refused" :name "localhost" :buffer # :host "localhost" :service 9988 :nowait nil)
make-network-process(:name "localhost" :buffer # :host "localhost" :service 9988 :nowait nil)
open-network-stream("localhost" # "localhost" 9988 :type plain :nowait nil)
byte-code . . . 
url-open-stream("localhost" # "localhost" 9988)
url-http-find-free-connection("localhost" 9988)
url-http([cl-struct-url "http" nil nil "localhost" 9988 "/execute/default" nil nil t nil t] #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)")
url-retrieve-internal("http://localhost:9988/execute/default" #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)" nil nil)
url-retrieve("http://localhost:9988/execute/default" #[128 

我试过了

toggle-debug-on-error edebug-eval-defun

但是我看不到回溯..

*Backtrace*缓冲区,我可以看到

Debugger entered: nil
  (progn (debug) (make-network-process :name (dbgp-make-listner-name 10004) :server 1 :service 10004 :family (quote ipv4) :nowait t :noquery t :filter (quote dbgp-comint-setup) :sentinel (quote dbgp-listener-sentinel) :log (quote dbgp-listener-log)))
  eval((progn (debug) (make-network-process :name (dbgp-make-listner-name 10004) :server 1 :service 10004 :family (quote ipv4) :nowait t :noquery t :filter (quote dbgp-comint-setup) :sentinel (quote dbgp-listener-sentinel) :log (quote dbgp-listener-log))) nil)
  edebug-eval-defun(nil)
  apply(edebug-eval-defun nil)
  eval-defun(nil)
  funcall-interactively(eval-defun nil)
  call-interactively(eval-defun record nil)
  command-execute(eval-defun record)
  helm-M-x(nil "eval-defun")
  funcall-interactively(helm-M-x nil "eval-defun")
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)

虽然第一个跟踪显示了 make-network-process 背后发生的事情,但我的跟踪并没有更深入..

【问题讨论】:

  • 你说你看不到回溯,然后你给我们看你能看到的回溯。请澄清一下?
  • @phils:我添加了另一个回溯,它低于 make-network-process 。我知道make-network-process 失败,想知道原因。

标签: debugging emacs backtrace


【解决方案1】:

所以问题是如何在回溯中获得更多细节

对于字节编译的 elisp 函数,加载相关库的 未编译 版本通常会为您提供更多详细信息,因为调试器随后可以向您显示确切的位置函数的事情发生了。

但是在本例中,make-network-process 是一个 C 函数,所以您现在看到的就是您要从 elisp 调试器中得到的全部内容。

如果您想了解更多信息,则必须检查/调试 process.c 中的源代码。

【讨论】:

  • 那么他是如何看到C函数的回溯byte-code部分的呢? github.com/gregsexton/ob-ipython/issues/4
  • 什么意思?该页面上的回溯不会比您自己的更进一步,在调用make-network-process 时停止。 C 函数没有字节码(根据定义,考虑到它们不是 elisp)。
  • 请注意,堆栈帧在回溯中从最新到最旧(从上到下)显示。错误后显示的第一件事是最近的调用,从该调用中触发了错误。下面的框架是导致该点的事件。
猜你喜欢
  • 2010-11-02
  • 2022-09-23
  • 2018-05-09
  • 1970-01-01
  • 1970-01-01
  • 2011-08-28
  • 2015-06-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多