Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Valgrind需要退出程序才能工作吗?_Linux_Memory Leaks_Valgrind - Fatal编程技术网

Linux Valgrind需要退出程序才能工作吗?

Linux Valgrind需要退出程序才能工作吗?,linux,memory-leaks,valgrind,Linux,Memory Leaks,Valgrind,注意: 1.我尝试传递标志--vgdb=yes,但在这种情况下,进程根本不运行。 2.我不赞成检测我的代码 问题: 我试图在一个定制的OS(基于linux的)用户空间进程上运行valgrind,该进程将永远运行。在这种情况下,我如何获得mem泄漏的Valgrind统计数据,即该过程永远运行。 在当前状态下,我使用Valgrind启动了该过程,并查看了以下日志: ==6561== Memcheck, a memory error detector

注意:
1.我尝试传递标志
--vgdb=yes
,但在这种情况下,进程根本不运行。
2.我不赞成检测我的代码

问题:
我试图在一个定制的OS(基于linux的)用户空间进程上运行valgrind,该进程将永远运行。在这种情况下,我如何获得mem泄漏的Valgrind统计数据,即该过程永远运行。 在当前状态下,我使用Valgrind启动了该过程,并查看了以下日志:

==6561== Memcheck, a memory error detector                                                                                                                                                                         
==6561== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==6561== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==6561== Command: xyz_server
==6561== Parent PID: 3056
. . . . 
==6561== 
==6561== Thread 12: 
==6561== Syscall param timer_create(evp) points to uninitialised byte(s)
==6561==    at 0x84949BD: timer_create (in /lib64/librt-2.12.so)
==6561==    by 0x56D518E: api_1 (in . . .) // removed proprietary lib name
==6561==    by 0x74DDDD2: api_2 (in . . .) // removed proprietary lib name
==6561==    by 0x827A9BB: start_thread (pthread_create.c:301)
==6561==  Address 0x1fb37a50 is on thread 12's stack
==6561==   
这里没有统计数据。例如,如果我在
ls
上使用相同的参数运行valgrind:

$ valgrind --leak-check=full ls -l
==12584== Memcheck, a memory error detector
==12584== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==12584== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==12584== Command: ls -l
==12584==
. . .
==12584== HEAP SUMMARY:
==12584==     in use at exit: 18,424 bytes in 10 blocks
==12584==   total heap usage: 71 allocs, 61 frees, 63,312 bytes allocated
. . .
==12584== LEAK SUMMARY:
==12584==    definitely lost: 0 bytes in 0 blocks
==12584==    indirectly lost: 0 bytes in 0 blocks
==12584==      possibly lost: 18,424 bytes in 10 blocks
==12584==    still reachable: 0 bytes in 0 blocks
==12584==         suppressed: 0 bytes in 0 blocks
==12584==
==12584== For counts of detected and suppressed errors, rerun with: -v
==12584== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 2 from 2
. . .

如何为我的程序获得类似的统计数据?我的进程永远不会退出。

您可以在程序运行时从shell或gdb触发泄漏搜索

为此,valgrind gdbserver必须处于活动状态。默认情况下会激活gdbserver(如果您给出--vgdb=no,则会禁用它)。没有理由认为给出--vgdb=yes会使程序无法运行

另一方面,给出--vgdb error=0意味着您的程序将等待来自gdb/vgdb的连接继续

要从外壳触发泄漏搜索,例如,您可以使用:

vgdb leak_search full

@cad的可能副本,没有回答我的问题。@ks1322:vgdb在我的情况下似乎不起作用。其他的答案是关于检测代码,而不是支持这一点。