gdb usage

gdb usage

attach process

gdb attach $pid

查看进程内的所有线程

info thread

切换跟踪线程

thread $thread_id   #此thread_id为info thread结果行首的thread id

查看变量值

先bt查看backtrace,再f $n设置栈帧,再p *mutex打印变量值(这里的mutex为一个结构体指针)

复制代码
(gdb) f 3
#3  __pthread_cond_wait (cond=0x10da6a0, mutex=0x10da688)
    at pthread_cond_wait.c:638
638     pthread_cond_wait.c: No such file or directory.
(gdb) p *mutex
$1 = {__data = {__lock = 0, __count = 0, __owner = 0, __kind = 2, 
    __nusers = 1, {__spins = 0, __list = {__next = 0x0}}}, 
  __size = '\000' <repeats 12 times>, "\002\000\000\000\001\000\000\000\000\000\000", __align = 0}
(gdb) 
复制代码

查看attach的进程内的所有线程的backtrace

thread apply all bt

 

posted @   aspirs  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
点击右上角即可分享
微信分享提示