Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ call graph, but as text

For a given method (eg. Settings.cpp getSettingByName()), I would like to get a text representation of the call graph. I've heard doxygen can generate an image of the call graph, I'm more interested in a text output.

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(); 

Is this possible?

Many thanks, Fidel

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

like image 380
Fidel Avatar asked Feb 20 '23 13:02

Fidel


1 Answers

I'm not aware of any prebuilt solutions for that.

However, Doxygen will in fact generate the (image) call graph by building a GraphViz dot file for the call graph. The Dot format is raw text and very simple, so you might find it easiest to let Doxygen run, and parse the generated .dot files yourself.

like image 197
2v0mjdrl Avatar answered Mar 06 '23 08:03

2v0mjdrl