LLDB 如何检查互斥锁的所有者?
lldb how to check the owner of the mutex?
我想知道使用 lldb 调试时互斥锁的所有者,我在线检查 gdb 是否可以像 https://en.wikibooks.org/wiki/Linux_Applications_Debugging_Techniques/Deadlocks 一样打印线程 ID
但是,当我在 lldb 中尝试此操作时,互斥锁中的成员变量是不透明的,例如:
Process 76057 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00000001000017f5 a.out`main at lol2.cc:65
62 }
63 std::cout << "main thread notify start" << std::endl;
64 std::this_thread::sleep_for(std::chrono::seconds(1));
-> 65 start = true;
66 cv.notify_all();
67 {
68 std::unique_lock<std::mutex> lk(mu1);
(lldb) p mu1
(mutex) $0 = {
__mutex_base = {
_M_mutex = (__sig = 1297437786, __opaque = char [56] @ 0x00007fc614127698)
}
}
(lldb)
有什么方法可以获取不透明部分的内容吗?谢谢。
我不能说我知道如何阅读不透明部分(可能取决于实现(,但我建议在这里使用 Ami Tavory 的答案来跟踪互斥锁的所有者,如果允许将std::mutex
封装在新类中。
相关文章:
- valgrind-hellgrind与泄漏检查的结果不同
- C++模板来检查友元函数的存在
- 检查输入是否不是整数或数字
- 试图让变量检查数组中的某些内容
- 检查值是否在集合p1和p2中,但不在p3中
- 函数何时会在c++中包含stack_Unwind_Resume调用
- C++概念:如何使用'concept'检查模板化结构的属性?
- 概念TS检查忽略私有访问修饰符
- 检查 std::shared_ptr<> 的当前底层类型是否为 T
- 在c++中检查长方体是否尽可能快地重叠(无迭代)
- 如何在C++中检查2D数组中负值的输入验证
- C++:正在检查LinkedList中的回文-递归方法-错误
- 使用for循环检查数组中的重复项
- Python中的for循环与C++有何不同
- 如何检查一个c++字符串中有多少相同的字符/数字
- 检查不带转换的扫描格式
- 如何检查线程是否锁定
- 清除前检查矢量
- 如何处理来自核心指南检查器的关于gsl::at的静态分析警告
- LLDB 如何检查互斥锁的所有者?