英文:
Make a valgrind error suppression generic for an object library, with wildcards
问题
在C++项目中使用Valgrind,我一直在尝试抑制来自第三方库的内存泄漏信息。我会通过运行Valgrind并使用--gen-suppressions=all
选项来生成特定的抑制文件条目,例如:
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
}
现在我想通用化该规则,以便抑制来自任何名为*libcuda*
的库的任何警告。我尝试了不同的方法,如:
{
cuda
memcheck:Leak
...
obj:*libcuda*
...
}
或者
{
cuda
memcheck:Leak
obj:*libcuda*
}
或者(受到这个回答的启发 this)
{
cuda
memcheck:Leak
fun:*alloc
...
obj:*libcuda*
...
}
以上所有方法都不起作用,因此即使Valgrind在不报错的情况下读取了抑制文件,我的libcuda来源的消息也不会被抑制。是否有办法让Valgrind接受这种通用抑制命令?
英文:
Using valgrind in the context of a C++ project, I have been trying to suppress memory leak information coming from third party libraries. I would generate the specific suppression file entry running valgrind with --gen-suppressions=all
and obtain for example:
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/lib/x86_64-linux-gnu/libcuda.so.515.105.01
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
obj:/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudart.so.11.6.55
}
Now I would like to generalize that rule so that it suppresses any warning coming from any library called *libcuda*
. I tried different things, like:
{
cuda
memcheck:Leak
...
obj:*libcuda*
...
}
or
{
cuda
memcheck:Leak
obj:*libcuda*
}
or (inspired by this)
{
cuda
memcheck:Leak
fun:*alloc
...
obj:*libcuda*
...
}
None of this worked, so even if the suppression file is read by valgrind with no complaint, none of my libcuda originated messages get suppressed.
Is there a way to make Valgrind accept this kind of generic suppression commands?
答案1
得分: 2
主要问题是您将 Memcheck
拼写为小写 m
。
以下内容将有效:
{
cuda
Memcheck:Leak
...
obj:*libcuda*
}
您放置的最后一个帧通配符 ...
是不必要的。
英文:
The main problem is that you have mispelled Memcheck
with lowercase m
.
The following will work:
{
cuda
Memcheck:Leak
...
obj:*libcuda*
}
The last frame wildcard ...
you had put is not necessary.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论