| 命令 | 作用 |
|---|---|
| l(list) | 显示源码 |
| b(break) | 设置断点 |
| r(run) | 运行程序 |
| bt或where | 显示调用栈 |
| n(next) | 单步运行(不进入函数) |
| s(step) | 单步运行(进入函数) |
| layout next | 分割窗口,查看源码 |
| watch | 监视变量,当变量变化时打印 |
| p(print) Var | 打印变量的值 |
| p arr@len | 打印数组 |
| c(continue) | 跳到下一个断点 |
| r | 刷新 |
| f(file) | 加载可执行程序 |
layout src | 分屏显示源码 |
layout asm | 分屏显示汇编代码 |
tui reg grneral | Display the general registers(显示通用寄存器) |
info threads
显示当前调试程序的所有线程,每个线程会有一个GDB为其分配的id,根据id操作制定的线程,* 表示当前调试的线程
thread id
切换为指定线程
break thread_test.c thread all
在所有线程的相应行上设置断点
thread apply id1 id2 command
指定线程执行command
例子
thread apply 1-4 print $sp thread apply all backtrace thread apply all backtrace full
thread apply all command
所有线程执行 command
set scheduler-locking off\ on\ step
off 不锁定任何线程(默认值)
on 只有当前线程会被执行
本文介绍了GDB调试器的基本使用方法,包括设置断点、单步执行、查看调用栈等常用命令,并提供了线程管理和变量监视的具体操作示例。

1366

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



