1

With emacs if there is a backtrace buffer open, new backtrace is ignored. I find it is unconvenient when I am trying to find out which function/hook changes a variable. I use debug-watch as described in https://stackoverflow.com/questions/62579200/find-out-when-a-variable-is-changed-in-emacs The problem is the variable changes happens after a backtrace buffer popup is impossible to know because of the backtrace blocking described above.

(debug-watch VARIABLE)

How can I make emacs popup as many backtrace buffers as possible or log the backtraces to a file?

Drew
  • 75,699
  • 9
  • 109
  • 225
godblessfq
  • 1,177
  • 8
  • 21
  • I am not sure what you mean with 'new backtrace is ignored' but you can exit the debugger and continue by pressing `c` (see the section [debugger commands](https://www.gnu.org/software/emacs/manual/html_node/elisp/Debugger-Commands.html) in the elisp manual). – dalanicolai May 25 '22 at 11:47
  • It takes time between debugger popping up and me pressing c, during that time, there is possible other backtraces buried without notice. I have come across this situation. :-( – godblessfq May 26 '22 at 02:54

1 Answers1

0

I'm not sure whether this helps answer your request, but you can use function backtrace directly, to print a backtrace at any time to standard-output (which you can bind to a buffer etc.). C-h f backtrace:

backtrace is a compiled Lisp function in subr.el.

`(backtrace)1

Print a trace of Lisp function calls currently active.

Output stream used is value of standard-output.

See the Elisp manual, node Internals of Debugger, for more info about this, including and example information about variable debugger-stack-frame-as-list.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • It surely helps in debugging one specific package. But often we don't know where is the problem. Like bookmark+ changing buffer local outline-regex and comment-start when saving bookmarks, while making outline-minor-mode crazy. – godblessfq May 26 '22 at 02:58
  • Sorry, but I don't recognize anything you say in your comment about Bookmark+ saving bookmarks. If you think you've found bugs, please report them specifically. AFAIK, Bookmark+ does nothing wrt `out-line-*` or `comment-start` when saving bookmarks or any other time. The only occurrence of `outline-*` in its code is in the doc string for `bookmark-after-jump-hook`, where it just suggests, as an example, that you can use the hook to unhide text in `outline-mode`. And there are no occurrences of `comment-start` in the code. – Drew May 26 '22 at 14:34
  • Bookmark+ seems to open the bookmark file in the background, and during processing of the file, it enables other mode that changes those variables. I disabled bookmark+ and everything is good now. I will look into it further later. – godblessfq May 27 '22 at 00:36
  • I think I have got the backtrace: https://gist.github.com/QiangF/706e6b103c668e87b8ae79fdc76700ea – godblessfq May 27 '22 at 00:44
  • Thanks, but I can't do anything with that really. You seem to have a lot of stuff going on, and it's not clear what - option customizations, key bindings, hydras, etc. Please (1) use `M-x bmkp-send-bug-report` to report the problem. But (2) do so with a *minimal recipe*, starting from `emacs -Q` to repro it. – Drew May 27 '22 at 01:28
  • You can also do `M-x debug-on-entry bookmark-save` and step through the debugger to see what happens. Use `d` for individual steps and `c` when you know you don't need to see the details within a step. With judicious use of `c` you can, in effect, bisect its use to drill into the relevant with details with `d`. – Drew May 27 '22 at 01:29
  • `bookmark-save` is short. You can also try commenting out parts of it, to perhaps see which parts you want to drill into, to find the problem. – Drew May 27 '22 at 01:35