Skip to content

Commit 3d62176

Browse files
committed
python: add graphviz callgraphs
Uses the JSON data extracted from LLVM bitcode by tools/frr-llvm-cg. Signed-off-by: David Lamparter <[email protected]>
1 parent 8fb4037 commit 3d62176

File tree

3 files changed

+488
-1
lines changed

3 files changed

+488
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
*_clippy.c
5858
*.bc
5959
*.cg.json
60+
*.cg.dot
61+
*.cg.svg
6062

6163
### gcov outputs
6264

Makefile.am

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ SUFFIXES += .lo.bc .o.bc
252252

253253
%.cg.json: %.bc tools/frr-llvm-cg
254254
tools/frr-llvm-cg -o $@ $<
255+
%.cg.dot: %.cg.json
256+
$(PYTHON) $(top_srcdir)/python/callgraph-dot.py $< $@
257+
%.cg.svg: %.cg.dot
258+
@echo if the following command fails, you need to install graphviz.
259+
@echo also, the output is nondeterministic. run it multiple times and use the nicest output.
260+
@echo tuning parameters may yield nicer looking graphs as well.
261+
fdp -GK=0.7 -Gstart=42231337 -Gmaxiter=2000 -Elen=2 -Gnodesep=1.5 -Tsvg -o$@ $<
262+
# don't delete intermediaries
263+
.PRECIOUS: %.cg.json %.cg.dot
255264

256265
# <lib>.la.bc, <lib>.a.bc and <daemon>.bc targets are generated by
257266
# python/makefile.py
@@ -264,7 +273,7 @@ clean-python:
264273
find . -name "*.pyc" -o -name "*_clippy.c" | xargs rm -f
265274

266275
clean-llvm-bitcode:
267-
find . -name "*.bc" -o -name "*.cg.json" | xargs rm -f
276+
find . -name "*.bc" -o -name "*.cg.json" -o -name "*.cg.dot" -o -name "*.cg.svg" | xargs rm -f
268277

269278
redistclean:
270279
$(MAKE) distclean CONFIG_CLEAN_FILES="$(filter-out $(EXTRA_DIST), $(CONFIG_CLEAN_FILES))"

0 commit comments

Comments
 (0)