call graph for a single method (c++ and java)
-
16-06-2021 - |
Domanda
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
Soluzione
Doxygen is an excellent tool that can do this for both Java and C++. It even generates graphical and clickable call graphs.
Altri suggerimenti
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.