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时展开全部


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值