【ns3】Debug技巧(GDB、ns3日志系统、ns3抓包)

5. 调试

5.1. GDB调试

启用GDB:gdb --args ./ns3 run

  1. –command-template=“gdb %s” 启动调试,
    1. 在里面可以用help查看一系列命令
    2. help running 输出运行相关的命令
  2. –command-template=“%s --help”
  3. General Arguments:
    • –PrintGlobals: Print the list of globals.
    • –PrintGroups: Print the list of groups.
    • –PrintGroup=[group]: Print all TypeIds of group.
    • –PrintTypeIds: Print all TypeIds.
    • –PrintAttributes=[typeid]: Print all attributes of typeid.
    • –PrintVersion: Print the ns-3 version.
    • –PrintHelp: Print this help message.

直接在终端使用下面命令:(先run一遍才能用这些命令好像)
./ns3 run scratch/wificsma_quic.cc --command-template="gdb %s"

常用 GDB 命令

  1. break 在指定函数设置断点(如 break main)
  2. break(b) <file:line/> 在指定文件的某一行设置断点
  3. b 文件名:行号
  4. b 函数名:行号
  5. b 函数名
  6. i loc 命令:当程序因观察点触发而暂停时,可以通过此命令查看局部变量的值
  7. info locals 显示所有局部变量及其值
  8. info args 显示函数参数及其值
  9. 或者断点后直接print变量即可;
  10. run® 启动程序
  11. finish 运行到函数结束
  12. next (n) 单步执行(不进入函数)
  13. step (s) 单步执行(进入函数)
  14. continue
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值