12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- # gcc-plugin-scallgraph
- Small gcc compiler plugin to generate a function callgraph of the compiled source code and works with gcc-8.3 ... gcc-11.1
- This is a very small gcc compiler plugin to generate a function callgraph of the compiled sourcecode.
- Because it is so small it should be easy to understand or customize to your own whishes.
- To compile this it needs on debian Linux the package gcc-plugin-dev installed for the used gcc version.
- To compile:
- ./autogen.sh
- ./configure
- make
- In directectory .libs ahould be a scallgraph_plugin.so.0.0.0 file created
- To use this plugin the path to the plugin so file must be specified like this
- gcc -c -fplugin=.libs/scallgraph_plugin.so test.c
- This generates a scallgraph.gv dot graph file with the callgraph of the routines.
- This dot file can be used with gml4gtk graph viewer or dot program.
- Other use:
- make CFLAGS="-fplugin=.libs/scallgraph_plugin.so"
- Or with own customized gcc compiler
- ./configure CC=$HOME/mygcc/bin/gcc
- And indirect function calls are not in the graph
- This is tested and works with gcc-8 and gcc-11.1 on debian Linux 2021 see the rungcc.sh script
- Also:
- make clean
- make distclean
- This is example graph output in test.c.scallgraph.gv
- // function callgraph generated with gcc scallgraph plugin running with gcc version 11.1.0
- digraph scallgraph {
- "f" -> "h";
- "f" -> "g";
- "g" -> "h";
- "main" -> "f";
- }
-
- Now a better callgraph plugin for gcc will follow
- Other way to generate callgraph using gcc:
- gcc -fcallgraph-info text.c
- The generated *.ci file is a vcg graph file usable with gml4gtk graph viewer
- Or another way to generate callgraph is using the egypt script and generate gfcc rtl data
- The Linux kernel source has maintained gcc plugins in directory linux/scripts/gcc-plugins/
|