vscode-docs/docs/cpp/pipe-transport.md

68 строки
2.5 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

2019-07-02 20:23:04 +03:00
---
2020-05-22 01:53:49 +03:00
Order:
2019-07-02 20:23:04 +03:00
Area: cpp
2019-07-26 00:36:04 +03:00
TOCTitle: Pipe transport
2019-07-02 20:23:04 +03:00
ContentId: 59BE5FF7-563F-4044-A562-294E75A75F96
PageTitle: Pipe transport for remote communication in C++ projects
2022-07-07 09:00:10 +03:00
DateApproved: 7/25/2019
2019-07-02 20:23:04 +03:00
MetaDescription: How to set up pipe transport for debugging C++ code in Visual Studio Code.
---
2019-07-26 00:59:33 +03:00
# Pipe transport
2019-07-02 20:23:04 +03:00
2020-05-22 01:53:49 +03:00
Pipe transport allows communication through a pipe program to a remote shell. For example, `ssh` on Linux. With the introduction of [Visual Studio Code Remote Development](/docs/remote/remote-overview.md) pipe transport is relevant primarily for IoT scenarios.
2019-07-02 20:23:04 +03:00
## How-To
`pipeTransport` is an option within the **launch.json** file. The structure looks as follows:
```json
"pipeTransport": {
"pipeCwd": "/usr/bin",
"pipeProgram": "/usr/bin/ssh",
"pipeArgs": [
"-pw",
"<password>",
"user@10.10.10.10"
],
"debuggerPath": "/usr/bin/gdb"
},
```
The `pipeArgs` can be any set of arguments necessary to set up and authenticate the pipe connection. In the example, a password is used but you can also use an SSH key.
2019-07-02 20:23:04 +03:00
You may also need to add a `sourceFileMap` to map the path of where the code exists on the remote shell to where it is locally:
```json
"sourceFileMap": {
// "remote": "local"
"/home/user/src": "/src/projectA/src"
}
```
## Attach
2021-04-01 06:44:56 +03:00
You can also use the above `pipeTransport` block to attach to a remote process. In the attach case, you need to specify a `processId`. The extension can query processes from the remote machine. To do this, change `processId": "${command:pickProcess}` to `processId": "${command:pickRemoteProcess}`. The `pipeTransport` settings will be used to query the processes on the remote machine. Then select the process from the dropdown list. As with `launch`, you may need to configure `sourceFileMap`.
2019-07-02 20:23:04 +03:00
## Docker example
The `pipeTransport` can also be used to debug a process in a Docker container. For an attach, **launch.json** will include:
```json
"pipeTransport": {
2020-04-22 23:02:02 +03:00
"pipeCwd": "${workspaceFolder}",
2019-07-02 20:23:04 +03:00
"pipeProgram": "docker",
"pipeArgs": [
"exec",
"-i",
"hello_gdb",
"sh",
"-c"
],
"debuggerPath": "/usr/bin/gdb"
},
```
Where `hello_gdb` is the name of your container.
2019-07-26 06:46:18 +03:00
Launch process by starting a container and then using the same `pipeTransport` to launch additional processes in the container. See this [launch.json](https://github.com/andyneff/hello-world-gdb/blob/master/.vscode/launch.json) for a [full example](https://github.com/andyneff/hello-world-gdb/).