板子: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运行的
2. 在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 systemctl enable ssh
sudo systemctl start ssh
sudo systemctl 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
公网远程使用sakuraFrp建立ssh管道
wget https://nya.globalslb.net/natfrp/client/frpc/0.51.0-sakura-4.3/frpc_linux_amd64
frpc_linux_amd64 -f *******************************************使用