一、問題的產(chǎn)生
當(dāng)分析一個(gè)很復(fù)雜的項(xiàng)目源代碼時(shí),如何有效的分析函數(shù)間的調(diào)用關(guān)系呢?從網(wǎng)上搜索到了如下方法:使用doxygen和graphviz來自動(dòng)分析函數(shù)間的調(diào)用關(guān)系。
二、工具簡介
doxygen:
Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D.
是一種從標(biāo)記過的C++源代碼生成文檔的標(biāo)準(zhǔn)工具,也支持C,Objective-C,C#,PHP,Java,Python,IDL,F(xiàn)ortran,VHDL,Tcl等。
graphviz:
Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics,? software engineering, database and web design, machine learning, and in visual interfaces for other technical domains.
是一種開源的將結(jié)構(gòu)化信息展示成抽象圖和網(wǎng)絡(luò)的工具,用于網(wǎng)絡(luò),生物信息,軟件工程,數(shù)據(jù)庫和網(wǎng)站設(shè)計(jì),機(jī)器學(xué)習(xí)以及其他技術(shù)領(lǐng)域的可視性接口。
三、生成函數(shù)調(diào)用圖
1、下載并安裝以下兩種工具
doxygen:(http://www.stack.nl/~dimitri/doxygen/index.html)
graphviz:(http://www.graphviz.org/)
注意下載時(shí),選擇的是windows版本,還是mac版本。
如果安裝過程中彈出“打不開 XXX,因?yàn)樗鼇碜陨矸莶幻鞯拈_發(fā)者”請進(jìn)入如下網(wǎng)址尋找解決辦法:
http://jingyan.baidu.com/article/f71d60377960651ab741d140.html
2、運(yùn)行DoxyWizard,彈出Doxygen配置界面

選擇Scan recursively則遞歸分析源代碼目錄中的子目錄內(nèi)的源代碼。






由于使用到了Graphviz,所以要設(shè)置Dot選項(xiàng),勾選HAVE_DOT,并設(shè)置DOT_PATH為Graphviz的bin目錄。(注意:MAC的Graphviz的bin目錄不在安裝包內(nèi),一般是在/usr/local/bin/,實(shí)在找不到就到終端用ls一層一層的查找)

另外,若Doxygen出現(xiàn)中文亂碼問題:
設(shè)置如下:
Expert選項(xiàng)卡-> Project:
DOXYFILE_ENCODING:UTF-8
OUTPUT_LANGUAGE:Chinese
Expert選項(xiàng)卡-> InPut:
INPUT_ENCODING:GB2312
這樣生就可以正確生成含有中文的文檔了。
文章出處:
1、http://www.itdecent.cn/p/f67ec1879fca
2、http://blog.csdn.net/play_fun_tech/article/details/22145943