打印通过gdb的完整控制流,包括变量的值 [英] Print complete control flow through gdb including values of variables

查看:161
本文介绍了打印通过gdb的完整控制流,包括变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个想法是给予程序的特定输入,不知何故,我想通过完整的程序自动进入并转储其控制流以及所有正在使用的数据,如类及其变量。他们是这样做的直接方法吗?或者可以通过gdb上的一些脚本来完成,还是需要在gdb中修改?



确定这个问题的原因是因为有关调试工具的想法。这是什么呢给定一个程序的两个不同的输入,一个导致错误的输出,另一个是正确的输入,它会告诉他们控制流的哪一部分是不同的。



所以我认为需要的是将这两个控制流完全转储到diff引擎中。如果这两个输入是相似的控制流,那么它们的差异(在许多情况下)会给出一个关于为什么存在错误的好主意。



这可以被做成

解决方案

详细了解环境。例如,dtrace将在Solaris或Leopard中做出奇妙的工作。 gprof是另一种可能性。



可以使用 yes(1) expect(1)



如果你想得到喜欢, GDB可以在某些版本中使用Python脚本


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.

解决方案

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的完整控制流,包括变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆