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
相关推荐
c++逐梦人几秒前
进程的优先级与切换
linux·服务器·操作系统
重生之绝世牛码1 分钟前
Linux软件安装 —— Redis集群安装(三主三从)
大数据·linux·运维·数据库·redis·数据库开发·软件安装
网安CILLE4 分钟前
Wireshark 抓包实战演示
linux·网络·python·测试工具·web安全·网络安全·wireshark
是jin奥6 分钟前
Ubuntu 18 安装 nodejs 合适版本
linux·ubuntu·vim
网硕互联的小客服10 分钟前
如何彻底删除CentOS自带的postfix服务释放25端口?
linux·运维·centos
七七powerful15 分钟前
docker 部署dirsearch并进行目录遍历扫描
运维·docker·容器
天码-行空15 分钟前
CentOS 误删 /dev 目录救援方案
linux·运维·centos
小码吃趴菜15 分钟前
mysql
linux·运维·服务器
呉師傅22 分钟前
东芝3525AC彩色复印机打印配件寿命和打印错误记录方法【实际操作】
运维·服务器·网络·windows·电脑
霖霖总总23 分钟前
[小技巧37]解构 my.cnf:[client] 与 [mysql] 背后的加载逻辑与优先级
运维·mysql