[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Adding a command to aid in debugging Octave
From: |
John W. Eaton |
Subject: |
Adding a command to aid in debugging Octave |
Date: |
Thu, 14 May 2020 13:25:14 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
When trying to debug an already running Octave session I often get the
pid and run "gdb -p PID" in a separate terminal window. That works for
me on Linux systems. I've also sometimes used a command like
system (sprintf ("gnome-terminal -- gdb -p %d", getpid ()),
false, "async");
at the Octave prompt.
I never expected something like that to work on Windows, but I recently
discovered that gdb can also connect to running processes on Windows.
Am I the only one who didn't know? Until that discovery, I didn't know
any easy way to debug Octave on Windows. But it still required opening
a command window and starting gdb. Then I also found that it is
possible to start gdb in a separate window from the Octave prompt using
system (sprintf ("start gdb -p %d", getpid ()));
Magic! (Also somewhat surprising to me, passing the "async" parameter
on Windows seemed to have the opposite effect and Octave did not return
to the command prompt until the gdb process exited, but I'll worry about
that later.)
To make debugging Octave even easier, would it be useful to add
something like the following function?
function __debug_octave__ ()
[status, ~] = system ("gdb --version");
if (status != 0)
error ("__debug_octave__: unable to execute gdb");
endif
if (isunix ())
## FIXME: Obviously, gnome-terminal is not always available.
system (sprintf ("gnome-terminal -- gdb -p %d", getpid ()),
false, "async");
elseif (ispc ())
system (sprintf ("start gdb -p %d", getpid ()));
elseif (ismac ())
## FIXME: What works?
else
## FIXME: Is this possible?
endif
endfunction
What's the right thing for Mac systems?
Unless there is some magic command I don't know about that works on
Unixy systems, we might need to search for known terminal since we can't
expect to always find gnome-terminal.
Comments? Is there a better way?
jwe
- Adding a command to aid in debugging Octave,
John W. Eaton <=