1

For a given method (eg. Settings.cpp getSettingByName()), I would like to build a static call graph. Is there an opensource tool that can do this for both java and c++?

For example, if I gave it "Settings.cpp getMethodByName" it would return:

Settings.cpp    getSettingByName();
    SettingsWrapper.cpp getMaximumSpeed();
        ECU.cpp monitorSpeed();
            Operate.cpp runECU();
                Main.cpp run();
        CruiseControl.cpp accelerate();
            Operate.cpp runCruiseControl();
                Main.cpp run();
        Radio.cpp playApplauseThroughSpeakers();
            Operate.cpp runStereo();
                Main.cpp run();

Don't freak about the code, it's just an example.

Many thanks, Fidel

Fidel
  • 7,027
  • 11
  • 57
  • 81
  • Haven't used this specific feature, but Doxygen? http://www.stack.nl/~dimitri/doxygen/config.html#cfg_call_graph – BoBTFish Jun 25 '12 at 15:52

2 Answers2

1

Eclipse provides a "call hierarchy" view. This is available in both the Java and C/C++ IDE flavors. For the latter, see this answer to the question: Could anyone tell me how to do static analysis for C++ code with Eclipse cdt?

See also Accessing Eclipse's call hierarchy programmatically.

Community
  • 1
  • 1
ewan.chalmers
  • 16,145
  • 43
  • 60
1

Doxygen is an excellent tool that can do this for both Java and C++. It even generates graphical and clickable call graphs.

albert
  • 8,285
  • 3
  • 19
  • 32
GETah
  • 20,922
  • 7
  • 61
  • 103
  • I didn't think Doxygen could correctly resolve overloaded symbols or methods from classes with multiple inheritance; it has a "hueristic" parser as a front end, not a real C++ front end. For tiny programs, maybe Doxygen gives the right result. Do you have specific experience or understanding that it will give the right result for a complex application in which the real complexities of C++ are present? – Ira Baxter Jun 25 '12 at 20:25
  • @IraBaxter Yep, I have tried it on fairly large applications which more than 100K LOC. My colleagues have tried it on on a C++, C++/CLI, C# application which has more then 5M LOC and did not hear any complains from them – GETah Jun 25 '12 at 20:31