Generate Call & Caller Graphs with Doxygen
Installation
Doxygen using dot from graphviz to generate graphs, install doxygen and its dependency:
sudo apt install doxygen -y
sudo apt-get install graphviz -y --allow-unauthenticated
Install with brew if using MacOS:
brew install doxygen
brew install graphviz
Configuration
Doxygen provides a self-explained example configuration file which can be generated
with doxygen -g
, it will create an example config file named Doxyfile.
Here we take android lmkd for example to generate call and caller graphs:
PROJECT_NAME = "lmkd"
# generate output to doc
OUTPUT_DIRECTORY = doc
EXTRACT_ALL = YES
EXTRACT_STATIC = YES
# disable latex output
GENERATE_LATEX = NO
# call/caller graph need this to be enabled
HAVE_DOT = YES
# generate call/caller graph
CALL_GRAPH = YES
CALLER_GRAPH = YES
# include body of functions into the documentation
INLINE_SOURCES = YES
INLINE_SOURCES option is very useful, it will include the body of fuctions, classes and enums directly into the documentation, like this:
If the project has subdirectories, set RECURSIVE
= YES
.
Generate Call/Caller Graphs
Issue command doxygen Doxyfile
will do the job for you, or just doxygen
will
be fine if you are using the default config file, here is an example call/caller
graph taken from above generated doc: