Print complete control flow through gdb including values of variables

旧城冷巷雨未停 提交于 2020-01-12 10:10:09

问题


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.


回答1:


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.




回答2:


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.




回答3:


Check this out, unlike Coverity, Fenris is free and widly used..

How to print the next N executed lines automatically in GDB?



来源:https://stackoverflow.com/questions/763891/print-complete-control-flow-through-gdb-including-values-of-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!