搜索
首页开发工具VSCodevscode如何使用gdb调试

vscode如何使用gdb调试

Feb 12, 2020 pm 02:00 PM
gdbvscode

vscode如何使用gdb调试

1、vscode启动debug窗口

按Ctrl Shift D,打开Debug窗口

默认是“No configurations”, 点击“F5”,会提示你配置GDB参数(选择gcc build and debug active file),配置文件名称为launch.json(配置参考3)

配置完成后,再按F5, 会提示配置GCC,选择“Configure Task”, 选择“C/C : build and debug active file”, 配置文件名称为task.json(配置参考2)

2、GCC配置

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc build active file",
            "command": "/usr/share/mips-gcc-4.6/staging_dir/bin/mips-linux-gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

“command”: 编译链的地址

3、GDB配置

{
    // 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": "gcc build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerServerAddress": "192.168.0.1:10000",
            "program": "/home/renyinshan/work/p53/apps/cmdlib/test",
            "args": [],
            "stopAtEntry": true,
            "cwd": "/home/renyinshan/work/p53/apps/cmdlib/",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc build active file",
            "miDebuggerPath": "/home/renyinshan/work/p53/apps/gdb/install/bin/mips-linux-gdb"
        }
    ]
}

“program”: 要调试的程序名(包含路径,最好绝对路径,免得麻烦)

“miDebuggerServerAddress”: 服务器的地址和端口

“cwd”: 调试程度的路径

“miDebuggerPath”: gdb的路径

4、GDB server编译及运行

1)编译

P53编译时,请打开如下开关; P59需要从编译链目录拷贝一个。

scripts/tozedap-router_4g_industry/config.tozedap-router_4g_industry:564:export NO_CPP_LIB=0

GDB运行需要libstdc++.so.6的库,所以需要把此开关打开。
./cool 3 gdb_build

等待完成即可

编译完成后的文件如下:

renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/install/*
../apps/gdb/install/bin:
mips-linux-gdb  mips-linux-gdb-add-index  mips-linux-run

../apps/gdb/install/include:
gdb

../apps/gdb/install/lib:
libmips-linux-sim.a

../apps/gdb/install/share:
gdb  info  locale  man

renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/installgdbserver/bin/
mips-linux-gdbserver
renyinshan@renyinshan:~/work/p53/build$

说明:

install/bin 目录的mips-linux-gdb为vscode中配置需要的;

installgdbserver/bin/ 目录中的mips-linux-gdbserver,需要拷贝到板子中;

2)ssh登录设备,下载gdbserver到/tmp目录中, 并增加 x权限

3)ssh登录设备,下载可执行程序到/tmp目录中, 并增加 x权限

4)运行

/tmp # ./mips-linux-gdbserver :10000 ./test

调试输出:

/tmp # ./mips-linux-gdbserver :10000 test 
Process /tmp/test created; pid = 22608
Listening on port 10000
Remote debugging from host 192.168.0.245
APP is running!

备注说明:
1) 下载的可执行程序,必须保证是设备所需编译链编译的;
2) vscode中按F5调试时,GCC编译的配置和GDB参考1和2;

5、调试

准备完成, 在VSCode进行调试。

相关推荐:vscode教程

以上是vscode如何使用gdb调试的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
vscode如何格式化jsonvscode如何格式化jsonApr 16, 2025 am 07:54 AM

在 VS Code 中格式化 JSON 的方法有:1. 使用快捷键 (Windows/Linux:Ctrl Shift I;macOS:Cmd Shift I);2. 通过菜单(“编辑” > “格式化文档”);3. 安装 JSON 格式化程序扩展(如 Prettier);4. 手动格式化(使用快捷键缩进/缩出块或添加花括号和分号);5. 使用外部工具(如 JSONLint 和 JSON Formatter)。

vscode如何编译vscode如何编译Apr 16, 2025 am 07:51 AM

在 VSCode 中编译代码分 5 步:安装 C 扩展;在项目文件夹中创建 "main.cpp" 文件;配置编译器(如 MinGW);使用快捷键("Ctrl Shift B")或 "Build" 按钮编译代码;使用快捷键("F5")或 "Run" 按钮运行编译后的程序。

vscode如何安装vscode如何安装Apr 16, 2025 am 07:48 AM

要安装 Visual Studio Code,请按以下步骤操作:访问官方网站 https://code.visualstudio.com/;根据操作系统下载安装程序;运行安装程序;接受许可协议并选择安装路径;安装完成后,VSCode 将自动启动。

vscode如何放大字体vscode如何放大字体Apr 16, 2025 am 07:45 AM

在 Visual Studio Code 中放大字体的方法有:打开设置面板(Ctrl , 或 Cmd ,)。搜索并调整“Font Size”。选择具有适合大小的“Font Family”。安装或选择提供合适大小的主题。使用键盘快捷键(Ctrl 或 Cmd )放大字体。

vscode如何连接远程服务器vscode如何连接远程服务器Apr 16, 2025 am 07:42 AM

如何通过 VSCode 连接远程服务器?安装 Remote - SSH 扩展配置 SSH在 VSCode 中创建连接输入连接信息:主机、用户名、端口、SSH 密钥在 Remote Explorer 中双击已保存的连接

vscode如何运行vuevscode如何运行vueApr 16, 2025 am 07:39 AM

在 VSCode 中运行 Vue 项目需要以下步骤:1. 安装 Vue CLI;2. 创建 Vue 项目;3. 切换到项目目录;4. 安装项目依赖;5. 运行开发服务器;6. 打开浏览器访问 http://localhost:8080。

vscode如何比较两个文件vscode如何比较两个文件Apr 16, 2025 am 07:36 AM

VSCode 中比较文件的方法:1. 打开两个文件,2. 启用“差异”视图(“视图”菜单),3. 查看差异(新增绿色、删除红色、修改紫色),4. 使用箭头键导航,5. 接受或拒绝更改。附加功能包括合并更改、复制更改、查看详细信息和编辑差异。

vscode如何运行js代码vscode如何运行js代码Apr 16, 2025 am 07:33 AM

如何在 VSCode 中运行 JS 代码?创建.js文件并编写代码;安装 Node.js 和 npm;安装Debugger for Chrome;打开调试控制台;选择Chrome;添加调试配置;设置调试脚本;运行代码;调试代码(可选)。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
4 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
4 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
1 个月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.聊天命令以及如何使用它们
1 个月前By尊渡假赌尊渡假赌尊渡假赌

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境