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.Cstrclass.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] 错误 1make[2]: Leaving directory `/usr/ddd-3.3.12/ddd’make[1]: *** [all] 错误 2make[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时展开全部

一个人去旅行,而且是去故乡的山水间徜徉。

Linux环境ddd安装与使用

相关文章:

你感兴趣的文章:

标签云: