Looks like Valgrind has two tools that both do thread error detection: Helgrind and DRD. These tools are substantially similar.
看起来Valgrind有两个工具都可以进行线程错误检测:Helgrind和DRD。这些工具基本相似。
My primary question is: when should I use one instead of the other to check my multi-threaded code?
我的主要问题是:我何时应该使用一个而不是另一个来检查我的多线程代码?
More broadly, why are there two tools? I assume they aren't entirely redundant. What are the important differences? Should I generally plan on running my code through both tools?
更广泛地说,为什么有两种工具?我认为它们并非完全多余。有什么重要的区别?我是否应该计划通过这两种工具运行我的代码?
4 个解决方案
#1
6
While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. Also, DRD has support for detached threads. There are more subtle differences too - compare the respective manuals if you want to know more. See also http://valgrind.org/docs/manual/hg-manual.html and http://valgrind.org/docs/manual/drd-manual.html.
虽然Helgrind可以检测到锁定顺序违规,但对于大多数程序,DRD需要较少的内存来执行其分析。此外,DRD支持分离线程。还有更微妙的差异 - 如果您想了解更多,请比较相应的手册。另见http://valgrind.org/docs/manual/hg-manual.html和http://valgrind.org/docs/manual/drd-manual.html。
#2
1
when should I use one instead of the other to check my multi-threaded code?
我何时应该使用一个而不是另一个来检查我的多线程代码?
Depends on what you want to check that code for.
取决于您要检查该代码的内容。
To check for data races, you might want to use ThreadSanitizer.
Comparison with DRD and others.
要检查数据争用,您可能需要使用ThreadSanitizer。与DRD和其他人比较。
#3
1
One other point to consider: as of valgrind version 3.6.0, DRD supports pthread spinlocks, but helgrind doesn't. I haven't tried 3.7.0, but the release notes lead me to believe that this hasn't changed.
还有一点要考虑:从valgrind版本3.6.0开始,DRD支持pthread螺旋锁,但helgrind不支持。我没有试过3.7.0,但发行说明让我相信这没有改变。
#4
1
If you're using any POSIX synchronization primitives besides mutexes (e.g., semaphores, barriers, condition variables, etc.), DRD is worth a run -- it can identify some subtle misuses that Helgrind doesn't detect.
如果您使用除互斥体之外的任何POSIX同步原语(例如,信号量,障碍,条件变量等),则DRD值得运行 - 它可以识别Helgrind未检测到的一些细微错误。
However, DRD seems to be much more resource intensive than Helgrind (in my runs using 3.14.0 there seems to be a tremendous amount of CPU overhead).
但是,DRD似乎比Helgrind更耗费资源(在我使用3.14.0的运行中似乎有大量的CPU开销)。
#1
6
While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. Also, DRD has support for detached threads. There are more subtle differences too - compare the respective manuals if you want to know more. See also http://valgrind.org/docs/manual/hg-manual.html and http://valgrind.org/docs/manual/drd-manual.html.
虽然Helgrind可以检测到锁定顺序违规,但对于大多数程序,DRD需要较少的内存来执行其分析。此外,DRD支持分离线程。还有更微妙的差异 - 如果您想了解更多,请比较相应的手册。另见http://valgrind.org/docs/manual/hg-manual.html和http://valgrind.org/docs/manual/drd-manual.html。
#2
1
when should I use one instead of the other to check my multi-threaded code?
我何时应该使用一个而不是另一个来检查我的多线程代码?
Depends on what you want to check that code for.
取决于您要检查该代码的内容。
To check for data races, you might want to use ThreadSanitizer.
Comparison with DRD and others.
要检查数据争用,您可能需要使用ThreadSanitizer。与DRD和其他人比较。
#3
1
One other point to consider: as of valgrind version 3.6.0, DRD supports pthread spinlocks, but helgrind doesn't. I haven't tried 3.7.0, but the release notes lead me to believe that this hasn't changed.
还有一点要考虑:从valgrind版本3.6.0开始,DRD支持pthread螺旋锁,但helgrind不支持。我没有试过3.7.0,但发行说明让我相信这没有改变。
#4
1
If you're using any POSIX synchronization primitives besides mutexes (e.g., semaphores, barriers, condition variables, etc.), DRD is worth a run -- it can identify some subtle misuses that Helgrind doesn't detect.
如果您使用除互斥体之外的任何POSIX同步原语(例如,信号量,障碍,条件变量等),则DRD值得运行 - 它可以识别Helgrind未检测到的一些细微错误。
However, DRD seems to be much more resource intensive than Helgrind (in my runs using 3.14.0 there seems to be a tremendous amount of CPU overhead).
但是,DRD似乎比Helgrind更耗费资源(在我使用3.14.0的运行中似乎有大量的CPU开销)。