当前位置:网站首页>GDB简介
GDB简介
2022-06-28 10:51:00 【MoyangCitta】
gcc -g -Wall program.c -o program“-g”选项的作用是在可执行文件中加入源代码信息,“-Wall”在尽量不影响程序行为的情况下打开所有warning。
单进程、单线程基础调试命令
启动、退出、查看代码
- 启动和退出
gdb 可执行程序
quit给程序设置参数/获取设置参数
set args 10 20
show args- GDB使用帮助
help- 查看当前文件代码
list/l (从默认位置显示)
list/l 行号(从指定的行显示)
list/l 函数名(从指定的函数显示)- 查看非当前文件代码
list/l 文件名:行号
list/l 文件名:函数名- 设置显示的行数
show list/listsize
set list/listsize 行数断点操作
- 设置断点
b/break 行号
b/break 函数名
b/break 文件名:行号
b/break 文件名:函数- 查看断点
i/info b/break- 删除断点
d/del/delete 断点编号- 设置断点无效
dis/disable 断点编号- 设置断点生效
ena/enable 断点编号- 设置条件断点(一般用在循环的位置)
b/break 10 if i==5调试命令
- 运行GDB程序
start (程序停在第一行)
run (遇到断点才停)- 继续运行,到下一个断点停
c/continue- 向下执行一行代码(不会进入函数体)
n/next- 变量操作
p/print 变量名(打印变量值)
ptype 变量名(打印变量类型)- 向下单步调试(遇到函数进入函数体)
s/step
finish (跳出函数体)- 自动变量操作
display 变量名(自动打印指定变量的值)
i/info display
undisplay 编号- 其他操作
set var 变量名=变量值(循环中用的较多)
until(跳出循环,要求循环中没有断点)多进程调试命令
(gdb) set follow-fork-mode modemode可以选择parent或者child,即:选择调试哪个进程
注:未被跟踪调试的进程会直接执行结束
多线程调试命令
- 利用 info threads 查看线程信息
- thread id 调试目标 id 指定的线程
set scheduler-locking off | on | step“off”表示不锁定任何线程;
“on”表示只有当前被调试的线程继续运行;
“step”在单步执行的时候,只有当前线程会执行。
边栏推荐
- Realization of a springboard machine
- 利用soapUI获取freemarker的ftl文件模板
- Must the MySQL table have a primary key for incremental snapshots?
- Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
- 线程和线程池
- Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
- Who knows if it is safe to open an account with CSC securities
- Metersphere实现UI自动化元素不可点击(部分遮挡)
- [unity][ecs] learning notes (III)
- OpenHarmony应用开发之二维码生成器
猜你喜欢

【monkey】monkey测试入门

mysql数据库概述以及安装过程

Wireless communication module fixed-point transmission - point to multipoint specific transmission application

Idea failed to connect to SQL Sever
Ribbon core source code analysis

Realization of a springboard machine

DataEase安装升级

Dataease installation upgrade

JS基础3

Mysql database overview and installation process
随机推荐
[QT] connect syntax reference implementation
【Qt】connect 语法参考实现
[unity][ecs] learning notes (II)
DlhSoft Kanban Library for WPF
Interface automation framework scaffolding - Implementation of parametric tools
Spatial-Temporal时间序列预测建模方法汇总
第六天 脚本与动画系统
【monkey】monkey测试入门
JSON模块、hashlib、base64
JS基础10
树莓派无需显示屏的VNC Viewer方式的远程连接
Who knows if it is safe to open an account with CSC securities
JS基础8
Dataease installation upgrade
[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)
【agora】get 一个 agora_refptr 对象的用法示例
Katalon框架测试一个web页面操作实例代码
MySQL(一)
Blackmail virus of industrial control security
OpenHarmony应用开发之二维码生成器