]> git.eshelyaron.com Git - emacs.git/commit
Experiment giving bytecode in traceback...
authorrocky <rocky@gnu.org>
Mon, 27 Apr 2020 19:14:12 +0000 (15:14 -0400)
committerrocky <rocky@gnu.org>
Mon, 27 Apr 2020 19:14:12 +0000 (15:14 -0400)
commite5734bef9074fa8b1c80c35aa9bf528e31d966a4
tree696212727a9f058b434a11c3881e2d52cbc0716f
parent08408b13faa911b586ac0c181159ada452a942cc
Experiment giving bytecode in traceback...

This commit only changes the behavior when `(cdr)` when it is not
given a `cons` node, in order to give some quick idea of how adding
more traceback information might work.

Here's how to see/use. Build this code.

Byte-compile this buggy function in `/tmp/foo.el`
with (byte-compile-file)
```lisp
(defun foo()
  (setq x 5)
  (cdr 'b)
  )
```

```
(load-file "/tmp/foo.elc")
(foo)
```

You should see:

```
Debugger entered--Lisp error: (wrong-type-argument listp b 3)
                                        this is the offset ^
  foo()
  eval((foo) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
```

Compare against disassembly:

```
byte code for foo:
  args: nil
0 constant  5
1 varset   x
2 constant  b
3 cdr
^^^ offset from above
4 return
```

You can try with other offsets such as by removing the `(setq x 5)`
and you'll see offset 1 instead.

Right now, we just pass to `signal` bytecode offset. More elaborate would be
to pass the code object and its offset. Even more elaborate schemes
could be imagined.
src/bytecode.c
src/data.c
src/eval.c
src/lisp.h