3

I am trying to debug a problem in some elisp and don't understand how to access the information I want from the Emacs Debugger.

Specifically, my backtrace looks like:

⋮
  #f(compiled-function (hover) #<bytecode 0x26f7872a3e8bae1>)(#<hash-table equal 1/1 0x1fe85528cbdf>)
  apply(#f(compiled-function (hover) #<bytecode 0x26f7872a3e8bae1>) #<hash-table equal 1/1 0x1fe85528cbdf>)
  #f(compiled-function (&rest args) #<bytecode 0xe8a92e4d3997328>)(#<hash-table equal 1/1 0x1fe85528cbdf>)
  #f(compiled-function (result) #<bytecode -0xd842d2c46378a2f>)(#<hash-table equal 1/1 0x1fe859656ddf>)
  #f(compiled-function (result) #<bytecode -0x6d44600f4b68ed1>)(#<hash-table equal 1/1 0x1fe859656ddf>)
  funcall(#f(compiled-function (result) #<bytecode -0x6d44600f4b68ed1>) #<hash-table equal 1/1 0x1fe859656ddf>)
⋮

and I want to examine those #<hash-table…> values.

How do I access those? That is, if I wanted to call (hash-table-keys #<hash-table…>), how would I do that from the *Backtrace* buffer?

(At least some of the functions are generated by complicated macros, so I can't just use Edebug—at least not easily.)

3
  • 1
    I personally have gone bonkers trying to debug stuff that has been compiled, and what I usually do is remove the byte-compiled files, reboot, and try to reproduce the bug without said files. That way, I can start examining stuff more easily.
    – lawlist
    Commented Aug 11, 2020 at 3:18
  • I would recommend simply visiting the library file in question and using M-x eval-buffer.
    – phils
    Commented Aug 11, 2020 at 3:36
  • Your lambda is compiled so the debugger can't step inside it. when it's not compiled, you'll be able to use e to get value of the hash table, see Drew's answer.
    – xuchunyang
    Commented Aug 11, 2020 at 4:12

1 Answer 1

3

Load the source file (*.el, not *.elc) that defines the function you're interested in. E.g., M-x load-file or M-x load-library (but be sure to specify .el).

Then use M-x debug-on-entry, to enter the debugger when that function is called. Step through the debugger with d (or c to skip through a step you're not interested in). Use e to evaluate any sexp (e.g. the value of an argument) at any time.

If the function you want has no name then you can, alternatively, insert (debug) anywhere in its source code, to create a break point, which will open the debugger at that point.

You can also insert (debug nil SEXP1 SEXP2...), where each SEXPN is something you want evaluated and printed when the debugger opens.

Not the answer you're looking for? Browse other questions tagged or ask your own question.