使用valgrind和gdb调试多线程程序

时间:2015-01-24 10:40:11

标签: c multithreading debugging

前提,我正在使用Eclipse。 在我寻求多线程应用程序的调试时,我首先运行了valgrind memcheck,它给了我一堆错误,无法识别这些错误来自哪些代码行。 然后我创建了一个配置文件以在Debug构建中使用valgrind,它给了我一个错误 “读取大小为1的无效”指向源代码中的一行,允许我修复它。现在在Debug构建上运行的valgrind没有给我任何错误,但如果我尝试在Release版本上运行valgrind,我会收到错误,这些错误无法查明。

==5083== 16 bytes in 1 blocks are definitely lost in loss record 2 of 4
==5083==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5083==    by 0x400F67: main (in /home/crysis/workspace/ReliableUPDserver/Release/ReliableUPDserver)
==5083== 
==5083== 16 bytes in 1 blocks are definitely lost in loss record 3 of 4
==5083==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5083==    by 0x400FA1: main (in /home/crysis/workspace/ReliableUPDserver/Release/ReliableUPDserver)
==5083== 
==5083== 512 bytes in 1 blocks are possibly lost in loss record 4 of 4
==5083==    at 0x4C2C080: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5083==    by 0x400F3E: main (in /home/crysis/workspace/ReliableUPDserver/Release/ReliableUPDserver)
==5083== 

为什么这些错误只出现在Release版本中?我该怎么做才能获得更多信息? 此外,我的多线程程序挂在某个地方,这是尝试找出问题所在的正确方法吗?

0 个答案:

没有答案