调试引擎的一次记录

valgrind的DRD和Helgrind

处理一个bug时,使用strace 发现线程死锁。

但是发生死锁的位置上下文怎样快速知道呢?

使用gdb 调试 打出调用栈,只能知道运行到此处发生死锁。但是是哪里开始出现死锁呢??

google搜索发现valgrind 的Helgrind可以解决

这个时候Helgrind就该出场了valgrind --tool=helgrind ./nobady

  Helgrind is a Valgrind tool for detecting synchronisation errors in C/C++ programs that use the POSIX threading primitives. The main abstractions in POSIX are: a set of threads sharing a common address space, thread creation, thread joining, thread exit, mutexes (locks), condition variables and barriers. Helgrind detects three types of errors: (1) misuses of the POSIX API, (2) potential deadlocks arising from lock ordering problems, and (3) data races.

 http://epic-beta.kavli.tudelft.nl/share/doc/valgrind-3.8.1/html/hg-manual.html

http://www.it.uc3m.es/pbasanta/asng/course_notes/helgrind_tool_en.html

也就是说 Helgrind 可以解决 死锁、资源访问不安全等问题

所以问题也就很快解决了 

gdb调试技巧:

disassemble 命令

 参考:blog

原文地址:https://www.cnblogs.com/codestack/p/13892573.html