vscode 部署远程调试

vscode 部署远程调试

 

  1. 安装扩展Remote Development

该步骤会自动安装 Remote-WSL / Containers / SSH 等插件。

 

  1. 安装扩展C/C++

 

 

  1. 添加远程机器
    1. 点击左侧远程的图标,资源管理器下拉选择远程;
    2. 点击配置按钮,修改配置文件添加远程机器;
    3. 点击+号添加远程机器,按照提示输入命令后回车;

 

步骤a:配置远程机器

 

步骤b:配置按钮方式配置远程机器

 

步骤c:+号方式配置远程机器

 

  1. 连接远程机器。

点击在当前窗口打开;点击在新窗口打开。

该过程会在服务器自动安装配置需要的服务,会在vscode右下角显示。

 

 

  1. 打开远程机器文件

 

 

  1. 配置远程调试

修改launch.json和task.json文件

 

launch.json配置示例:
       {

            "name": "(gdb) patrolserver_d",

            "type": "cppdbg",

            "request": "launch",

            "program": "/home/ecs/ies-max/bin/patrolserver_d",

            "args": [],

            "stopAtEntry": false,

            "cwd": "${fileDirname}",

            "externalConsole": false,

            "MIMode": "gdb",

            "setupCommands": [

                {

                    "description": "为 gdb 启用整齐打印",

                    "text": "-enable-pretty-printing",

                    "ignoreFailures": true

                },

                {

                    "description":  "将反汇编风格设置为 Intel",

                    "text": "-gdb-set disassembly-flavor intel",

                    "ignoreFailures": true

                }

         }

 

task.json配置示例:

{

            "label": "stop patrolserver_d",

            "type": "shell",

            "command": "kp patrolserver_d"

     },

 

  1. 启动调试

选择需要调试的程序,点击左侧启动按钮即可。

 

 

  1. 使用方式类似Visual Studio

添加断点:在某行代码前单击

逐过程:F10

单步执行:F11

继续:F5

 


 

附录:

{

"name": "(gdb) jkautochk_d",

"type": "cppdbg",

"request": "launch",

"program": "/home/ecs/ies-max/bin/jkautochk_d",

"args": [],

"stopAtEntry": false,

"cwd": "${fileDirname}",

"environment": [{"name": "DISPLAY","value": "195.10.1.133:0.0"}],

"externalConsole": false,

"MIMode": "gdb",

"setupCommands": [

{

"description": "为 gdb 启用整齐打印",

"text": "-enable-pretty-printing",

"ignoreFailures": true

},

{

"description":  "将反汇编风格设置为 Intel",

"text": "-gdb-set disassembly-flavor intel",

"ignoreFailures": true

}

]

},

 

posted @ 2023-06-05 19:36  大白菜爱上小香菜  阅读(380)  评论(0)    收藏  举报