2015年1月7日 星期三

GDB 教學

常用指令

del       : delete all break point
hb 123 : set hardware breakpoint at line 123
bt         : back trace (stack dump)
/nfu  address: print memory , n,f,u  都是參數
        n,  the repeat count
         f,  the display format
              `s' (null-terminated string), or `i' (machine instruction). The default is `x' (hexadecimal)
        u,  the unit size : 分為 b(Bytes)
                                             h(Halfwords , "two bytes")
                                             w(Words "four bytes")
                                             g(Giant words "eight bytes".)
  e.g.  x /48xw 0x89003b40

 info register : 顯示所有的暫存器
 info breakpoints : 顯示目前的中斷點
 info files


程式執行
  • run (r) -- 開始執行程式
  • continue (c) -- 離開中斷點,繼續執行程式
  • next (n) -- 單步執行 (step over)
  • step (s) -- 進入函式 (step into)
  • until (u) -- 離開 while, for等迴圈。 執行到程式碼的行數比目前的大,如果目前是迴圈的最後一行,就會離開迴圈
  • finish -- 繼續執行程式直到函式返回
  • start --在 main 設置暫時中斷點,並開始執行程式
  • advance -- 執行程式直到指定的位置
  • run arglist -- 同 run,並指定程式參數
  • start arglist -- 同 start,並指定程式參數
  • kill (k) --終止程式執行
  • quit (q) --離開 GDB
  • x -- print Memory

沒有留言:

張貼留言