通过 gdb 打印完整的控制流,包括变量值
这个想法是,给定程序的特定输入,我想以某种方式自动介入整个程序并转储其控制流以及所有正在使用的数据(例如类及其变量)。 他们是这样做的直接方法吗? 或者这可以通过 gdb 上的一些脚本来完成还是需要在 gdb 中进行修改?
好吧,这个问题的原因是因为关于调试工具的想法。 它的作用是这样的。 给定程序两个不同的输入,一个导致错误的输出,另一个导致正确的输出,它将告诉它们控制流的哪一部分有所不同。
因此,我认为需要将这两个控制流完整转储到差异引擎中。 如果两个输入遵循相似的控制流,那么它们的差异(在许多情况下)可以很好地了解错误存在的原因。
这可以成为一个非常有吸引力的工具,并在此基础上构建许多功能。
The idea is that given a specific input to the program, somehow I want to automatically step-in through the complete program and dump its control flow along with all the data being used like classes and their variables. Is their a straightforward way to do this? Or can this be done by some scripting over gdb or does it require modification in gdb?
Ok the reason for this question is because of an idea regarding a debugging tool. What it does is this. Given two different inputs to a program, one causing an incorrect output and the other a correct one, it will tell what part of the control flow differ for them.
So What I think will be needed is a complete dump of these 2 control flows going into a diff engine. And if the two inputs are following similar control flows then their diff would (in many cases) give a good idea about why the bug exist.
This can be made into a very engaging tool with many features build on top of this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请告诉我们更多有关环境的信息。 例如,dtrace 在 Solaris 或 Leopard 中可以出色地完成此任务。 gprof 是另一种可能性。
可以使用“yes(1)”或“expect(1)”来完成此操作的凹凸版本。
如果你想变得更奇特,GDB 可以使用 Python 编写脚本一些版本。
Tell us a little more about the environment. dtrace, for example, will do a marvelous job of this in Solaris or Leopard. gprof is another possibility.
A bumpo version of this could be done with yes(1), or expect(1).
If you want to get fancy, GDB can be scripted with Python in some versions.
你所描述的听起来有点像 gdb 的“跟踪点调试”。
请参阅 gdb 的内部帮助“helptracepoint”。 您还可以查看白皮书
这里: http://sourceware.org/gdb/talks/esc-west-1999 /
不幸的是,此功能目前尚未实现
本机调试,但我相信 CodeSourcery 正在做一些工作
在上面。
What you are describing sounds a bit like gdb's "tracepoint debugging".
See gdb's internal help "help tracepoint". You can also see a whitepaper
here: http://sourceware.org/gdb/talks/esc-west-1999/
Unfortunately, this functionality is not currently implemented for
native debugging, but I believe that CodeSourcery is doing some work
on it.
看看这个,与 Coverity 不同,Fenris 是免费的并且被广泛使用。
如何打印下一个GDB自动执行N行?
Check this out, unlike Coverity, Fenris is free and widly used..
How to print the next N executed lines automatically in GDB?