VSCode + GDBServer 远程调试C/C++流水账
VSCode + GDBServer 远程调试C/C++流水账
配置了一个开发环境,写个流水账供日后查阅
工程文件
main.c
#include <stdio.h>
void main()
{
printf("hw\n");
return;
}
Makefile
# C compiler options
CC = gcc
#CC = x86_64-w64-mingw32-gcc
CFLAGS=
RELEASE = release.elf
DEBUG = debug.elf
LIBS =
INC =
# Source files
SRCS = main.c
# Make everything
all: $(RELEASE)
debug: $(DEBUG)
# Make the application
$(RELEASE): $(OBJS)
$(CC) -o $(RELEASE) $(SRCS) $(LIBS) $(CFLAGS)
$(DEBUG): $(OBJS)
$(CC) -g -ggdb3 -o $(DEBUG) $(SRCS) $(LIBS) $(CFLAGS)
gdbserver :1234 $(DEBUG)
#
# Clean all object files...
#
clean:
$(RM) $(DEBUG) $(RELEASE)
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "GDB Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/debug.elf",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"logging": {
"moduleLoad": true,
"engineLogging": true,
"trace": true
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"linux": {
"miDebuggerPath": "/usr/bin/gdb",
},
//"preLaunchTask": "RunGDBServer",
"miDebuggerServerAddress": "127.0.0.1:1234"
}
]
}
RunDebug.sh
make debug
gdbserver :1234 debug.elf
操作步骤:
- 运行
RunDebug.sh
生成调试文件,以及运行gdbserver
- 在VSCode里按F5开始调试
"随笔"类型下的内容为原创,转载请注明来源. http://www.cnblogs.com/DragonStart/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
2020-01-05 OrangePI通过ffmpeg和nginx把摄像头输出为rtmp
2020-01-05 友情链接