CentOS下安装ddd

来源:互联网 发布:美国非农数据最新信息 编辑:程序博客网 时间:2024/05/21 08:56

先是基本的

http://www.cnblogs.com/osyun/archive/2011/12/08/2281004.html

再是一篇好文,亲测有效,搬运如下

http://blog.csdn.net/unix21/article/details/8450040

但出了错:cannot find termcap compatible library

解决方案:http://blog.csdn.net/augusdi/article/details/38614707



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


0 0