Re: Source level debug?
"Willem Broekema" <[email protected]> Sun, 26 Oct 2008 22:38:16 +0100
| Newsgroups | gmane.lisp.allegro |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Oct 25, 2008 at 12:05 PM, Andreas Thiele <[email protected]> wrote: > I have a lengthy function which produces an error. Is there a change to see, where in > the source the error occurs? > > At the moment I only understand, that the function is responsible for the error. > Unfortunately I have no clue where in this lengthy function the error is. There is a wealth of documentation at: http://www.franz.com/support/documentation/8.1/doc/debugging.htm Here are two ideas I use most myself: first, look at the stack trace leading to the error using the :zoom and :loc commands. Second, improve the clarity of the stack trace by running the function interpreted instead of compiled. Here's an example interaction, where first function foo is compiled and called leading to an error. The first :zoom (or :zo) command lists the stack tracem says the error is somewhere in 'foo. Assuming I'm very dense and don't understand the error yet ;) I run the same function interpreted, and it shows the exact division operation that goes wrong. In interpreted code even let forms and such are visible as frames in the stack trace. Couple this with :loc showing the local variables of the frame, and pinpointing the errors is usually straightforward. Hope this helps, - Willem cl-user(1): (defun foo (x) (/ 3 x)) foo cl-user(2): (compile 'foo) foo nil nil cl-user(3): (foo 0) Error: Attempt to divide 3 by zero. [condition type: division-by-zero] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart). 1: Abort entirely from this (lisp) process. [1] cl-user(4): :zo Evaluation stack: (error division-by-zero :operation ...) ->(foo 0) [... excl::%eval ] (eval (foo 0)) (tpl:top-level-read-eval-print-loop) (tpl:start-interactive-top-level #<terminal-simple-stream [initial terminal io] fd 0/1 @ #x10115bca> #<Function top-level-read-eval-print-loop> ...) [1] cl-user(5): :res cl-user(6): (defun foo (x) (/ 3 x)) foo cl-user(7): (foo 0) Error: Attempt to divide 3 by zero. [condition type: division-by-zero] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart). 1: Abort entirely from this (lisp) process. [1] cl-user(8): :zo Evaluation stack: (error division-by-zero :operation ...) ->(/ 3 0) (foo 0) (eval (foo 0)) (tpl:top-level-read-eval-print-loop) (tpl:start-interactive-top-level #<terminal-simple-stream [initial terminal io] fd 0/1 @ #x10115bca> #<Function top-level-read-eval-print-loop> ...) [1] cl-user(9): :loc Interpreted lexical environment: x: 0 Compiled lexical environment: 0(required): number: 3 1(rest): excl::more-numbers: (0) 2(local): x: 0 3(local): excl::local-0: (0) 4(local): excl::local-1: 3 5(local): excl::local-2: (0)