gdb debug summary

 

  •  gdb attach program

gdb -p $(pidof rcpd)

 gdb use symbol
gdb att 2271 -s cips_app.sym

  •  gdb create struct params
(gdb) call malloc(sizeof(dps_l1xc_info_t))
(gdb) p *(dps_l1xc_info_t *)$1
$3 = {src_port = -1213914024, dst_port = -1213914024}
(gdb) set (*(dps_l1xc_info_t *)$1).src_port=10
(gdb) set (*(dps_l1xc_info_t *)$1).dst_port=20
(gdb) p *(dps_l1xc_info_t *)$1
$4 = {src_port = 10, dst_port = 20}
 
call malloc(sizeof(dps_phyport_key_t))
set (*(dps_phyport_key_t *)$2).
 
call malloc(sizeof(dps_phyport_key_t))
$2 = (void *) 0xc656148
set (*(dps_phyport_key_t *)$2).slot=10
set (*(dps_phyport_key_t *)$2).chip=0
set (*(dps_phyport_key_t *)$2).bcmPort=160
  • gdb disassemble

set disassemble-next-line on
ni
si
info registers:指令查看各寄存器的值
 

(gdb) p $pc
$1 = (void (*)()) 0xf543a38 <select+96>

(gdb) disas
 

(gdb) p $pc
$1 = (void (*)()) 0xf543a38 <select+96>

(gdb) disas
Dump of assembler code for function select:
   0x0f5439d8 <+0>:     lwz     r10,-29856(r2)
   0x0f5439dc <+4>:     cmpwi   r10,0
   0x0f543a30 <+88>:    li      r0,142
   0x0f543a34 <+92>:    sc      
=> 0x0f543a38 <+96>:    mfcr    r0
   0x0f543a3c <+100>:   stw     r3,8(r1)

 

 

  • gdb stack info

  frame 打印當前棧幀的簡要信息。
  frame 2 : jump to the 2nd frame
  info frame 打印當前棧幀的詳細信息。
  info frame args 打印指定棧幀的詳細信息。
  info args 打印函數參數信息。
  info locals 打印當前可訪問的局部變量的信息。
 使用 up down ,跳轉不同堆棧,查詢其中的堆棧簡要信息

  • gdb command script
(gdb) b dpsi_pkt_send_by_pcie
Breakpoint 14 at 0x1280e31c: file ./core/dps_pdu/dpsi_pkt_tr.c, line 36.
(gdb) command 14
Type commands for breakpoint(s) 14, one per line.
End with a line saying just "end".
>return
>c
>end
(gdb) c
  • gdb -x command file
$gdb cips_app -x debug.cmd
#####debug.cmd######
set pagination off
set logging file debug.log
set logging overwrite
set logging on
start
set $addr1=pthread_mutex_lock
set $addr2=pthread_mutex_unlock
b *$addr1
b *$addr2
while 1
     c
     if $pc != $addr1 && $pc != $addr2
        quit
     end
     bt
end
#####################
  • gdb core dump
sh-4.2# cd /run/corefile/     
sh-4.2# ls
core.bcmRX.gz
sh-4.2# gzip -d ./core.bcmRX.gz 
sh-4.2# gdb /run/cips/cips_app ./core.bcmRX

 

  • gdb check stack overflow
>p $sp
$1=(void *)0xbf06dffc
>i proc mapping
Start Addr    End Addr    Size    Offset    objfile
0x8048000     0x8049000   0x1000   0
...
0xbf06e000    0xbf86e000  0x800000 0xbf800000

Since stack top is 0xbf86e000, $pc is 0xbf06dffc which is smaller than stack top.

This means stackoverflow.(stack is increase from larger address to smaller one)

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章