README 1.8 KB

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