温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

VSCode搭建Arm远程调试环境的操作步骤

发布时间:2021-02-07 11:29:56 来源:亿速云 阅读:834 作者:小新 栏目:编程语言

这篇文章主要介绍VSCode搭建Arm远程调试环境的操作步骤,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

前提条件:

  • 确保本机已经安装 VS Code。

  • 确保本机已安装 SSH client, 并且确保远程主机已安装 SSH server。

  • VSCode 已经安装了插件 C/C++。

本次搭建的环境:

  • 主机:windows 10

  • 服务器:ubuntu 16.04

  • VSCode 版本:February 2020 (version 1.43)

  • Arm:海思 3559A (已配置好编译工具链和 gdb server)

连接远程主机

Remote Development

首先安装 Remote Development 插件,安装完成之后:

VSCode搭建Arm远程调试环境的操作步骤

如上图所示,输入:Remote-SSH:Connect to Host->Configure SSH Hosts->选择一个config,配置信息:

# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host Server
    HostName 10.10.1.111
    User name

其中:

  • Host: 远程主机名称。

  • HostName: 远程主机 IP。

  • User: 连接用户名。

输入完毕后保存,左侧会出现配置好的信息,右键登陆,可能需要密码:

VSCode搭建Arm远程调试环境的操作步骤

插件安装

连接到 server 后会发现,安装的插件分为两栏,可以在远程服务器安装需要的插件:

VSCode搭建Arm远程调试环境的操作步骤

远程主机命令行

Ctrl + ~ 打开终端窗口,VS Code 连接到远程主机后,就可以直接使用终端窗口在远程主机上执行终端命令。

arm 远程调试

VSCode 配置

配置 gdb 的配置文件 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}/build/bin/test.debug",
   "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/aarch74-himix100-linux/bin/aarch74-himix100-linux-gdb",
   "miDebuggerServerAddress": "192.168.172.110:1234"
  }
 ]
}
  • type:调试的类型

  • name:配置文件的名字

  • request:配置文件的请求类型,有 launch 和 attach 两种,具体看官方文档

  • program:可执行文件的路径和文件名称

  • args:主函数调用时传入的参数

  • stopAtEntry:设为true时程序将暂停在程序入口处

  • cwd:调试时的工作目录

  • externalConsole:调试时是否显示控制台窗口

  • MIMode:指定 VS Code 连接的调试器,必须为 gdb 或者 lldb

  • miDebuggerPath:调试器路径

  • miDebuggerServerAddress: 板子 ip

arm 上运行 gdb server

./gdbserver :1234 test.debug

开始调试

VSCode 按 F5 开始调试:

VSCode搭建Arm远程调试环境的操作步骤

断点设置,变量、栈查看:

VSCode搭建Arm远程调试环境的操作步骤

以上是“VSCode搭建Arm远程调试环境的操作步骤”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI