help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keyboard or dbstop


From: Philip Nienhuis
Subject: Re: keyboard or dbstop
Date: Wed, 5 Feb 2014 12:55:36 -0800 (PST)

Philip Nienhuis wrote
> Helios de Rosario wrote:
>> (It was Re: showtrainprogress: invalid conversion from NaN to logical)
>>
>>>>> On 30/01/2014 at 23:24, Philip Nienhuis <

> address@hidden

> >
>> wrote:
>>
>> [... snip the error report of the OP, which I think is not crucial for
>> my question ...]
>>
>>> You can safely assume that Octave doesn't complain about the if
>> statement in
>>> L. 304 for nothing. So the question is how to find out what is wrong
>> there.
>>>
>>> Well, insert a keyboard statement in empty line 302 and run your
>> code.
>>
>> I would have set a breakpoint with
>> dbstop("/home/syedk/OCT/nnet/tests/MLP/__trainlm.m", 302) instead. I
>> always felt that debugging with "keyboard" is quite uncomfortable,
>> because you must edit the file once and again. But I also wondered if
>> there is some reason that I'm missing, why it could be more
>> recommendable in some cases. Do you have such reason for recommending
>> inserting the keyboard statement in this case? Or it is just a matter of
>> taste?
> 
> Both.
> 
> For one, dbstop didn't always work for me (execution would just ignore 
> the dbstop breakpoint); especially not with function in "private" subdirs.
> (Auto-) Saving the function/script file (which I regularly do while 
> debugging problems - don't you?) might also wipe breakpoints. In this 
> respect your "edit file once and again" point is a bit lost on me :-)
> 
> So I use a keyboard statement as a guaranteed interruption.

I forgot to mention another advantage of the keyboard statement: it's about
the only way to have conditional breakpoints.
Suppose you want to debug a loop that is known to fail somewhere in the
10,000th iteration. It's easier to add an "if (<loopcount>  > 9999);
keyboard; endif" than to 9,999 times enter "dbcont" to get past a dbstop
breakpoint in the loop.

If you depend on e.g., "debug_on_error" the debug prompt often comes too
late to be able to follow how errors are being cooked up.

Philip




--
View this message in context: 
http://octave.1599824.n4.nabble.com/keyboard-or-dbstop-tp4661612p4661685.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]