Tool for source code analysis? [closed]

喜欢而已 提交于 2019-12-21 03:17:06

问题


Source code analysis and exploration tools for C and C++ seem to be sorely lacking.

Are there any tools which I can use to gather information about C and/or C++ source files? cscope does part of what I would need, Doxygen looks closer.

At a minimum list of all function, callers, callees, variable references etc. Perhaps Doxygen's xml output would work.

Ideally gcc or llvm could be hooked for this purpose but I have yet to find a convenient way to do so.

Any suggestions?


回答1:


There is the clang static analyzer which is part of the clang front end for llvm, but I don't know how well it works for C/C++. It seems most of their effort is going towards Objective-C.

http://clang-analyzer.llvm.org/

Doxygen is good for call graphs, you'll want to have GraphViz installed and use doxywizard to select the Call graphs and Called by graphs tick boxes in the Diagrams section (CALL_GRAPH and CALLER_GRAPH in the expert mode Dot section.)




回答2:


You might find SourceMonitor helpful for more statistical analysis for code, plus its free :)




回答3:


Try Klocwork. It has every gory detail you could ever need about C/C++ source code plus much much more.




回答4:


Our DMS Software Reengineering Toolkit with its C front end and C++ Front End can provide a lot of information about C and C++ programs.

DMS with the C front end can parse large sets of C source files, build complete ASTs (even capturing comments) and symbol tables, and provide control and data flow analysis, with points-to analysis and call graphs. The C++ front end builds ASTs and full symbol tables, but does not yet provide all the flow analysis information.

DMS provides facilities to invoke the parsers/flow analyzers; you provide some custom code to extract the information you want.

It has the additional capability of modifying the ASTs and regenerating compilable source code.

I think you'll find that no tools for which you can extract precise custom data are "easy" to use; the very nature of the questions you ask and the answers have lots of complications caused by the complex language semantics.




回答5:


You can try CppDepend based on CLang. It is a good tool.

It gives 60 metrics (including of course the functions you need : list of functions/classes, callers, callees, dependency graph,...).




回答6:


Sonar is a really good Java projects analyzer. It now supports some other languages, including .Net. At the end of this blog post, you can see that a C plugin will be released soon...




回答7:


The Polyspace static analysis tool can display functions, callers, callees, variable references, global variable reads/writes. You have the ability to drill down into data structures to determine where the access occurs. Information is displayed in both text and graphical format. Variable range information is also determined. More information in the online user guide. Link to one of the sections given below:

http://www.mathworks.com/help/toolbox/polyspace/c_ug/brz384r-12.html#brz384r-17

Disclaimer: I work for MathWorks, the makers of the Polyspace static analysis tool.



来源:https://stackoverflow.com/questions/3761282/tool-for-source-code-analysis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!