禁用特定命令的 gdb 输出

问题描述 投票:0回答:2

我想在 gdb 中运行以下命令:

while 1
x $pc
stepi
end

但我不想要stepi命令的输出。有没有办法只禁用stepi命令输出?

gdb
2个回答
0
投票

您可能想尝试一下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

0
投票

我使用 -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
© www.soinside.com 2019 - 2024. All rights reserved.