How is the octave debugger used?

余生颓废 提交于 2020-07-02 15:46:08

问题


So I'm trying to use the octave debugger to detect where division by zero happens. For that it seems logical to use "debug_on_warning ()". However I'm just not understanding how to use this function call. I mean should I place it in the script somewhere? but then how would the debugger start? an example would be great!


回答1:


Take a look at the Debugging section of the Octave manual.

For your case, you should place debug_on_warning (1) at the top of your script so it stops when the warning happens and drops you in debug mode. Then type dbwhere to find out where you are.

An alternative, that's the way I do it, leave the command keyboard in certain areas where you think the problem may be. Then use dbstep to evaluate your script line by line.




回答2:


Solution for setting a breakpoint in octave

Set breakpoint in file myOctaveCode.m in line 18

dbstop myOctaveCode 18

Call function

myOctaveCode

Debugger stops

stopped in /.../myOctaveCode.m at line 18
...

Now I can use the debugger

debug> who

Variables in the current scope:
... 

When calling dbstep I will jump to the next line

debug> dbstep

Documentation: https://octave.org/doc/v4.4.1/Debug-Mode.html#Debug-Mode

Remark

My answer just fits to the question's title. It's not an exact answer for the question. But I hope it might help others who stumble upon that question while searching for general octave debugging hints. So please do not vote me down.



来源:https://stackoverflow.com/questions/20348811/how-is-the-octave-debugger-used

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!