简体   繁体   English

用于复杂C ++项目的动态死代码消除工具

[英]Dynamic dead code elimination tools for complex C++ projects

We have a project with a lot of code, part of it is legacy. 我们有一个包含大量代码的项目,其中一部分是遗留的。 As part of the work flow, every once in a while, all the functionality of the product is checked. 作为工作流程的一部分,每隔一段时间,就会检查产品的所有功能。 I wonder if there is a way to use this fact to dynamically check which parts of the code were never used? 我想知道是否有办法使用这个事实动态检查代码的哪些部分从未使用过? (The difficult part is the C++ code, the .Net and Java are more under control and have less legacy). (困难的部分是C ++代码,.Net和Java受到更多控制并且遗留的更少)。

Also - are there dynamic dead code elimination tools are there that can work with lots of code and complex projects (ie ~1M lines)? 另外 - 是否有动态死代码消除工具可以处理大量代码和复杂项目(即约1M行)?

All the similar questions I found talked about static analysis which we all ready do. 我发现的所有类似问题都谈到了我们都准备好做的静态分析。

Thank you! 谢谢!

You might want to look at the code coverage tools that are used in testing. 您可能希望查看测试中使用的代码覆盖率工具。 The idea of these tools is that they instrument the code and after running the set of tests you know what lines of code were executed at least once and what lines were never executed. 这些工具的想法是他们检测代码,在运行测试集之后,您知道哪些代码行至少执行一次以及哪些行从未执行过。 After that you can improve tests. 之后,您可以改进测试。

The same thing can be used to identify dead code in case if you have diverse enough execution environment. 如果你有足够多的执行环境,同样的事情可以用来识别死代码。

I don't know what platform you are on but we have used Gcov with success if you're compiling with the gnu toolchain: 我不知道你在哪个平台上,但如果你正在使用gnu工具链进行编译,我们已经成功使用了Gcov:

http://gcc.gnu.org/onlinedocs/gcc/Gcov.html http://gcc.gnu.org/onlinedocs/gcc/Gcov.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM