Help a newbie figure out how to enter the debugger please!

Friends -

I’ve been using Octave for a few weeks now, and I’m getting a lot done. However, it’s time for me to learn how to use the debugger. The script I’m debugging is hanging for an unknown reason, and I’d like to see where it stopped and check out the situation.

I’m using the GUI on Windows. I’m attempting to decipher the intsructions at https://octave.org/doc/v6.2.0/Debugging.html

I’ve put debug_on_interrupt(1); at the top of my script. While the script is running, I hit Ctrl-C, and it takes me back to the >> prompt. From there, I’ve tried a few of the commands from the documentation:

>> dbwhere
at top level
>> dblist
error: dblist: must be inside a user function to use dblist
>> isdebugmode()
ans = 0
>> dbstatus
stop if interrupt
>> dbtype
error: dbtype: must be inside a user function to give no arguments to dbtype
>>

Note: the script I’m debugging is a .m file with no functions in it. Is that the problem? Do I need to wrap my code inside a function in order to debug it?

Thanks in advance!

Solomon

Two easy ways.

  1. Use the command keyboard; wherever you want the program to halt and return control to the keyboard inside debug mode.

  2. In the editor, click to the left of the line number to add a red circle, which is a debug breakpoint, that will do the same as keyboard.

1 Like

Thanks, that helps a lot!

Can you explain what I’m misundestanding about debug_on_interrupt?

I don’t think it works properly in recent released versions of Octave.

See also bug #60174.

Third easy way:

  1. Use dbstop FUNCTION_NAME LINE_NUMBER at the command line.