• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            gdb 對程序進行匯編級調試

            Posted on 2010-04-03 10:32 T.S Liu 閱讀(1678) 評論(1)  編輯 收藏 引用

            使用 gdb 對程序進行匯編級調試

                                                         轉自http://www.cnblogs.com/diylab/archive/0001/01/01/1524483.html

            開始/重新開始
              ( gdb) r     ( run )
              
              下斷點
              (gdb) b *0x0804ce2b
               b 表示  break
              
              單步步過
              (gdb) ni    (next instruction)
              單步步入  
              (gdb) si    ( step instruction )
              繼續執行
              ( gdb )c
              
              執行到返回
              (gdb) finish
              
              disas 
              
              反匯編一段指令。可以帶零個、一個或兩個參數。第一個參數是反匯編開始地址,第二個參數是反匯編結束地址。
              
              如果沒有參數,則反匯編當前的函數。
              
              
              內存讀/寫斷點
              watch *(int  *)0x8049aa4
              在 0x8049aa4 處下寫斷點,斷點的范圍為 4個字節。
              gdb支持更大范圍的內存寫斷點。但在匯編條件下,我還沒有找到設置更大內存寫斷點的方法。
              rwatch ,awatch 用法同 watch ,分別表示讀斷點和 讀寫斷點。
              讀寫斷點依賴于 gcc可用的硬件高度寄存器。
              
              
              
              寄存器窗口
              
              (gdb) display
              
              設定要觀察的變量的內容。這些變量的值在程序每次被斷下來后顯示在屏幕上。
              
              例如,我們經常要關注  eax, ebx, ecx,edx的內容,則用 display 設置他們為觀察變量。
              
              (gdb) display  /x $eax
              
              (gdb) display  /x $ebx
              
              (gdb) display  /x $ecx
              
              (gdb) display  /x $edx
              
              
              (gdb) until 
            相當于 od  的 f4
              
              
              特色功能:
              1、設置反匯編代碼使用的指令集
              (gdb) set disas intel
              
              設置反匯編代碼使用的指令集,可選擇 intel 指令集或 AT&T指令集.
              
              該指令只能用于x86平臺。
              
              
              捕獲 “段錯誤”的信號
              (gdb) handle SIGSEGV

              拋出異常時捕獲
              (gdb) catch throw
              
              查看棧幀。
              (gdb) where
               
              強制返回
              (gdb) return 
              程序直接從當前行跳轉到 return 處。如果函數有返回值,則加在 return 命令之后。例如, return 1。跳轉中,棧平衡是自動維護的。修改程序代碼段:

            By default, GDB opens the le containing your program's executable code (or the core le) read-only. This prevents accidental alterations to machine code; but it also prevents you from intentionally patching your program's binary. If you'd like to be able to patch the binary, you can specify that explicitly with the set write command. For example, you might want to turn on internal debugging ags, or even
            to make emergency repairs.

            set write on

            exec-file

             

            The dump and append commands write data to a file, and the restore command reads data from a file back into the inferior’s memory.

            寫內存:

            To store values into arbitrary places in memory, use the `{...}' construct to generate a value of speci ed type at a speci ed address (see Section 8.1 [Expressions], page 63). For example, {int}0x83040 refers to memory location 0x83040 as an integer (which implies a certain size and representation in memory), and set {int}0x83040 = 4
            stores the value 4 into that memory

             

             

            參考資料:

             <debugging with gdb> by Richard Stallman, Roland Pesch etc, Published by the Free Software Foundation

             

            Feedback

            # re: gdb 對程序進行匯編級調試  回復  更多評論   

            2012-03-24 23:12 by 葉劍飛
            在gdb中設置反匯編代碼使用的指令集,不能用set disas intel,否則會出現如下錯誤信息
            Ambiguous set command "disas intel": disassemble-next-line, disassembly-flavor.

            正確的方法應該用
            set disassembly-flavor intel
            性色欲网站人妻丰满中文久久不卡| 亚洲国产精品人久久| 亚洲国产成人久久综合区| 性做久久久久久久| 亚洲综合精品香蕉久久网97| 无码任你躁久久久久久久| AV狠狠色丁香婷婷综合久久| 久久成人18免费网站| 一本久久知道综合久久| 精品欧美一区二区三区久久久| 亚洲中文字幕无码久久2017| 国产精品久久久久久久午夜片 | 欧洲成人午夜精品无码区久久| 久久久久一区二区三区| 思思久久精品在热线热| 国产成人精品久久一区二区三区av| 中文字幕久久精品无码| 久久久久久亚洲精品无码| 久久精品国产精品国产精品污| 国产aⅴ激情无码久久| 亚洲精品NV久久久久久久久久 | 久久精品国产99久久丝袜| 人妻精品久久无码区| 香蕉久久久久久狠狠色| 久久精品中文字幕有码| 日本久久久精品中文字幕| 996久久国产精品线观看| 午夜精品久久久久久中宇| 7777久久久国产精品消防器材| 午夜视频久久久久一区| 蜜臀久久99精品久久久久久 | 香蕉久久夜色精品升级完成 | 欧美久久综合性欧美| 久久精品无码午夜福利理论片 | 久久久久亚洲AV无码网站| 影音先锋女人AV鲁色资源网久久| 亚洲国产日韩综合久久精品| 一本色道久久88综合日韩精品 | 亚洲国产成人久久精品动漫| www久久久天天com| 51久久夜色精品国产|