简体   繁体   English

如何使用八度调试器?

[英]How is the octave debugger used?

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 ()". 为此,使用“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! 一个例子会很棒!

Take a look at the Debugging section of the Octave manual. 看一下Octave手册的Debugging部分

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. 对于您的情况,您应该将debug_on_warning (1)放在脚本的顶部,以便在警告发生时停止并使您进入调试模式。 Then type dbwhere to find out where you are. 然后键入dbwhere以找出您的位置。

An alternative, that's the way I do it, leave the command keyboard in certain areas where you think the problem may be. 另一种选择,就是我这样做,将命令keyboard留在您认为可能出现问题的某些区域。 Then use dbstep to evaluate your script line by line. 然后使用dbstep评估您的脚本。

Solution for setting a breakpoint in octave 以八度为单位设置断点的解决方案

Set breakpoint in file myOctaveCode.m in line 18 在第18行的文件myOctaveCode.m中设置断点

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 当调用dbstep时,我会跳转到下一行

debug> dbstep

Documentation: https://octave.org/doc/v4.4.1/Debug-Mode.html#Debug-Mode 文档: 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. 所以请不要投票给我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM