linux板子vscode gdb 远程调试

板子:hi3556v200

交叉编译工具:arm-himix200-linux

主机:win10+虚拟机的ubuntu16.4

gdb:gdb-8.2.tar.gz

1.在ubuntu交叉编译gdb(Remote 'g' packet reply is too long解决)

建议修改gdb8.2/gdb目录下面的remote.c解决Remote 'g' packet reply is too long

修改:

/* Further sanity checks, with knowledge of the architecture. */

if (buf_len > 2 * rsa->sizeof_g_packet)

error (_("Remote 'g' packet reply is too long (expected %ld bytes, got %d "

"bytes): %s"), rsa->sizeof_g_packet, buf_len / 2, rs->buf);

修改为:

/* Further sanity checks, with knowledge of the architecture. */

if (buf_len > 2 * rsa->sizeof_g_packet) {

rsa->sizeof_g_packet = buf_len ;

for (i = 0; i < gdbarch_num_regs (gdbarch); i++) {

if (rsa->regs[i].pnum == -1)

continue;

if (rsa->regs[i].offset >= rsa->sizeof_g_packet)

rsa->regs[i].in_g_packet = 0;

else

rsa->regs[i].in_g_packet = 1;

}

}

在gdb8.2的目录执行

./configure --target=arm-himix200-linux --prefix=$(pwd)/cbInstall

make

make install

将在当前目录的cbInstall生成gdb工具,这个工具是ubuntu运行的

  1. 在ubuntu交叉编译gdbserver

在gdb8.2/gdb/gdbserver的目录执行

./configure --target=arm-himix200-linux --prefix=$(pwd)/cbInstall

make

make install

将在当前目录的cbInstall生成gdbserver工具,这个工具需要拷贝到3556v200开发板

3.使用步骤

例子程序testProgram编译的时候需要加入-g参数

在板子运行

./gdbserver port:1234 ./testProgram
在ubuntu运行

./arm-himix200-linux-gdb

然后输入

target remote 192.168.10.10:1234

contiune

结果:

4.vscode远程调试

4.1ubuntu装ssh服务器

sudo apt update

sudo apt upgrade

sudo apt install openssh-server

sudo sytemctl enable ssh

sudo sytemctl start ssh

sudo sytemctl status ssh

sudo ufw allow ssh

sudo ufw enable

sudo ufw status

4.2 vscode装好ssh插件并链接ubuntu

然后配置

输入ssh xxx(ubuntu名称)@xxxxxx(ip地址)

远程调试最主要是配置vscode调试json文件 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": [
    
     {
      "type": "cppdbg",	
      "request": "launch",
      "name": "Debug for test", 
      "skipFiles": [
       "<node_internals>/**"
      ],
      "args": [],
      "program": "${workspaceFolder}/testProgram",
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "externalConsole": true, 
      "MIMode": "gdb",
      "setupCommands": [
       {
        "description": "Enable pretty-printing for gdb",
        "text": "-enable-pretty-printing",
        "ignoreFailures": true
       }
      ], 
      "miDebuggerPath":"/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gdb",
      "miDebuggerServerAddress": "192.168.10.10:1234"
     }
    ]
}
type:调试的类型
name:配置文件的名字
request:配置文件的请求类型,有 launch 和 attach 两种,具体看官方文档
program:可执行文件的路径和文件名称
args:主函数调用时传入的参数
stopAtEntry:设为true时程序将暂停在程序入口处
cwd:调试时的工作目录
externalConsole:调试时是否显示控制台窗口
MIMode:指定 VS Code 连接的调试器,必须为 gdb 或者 lldb
miDebuggerPath:调试器路径,这个需要修改为上面编译好的那个,我这里是替换了海思原来的gdb工具
miDebuggerServerAddress: 板子 ip
相关推荐
MrZhangBaby5 分钟前
SQL-leetcode—3374. 首字母大写 II
linux·sql·leetcode
czhc114007566331 分钟前
LINUX 820 shell:shift,expect
linux·运维·excel
咕噜签名分发冰淇淋1 小时前
签名应用APP分发平台的微服务化部署是什么?其有哪些优势?
java·运维·微服务
望获linux1 小时前
【实时Linux实战系列】基于实时Linux的物联网系统设计
linux·运维·服务器·chrome·php
进击的阿尔法猿2 小时前
docker
运维·docker·容器
yuxb732 小时前
Linux 文本处理与 Shell 编程笔记:正则表达式、sed、awk 与变量脚本
linux·笔记·正则表达式
Zeluar2 小时前
关闭VSCode Markdown插件在Jupyter Notebook中的自动预览
ide·vscode·jupyter
北京阿法龙科技有限公司2 小时前
AR 虚实叠加技术在工业设备运维中的实现流程方案
运维·ar
刘一说2 小时前
CentOS 系统 Java 开发测试环境搭建手册
java·linux·运维·服务器·centos
wdxylb7 小时前
云原生俱乐部-shell知识点归纳(1)
linux·云原生