Editing Debugging Octave
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 19: | Line 19: | ||
Alternatively, you can attach a debugger to a running Octave session. Current versions of Octave include the command <code>__debug_octave__</code> to manage the details. Executing this command at the Octave prompt should open a separate window for a debugger session attached to the current Octave process. On Linux systems, the default terminal window is <code>gnome-terminal</code>. On MacOS systems, the default debugger is <code>lldb</code>. | Alternatively, you can attach a debugger to a running Octave session. Current versions of Octave include the command <code>__debug_octave__</code> to manage the details. Executing this command at the Octave prompt should open a separate window for a debugger session attached to the current Octave process. On Linux systems, the default terminal window is <code>gnome-terminal</code>. On MacOS systems, the default debugger is <code>lldb</code>. | ||
Independent of how <code>gdb</code> was started and Octave was attached to it, it is now possible to issue gdb commands on the <code>(gdb)</code> prompt. See e.g. the [https://sourceware.org/gdb/download/onlinedocs/gdb/index.html gdb documentation]. To return to Octave while gdb is still attached to it, execute <code>continue</code> (or <code>c</code>) at the <code>(gdb)</code> prompt. | Independent of how <code>gdb</code> was started and Octave was attached to it, it is now possible to issue gdb commands on the <code>(gdb)</code> prompt. See e.g. the [https://sourceware.org/gdb/download/onlinedocs/gdb/index.html gdb documentation]. To return to Octave while gdb is still attached to it, execute <code>continue</code> (or <code>c</code>) at the <code>(gdb)</code> prompt. | ||
*NOTE: Ubuntu introduced a patch to disallow ptracing of non-child processes by non-root users - | *NOTE*: Ubuntu introduced a patch to disallow ptracing of non-child processes by non-root users - ie. only a process which is a parent of another process can ptrace it for normal users - whilst root can still ptrace every process. | ||
That's why gdb won't be able to link to the octave process if you start gdb from within an Octave session using the <code>__debug_octave__</code> command | That's why gdb won't be able to link to the octave process if you start gdb from within an Octave session using the <code>__debug_octave__</code> command | ||
You can temporarily disable this restriction by doing: | You can temporarily disable this restriction by doing: | ||
Line 31: | Line 29: | ||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | ||
</syntaxhighlight> | </syntaxhighlight> | ||
and then reopen | and then reopen the gdb using the command mentioned above from within an Octave session or if you have admin right you can simply do: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
__debug_octave__ ("gnome-terminal --command 'sudo gdb -p %d'") | __debug_octave__ ("gnome-terminal --command 'sudo gdb -p %d'") |