逆向工程 C++ 的工具(即查看 C++ 类)
我有大量手写的 C++ 源代码(即 WebKit 和其他开源代码)。
我想要一个工具,它能够:
- 让我查看每个类和任何类的类间关系:
- 包含关系:即哪些其他类包含该类,或者被该类包含(头文件将模板化智能指针类型声明为成员数据)
- 声明的依赖项(即在方法签名中使用类型;尽管我可以使用“在文件中查找”很好地看到这一点)
- 子类和超类层次结构
- 在 Windows 或 Linux 上运行(甚至是基于 Web 的解决方案)
- 最好有一个 UI(或者这要求太多了吗?)
- 可以选择是 IDE 中的
插件有关的问题,C++ 到 UML(逆向工程/往返工程),我不需要它:
- 解析定义/实现(cpp 和 c 文件)
- 支持编辑或“往返”源
相反,解析应用程序和系统头中的类型声明(包括模板类型和 typedef)就足够了。我有所有头文件的列表。
如果它可以处理预处理器定义(特别是#include 和#if),我会更喜欢它,但如果有必要,我可以进行预处理;和/或为其提供各种格式的制作或项目文件。
I have a large body of hand-written C++ source (i.e. WebKit and other open source).
I want a tool which will:
- Let me see the inter-class relationships for each and any class:
- Containment relationships: i.e. which other classes contain this class, or are contained by it (the header files declare templated smart pointer types as member data)
- Declared dependencies (i.e. use of the type in method signatures; though I can see this pretty well using 'find in files')
- Subclass and superclass hierarchies
- Run on Windows or Linux (or even a web-based solution)
- Preferably have a UI (or is that too much to ask?)
- Optionally be a plugin in an IDE
Unlike the related question, C++ to UML (Reverse engineer / Round-trip engineering), I do NOT need it to:
- Parse the definitions/implementation (the cpp and c files)
- Support editing or 'round-tripping' the source
Instead, parsing the type declarations in the application and system headers (including template types and typedefs) would be enough. I have lists of all the header files.
I'd prefer it, if it could handle preprocessor definitions (especially #include and #if), but I can preprocess if that's necessary; and/or give it make or project files in various formats.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种可能性是通过扩展现有的 C++ 编译器来自定义您自己的工具。
您可以扩展两个编译器:
在我(有偏见的)看来,扩展 GCC 是最好的方法。但我确实承认(即使有 MELT 的帮助)这并不简单,因为您需要部分理解 GCC 主要内部表示(Gimple、Tree)和内部通道。 (我猜你对 LLVM/Clang 也有同样的问题:要扩展它,你需要理解它)。
GCC 扩展(在 MELT 中)或插件(在 C 中)主要用于 Gimple 表示(模板扩展后)。
如果对使用 MELT 感兴趣,请随时向我询问更多信息。
存在一些昂贵的专有工具,例如 coverity - 但它们太贵了,我不知道它们能够做什么做。
another possibility is to customize your own tool, by extending an existing C++ compiler
There are two compilers which you could extend:
Extending GCC is in my (biased) view the good way to do it. But I do admit that (even with t he help of MELT) it is non-trivial, because you need to partly understand GCC main internal representations (Gimple, Tree) and internal passes. (I guess that you have same issue with LLVM/Clang: to extend it you need to understand it).
GCC extensions (in MELT) or plugins (in C) are mostly working on the Gimple representations (after template expansion).
If interested in using MELT, feel free to ask more to me.
Some costly proprietary tools exist, like e.g. coverity - but there are so expensive that I have no idea of what they are able to do.
您始终可以使用 doxygen,它会为您提供有关标头集的完整文档(继承、用法等),它还可以从类层次结构中生成图形。
You could always use doxygen, it'll give you full documentation on your set of header (inheritance, usage, ...) It can also generate graphs out of the class hierarchy.