Debugging Octave: Difference between revisions
(→Debugging oct-files: Inserted a small howto) |
|||
Line 32: | Line 32: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Octave will start up. Now halt execution of Octave by typing ctrl+c, you'll see again the | Octave will start up. Now halt execution of Octave by typing ctrl+c, you'll see again the gdb prompt. Set now a breakpoint in the line of interest | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
Revision as of 14:34, 23 August 2012
Preliminaries
Since compilation of all the source from scratch can take long it is good to have a source folder where most of the source has been compiled. To do this ...
Workflow
- Clone the repository.
- Regenerate the scripts.
- Configure.
- Compile the code.
- Start debugging.
Basic debugging processes
Error & trace the stack
Debugging oct-files
To debug oct-files, avoid making any optimization during compilation. Use export CXXFLAGS="-ggdb -Wall -O0"
for C++ code or export CFLAGS="-ggdb -Wall -O0"
for C code to suppress optimization. Compile the oct-file with the debug flag -g
which enables debug symbols
mkoctfile -g file.cpp
start now the GNU debugger with octave
gdb octave
and run it
(gdb) run
Octave will start up. Now halt execution of Octave by typing ctrl+c, you'll see again the gdb prompt. Set now a breakpoint in the line of interest
(gdb) b file.cpp:40
by typing now c the execution of octave will continue and you can run your oct-file
octave:1> x = file(y)
the debugger will now stop on the above defined line and you can start debugging according to the manual of GNU debugger.
Tools for debugging
GBD
To start Octave under gdb use the script run-octave
at the top level of the source tree and run it with the command-line option -g
like this
cd /octave/source/tree
./run-octave -g
Most used commands
Emacs
In short:
To start Octave in debug mode within emacs type
M-x gud-gdb
then change the command in the minibuffer to
Run gud-gdb (like this): /path/to/octave/source/tree/run-octave -gud
For more info use this
link
to the emacs manual section on debuggers operation
ddd