有没有一种方法可以在Visual Studio中获取某些c ++函数的调用图? [英] Is there a way to get a call graph for certain c++ function in Visual Studio?
问题描述
我想知道是否有一个VS工具可以为我显示给定C ++函数的调用图(即列出所有可能执行路径的图).如果仅在几个地方调用函数,这将有助于导航大型代码库.
对于像printf
这样的经常调用的函数,它可以简单地说:
太多选择...
同样,我想制作这样的工具并不容易,所以我想知道它是否存在,但是您知道这样做似乎有可能,所以您永远都不知道...
我知道找到所有引用,但这仅给出了函数的调用站点,而不是给出了调用函数的函数的调用站点……
VS是2010,但如有必要,可以选择VS2012.
您提到您了解有关查找所有引用的知识.您是否看过Call Hierarchy
?它可能不是您的梦想方法",但确实允许您根据给定函数的调用"和来自"的调用来查看函数.该窗口还允许您添加多个功能以树状格式查看.因此,基本上,您会在可能的结果中大跌眼镜.
右键单击所需的方法(可以在层次结构中的任何位置)=>
选择查看呼叫层次结构"
请注意,如果可以在窗口中添加多个参考点.在需要时删除
您还可以使用Ctrl + K或Ctrl + T
另一个很好的例子,恕我直言,令人失望的是C ++和C#与VS之间的差异.我认为代码映射正是您所需要的.当然,假设您使用的是Ultimate,但不,不是使用C ++.
I wonder whether there is a tool for VS that can show me a call graph (that is, a diagram listing all possible execution paths) for a given C++ function. It would help in navigating a big code base, in cases where a function is called in only a few places.
For oft-called functions like printf
it could simply say:
too many options...
Again I guess it is not really easy to make such tool so I wonder if it exists, but you know it seems possible to do it so you never know... :)
EDIT: I know about find all references, but that gives just call sites of the function, not the call site of the function that called the function that called the function...
EDIT: VS is 2010, but if necessary VS2012 is an option.
You mentioned that you know about finding all the references. Have you looked into viewing the Call Hierarchy
? It's probably not your "dream method" but it does allow you to look at a function in terms of "calls to" and "calls from" the given function. The window also allows you to add multiple functions to view in a tree format. So basically you would tree up or down through the possible outcomes.
Right click on the desired method ( could be anywhere in the hierarchy ) =>
Select "View Call Hierarchy"
Note that if you can add more than one reference point to the window. Delete when needed
You could also use Ctrl+K or Ctrl+T
Another fine example, IMHO, of a disappointment in the differences between C++ and C# with VS. I think Code Maps would be just what you're looking for. Assuming of course you were working with Ultimate - but nope, not with C++.
这篇关于有没有一种方法可以在Visual Studio中获取某些c ++函数的调用图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!