注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

gdb多线程程序调试常用几个命令  

2013-11-13 15:16:11|  分类: linux相关 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

(gdb) set print pretty on  打印结构时, 缩进比较漂亮

      show print pretty


(gdb) ptype   pthread_cond_t  打印类型定义,结构定义 

(gdb) info types pthread_cond_t  打印所有指定类型的变量



gdb attach 25362     

gdb thread apply all bt  查看全部线程的调用栈,在所有线程上面执行bt命令

(gdb)  info threads        查看当前所有线程
  14 Thread 25267120 (LWP 25364)  0x00a4b59b in pthread_cond_timedwait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  13 Thread 66902960 (LWP 25365)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  12 Thread 45226928 (LWP 25366)  0x00628b1c in __nanosleep_nocancel () from /lib/tls/libc.so.6
  11 Thread 132537264 (LWP 25367)  0x005a72ee in sigsuspend () from /lib/tls/libc.so.6
  10 Thread 55716784 (LWP 25368)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  9 Thread 121064368 (LWP 25369)  0x00a4b59b in pthread_cond_timedwait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  8 Thread 77392816 (LWP 25370)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
  7 Thread 87882672 (LWP 25371)  0x00a4b59b in pthread_cond_timedwait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  6 Thread 98372528 (LWP 25372)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
  5 Thread 108862384 (LWP 25373)  0x00a4dd9e in accept () from /lib/tls/libpthread.so.0
  4 Thread 145025968 (LWP 25374)  0x00a4dd9e in accept () from /lib/tls/libpthread.so.0
  3 Thread 155515824 (LWP 25375)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
  2 Thread 171506608 (LWP 4334)  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
  1 Thread -1218530656 (LWP 25362)  0x00a49d58 in pthread_join () from /lib/tls/libpthread.so.0




(gdb) thread 10    切换到第几个线程
[Switching to thread 10 (Thread 55716784 (LWP 25368))]#0  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
(gdb) bt
#0  0x00a4b3ad in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
#1  0x00398b7a in fd_fifo_post_internal (queue=0x983c998, item=0x35229e4, skip_max=0)
    at /home/bright/freediameter/libfdproto/fifo.c:347
#2  0x00399414 in fd_fifo_post_int (queue=0x983c998, item=0x35229e4)
    at /home/bright/freediameter/libfdproto/fifo.c:418
#3  0x008c2f61 in fd_out_send (msg=0x35229e4, cnx=0x99731f8, peer=0x983c808, flags=1)
    at /home/bright/freediameter/libfdcore/p_out.c:191
#4  0x008bb58a in fd_p_dw_handle (msg=0x35229e4, req=128, peer=0x983c808)
    at /home/bright/freediameter/libfdcore/p_dw.c:109
#5  0x008ca9a7 in p_psm_th (arg=0x983c808) at /home/bright/freediameter/libfdcore/p_psm.c:614
#6  0x00a48dd8 in start_thread () from /lib/tls/libpthread.so.0
#7  0x0065bfca in clone () from /lib/tls/libc.so.6
db) frame 1        切换调用栈
#1  0x00398b7a in fd_fifo_post_internal (queue=0x983c998, item=0x35229e4, skip_max=0)
    at /home/bright/freediameter/libfdproto/fifo.c:347
347 /home/bright/freediameter/libfdproto/fifo.c: No such file or directory.
in /home/bright/freediameter/libfdproto/fifo.c

(gdb) p *queue 
$1 = {eyec = -403959504, mtx = {__m_reserved = 0, __m_count = 0, __m_owner = 0x0, __m_kind = 0, __m_lock = {
      __status = 3, __spinlock = 0}}, cond_pull = {__c_lock = {__status = 0, __spinlock = 200300}, 
    __c_waiting = 0x18736, 
    __padding = "\000\000\000\0006\207\001\000\000\000\000\0005\207\001\000\000\000\000\000\234?203\t\000\000\000", __align = 0}, cond_push = {__c_lock = {__status = 0, __spinlock = 4}, __c_waiting = 0x3, 
    __padding = "\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\234?203\t\000\000\000", __align = 0}, list = {next = 0xb7106b68, prev = 0xb71cd258, head = 0x983ca14, o = 

0x0}, 
  count = 5, thrs = 1, max = 5, thrs_push = 2, high = 0, low = 0, data = 0x0, h_cb = 0, l_cb = 0, 
  highest = 0, highest_ever = 5}


  评论这张
 
阅读(504)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017