1. 程式人生 > >cgdb---ubuntu14.04下安裝cgdb及gdb的使用

cgdb---ubuntu14.04下安裝cgdb及gdb的使用

一. ubuntu 14.04 下安裝cgdb
1.ubuntun14.04下安裝cgdb
[email protected]:~$ sudo apt-get install cgdb
2. 使用: cgdb ./hello就可以了
a. cgdb分為上面的vi視窗與下面的gdb視窗
  1. ESC-->切到vi視窗
  2. -->切到gdb視窗
  3. - -->減小vi視窗
  4. = -->增大vi視窗
  5.  shift - -->減小很多vi視窗
  6.  shift = -->增大很多vi視窗
b.斷點
空格新增/刪除斷點
c. gdbinit指令碼不能用
  1. warning: File "/work/ffmpeg/jpeg/jpegc/.gdbinit"
     auto-loading has been declined by your `auto-load safe-path'setto"$debugdir:$datadir/auto-load".
  2. To enable execution of this file add   add-auto-load-safe-path /work/ffmpeg/jpeg/jpegc/.gdbinit   line to your configuration file "/home/cong/.gdbinit".
  3. To completely disable this security protection add    set
     auto-load safe-path /    line to your configuration file "/home/cong/.gdbinit".
  4. For more information about this security protection see the  "Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
  5.         info "(gdb)Auto-loading safe path"
臨時的方法: 在gdb的命令列裡面  source .gdbinit
永久的方法: 
[email protected]
:~$ cat .gdbinit 

set auto-load safe-path / 二. gdb的使用
1. 斷點
a. 在指定檔案中指定函式處設斷點
  1. <filename>: <func_name>
  2. <filename>: <line_num>   --> 例: break mm/slab.c:673
2. 列印
2.1 
{i,j,k,l}            -->列印多個變數
display {i,j,k,l}   --> 每執行一次都列印這幾個變數
undisplay           --> 去掉display

3.2 列印某個地址處的資料
  1. (gdb) help x
  2. Examine memory: x/FMT ADDRESS.
  3. ADDRESS is an expression for the memory address to examine.
  4. FMT is a repeat count followed by a format letter and a size letter-->顯示格式用兩部分表示
  5. Format letters are:                     -->格式型別 
  6.     o(octal), 
  7.     x(hex), 
  8.     d(decimal), 
  9.     u(unsigned decimal),
  10.     t(binary), 
  11.     f(float), 
  12.     a(address), 
  13.     i(instruction), 
  14.     c(char), 
  15.     s(string)
  16.     z(hex, zero padded on the left).
  17. Size letters are:                        -->長度型別 
  18.     b(byte), 
  19.     h(halfword), 
  20.     w(word), 
  21.     g(giant, 8 bytes).
  22. The specified number of objects of the specified size are printed
  23. according to the format.
例如要按16進位制顯示型別為short的inode->i_zone
(gdb) x /20xh  inode->i_zone
0x2cb92 : 0xbbc7 0xbbc8 0xbbc9 0xbbca 0xbbcb 0xbbcc 0xbbcd 0xbbce
0x2cba2 : 0x0000 0x0000 0x0000 0x0000 0x0000 0x0b6b 0x9bdc 0x0000
0x2cbb2 : 0x0000 0x0301 0x0931 0x0001

注: 要用display自動顯示--> display /40wx 0xc0101f80

2.3 gdb彙編級除錯
  1. (gdb) display /5i $pc                  -->pc是gdb的一個內部變數,列印當前的5條彙編指令
  2. 1: x/5i $pc
  3. => 0x1111dc <system_call>:    push %eax
  4.    0x1111dd <system_call+1>:    cld 
  5.    0x1111de <system_call+2>:    push %gs
  6.    0x1111e0 <system_call+4>:    push %fs
  7.    0x1111e2 <system_call+6>:    push %es
  8. (gdb) ni                              --> ni(nexti) 或si(stepi)進行彙編指令級除錯
  9. 0x001111dd in system_call ()


相關推薦

cgdb---ubuntu14.04安裝cgdbgdb的使用

一. ubuntu 14.04 下安裝cgdb1.ubuntun14.04下安裝cgdb[email protected]:~$ sudo apt-get install cgdb 2. 使

Ubuntu14.04安裝opencvROS Indigo配置Kinect V2

Ubuntu14.04下安裝opencv及ROS Indigo下配置Kinect V2 本篇文章是我在配置Kinect V2時的一些記錄,參考了一些前人的經驗部落格,並把遇到的問題記錄了下來。但之前儲存在了word裡面,出現了一些亂碼,這是我盡力修改了之後的結果,但也難免哪裡會出錯,還請

ubuntu14.04 安裝matlabR2015b遇到的一些問題及其解決方法

cal abr 問題 它的 文件夾 打開 pen atl usr 問題1:錯誤提示關於未取得權限,不能再/crack/bin文件中復制文件到安裝matlab的/usr/bin文件中? 采取解決方法: 再終端裏輸入 sudo nautilus,在彈出文件夾裏即可進行相應操作。

Ubuntu14.04安裝Composer

14.04 blog har oca version ins curl pos tps 下載Composer: curl -sS https://getcomposer.org/installer | php 安裝Composer: /usr/bin/php comp

Ubuntu14.04安裝 ffmpeg-2.4.13(處理視頻用,將視頻保存為圖片序列)

ibm blog 提取 ext aac sta video images bmp 首先在 http://www.ffmpeg.org/olddownload.html 下載 ffmpeg-2.4.13.tar.bz2 ; 然後安裝 yasm 和 libx264: apt

Ubuntu14.04安裝 boost (boost_1.54 最簡單的方法)

urn 分享 ubun 命令 寫入 return test 簡單的 logs 直接執行命令: sudo apt-get install libboost-dev 測試: 創建一個 boost_test.cpp 文件,寫入 #include <boost/lexi

Ubuntu14.04安裝redis

sudo apt-get update sudo apt-get install redis-server 啟動redis服務 sudo /etc/init.d/redis-server restart sudo service redis-server restart 2.連線redis

Ubuntu14.04安裝glog

下載原始程式碼編譯 1. Clone Source Code  glog git clone https://github.com/google/glog 2. Install dependencies and tools sudo apt-get install auto

ubuntu14.04安裝cmake 3.5

對於ros的應用,很多還侷限在indigo下,因此要求的Ubuntu版本還限制在14.04但對於很多新的功能包,是在kinetic下執行的,很多cmake要求在3.5以上,而安裝ros indigo時,預設安裝的cmake版本為2.4,這樣會有很大的影響,包括使用sudo a

Docker學習系列(二):Ubuntu14.04安裝Docker-2016.06.26更新版

注:docker官網更新很快,而且更新變化很大,3個月前的安裝方法,今天發現已經不再適用,所以,這裡對ubuntu下安裝docker的方法進行更新 Ubutnu上安裝Docker的詳細教程見新版的Docker官網 安裝使用時,需要注意一點:要用sudo許可

ubuntu14.04 安裝qq完美解決版本過低無法使用問題。

由於Wine QQ一直沒更新版本導致目前版本報版本過低無法使用,暫時先上UK官網的國際版Wine QQ,雖然功能沒那麼新,但穩定能用: 下載: 下載地址:http://www.ubuntukylin.com/applications/showimg.php?lang=cn&id=23 下載後解壓得到

Ubuntu14.04安裝Anaconda3-4.3.0後,無法建立虛擬環境的解決方法

    因為研究需要,涉及到了強化學習(Reinforcement Learning, RL)內容,繼而進入了一個充滿荊棘的的領域。    強化學習方面的書籍寥寥無幾,98年,Richard S. Sutton出版了他的強化學習導論第一版,即Reinforcement Lea

ubuntu14.04安裝nodejs

1、進入官網下載合適的版本,直接下編譯好的版本。http://nodejs.cn/ 2、解壓到usr/local/node目錄下 3、修改目錄許可權:chmod 755 /usr/local/node/* -R 4、進入node/bin目錄,然後./n

一、Ubuntu14.04安裝Hadoop2.4.0 (單機模式)

一、在Ubuntu下建立hadoop組和hadoop使用者     增加hadoop使用者組,同時在該組裡增加hadoop使用者,後續在涉及到hadoop操作時,我們使用該使用者。 1、建立hadoop使用者組              2、建立hadoop使用者   

ubuntu14.04 安裝 glib-2.44.1 的過程記錄

安裝glib-2.44.1 先說清楚,這是一篇糾結文,正確答案請看這裡 糾結開始了: 要用到autoconf生成配置指令碼 先使用apt-get install autoconf安裝autoconf,這個稍微有點慢。  然後在glib-master目錄下執行 autoco

Ubuntu14.04安裝GTK+

一、安裝   1、安裝gcc/g++/gdb/make 等基本程式設計工具 $sudo apt-get install build-essential   2、安裝 libgtk2.0-dev libglib2.0-dev 等開發相關的庫檔案 $sudo apt

Ubuntu14.04安裝AMD閉源顯示卡驅動fglrx(開發專用)

我的電腦是AMD的R9 200系列顯示卡。 安裝完Ubuntu系統之後,進入system setting可以看到當前使用的是開源驅動。 接下來我把我整理出來的目前可行的安裝方法分享給大家。 (額外補充一點,在你安裝完Ubuntu系統之後,建議馬上在設定中將映象伺服器,也就是

ubuntu14.04安裝svn

1. 安裝svn工具sudo apt-get install subversion subversion-tools2. 克隆倉庫svn co svn://192.168.11.22/software/ --username svn使用者名稱 --password svn密碼

ubuntu14.04安裝WebStorm,並建立桌面圖表

一.WebStorm 是 jetbrains 公司旗下一款 JavaScript 開發工具,被廣大 JS 開發者譽為“Web前端開發神器”。 安裝 解壓下載的 gz 包,命令列下執行: cd bin ./webstorm.sh 不過 WebStorm 預設情況下是需要收

Ubuntu14.04安裝最新OpenJdk1.8

1. Ctrl+Alt+T 開啟終端執行以下命令:sudo add-apt-repository ppa:openjdk-r/ppa輸入你的sudo密碼繼續2. 升級系統資源包並安裝openjdk1.8:sudo apt-get update sudo apt-get i