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
相关推荐
nuomigege几秒前
beagleboneblack刷入官方IOT镜像后无法运行nodered问题的处理
linux·运维·服务器
huaxiu525 分钟前
ubuntu下应用打不开
linux·运维·ubuntu
m0_6831247930 分钟前
Ubuntu服务设置开机自启
linux·运维·ubuntu
BestOrNothing_201534 分钟前
(1)双系统中Ubuntu22.04启动盘制作与启动盘恢复全过程
linux·ubuntu·双系统·启动盘制作·启动盘恢复
AI成长日志38 分钟前
【实用工具教程】Linux常用命令速查与实战场景:文件操作、进程管理与网络调试高频命令解析
linux·php
落叶花开又一年43 分钟前
检验检测机构资质认定远程评审工作程序
linux·运维·服务器
wanhengidc43 分钟前
《三国志异闻录》搬砖新游戏 云手机
运维·服务器·数据库·游戏·智能手机
idolao1 小时前
CentOS 7 安装 jdk-7u25-linux-x64.tar.gz 详细步骤(解压配置环境变量)
linux
i建模1 小时前
通过命令行使用密钥登录远程SSH主机
运维·ssh
旺仔.2911 小时前
僵死进程及Linux文件操作 详解
linux·运维·服务器