Is there a way to get a call graph for certain c++ function in Visual Studio?

c++, visual-studio

Solution

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++.

Problem

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.

Original source