Subject: bug#24616: 26.0.50; No backtrace when emacsclient --eval fails

From: Live System User <[email-masked]>
Date: Sun, 23 Oct 2016 20:51:19 -0400

[email-masked] writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: [email-masked]
>>> Cc: [email-masked],  [email-masked]
>>> Date: Sat, 22 Oct 2016 11:35:49 -0400
>>> 
>>> Something like this?
>>> 
>>> diff --git i/doc/lispref/debugging.texi w/doc/lispref/debugging.texi
>>> index c88a2fa..bb3ced4 100644
>>> --- i/doc/lispref/debugging.texi
>>> +++ w/doc/lispref/debugging.texi
>>> @@ -152,6 +152,11 @@ Error Debugging
>>>  must still fulfill the criteria specified by @code{debug-on-error} and
>>>  @code{debug-ignored-errors}.)
>>>  
>>> +For example, setting this variable is useful to get a backtrace from
>>> +code evaluated by emacsclient.  If elisp code evaluated by emacsclient
>>> +signals an error while this variable is non-@code{nil}, the backtrace
>>> +will popup in the running Emacs.
>>> +
>>
>> Yes, but please mention "--eval", and add an index entry so that this
>> text would be easier to locate.  Something like this:
>>
>>   @cindex emacsclient, getting a backtrace
>>   @cindex backtrace from emacsclient's @option{--eval}
>>
>> Also, a nit: I don't think we use "elisp" in the manual, we say
>> "Lisp" instead.
>>
>> Thanks.
>
> Fixed and pushed as b2ba6307 "Explain how to debug emacsclient lisp
> errors".

  This example doesn't work for me with Emacs daemon and the default
  Emacs terminal:

0. emacs -Q --daemon
Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Starting Emacs daemon.

1. emacsclient -n --eval '(progn (defun f () (error "foo")) (setq debug-on-signal t debug-on-error t) (f))'

  (Aside: Although the option "-n" was used, Emacs doesn't return to the
  command prompt.)

2. From another xterm, connect to the Emacs server in order to see the
   *backtrace* buffer that should have been created:

   emacsclient -n non-existant-file.txt

   You now see an Emacs in the default TTY-mode with the *backtrace* buffer
   displayed:

Debugger entered--Lisp error: (error "foo")
  signal(error ("foo"))
  error("foo")
  f()
  (progn (defun f nil (error "foo")) (setq debug-on-signal t debug-on-error t) $
  eval((progn (defun f nil (error "foo")) (setq debug-on-signal t debug-on-erro$
  server-eval-and-print("(progn (defun f () (error \"foo\")) (setq debug-on-sig$
  #[0 "\302\301\242\300\"\207" [#<process server <1>> ("(progn (defun f () (err$
  funcall(#[0 "\302\301\242\300\"\207" [#<process server <1>> ("(progn (defun f$
  mapc(funcall (#[0 "\302\301\242\300\"\207" [#<process server <1>> ("(progn (d$
  server-execute(#<process server <1>> nil t (#[0 "\302\301\242\300\"\207" [#<p$
  #[0 "r\310^N^K!q\210\305\242\203^X^@\311\305\242!\203^X^@\305\242\202^Z^@^N\f$
  server-execute-continuation(#<process server <1>>)
  server-process-filter(#<process server <1>> "-dir /home/liveuser/ -nowait -cu$

  However, when you press any keycords, like "C-x C-b" (list-buffers),
  nothing happens!

  You can't "C-x k" (kill-buffer) or "M-x" (execute-extended-command).

  The only thing you can do is kill Emacs from another terminal shell prompt.

  You can, of course, do all f these things if you use Emacs in GUI-mode
  (emacsclient -c ...) instead of its default TTY-mode.

  Thanks.