eugene
eugene

Reputation: 41725

elisp debugging, show backtrace when function fails

I'd like to see the backtrace of error when I run this code.

 (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
This shows that I can see what's going on under 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 

I tried

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

But I can't see the backtrace..

on *Backtrace* buffer, I can see

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)

While the first trace shows what's going on behind make-network-process, my trace doesn't go deeper..

Upvotes: 1

Views: 807

Answers (1)

phils
phils

Reputation: 73314

So the question is how to get more detail in the backtrace.

For byte-compiled elisp functions, loading the uncompiled version of the library in question will generally give you more detail, as the debugger can then show you exactly where in the function things happened.

However in this instance, make-network-process is a C function, so what you see now is all you're going to get out of the elisp debugger.

You'll have to examine/debug the source code in process.c if you want to know more.

Upvotes: 2

Related Questions