当前位置:网站首页>GDB 在嵌入式中的相关概念
GDB 在嵌入式中的相关概念
2022-07-03 01:06:00 【TangZhenye】
1. 背景
在嵌入式开发中调试器起着非常大的作用,下载程序、单步调试程序、下断点、通过函数调用栈查看函数调用关系等。通常我们不关心调试器的工作原理,只管调试就好,但是底层原理的认知是非常重要的,本文将打开一大块知识拼图。
2. GDB 是什么
本人理解,不按照官方的解释,什么GNU计划什么的。GDB 是 gcc 工具链带的一个调试程序,注意是程序。
3. GDB 的两个概念
GDB 是程序,调试器也只是运行着 GDB 程序的嵌入式工具罢了,调试器中的 GDB 程序常称为 GDB Server,顾名思义,就是个 GDB 服务器。服务器是服务客户端的,一直监听客户端发来的请求。所以,PC 端一定存在一个 GDB Client 的客户端程序。
经常用的 Jlink,ST-link 等调试工具,一般都用自己的 gdb server 程序运行在上面,因此,我们通常通过芯片上的 JTAG 接口,SWD 接口与调试器连接,连接上后,我们在 IDE 上点击小虫子按钮来调试板子,此时,IDE 中已经集成了 GDB Client,IDE 通过这个 Client 与 ST-link 或者 Jlink 中的 Server 通讯,比如发送个断点指令(在 IDE 中就点击出现个红色圈圈),然后全速运行,Client 就会发送全速运行的命令给 Server,此时 Server 就通过实际的连的杜邦线将信号发到芯片内部调试单元上,芯片就跑了起来。
4. GDB 串行协议
通常我们使用调试器连接开发板,这样 Client 与 Server 之间发送的命令很难观察到,因此,可以通过 qemu 的方式,让 qemu 运行 Server 程序并启动网络协议栈,Client 通过网络的方式连接 Server 来调试 Server 端的代码,这样,通过抓包工具将 Client 与 Server 之间交互的数据给抓下来,就能够知道他俩之间到底都说了啥。
5. GDB 相关命令
gdb xxx.elf // client 端载入符号表
target remote ip:port // 连接 Server
load xxx.elf // 将 elf load 到 Server 端,相当于给板子重新下载程序
b xxx // 在xxx 出下断点
c // 全速运行,遇到断点停止
bt // 显示函数调用栈
.
.
.
.
.
边栏推荐
- [untitled]
- 测试右移:线上质量监控 ELK 实战
- 數學知識:臺階-Nim遊戲—博弈論
- Excel removes the data after the decimal point and rounds the number
- Why can't the start method be called repeatedly? But the run method can?
- Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
- 串口抓包/截断工具的安装及使用详解
- MySQL - database query - basic query
- Key wizard hit strange learning - automatic path finding back to hit strange points
- 【FH-GFSK】FH-GFSK信号分析与盲解调研究
猜你喜欢

MySQL --- 数据库查询 - 条件查询

串口抓包/截断工具的安装及使用详解

C#应用程序界面开发基础——窗体控制(2)——MDI窗体
![[Androd] Gradle 使用技巧之模块依赖替换](/img/5f/968db696932f155a8c4a45f67135ac.png)
[Androd] Gradle 使用技巧之模块依赖替换

MySQL foundation 05 DML language

强化学习 Q-learning 实例详解

C#应用程序界面开发基础——窗体控制(1)——Form窗体

Matlab Doppler effect produces vibration signal and processing
![[C language] detailed explanation of pointer and array written test questions](/img/24/c2c372b5c435cbd6eb83ac34b68034.png)
[C language] detailed explanation of pointer and array written test questions

Database SQL language 02 connection query
随机推荐
Mathematical Knowledge: Steps - Nim Games - Game Theory
【无标题】
Test shift right: Elk practice of online quality monitoring
MySQL foundation 04 MySQL architecture
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
Database SQL language 02 connection query
音程的知识的总结
数学知识:Nim游戏—博弈论
MySQL - database query - condition query
[C language] detailed explanation of pointer and array written test questions
C#应用程序界面开发基础——窗体控制(1)——Form窗体
[shutter] animation animation (the core class of shutter animation | animation | curvedanimation | animationcontroller | tween)
Button wizard play strange learning - automatic return to the city route judgment
电信客户流失预测挑战赛
Druid database connection pool
MySQL basics 03 introduction to MySQL types
Mathematical knowledge: divisible number inclusion exclusion principle
Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
Canvas drawing -- bingdd
一位苦逼程序员的找工作经历