501
edits
m (Added chapter "Debugging oct-files") |
(→Debugging oct-files: Inserted a small howto) |
||
Line 13: | Line 13: | ||
= Debugging oct-files = | = Debugging oct-files = | ||
To debug oct-files, avoid making any optimization during compilation. Use <code>export CXXFLAGS="-ggdb -Wall -O0"</code> for C++ code or <code>export CFLAGS="-ggdb -Wall -O0"</code> for C code to suppress optimization. Compile the oct-file with the debug flag <code>-g</code> which enables debug symbols | |||
<syntaxhighlight lang="bash"> | |||
mkoctfile -g file.cpp | |||
</syntaxhighlight> | |||
start now the GNU debugger with octave | |||
<syntaxhighlight lang="bash"> | |||
gdb octave | |||
</syntaxhighlight> | |||
and run it | |||
<syntaxhighlight lang="bash"> | |||
(gdb) run | |||
</syntaxhighlight> | |||
Octave will start up. Now halt execution of Octave by typing ctrl+c, you'll see again the gnu prompt. Set now a breakpoint in the line of interest | |||
<syntaxhighlight lang="bash"> | |||
(gdb) b file.cpp:40 | |||
</syntaxhighlight> | |||
by typing now c the execution of octave will continue and you can run your oct-file | |||
<syntaxhighlight lang="matlab"> | |||
octave:1> x = file(y) | |||
</syntaxhighlight> | |||
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 = | = Tools for debugging = |
edits