如何将瓦尔格林德与介子一起使用?

How to use Valgrind with Meson?

本文关键字:一起 林德      更新时间:2023-10-16
project('testproject', 'cpp')
src = ['a.cpp', 'b.cpp']
executable('test', src)

使用Meson 构建系统使用 Valgrind 构建我的可执行文件的最简单方法是什么?

为了完整起见,我想注意的是,valgrind可以用作介子命令行中的包装器,例如

$ meson test --wrap='valgrind --leak-check=full --error-exitcode=1' testname

$ meson test --wrap='valgrind --tool=helgrind -v --error-exitcode=1' testname

可以与其他测试选项结合使用,例如

$ meson test --wrap='valgrind --leak-check=full --error-exitcode=1' testname --repeat=100

查看此参考手册页面。

Valgrind 是一个动态分析工具,没有必要专门为 Valgrind 重新编译它。

例如,您可以执行以下操作:

瓦尔格林德 LS

瓦尔格林德将运行并分析LS命令。

但是请注意,建议使用调试信息进行编译,否则valgrind的错误报告将不太容易理解。

有关如何使用valgrind的介绍可在 http://www.valgrind.org/docs/manual/QuickStart.html