gpt4 book ai didi

unix - gdb:记录一些东西而不是破坏?

转载 作者:行者123 更新时间:2023-12-04 16:55:46 25 4
gpt4 key购买 nike

是否可以让 gdb 将某些内容记录到终端而不是破坏它?例如,我想在某个方法上设置一个“断点”,并在每次调用该方法时让 gdb 打印 self 以及参数。基本上我想在不实际重新编译的情况下将打印语句插入到任意位置。

感谢您的任何建议

这是我在这些有用的评论之后到目前为止所拥有的:

define logFoo
b fooMethod
commands
po self
end
end

不过,GDB 似乎不喜欢嵌套的 end 语句。有什么想法吗?

最佳答案

您可以使用 Breakpoint Command Lists .有一个例子如何做到这一点。

For example, here is how you could use breakpoint commands to print the value of x at entry to foo whenever x is positive.

 break foo if x>0
commands
silent
printf "x is %d\n",x
cont
end

关于unix - gdb:记录一些东西而不是破坏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6206447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com