Proposal of adding a debug function
Krzesimir Nowak
qdlacz at gmail.com
Thu Sep 11 07:32:15 CDT 2008
Hi,
I'd like to go straight into the matter:
Suggestion:
Adding to Octave3.1 a command called dbmode, which returns true when
debug mode is on, and false when it's off.
Rationale:
- Make it easy for external process to know in which mode Octave now is.
Here I think mainly about GUI which communicates with Octave through
some interprocess communication system (eg. DBus in my project).
- User writing a script could use this for debugging by writing:
if (dbmode())
do_some_checking();
#and zounds of printfs;
endif
End of rationale.
I attached a diff made with diff -u against version 3.1.51 and a
ChangeLog.
I compiled Octave and tested the function, and it seems to work (it's a
simple function, so there rather are no complications).
The only thing which may be disturbing is compatibility with MATLAB,
because I don't know if MATLAB has any function of that sort (MATLAB 7.0
doesn't have). I could think about it as an extension to MATLAB like ++
increment operator.
An example of my function:
octave3.1:6> dbstop("hopfield", 20)
ans = 23
octave3.1:7> dbmode
Debug mode is off
octave3.1:8> hopfield(0.5, 5);
hopfield: line 23, column 17
digits (:, :, 3) = [1, -1, -1, -1, -1, -1, 1; 1, -1, 1, 1, 1, -1, 1; 1,
-1, 1, 1, 1, -1, 1; 1, 1, 1, 1, -1, -1, 1; 1, 1, 1, -1, -1, 1, 1; 1, 1,
-1, -1, 1, 1, 1; 1, -1, -1, 1, 1, 1, 1; 1, -1, 1, 1, 1, 1, 1; 1, -1, -1,
-1, -1, -1, 1]
keyboard: stopped in /home/kudi/projekty/octave/hopfield/hopfield.m at
line 23
debug> dbmode
Debug mode is on
debug> if (dbmode())
> printf("I'm in debbugging mode.\n");
> else
> printf("I'm not debugging now.\n");
> endif
I'm in debbugging mode.
debug> dbquit
octave3.1:8> if (dbmode())
> printf("I'm in debbugging mode.\n");
> else
> printf("I'm not debugging now.\n");
> endif
I'm not debugging now.
octave3.1:9>
I wonder if a bug report for this is needed.
Thanks,
Krzesimir Nowak.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ChangeLog
Type: text/x-changelog
Size: 117 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20080911/c54ef5e5/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug.diff
Type: text/x-patch
Size: 761 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20080911/c54ef5e5/attachment-0001.bin
More information about the Bug-octave
mailing list