一、問題的產生 最近需要分析一個很老的工程的原始碼,原始碼的內容複雜,而且找不到比較熟悉此代碼的人。我這裡首先要分析下函數間的調用關係,於是從網上搜尋到了如下方法:使用doxygen和graphviz來自動分析函數間的調用關係。
二、工具簡介 doxygen:( http://www.stack.nl/~dimitri/doxygen/index.html)
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.
是一種從標記過的C++原始碼產生文檔的標準工具,也支援C,Objective-C,C#,PHP,Java,Python,IDL,Fortran,VHDL,Tcl等。
graphviz:( http://www.graphviz.org/)
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.
是一種開源的將結構化資訊展示成抽象圖和網路的工具,用於網路,生物資訊,軟體工程,資料庫和網站設計,機器學習以及其他技術領域的可視性介面。
三、產生函數調用圖 安裝此兩種工具,然後可以方便的分析代碼,產生相應的函數調用圖。
1)開啟DoxyWizard,彈出Doxygen配置介面。 2)如下圖,標出了主要需要設定的選項