我想在 gdb 中运行以下命令:
while 1
x $pc
stepi
end
但我不想要stepi命令的输出。有没有办法只禁用stepi命令输出?
您可能想尝试一下gdbpython:
while True:
gdb.execute("x/i $pc") # you can see the output on terminal
gdb.execute("stepi", to_string=True) # so that you cannot see its output
# some stop criteria here?
在 gdb 中输入这样的内容:
python
while True:
gdb.execute("x/i $pc")
gdb.execute("stepi", to_string=True)
end
我使用 -batch-silent 键解决了类似的问题。
阻止所有 GDB 输出到 stdout(stderr 不受影响)。
要将输出重定向到 stderr,您可以使用 setlogging:
while 1
set logging file /dev/stderr
set logging on
x/1i $pc
set logging file /dev/stdout
set logging off
stepi
end