我正在尝试在我正在使用的程序上使用Valgrind,但是Valgrind为我正在使用的其中一个库生成了一堆错误.我希望能够告诉它压制涉及该库的所有错误.我能为抑制文件提出的最接近的规则是
{
rule name
Memcheck:Cond
...
obj:/path/to/library/thelibrary.so
}
Run Code Online (Sandbox Code Playgroud)
然而,这并不能完全胜任这项工作.我必须为每个出现的抑制类型(Cond,Value4,Param等)创建其中一个,并且它似乎仍然会遗漏一些在堆栈跟踪中具有库的错误.
有没有办法让Valgrind有一个单一的抑制规则让它完全忽略一个特定的库?即使没有办法制定涵盖所有抑制类型的规则,是否至少有一种方法可以创建一个忽略特定库中特定抑制类型的所有错误的规则?
我在C++类上实现了Python扩展.我没有运行valgrind的C++目标.我想用valgrind进行内存检查.
我可以在Python中使用valgrind吗?
是否有任何工具,除了KCacheGrind,能够查看callgrind结果?对于Windows平台最好?
杀死valgrind进程本身不会留下内部进程执行的报告.
是否可以向valgrind内部运行的进程发送终止信号?
我尝试使用命令“brew install valgrind”安装 Valgrind,我收到一条消息:
“valgrind:由于上游不兼容,此公式无法在比 Sierra 更新的 macOS 版本上按预期编译或运行。错误:未满足的要求使此构建失败。”
我还尝试在代码的头部部分“brew edit valgrind”并用“git://sourceware.org/git/valgrind.git”替换“sourceware.org/git/valgrind.git”,然后在Iterm上写“ brew install --HEAD valgrind
“但它给了我:
Last 15 lines from /Users/m/Library/Logs/Homebrew/valgrind/02.configure:
checking for gcc-ar... no
checking for perl... /usr/bin/perl
checking for gdb... /no/gdb/was/found/at/configure/time
checking dependency style of clang... none
checking for diff -u... yes
checking for clang option to accept ISO C99... none needed
checking for a supported version of gcc... ok (clang-11.0.0)
checking build system type... x86_64-pc-darwin
checking host system type... x86_64-pc-darwin
checking for a supported CPU... ok …
Run Code Online (Sandbox Code Playgroud) 我使用valgrind
with 检查了C++中的以下代码--leak-check=full
,它说没有内存泄漏.这是为什么?
char *p = new char[256];
delete p;
Run Code Online (Sandbox Code Playgroud)
new[]
delete[]
据我所知应该匹配.
我正在寻找以下调试工具之间的区别.
那些是什么?
E:关于有人在这里偶然发现并且想知道"差异"的相同之处(从手册页缩写):
GDB
允许您查看程序在运行/崩溃时"内部"发生的情况.
Valgrind
一系列灵活的调试和分析工具.
Strace
记录/拦截进程调用/接收的系统调用.
Ltrace
记录/拦截进程调用/接收的信号/动态库/系统调用.
Apport
拦截崩溃/未处理的异常,收集操作系统信息,提供有用的UI,并能够提交非崩溃错误.
我有以下代码:
#include <iostream>
#include <random>
int main() {
std::mt19937_64 rng(std::random_device{}());
std::cout << std::uniform_int_distribution<>(0, 100)(rng) << '\n';
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用valgrind
它来描述它,但它说:
vex amd64->IR: unhandled instruction bytes: 0xF 0xC7 0xF0 0x89 0x6 0xF 0x42 0xC1
vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR: VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=0F
vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0
==2092== valgrind: Unrecognised instruction at address 0x4cdc1b5.
==2092== at 0x4CDC1B5:std::(anonymous namespace)::__x86_rdrand() (random.cc:69)
==2092== by 0x4CDC321: std::random_device::_M_getval() (random.cc:130)
==2092== by 0x4009D4: main (random.h:1619)
Run Code Online (Sandbox Code Playgroud)
在多个实例之前:
--2092-- WARNING: Serious error when reading …
Run Code Online (Sandbox Code Playgroud) 在Linux中,我一直在使用valgrind来检查应用程序中是否存在内存泄漏.Windows中的等价物是什么?可以使用Visual Studio 2010完成吗?