unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Summer of Code Project
@ 2020-04-27 19:59 Rocky Bernstein
  0 siblings, 0 replies; only message in thread
From: Rocky Bernstein @ 2020-04-27 19:59 UTC (permalink / raw)
  To: emacs-devel, Zach Shaftel

[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]

Hi -

There is a possibility of a Google funding a Summer of Code project to add
bytecode offsets on bytecode errors and also perhaps in tracebacks.

However since this would be considerable effort on the Summer of Code
student and me, I don't want to undertake this if it is not there is
concern.

As a small first step to give people a feeling of how this might start out,
I've created a branch in emacs: feature/soc-bytecode-in-traceback
<http://git.savannah.gnu.org/cgit/emacs.git/log/?h=feature/soc-bytecode-in-traceback>
to
explore what things might look like.

If you build that code and emacs when the bytecode hits an error in running
`cdr` because it is given a non-cons argument you'll see the offset shown
as last (3rd) argment in the debugger argument.

For example:

Byte-compile this buggy function in /tmp/foo.el
with (byte-compile-file):

(defun foo()
  (setq x 5)
  (cdr 'b) ;; Invalid cdr argument: 'b
)


Then run :

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

and 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 the bytecode offset. More elaborate would
be
to pass the code object and its offset.

And even more elaborate schemes could be imagined.

If there is trepidation or concerns about this, let me know.

[-- Attachment #2: Type: text/html, Size: 2924 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-27 19:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 19:59 Summer of Code Project Rocky Bernstein

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).