Debugging Octave: Difference between revisions

1,064 bytes added ,  14 November 2012
Line 51: Line 51:


the debugger will stop on the above defined line and you can start debugging according to the manual of GNU debugger.
the debugger will stop on the above defined line and you can start debugging according to the manual of GNU debugger.
If you encounter problem with interrupting octave (i.e. "^C" is only
printed when you press ctrl+c and control is not transferred to gdb)
then you might follow following steps (which should work always).
# Start gdb<br/><syntaxhighlight lang="bash">> gdb octave</syntaxhighlight>
# Catch loading of your oct-file ("file" below is a regex matching name of your oct-file)<br/><syntaxhighlight lang="bash">(gdb) catch load file</syntaxhighlight>
# Run octave<br/><syntaxhighlight lang="bash">(gdb) r</syntaxhighlight>
# From octave request loading of your oct-file by calling function<br/><syntaxhighlight lang="matlab">octave> x = file(y)</syntaxhighlight>
# Control will switch to gdb just after oct-file is loaded and at this point all symbols from oct-file are available so you can either set up a breakpoint at particular line or at function entry.<br/><syntaxhighlight lang="bash">(gdb) b file.cpp:40</syntaxhighlight>
# Resume execution of octave by<br/><syntaxhighlight lang="bash">(gdb) c</syntaxhighlight>
and debugger will stop at the breakpoint defined.


= Tools for debugging =
= Tools for debugging =
1

edit