确定gdb安装没有问题,解决方法:
1. 修改makefile.in:加上-g3选项
.cc.o:
@rm -f $@
$(CPP) -g3 -c $(CFLAGS) $(INCLUDES) -o $@ $*.cc
.c.o:
@rm -f $@
$(CC) -g3 -c $(CFLAGS) $(INCLUDES) -o $@ $*.c
2. 修改Makefile(没有任何后缀的)将里面
CCOPT = -Wall -Wno-write-strings
STATIC =
LDFLAGS = $(STATIC)
LDOUT = -o $(BLANK)
改变为:
CCOPT = -Wall -g -Wno-write-strings(就改这一个地方)
STATIC =
LDFLAGS = $(STATIC)
LDOUT = -o $(BLANK)
3. 在ns-allinone-2.34/ns-2.34目录下重新编译
make clean
make
4. 成功后开始调试:
转到ns-2.34目录下,cd ~/ns-allinone-2.34/ns-2.34/
gdb ns
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
设置断点:
(gdb) b aodv.cc:559
Breakpoint 1 at 0x82d058e: file aodv/aodv.cc, line 559.
运行:
(gdb) r wireless-flooding.tcl
Starting program: /home/hanwei/ns-allinone-2.34/bin/ns wireless-flooding.tcl
num_nodes is set 24
INITIALIZE THE LIST xListHead
Breakpoint 1, AODV::recv (this=0x8ebe150, p=0x93445c8) at aodv/aodv.cc:559
559 AODV::recv(Packet *p, Handler*) {
Current language: auto; currently c++
接下来就可以调试了哦~