Linux环境ddd安装与使用
ddd是一個優(yōu)秀的調(diào)試器,安裝ddd破費(fèi)周折
必須安裝x開發(fā)環(huán)境
?
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
解決方法:
#find -name strclass.C
找到路徑后編輯在改文件頭部加入 #define EOF -1
終于可以make成功了!
?
4.安裝
# make install
?
5.啟動
進(jìn)入ddd的安裝目錄/usr/local/ddd,還要再進(jìn)入bin子目錄
#cd /usr/local/ddd/bin
#ddd
成功啟動界面
?
6.調(diào)試
靜態(tài)調(diào)試:
在要調(diào)試的程序所在目錄
#/usr/local/ddd/bin/ddd?? 程序
?
動態(tài)調(diào)試:
ddd更強(qiáng)大的是是可以綁定到運(yùn)行中的程序例如Nginx進(jìn)程上
# ps aux|grep nginx
#ddd -p nginx_pid
?
設(shè)置斷點:在需要設(shè)置斷點代碼行,按鼠標(biāo)右鍵彈出菜單選SetBreakoint。
查看所有斷點,可以點source->Breakoints彈出窗口。
查看變量:右擊鼠標(biāo)選中變量,點Display即可以圖形化查看變量。
?
如果變量是結(jié)構(gòu)體包含的結(jié)構(gòu)體,那么還可以在Display出來的圖形化結(jié)構(gòu)體中,選中其中是結(jié)構(gòu)體的變量繼續(xù)Display。
?
小技巧:可以使用showall和hideall顯示和隱藏子結(jié)構(gòu),例如nginx的內(nèi)存池對象*p的d子結(jié)構(gòu)可以在display時展開全部
總結(jié)
以上是生活随笔為你收集整理的Linux环境ddd安装与使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VirtualBox虚拟机安装RedHa
- 下一篇: 使用cat /proc/进程id/map