unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Getting stack traces without entering the debugger
@ 2014-02-19 16:12 E Sabof
  2014-02-19 17:13 ` Michael Heerdegen
  2014-02-19 18:04 ` Andreas Röhler
  0 siblings, 2 replies; 5+ messages in thread
From: E Sabof @ 2014-02-19 16:12 UTC (permalink / raw)
  To: help-gnu-emacs

I'm trying to investigate an isearch-related issue, where a function gets called twice, instead of once.

Is there a way to get a stack trace and save it to a variable, without calling the debugger?

Evgeni



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting stack traces without entering the debugger
  2014-02-19 16:12 Getting stack traces without entering the debugger E Sabof
@ 2014-02-19 17:13 ` Michael Heerdegen
  2014-02-19 17:18   ` E Sabof
  2014-02-19 18:04 ` Andreas Röhler
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2014-02-19 17:13 UTC (permalink / raw)
  To: help-gnu-emacs

E Sabof <esabof@gmail.com> writes:

> I'm trying to investigate an isearch-related issue, where a function
> gets called twice, instead of once.

Why don't you just `debug-on-entry' that function?

> Is there a way to get a stack trace and save it to a variable, without
> calling the debugger?

You can use `backtrace' (which is actually called by the debugger to
fill the *Backtrace* buffer) and use some temp buffer as
`standard-output'.

In recent Emacs version, there's also `macroexp--backtrace', a little
helper in macroexp.el that returns a backtrace as a lisp expression.
Even in older version, the simple definition should still work:

(defun macroexp--backtrace ()
  "Return the Elisp backtrace, more recent frames first."
  (let ((bt ())
        (i 0))
    (while
        (let ((frame (backtrace-frame i)))
          (when frame
            (push frame bt)
            (setq i (1+ i)))))
    (nreverse bt)))

Unlike `backtrace', the result is complete, there are no parts that are
replaced with ellipses by the printer.  Of course, parts can still be
omitted when you print the result.   `pp' should work fine.

The doc of `backtrace-frame' describes the format of the backtrace
frames returned.

Michael.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting stack traces without entering the debugger
  2014-02-19 17:13 ` Michael Heerdegen
@ 2014-02-19 17:18   ` E Sabof
  0 siblings, 0 replies; 5+ messages in thread
From: E Sabof @ 2014-02-19 17:18 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

Thanks!

Evgeni



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting stack traces without entering the debugger
  2014-02-19 16:12 Getting stack traces without entering the debugger E Sabof
  2014-02-19 17:13 ` Michael Heerdegen
@ 2014-02-19 18:04 ` Andreas Röhler
  2014-02-19 18:10   ` E Sabof
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Röhler @ 2014-02-19 18:04 UTC (permalink / raw)
  To: help-gnu-emacs

Am 19.02.2014 17:12, schrieb E Sabof:
> I'm trying to investigate an isearch-related issue, where a function gets called twice, instead of once.
>
> Is there a way to get a stack trace and save it to a variable, without calling the debugger?
>
> Evgeni
>
>

Maybe M-x trace-function... ?

It displays an output-buffer, which might be saved.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting stack traces without entering the debugger
  2014-02-19 18:04 ` Andreas Röhler
@ 2014-02-19 18:10   ` E Sabof
  0 siblings, 0 replies; 5+ messages in thread
From: E Sabof @ 2014-02-19 18:10 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs


Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> Maybe M-x trace-function... ?
>
> It displays an output-buffer, which might be saved.

I've traced the error to an old defadvice. Still, trace-function does look useful.

Evgeni



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-19 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 16:12 Getting stack traces without entering the debugger E Sabof
2014-02-19 17:13 ` Michael Heerdegen
2014-02-19 17:18   ` E Sabof
2014-02-19 18:04 ` Andreas Röhler
2014-02-19 18:10   ` E Sabof

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).