callgraph

runtime callgraph generator
git clone git://git.2f30.org/callgraph.git
Log | Files | Refs | README

README (910B)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Runtime callgraph generator
===========================

First type make to create libcallgraph.so.

To generate a runtime callgraph of any program, compile it by adding the
-finstrument-functions flag and linking against libcallgraph.so.  For
example, modify its Makefile to include:

	CFLAGS += -finstrument-functions
	LDFLAGS += -L${PWD}
	LDLIBS += -lcallgraph

	make

At this point you just run the program taking care for the library file
to be in the library path.

	LD_LIBRARY_PATH=$PWD ./prog [ARGS]

This generates a callgraph.dot file by default.  If you want another
output filename just set the CGRAPH_OUT environment variable.

	CGRAPH_OUT=prog.dot

Once the program terminates, you may want to replace addresses in the
generated .dot file with function names, using the symbolizer.

	./symbolize.sh ./prog

Generate a jpeg of the callgraph.

	dot -Tjpg callgraph.dot -o callgraph.jpg

That's it!