Re: Line number and source file names in stack trace, part 1

From: Michael Hohn <hohn_at_math.utah.edu>
Date: Sat, 1 Jan 2000 23:51:08 -0700 (MST)

Hello again,

I cured my hangover through programming, so expect some bugs :)

A short description of the patch (to be applied in STk-4.0.1 via
patch -p1 < ../stk-dbg-diff
) follows.

I added READ_HOOK macro to stk.h; it is initialized to #f in toplevel.c
The Scheme name is *read-hook*.
When non-#f, *read-hook* is called with (cons file line) arguments for
every line read from a file input port (files and stdin).

An example binding for tracking locations is in Lib/error.stk
(dbg-track-source), along with a modified (but separate) version of
STk:report-error.

A short usage example:
1. start emacs
2. in emacs, do M-x server-start
3. start stk
4. in stk
    o do (load "td.scm"), with the contents below.
    o try (thi 'a), and get the stack trace.
    o in the traceback, click on one of the line numbers. Emacs
        should visit the file at that line.
cat > td.scm <<EOF
; test debugging facilities
(dbg-track-source)

(define (foo n)
  (+ n 2))
  
(define (bar n)
  (* n
     n
     (foo n)))

(define (thi n)
  (+ 2
     3
     (bar n)))
EOF


Some possible problems/shortcomings:
o Src/read.c: read_list() calls STk_lookup_variable() when
    necessary. This may slow down the reading of files -- I have not
    tested this.

o Lib/error.stk: There are many choices for debugger interaction. I
    like emacs, hence the emacsclient calls. But using a text widget
    may be more suitable for quick and simple debugging.
    Also, new debuggers should probably not go into error.stk

o dbg-track-source is autoloaded in the same way as
    STk:report-error. Is this always safe?

Improvements, fixes etc. are always welcome.

Cheers,
    Michael
Received on Sun Jan 02 2000 - 07:51:55 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST