Linux環境ddd安裝與使用


ddd是一個優秀的調試器,安裝ddd破費周折

必須安裝x開發環境

 

1.下載

http://ftp.gnu.org/gnu/ddd/,下載最新的ddd-3.3.12.tar.gz

# wget http://ftp.gnu.org/gnu/ddd/ddd-3.3.12.tar.gz

# tar zxvf ddd-3.3.12.tar.gz

# cd ddd-3.3.12/

 

2.配置

# ./configure --prefix=/usr/local/ddd

 

安裝缺失文件

1).如果configure的時候報錯:
You must set the environment variable CXX to a working C++ compiler
這說明缺少C++編譯器

#yum install gcc-c++

 

2).如果configure的時候報錯:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for tgetent in -ltinfo... no

checking for termcap functions library... configure: error: No curses/termcap library found

這說明缺少ncurses安裝包

#yum list|grep ncurses
#yum -y install ncurses-devel
#yum install ncurses-devel


 

3).如果configure的時候報錯:

configure: error: The X11 library '-lX11' could not be found.
Please use the configure options '--x-includes=DIR'
and '--x-libraries=DIR' to specify the X location.
See the files 'config.log' and 'ddd/config.log'
for further diagnostics.

這說明缺少openmotif

# yum install openmotif

# yum install openmotif-devel

 

配置成功,如下圖所示:

 

3.編譯

# make

如果make報錯如下:
g++ -DHAVE_CONFIG_H -I. -I./.. -O2 -g -Wall -W -Wwrite-strings -trigraphs -MT strclass.o -MD -MP -MF .deps/strclass.Tpo -c -o strclass.o strclass.C
strclass.C: In function ‘std::istream& operator>>(std::istream&, string&)’:
strclass.C:1546: 錯誤:‘EOF’在此作用域中尚未聲明
strclass.C:1559: 錯誤:‘EOF’在此作用域中尚未聲明
strclass.C: In function ‘int readline(std::istream&, string&, char, int)’:
strclass.C:1589: 錯誤:‘EOF’在此作用域中尚未聲明
strclass.C:1602: 錯誤:‘EOF’在此作用域中尚未聲明
make[2]: *** [strclass.o] 錯誤 1
make[2]: Leaving directory `/usr/ddd-3.3.12/ddd'
make[1]: *** [all] 錯誤 2
make[1]: Leaving directory `/usr/ddd-3.3.12/ddd'
make: *** [all-recursive] 錯誤 1

 

錯誤內容是說EOF沒有聲明,文件是strclass.C

解決方法:

#find -name strclass.C

找到路徑后編輯在改文件頭部加入 #define EOF -1

終於可以make成功了!

 

4.安裝

# make install

 

5.啟動

進入ddd的安裝目錄/usr/local/ddd,還要再進入bin子目錄

#cd /usr/local/ddd/bin

#ddd

成功啟動界面

 

6.調試

靜態調試

在要調試的程序所在目錄

#/usr/local/ddd/bin/ddd   程序

 

動態調試

ddd更強大的是是可以綁定到運行中的程序例如Nginx進程上

# ps aux|grep nginx

#ddd -p nginx_pid

 

設置斷點:在需要設置斷點代碼行,按鼠標右鍵彈出菜單選SetBreakoint。

查看所有斷點,可以點source->Breakoints彈出窗口。

查看變量:右擊鼠標選中變量,點Display即可以圖形化查看變量。

 

如果變量是結構體包含的結構體,那么還可以在Display出來的圖形化結構體中,選中其中是結構體的變量繼續Display。

 

小技巧:可以使用showall和hideall顯示和隱藏子結構,例如nginx的內存池對象*p的d子結構可以在display時展開全部


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM