GDB:每步操作后禁用当前行的打印 [英] GDB: disable printing of current line after every step
问题描述
GNU gdb命令行调试器在每个 step
和 next
命令之后打印当前所在的行.考虑下面的gdb会话,我在其中逐步执行一些代码:
The GNU gdb commandline debugger prints the line it is currently on after every step
and next
command. Consider the following gdb session where I step through some code:
...
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd848)
at src/main.cc:3
3 int main(int argc, char **argv){
(gdb) next
4 Printf("Hello World\n"); // <--- disable this
(gdb)
5 printf("Hello World 2\n"); // <--- disable this
(gdb)
是否有gdb设置来禁用此打印?我知道这在技术上是可行的,因为gdb TUI确实具有我要查找的行为(可通过gdb命令 set enable tui
访问).
Is there a gdb setting to disable this printing? I know this is technically possible because the gdb TUI has exactly the behaviour i'm looking for (accessible through gdb command set enable tui
).
谢谢!
推荐答案
我是通过重定向实现的:
I achieved it through redirection:
define n
set logging file /dev/null
set logging redirect on
set logging on
next
set logging off
display
end
我发现使用 gdb.execute
(gdb的python API)无法捕获 next
的输出.我希望是这种情况,因为源行不是由 next
本身打印的,而是由触发的stop事件打印的.
I found that capturing the output of next
did not work using gdb.execute
(gdb's python API). I expect that this is the case because the source line is not printed by next
itself, but by the stop event that is triggered.
这篇关于GDB:每步操作后禁用当前行的打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!