添加调试

This commit is contained in:
2025-10-19 11:44:16 +00:00
parent 9eb6989ad0
commit 97d7d66548
6 changed files with 192 additions and 51 deletions

View File

@@ -1,16 +1,18 @@
FROM mcr.microsoft.com/devcontainers/base:dev-ubuntu-20.04
# 安装 build-essential
# 安装 build-essential 和调试工具
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
#清理 apt 缓存
apt-get install -y --no-install-recommends \
build-essential \
gdb \ # 添加GDB调试器
gcc \
make && \
# 清理 apt 缓存
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 设置工作目录(可选)
WORKDIR /workspace
# 设置工作目录
WORKDIR /workspace
# 可以添加其他的自定义设置,比如复制源代码等
CMD ["/bin/bash"] # 可以添加默认命令,比如进入 bash
CMD ["/bin/bash"]

View File

@@ -1,18 +1,23 @@
{
"name": "DevContainerExample",
"image": "mcr.microsoft.com/devcontainers/base:dev-ubuntu-20.04",
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y gdb && make",
"customizations": {
"vscode": {
"settings": {},
"extensions": [
]
}
"vscode": {
"settings": {
"debug.onTaskErrors": "debugAnyway"
},
"extensions": [
"ms-vscode.cpptools"
]
}
},
"portsAttributes": {
"3000": {
"label": "Web Server",
"onAutoForward": "notify"
}
}
}
"3000": {
"label": "Web Server",
"onAutoForward": "notify"
}
},
"initializeCommand": "gdb -ex 'set confirm off' -ex quit", // 初始化GDB配置
"postAttachCommand": "make debug" // 假设你的Makefile有debug目标
}