(gdb)中b aodv.cc:112时错误:no source file named aodv.cc

本文介绍如何通过修改Makefile文件配置并使用GDB工具来调试NS-2网络模拟软件,包括设置断点、运行调试等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

确定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++

 

接下来就可以调试了哦~

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值