核心转储和 gcov 覆盖率报告
我正在对多线程程序进行压力测试并收集覆盖率。 据我所知,当程序被 _exit() 或某些信号(例如 SIGABRT、SIGSEGV 等)终止时,gcov 不会生成 .gcda 文件。
当程序崩溃时,信号会生成核心文件,并且不会生成 gcov 覆盖率数据。显然我可以处理信号并生成覆盖数据,但在这种情况下我无法生成核心转储文件。但我想生成核心转储和 gcov 数据文件来找出崩溃的原因。
我的问题是,有没有办法在没有信号的情况下生成核心转储,或者有没有办法在程序突然终止时生成 gcov 覆盖数据文件?
I'm doing stress testing on multi-threaded program and collecting coverage as well.
As far as I know, gcov doesn't produce .gcda files when program is terminated by _exit() or some signals such as SIGABRT, SIGSEGV and so on.
When the program crashes, core file is generated by signal and gcov coverage data isn't generated. Obviously I could handle the signal and generate the coverage data but in this case I couldn't generate core dump file. But I'd like to generate both core dump and gcov data file to figure out the cause of the crash.
My question is that is there any way to generate core dump without signals or is there any way to generate gcov coverage data file when the program abruptly terminates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您需要自动进行代码覆盖率回归测试。试试这个:
https: //www.osadl.org/Dumping-gcov-data-at-runtime-simple-ex.online-coverage-analysis.0.html
在程序的“main.c”中放置:
然后重新构建你的程序并运行:
这样它仍然应该生成 .gcda 文件
If you have need to do regression testing of code coverage automatedly. Try this:
https://www.osadl.org/Dumping-gcov-data-at-runtime-simple-ex.online-coverage-analysis.0.html
Inside your program's "main.c" put:
Then re-build your program and run:
this way it should still generate .gcda files
您需要做的是,在开始测量测试覆盖率之前修复错误。
如果您的程序未通过其他测试,那么覆盖率信息无论如何都是毫无意义的。崩溃显然是某种故障,因此您需要解决这个问题。
修复错误,然后您就可以了解您的(无故障)程序的测试效果如何。
如果您编写一个自动化测试来重现崩溃,以确保它随后不会回归,也许会有帮助?
What you need to do is, fix the bugs before you start measuring test coverage.
If your program is failing other tests, coverage information is meaningless anyway. Crashing is clearly a failure of some kind, so you need to fix this.
Fix the bugs, then you can find out how effectively your (non-faulty) program is being tested.
Perhaps it will help if you write an automated test to reproduce the crash, to ensure it doesn't subsequently regress?
我大力提倡在运行测试时仅使用代码覆盖率 - 确定性测试。通过单元测试获得 100% 的线路覆盖率是可能的(也是可取的)。
另外,对于测试,如果您确实遇到某种崩溃,很容易在源代码管理中禁用测试,直到其修复。
I am a big advocate of only using code coverage whilst running tests - deterministic tests. Its possible (and desirable) to get 100% line coverage with unit tests.
Also with tests, if you do get a crash of some sort it would be easy to disable the test in source control until its fixed.
查看 valgrind (或发布代码,以便我们提供帮助)
Have a look at valgrind (or post code so we can help)