GDB操作基本命令

來源:互聯網
上載者:User

標籤:test   函數   isa   解釋   tis   whatis   text   nts   set   

GDB操作基本命令1 開啟檔案及退出操作

  shell下輸入  gdb filename : 開啟單個檔案

  gdb filename -q: 開啟單個檔案,屏蔽掉GDB內建的說明資訊

  gdb下輸入quit(q),退出調試

2 gdb命令
命令 縮寫 解釋
file filename   gdb下開啟檔案
list   l

顯示代碼,預設顯示10行。輸入Enter顯示下10行

list可以加入其他參數,如:

list 5,10   顯示第5行到第10行的代碼;

list func   顯示func函數周圍的代碼,顯示範圍和list參數有關;

list test.c:5,10  顯示源檔案test.c第5行到第10行的代碼,

一般用於調試含多個源檔案的程式。

shell  clear    清空shell,清屏
 break linenumber/funname b

 break 6 : 在第6行打上斷點,或者在函數上打斷點

條件斷點:

break 6 if n == 0,當變數n==0時,觸發斷點

 info  i

info breakpoints(i b): 顯示所有斷點

info source 查看當前程式

info stack 查看堆棧資訊

info args 查看當前參數值

info reg 輸出所有寄存器的當前值

info frame 輸出棧幀的使用方式

info b n  其中 n 為指定的斷點號,顯示指定斷點的狀態資訊,不加參數 n 時,會顯示所有的斷點的資訊

disable breaknumber   disable 1 :使得 斷點1無法被觸發
clear  breaknumber    clear 1 :刪除N行斷點
delete  breaknumber    刪除N號斷點,預設刪除所有斷點
run    r  執行程式
next  n 下一條語句,不會進入函數
continue  c  繼續執行
step  s  步進,會進入函數體
print 變數名或運算式   列印該變數或者該運算式的值 
whatis  變數名或者運算式    顯示該變數或運算式的資料類型
set  variable 變數=值    給對應的變數賦值
watch variable    設定觀察變數,變數值發生改變時將觸發
finish    跳出當前的函數
     
     

GDB操作基本命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.