Skip to content

Add deploySteps and variables to cppdbg #9418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jul 7, 2022

Conversation

xisui-MSFT
Copy link
Contributor

Add deploySteps and variables to cppdbg. Spec available upon request.

There will be follow up PRs, which implement deploy in multiroot scenarios, and process picker for gdb extended-remote, separately.

@sean-mcmanus sean-mcmanus added this to the 1.11 milestone Jun 8, 2022
@xisui-MSFT xisui-MSFT changed the title Dev/xisui/deploy Add deploySteps and variables to cppdbg Jun 8, 2022
@WardenGnaw
Copy link
Member

In this PR, could you provide an example launch.json with variables and deploy and give a quick explanation of what would happen with those configuration fields set (or a GIF of it if it is working end to end.)

@xisui-MSFT
Copy link
Contributor Author

In this PR, could you provide an example launch.json with variables and deploy and give a quick explanation of what would happen with those configuration fields set (or a GIF of it if it is working end to end.)

Sample launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Pi1",
            "type": "cppdbg",
            "request": "launch",
            "variables": {
                "user": "pi",
                "host": "${input:targetIP}",
                "port": "22100",
                "program": "${command:cmake.launchTargetPath}",
                "targetDir": "/home/pi",
                "targetFilePath": "${targetDir}/${command:cmake.launchTargetFilename}"
            },
            "cwd": "${workspaceFolder}",
            "program": "${program}",
            "stopAtEntry": true,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "miDebuggerServerAddress": "${host}:${port}",
            "deploySteps": [
                {
                    "type": "scp",
                    "files": "${program}",
                    "host": {
                        "user": "${user}",
                        "hostName": "${host}"
                    },
                    "targetDir": "${targetDir}"
                },
                {
                    "type": "ssh",
                    "host": {
                        "user": "${user}",
                        "hostName": "${host}"
                    },
                    "command": "chmod +x ${targetFilePath}",
                },
                {
                    "type": "ssh",
                    "host": {
                        "user": "${user}",
                        "hostName": "${host}"
                    },
                    "command": "gdbserver :${port} ${targetFilePath}",
                    "continueOn": "Listening on port",
                    "debug": true
                },
                {
                    "type": "ssh",
                    "host": {
                        "user": "${user}",
                        "hostName": "${host}"
                    },
                    "command": "${targetFilePath}",
                    "debug": false
                }
            ],
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ],
    "inputs": [
        {
            "type": "promptString",
            "id": "targetIP",
            "description": "Enter the IP address of the target device"
        }
    ]
}

Stepps:

  1. Expand all variables in this launch config that are not resolved by VS Code.
  2. Run deploy steps. ask for password for scp/ssh steps. The authentication method is the same as using ssh in the terminal. For example, if key based authentication is used, then no authentication will be asked.
  • Copy binary to the device using SCP.
  • chom +x in case there are any permission issue.
  • Start gdbserver when starting debugging; start the program only when starting without debugging.
  1. Start debugging.

GIF:
deploy

Copy link
Member

@WardenGnaw WardenGnaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@sean-mcmanus sean-mcmanus modified the milestones: 1.11, 1.12.0 Jun 21, 2022
@sean-mcmanus sean-mcmanus modified the milestones: 1.12.0, 1.11.1 Jul 6, 2022
@sean-mcmanus sean-mcmanus merged commit b55a98c into microsoft:main Jul 7, 2022
sean-mcmanus added a commit that referenced this pull request Jul 8, 2022
sean-mcmanus added a commit that referenced this pull request Jul 8, 2022
sean-mcmanus added a commit that referenced this pull request Jul 8, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants