• <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 對程序進(jìn)行匯編級(jí)調(diào)試

                                                         轉(zhuǎn)自http://www.cnblogs.com/diylab/archive/0001/01/01/1524483.html

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

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

            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.

            寫內(nèi)存:

            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 對程序進(jìn)行匯編級(jí)調(diào)試  回復(fù)  更多評(píng)論   

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

            正確的方法應(yīng)該用
            set disassembly-flavor intel

            只有注冊用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            亚洲午夜久久久久久久久电影网| 精品国产婷婷久久久| 日韩乱码人妻无码中文字幕久久 | 久久亚洲私人国产精品vA| 99久久成人国产精品免费| 久久久久久毛片免费看| 久久久久久久精品妇女99| 久久99国产精品久久99| 久久精品国产99国产精品亚洲| 国产精品久久久久久久| 久久这里只有精品首页| 国产精品伦理久久久久久| 97久久国产露脸精品国产| 久久人妻少妇嫩草AV无码蜜桃| 天天躁日日躁狠狠久久| 婷婷国产天堂久久综合五月| 91精品国产91热久久久久福利| 人妻少妇久久中文字幕一区二区| 香蕉99久久国产综合精品宅男自 | 66精品综合久久久久久久| 久久亚洲精品成人av无码网站| 久久丝袜精品中文字幕| 色偷偷888欧美精品久久久| 人妻精品久久无码区| 一本久久a久久精品综合香蕉| 国产精品欧美久久久久无广告| 97久久超碰国产精品2021| 久久久久亚洲精品天堂| 97精品伊人久久久大香线蕉| 久久无码AV中文出轨人妻| 久久久噜噜噜久久| 久久精品国产WWW456C0M| 久久精品国产精品亚洲下载| 久久99国产一区二区三区| 国产精品免费久久| 久久无码一区二区三区少妇| 亚洲&#228;v永久无码精品天堂久久| 精品久久久久久| 久久电影网| 久久精品国产亚洲αv忘忧草| 日韩久久久久久中文人妻|