unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Use GNU standard for displaying backtraces?
@ 2014-08-08 18:22 Jan Nieuwenhuizen
  2014-08-08 18:23 ` [PATCH] Use GNU standard for displaying backtraces. Allows Emacs integration Jan Nieuwenhuizen
  2014-08-08 18:28 ` Use GNU standard for displaying backtraces? Thompson, David
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 18:22 UTC (permalink / raw)
  To: guile-devel

Hi,

Trying to get Emacs's compilation-mode to support stepping down Guile
backtraces, I wrote some elisp code to determine the absolute file
name for incomplete relative files that come from Guile's load path,
e.g., ice/boot-9.scm.

Resolving this in Emacs is very difficult to do cleanly, if at all
possible.  Also, supporting other editors will have the same problem.
See: https://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00137.html

That's why I propose to discuss this patch.  It changes the backtrace
output from

    guile --debug -e main examples/gud-break.scm
    Backtrace:
    In ice-9/boot-9.scm:
     157: 6 [catch #t #<catch-closure abe3e0> ...]
    In unknown file:
       ?: 5 [apply-smob/1 #<catch-closure abe3e0>]
    In ice-9/boot-9.scm:
      63: 4 [call-with-prompt prompt0 ...]
    In ice-9/eval.scm:
     432: 3 [eval # #]
    In unknown file:
       ?: 2 [eval (main (command-line)) #<directory (gud-break) ab2240>]
    In /home/janneke/vc/guile/examples/gud-break.scm:
    1038: 1 [main ("examples/gud-break.scm")]
    1032: 0 [stderr "~a:hello world\n" (# # #)]

    /home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure stderr:
    /home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure module-lookup: Unbound variable: o

to

    ~/guile-2.2/bin/guile --debug -e main examples/gud-break.scm
    Backtrace:
    unknown file:
       ?: 5 [apply-smob/1 #<catch-closure b9bca0>]
    /home/janneke/guile-2.2/share/guile/2.2/ice-9/boot-9.scm:732:
     732: 4 [call-with-prompt #<unbound> #<unbound> ...]
    /home/janneke/guile-2.2/share/guile/2.2/ice-9/eval.scm:527:
     527: 3 [eval _ #(#<directory (guile-user) b892d0>)]
    unknown file:
       ?: 2 [eval (main (command-line)) #<directory (gud-break) dc0360>]
    /home/janneke/vc/guile/examples/gud-break.scm:1038:
    1038: 1 [main . _]
    1032: 0 [stderr _ . _]

    /home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure stderr:
    /home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure module-lookup: Unbound variable: o

What do you think?

Stefan Monnier also suggests to postfix the backtrace line with `info',
something like

    /home/janneke/vc/guile/examples/gud-break.scm:1038:info:
    1038: 1 [main . _]
    1032: 0 [stderr _ . _]

however, I like to step down all lines of a backtrace with
next-error/previous-error, so haven't done that.

Greetings, Jan


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



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

* [PATCH] Use GNU standard for displaying backtraces. Allows Emacs integration.
  2014-08-08 18:22 Use GNU standard for displaying backtraces? Jan Nieuwenhuizen
@ 2014-08-08 18:23 ` Jan Nieuwenhuizen
  2014-08-08 18:28 ` Use GNU standard for displaying backtraces? Thompson, David
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 18:23 UTC (permalink / raw)
  To: guile-devel

	* libguile/backtrace.c (display_backtrace_file_and_line): Return
	absolute file name if not accessible from here.
	(display_backtrace_file): Use GNU-standard error message; remove
	"In "-prefix, add `:line:column' suffix.
---
 libguile/backtrace.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libguile/backtrace.c b/libguile/backtrace.c
index 0c0f110..3b004b6 100644
--- a/libguile/backtrace.c
+++ b/libguile/backtrace.c
@@ -319,16 +319,19 @@ display_backtrace_get_file_line (SCM frame, SCM *file, SCM *line)
     {
       /* (addr . (filename . (line . column))), from vm compilation */
       *file = scm_cadr (source);
+      if (scm_is_false (scm_stat (*file, SCM_BOOL_F)))
+        {
+          SCM full = SCM_BOOL_F;
+          full = scm_sys_search_load_path (*file);
+          if (!scm_is_false (full))
+            *file = full;
+        }
       *line = scm_caddr (source);
     }
 }
 
 static void
-display_backtrace_file (frame, last_file, port, pstate)
-     SCM frame;
-     SCM *last_file;
-     SCM port;
-     scm_print_state *pstate;
+display_backtrace_file (SCM frame, SCM *last_file, SCM port, scm_print_state *pstate)
 {
   SCM file, line;
 
@@ -339,7 +342,6 @@ display_backtrace_file (frame, last_file, port, pstate)
 
   *last_file = file;
 
-  scm_puts_unlocked ("In ", port);
   if (scm_is_false (file))
     if (scm_is_false (line))
       scm_puts_unlocked ("unknown file", port);
@@ -349,6 +351,8 @@ display_backtrace_file (frame, last_file, port, pstate)
     {
       pstate->writingp = 0;
       scm_iprin1 (file, port, pstate);
+      scm_puts_unlocked (":", port);
+      scm_intprint (scm_to_int (line) + 1, 10, port);
       pstate->writingp = 1;
     }
   scm_puts_unlocked (":\n", port);
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




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

* Re: Use GNU standard for displaying backtraces?
  2014-08-08 18:22 Use GNU standard for displaying backtraces? Jan Nieuwenhuizen
  2014-08-08 18:23 ` [PATCH] Use GNU standard for displaying backtraces. Allows Emacs integration Jan Nieuwenhuizen
@ 2014-08-08 18:28 ` Thompson, David
  1 sibling, 0 replies; 3+ messages in thread
From: Thompson, David @ 2014-08-08 18:28 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-devel

On Fri, Aug 8, 2014 at 2:22 PM, Jan Nieuwenhuizen <janneke@gnu.org> wrote:
> Trying to get Emacs's compilation-mode to support stepping down Guile
> backtraces, I wrote some elisp code to determine the absolute file
> name for incomplete relative files that come from Guile's load path,
> e.g., ice/boot-9.scm.
>

[snip]

> however, I like to step down all lines of a backtrace with
> next-error/previous-error, so haven't done that.

+1 to using the GNU standard.

I can't speak to the quality of the patch, but I have also noticed
that next-error/previous-error didn't work with guile backtraces.  It
would be really useful if it worked.

- Dave



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

end of thread, other threads:[~2014-08-08 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-08 18:22 Use GNU standard for displaying backtraces? Jan Nieuwenhuizen
2014-08-08 18:23 ` [PATCH] Use GNU standard for displaying backtraces. Allows Emacs integration Jan Nieuwenhuizen
2014-08-08 18:28 ` Use GNU standard for displaying backtraces? Thompson, David

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