This article concentrates on describing how to use gdb. If you run Octave from a build tree, execute. Note that when Octave runs in GUI mode, it forks at startup on Linux and MacOS systems, so this method will only work if gdb correctly follows the process across the fork and exec system calls. Alternatively, you can attach a debugger to a running Octave session. 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 gnome-terminal. On MacOS systems, the default debugger is lldb. For some kinds of errors on some OS, the last approach might not be useful.
The OS might kill the shell that runs gdb as soon as the spawning process i. Octave crashes. In that case, you can attach to Octave from an "independent" shell.
On Windows, use the msys2 shell that can be started with the file cmdshell. Independent of how gdb was started and Octave was attached to it, it is now possible to issue gdb commands on the gdb prompt. See e. To return to Octave while gdb is still attached to it, execute continue or c at the gdb prompt. To debug oct-files, avoid making any optimization during compilation. Compile the oct-file with the debug flag -g which enables debug symbols. In next step you will use GNU debugger or gdb.
The symbols from your oct-file will only be available to gdb once the oct-file is loaded in Octave. To do that without executing any functions from the oct-file, you can ask Octave to display the help for the oct-file:.
To document mex-files, there should exist an m-file in the same directory as the mex-file itself. Taking the above as an example, we would therefore have a file myhello. In this case, the function that will be executed within Octave will be given by the mex-file, while the help string will come from the m-file. This can also be useful to allow a sample implementation of the mex-file within the Octave language itself for testing purposes.
Although there cannot be multiple entry points in a single mex-file, one can use the mexFunctionName function to determine what name the mex-file was called with.
This can be used to alter the behavior of the mex-file based on the function name. Improve this answer. Cris Luengo Cris Luengo Hi, I asked how to start the debugger, dbstop and dbstep is for when I am already in the debug mode executing the. Could you please add just a little more explanation on how to enter that debug mode? ChanKim: dbstop can be used at any time, also and especially outside of debug mode.
See my edit. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related
0コメント