5. 调试
5.1. GDB调试
启用GDB:gdb --args ./ns3 run
- –command-template=“gdb %s” 启动调试,
- 在里面可以用help查看一系列命令
- help running 输出运行相关的命令
- –command-template=“%s --help”
- 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 命令
- break 在指定函数设置断点(如 break main)

- break(b) <file:line/> 在指定文件的某一行设置断点
- b 文件名:行号
- b 函数名:行号
- b 函数名
- i loc 命令:当程序因观察点触发而暂停时,可以通过此命令查看局部变量的值
- info locals 显示所有局部变量及其值
- info args 显示函数参数及其值
- 或者断点后直接print变量即可;
- run® 启动程序
- finish 运行到函数结束

- next (n) 单步执行(不进入函数)
- step (s) 单步执行(进入函数)
- continue

最低0.47元/天 解锁文章
4997

被折叠的 条评论
为什么被折叠?



