最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual studio code - Remote debug C, C++ binaries in VSCode - Stack Overflow

programmeradmin4浏览0评论

How to remotely debug C, C++ binaries installed in Linux environments in VSCode environments connected by ssh.

  1. Insatlling VSCode on Windows
  2. Installing C/C++, C/C++ Extension in VSCode
  3. VSCode to connect to Linux server via SSH at /home/my
  4. edit 'launch.json' File

{
    "version": "0.2.0",
    "configurations": [   
        {
            "name": "tsblock",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/develop/bin/tsblock",
            "miDebuggerServerAddress": "localhost:9999",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            ]
        }
    ]
}

How to remotely debug C, C++ binaries installed in Linux environments in VSCode environments connected by ssh.

  1. Insatlling VSCode on Windows
  2. Installing C/C++, C/C++ Extension in VSCode
  3. VSCode to connect to Linux server via SSH at /home/my
  4. edit 'launch.json' File

{
    "version": "0.2.0",
    "configurations": [   
        {
            "name": "tsblock",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/develop/bin/tsblock",
            "miDebuggerServerAddress": "localhost:9999",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            ]
        }
    ]
}

  1. gdbserver cmd execute ( binary path = /home/my/develop/bin/tsblock ) $[bash] gdbserver --attach :9999

I checked that the port is in a normal listening state.

  1. Push F5 at VSCode for Remote Debug

but something wrong.

The progress bar moves for a moment and then shuts down without taking any action. There is no separate exit message.

It doesn't connect either.

Is there a setting I'm missing?

I don't think there's a problem with the settings on the .vscode and .vscode-server side of Localhost. The reason is that 3 years ago, other hosts also debugged using VSCode, where the .vscode and .vscode-server directories remain the same 3 years ago. However, after reinstalling VSCode in Windows, remote debugging does not work properly even in previous host environments. (Same phenomenon)

As I reinstalled VSCode in Windows, it seems that the relevant setup file is missing.

Does anyone know about this?

Share Improve this question edited Feb 17 at 1:27 Smallrengar asked Feb 14 at 7:35 SmallrengarSmallrengar 313 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I found the reason.

The reason is that the Version of C/C++ extension package was different.

I downgraded to v1.11.4 and ran debugging.

Finally, I can to debug successfully.

launch.json was not reason.

发布评论

评论列表(0)

  1. 暂无评论