How do I know where error is occured?

Discussion of Common Lisp
Post Reply
yougene
Posts: 23
Joined: Thu Jan 21, 2010 1:23 pm

How do I know where error is occured?

Post by yougene » Fri Feb 12, 2010 5:48 pm

Error messages don't always list the function where an error occured. How do I find this information?

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: How do I know where error is occured?

Post by nuntius » Fri Feb 12, 2010 8:23 pm

What type of messages are you getting? If you're in a debugger, have you looked at the backtraces? Errors often occur long before the problem becomes evident... For example, something sets a value to nil, then another function tries using it as a number.

smithzv
Posts: 94
Joined: Wed Jul 23, 2008 11:36 am

Re: How do I know where error is occured?

Post by smithzv » Fri Feb 12, 2010 9:22 pm

Yes, usually you are told of the inner most function, so you often get things like "Error: (+ X 5); X is not a number." You need a backtrace to find out the information I think you're after, and how you get it depends on the implementation you are using. In Slime, and error will come with a backtrace right in the debugger interaction buffer, just look at the enclosing frames. If you are at the command line, which I kind of assume you are, in SBCL, for instance, you would type BACKTRACE at the debugger prompt "0]"; in CLISP, you would type :bt (or one of the other backtrace commands) at the debugger prompt "Break 1 [n]>".

hewih
Posts: 30
Joined: Tue Jan 19, 2010 9:36 am

Re: How do I know where error is occured?

Post by hewih » Sat Feb 13, 2010 2:58 pm

finding the error section is my hardest problem currently too
in LispWorks you can use the debugger and click at the stack calls ("Subfunction 17")
i also use a mix of (format T "i am here"), (break "description of break") and backtrace

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: How do I know where error is occured?

Post by ramarren » Sat Feb 13, 2010 3:15 pm

hewih wrote:finding the error section is my hardest problem currently too
In Emacs with Slime in debugger you can press "v" with the cursor on the specific frame in the backtrace and the form will get highlighted. Well, some form will get highlighted, getting precise location require compiling with high debug setting. There is a shortcut in Slime to recompile a form with maximum debug, by default C-u C-c C-c . All this works at least in SBCL.

Jesdisciple
Posts: 26
Joined: Thu Feb 04, 2010 5:56 pm

Re: How do I know where error is occured?

Post by Jesdisciple » Sat Feb 13, 2010 11:20 pm

So far I've found the output from Slime-CLisp's debugger (with default settings) pretty much useless. I've gathered a few links that I can read on the topic, but so far I guess I just haven't had my fill of punishment; I've found all my bugs by building test-cases and putting them in the REPL (or coming here if I get really stumped). And yes, the implication that I don't actually program in the REPL is correct; I haven't read enough on that either.

Linkies:
http://clisp.cons.org/impnotes/debugger.html
http://lispforum.com/viewtopic.php?f=2&t=564
http://common-lisp.net/project/slime/do ... ugger.html
I'm off my grokker.
- Chris

Post Reply