Page 1 of 1

How do I know where error is occured?

Posted: Fri Feb 12, 2010 5:48 pm
by yougene
Error messages don't always list the function where an error occured. How do I find this information?

Re: How do I know where error is occured?

Posted: Fri Feb 12, 2010 8:23 pm
by nuntius
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.

Re: How do I know where error is occured?

Posted: Fri Feb 12, 2010 9:22 pm
by smithzv
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]>".

Re: How do I know where error is occured?

Posted: Sat Feb 13, 2010 2:58 pm
by hewih
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

Re: How do I know where error is occured?

Posted: Sat Feb 13, 2010 3:15 pm
by ramarren
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.

Re: How do I know where error is occured?

Posted: Sat Feb 13, 2010 11:20 pm
by Jesdisciple
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