1. $ ls instrument.c pvtrace.zip stack.h symbols.h trace.c Makefile stack.c symbols.c test.c 2. make 生成pvtrace可执行文件. 可以从 http://www.ibm.com/developerworks/cn/linux/l-graphvis/ 下载 测试需要的文件如下: border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ls instrument.c Makefile test.c 3. make test 生成test 可执行文件(PS: 在生成可执行文件时一定要加 -g -finstrument-functions) border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ls instrument.c instrument.o Makefile test test.c test.o 4. 执行test生成trace.txt文件 border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ./test Enter classHello, World! Enter classHello, printHello! exit classEnter classHello, printHello 2 ! Enter classHello, printHello 3 ! Enter classHello, printHello! exit classexit classexit classexit classborder@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ls instrument.c instrument.o Makefile test test.c test.o trace.txt 5. 通过pvtrace 生成graph.dot 文件 border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ../pvtrace test border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ls graph.dot instrument.o test test.o instrument.c Makefile test.c trace.txt 6. 通过dot生成图片 border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ dot -Tjpg graph.dot -o graph.jpg border@ubuntu:/work/border/tech/graphviz/pvtrace/test$ ls graph.dot instrument.c Makefile test.c trace.txt graph.jpg instrument.o test test.o 参考: 1. http://www.ibm.com/developerworks/cn/linux/l-graphvis |