all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Debugger output: where to look for its explanation?
@ 2015-03-28 23:03 Marcin Borkowski
  2015-03-29  1:01 ` Drew Adams
  2015-03-30  7:00 ` Nicolas Richard
  0 siblings, 2 replies; 4+ messages in thread
From: Marcin Borkowski @ 2015-03-28 23:03 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi all,

so I got this as a *Backtrace*:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 2959 2959)
  scan-sexps(2980 -3)
  forward-sexp(-3)
  backward-sexp(3)
  (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p)))))
  (if (and (eq major-mode (quote emacs-lisp-mode)) (nth 3 (syntax-ppss))) (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p))))))
  (save-excursion (skip-syntax-forward "\"-") (if (and (eq major-mode (quote emacs-lisp-mode)) (nth 3 (syntax-ppss))) (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p)))))))
  is-current-line-docstring-p()
  eval((is-current-line-docstring-p) nil)
  eval-expression((is-current-line-docstring-p) nil)
  funcall-interactively(eval-expression (is-current-line-docstring-p) nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
--8<---------------cut here---------------end--------------->8---

etc.

I grepped both the Emacs manual and the Elisp reference for "Lisp
error", but couldn't find specific info.

What do the 2959 2959 mean?  (I assume they are some positions in the
buffer; I found out that they correspond to the beginning of the line
where the error manifested itself - but what are they exactly?)

I'm rather confident that the numbers in parens after function names are
their arguments.

OTOH, some of these lines contain forms and not functions.  Why?  Why is
my function ("is-current-line-docstring-p") "split" into forms
(save-excursion, if and let) and other functions are not?

Some of the function names are clickable and some are not.  Why?  (I
would assume that the Elisp ones are clickable and the C ones are not.
Correct?)

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* RE: Debugger output: where to look for its explanation?
  2015-03-28 23:03 Debugger output: where to look for its explanation? Marcin Borkowski
@ 2015-03-29  1:01 ` Drew Adams
  2015-03-29 13:03   ` Marcin Borkowski
  2015-03-30  7:00 ` Nicolas Richard
  1 sibling, 1 reply; 4+ messages in thread
From: Drew Adams @ 2015-03-29  1:01 UTC (permalink / raw)
  To: Marcin Borkowski, Help Gnu Emacs mailing list

> so I got this as a *Backtrace*:
> 
> Debugger entered--Lisp error: (scan-error "Containing expression ends
> prematurely" 2959 2959)

No doubt someone will give you interesting details about the info
in the backtrace.

FWIW, whenever I get that error message it's pretty clear what the
problem is, because I was evaluating a sexp (so I know which one is
problematic).  It's typically because I forgot a right paren somewhere.



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

* Re: Debugger output: where to look for its explanation?
  2015-03-29  1:01 ` Drew Adams
@ 2015-03-29 13:03   ` Marcin Borkowski
  0 siblings, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2015-03-29 13:03 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list


On 2015-03-29, at 03:01, Drew Adams <drew.adams@oracle.com> wrote:

>> so I got this as a *Backtrace*:
>> 
>> Debugger entered--Lisp error: (scan-error "Containing expression ends
>> prematurely" 2959 2959)
>
> No doubt someone will give you interesting details about the info
> in the backtrace.

I would hope!  It seems this is not very well documented in the Emacs
manual.

> FWIW, whenever I get that error message it's pretty clear what the
> problem is, because I was evaluating a sexp (so I know which one is
> problematic).  It's typically because I forgot a right paren somewhere.

Not really in this case -- I was writing a function which analysed the
code.  More precisely, given that the point was somewhere in a string,
the function decides whether it's a docstring or not.  (It is part of my
SLOC counting library.)  But I agree, it *was* clear where the problem
was.  But thanks anyway!

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: Debugger output: where to look for its explanation?
  2015-03-28 23:03 Debugger output: where to look for its explanation? Marcin Borkowski
  2015-03-29  1:01 ` Drew Adams
@ 2015-03-30  7:00 ` Nicolas Richard
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Richard @ 2015-03-30  7:00 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:

> Hi all,
>
> so I got this as a *Backtrace*:
>
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 2959 2959)
>   scan-sexps(2980 -3)
>   forward-sexp(-3)
>   backward-sexp(3)
>   (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p)))))
>   (if (and (eq major-mode (quote emacs-lisp-mode)) (nth 3 (syntax-ppss))) (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p))))))
>   (save-excursion (skip-syntax-forward "\"-") (if (and (eq major-mode (quote emacs-lisp-mode)) (nth 3 (syntax-ppss))) (let ((beg-string (nth 8 (syntax-ppss))) (current-line (line-number-at-pos))) (goto-char beg-string) (backward-sexp 3) (if (and (member (symbol-at-point) symbols-with-docstrings) (looking-back "^(")) (progn (goto-char beg-string) (forward-sexp) (or (> (line-number-at-pos) current-line) (is-current-line-comment-only-p)))))))
>   is-current-line-docstring-p()
>   eval((is-current-line-docstring-p) nil)
>   eval-expression((is-current-line-docstring-p) nil)
>   funcall-interactively(eval-expression (is-current-line-docstring-p) nil)
>   call-interactively(eval-expression nil nil)
>   command-execute(eval-expression)
> --8<---------------cut here---------------end--------------->8---

The following descriptions is from my experience, not from the source,
but I'm fairly confident it is right (modulo me not being able to
express myself correctly) :

- The first line is a special one: it shows you which error
  was thrown. Look into the source code, it happens in scan_lists (a C
  function) :

  xsignal3 (Qscan_error, build_string ("Containing expression ends
  prematurely"), make_number (last_good), make_number (from));

  This also tells you the meaning of the numbers.

- Each line below that one is "something" that was evaluated by emacs,
  with the latest at the top (second line). A line that begins with a
  symbol means a function call, and if it begins with an opening paren
  it's evaluation of a form.

- Most lines are of the "function call" kind when you run byte-compiled
  code. When the code was evalled from the source file, you get to see
  more of the "evaluated form" kind (they represent the steps
  between function calls).

- In each "function call" kind, you see the name of the function and the
  value of its arguments.

- In the "evaluated form" kind of line, you can see precisely which form
  was called, which allows you to follow the execution path. E.g. above
  is-current-line-docstring-p, you see a (save-excursion ...) form which
  corresponds to the definition of that function. The line above that
  one is an (if ...), precisely the one that's in the save-excursion.
  etc.
  
Btw that buffer is more than just a backtrace : you're in a debugger
where you can e.g. eval things in the context (with `e'). See C-h m as
usual.

HTH,

Nicolas.



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

end of thread, other threads:[~2015-03-30  7:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-28 23:03 Debugger output: where to look for its explanation? Marcin Borkowski
2015-03-29  1:01 ` Drew Adams
2015-03-29 13:03   ` Marcin Borkowski
2015-03-30  7:00 ` Nicolas Richard

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.