Is there a gdb command to finish a loop construct?

三世轮回 提交于 2019-12-03 04:53:44

问题


In gdb, I have the finish command to easily finish execution of a function frame, often when walking through code in the debugger, after looking at a few iterations of a loop, I'd like to finish the loop and continue walking after it. Presently, I do this by setting a break point on the first line after the loop and continue, however, it would be really handy if there was a simple gdb command to have the same effect of this but not require a break point to be set and later cleared.

Is there anyway in gdb to finish execution of the current loop being executed?


回答1:


Is there a gdb command to finish a loop construct?

Execute until on the last line of the loop, or until NNN where NNN is the last line of the loop.

(gdb) help until
Execute until the program reaches a source line greater than the current
or a specified location (same args as break command) within the current frame.

not require a break point to be set and later cleared.

Temporary breakpoints automatically clear themselves:

(gdb) help tbreak
Set a temporary breakpoint.
Like "break" except the breakpoint is only temporary,
so it will be deleted when hit.  Equivalent to "break" followed
by using "enable delete" on the breakpoint number.



回答2:


gdb doesn't know where a loop ends so it can't do that. I think the best you can do is use the advance command with a location after the loop.



来源:https://stackoverflow.com/questions/14651073/is-there-a-gdb-command-to-finish-a-loop-construct

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