首页 > 其他分享 >VSCode GDB调试配置

VSCode GDB调试配置

时间:2022-12-12 21:11:36浏览次数:65  
标签:renyinshan VSCode apps gdb GDB build linux mips 调试

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进行调试。(断电,单步等)

非常实用,可以经常使用 !!!

 

标签:renyinshan,VSCode,apps,gdb,GDB,build,linux,mips,调试
From: https://www.cnblogs.com/lidabo/p/16977099.html

相关文章

  • idea远程调试线上jar包
    有时候本地代码没问题但在线上运行会报错,这时候可以使用idea的remote功能调试线上jar包步骤1:点击设置  步骤2:新建remote  步骤3:配置服务器ip和端口并复制生成......
  • ios调试
    ios调试安装XCode1、从https://developer.apple.com/downloads/下载Xcode的最新版本。2、双击Xcodedmg文件3、安装Xcode运行运行到iOS模拟器App基座选择模......
  • pycharm的调试功能介绍
    ......
  • visual studio 2015/2019下使用gcc调试linux c++开发环境搭建完整详解
    一直以来,相信绝大部分的开发都是windows/mac下做开发,尤其是非嵌入式和qt系的,而开源服务器程序绝大部分都是跑在Linux下,几乎就没有跑在windows下的。一直以来开发人员都......
  • nasm + vscode 搭建ASM汇编开发环境
    一:背景1.简介.NET高级调试要想玩的好,看懂汇编是基本功,但看懂汇编和能写点汇编又完全是两回事,所以有时候看的多,总手痒痒想写一点,在Windows平台上搭建汇编环境不是那......
  • 光纤中继器的安装调试
    随着光通信领域的应用逐渐深入,国内通信厂商也逐渐开始自主研发光纤中继器产品,国产中继器的出现使得整个光纤中继器的成本大幅下降,此时,单模光缆和光纤中继器也逐步成熟,使得传......
  • 如何远程调试k8s里的jettypod
     ​课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。介绍主要的k8s资源的使用配置和命......
  • vscode+gdbserver 开发板调试
    参考嵌入式gdb+gdbserver调试环境搭建与使用参考嵌入式VSCode+gdbserver图形化调试环境搭建与使用参考VSCode+gdbserver嵌入式arm远程调试参考stepbystep使用g......
  • 使用 VSCode 远程 图形化 GDB 调试 嵌入式linux
     目录标题引言环境步骤vscoderemotessh配置Linux编译机配置设备板端配置vscodelaunch设置调试引言之前说了,通过coredump找程序bug,但是有些时候......
  • vscode Remote-SSH 相关问题
    1.远程连接时一直提示重复输入密码在vscode菜单栏里点击"查看"->"命令面板"输入remote-ssh:killvscodeserveronhost选择连接有问题的host重新输入密码即......