microsoft / microsoft/vscode-cpptools

Running gdbserver as a `preLaunchTask` - need to press start/stop button several times

Open
#898 15 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger more info needed
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

  • VSCode Version: Code 1.14.0 (b8cd5b9556d8b70ea560d35b903422363f6c5c40, 2017-07-10T20:36:40.018Z)
  • OS Version: Linux x64 4.4.0-53-generic
  • Extensions:
Extension Author (truncated) Version
vscode-docker Pet 0.0.16
tslint eg2 0.16.0
language-haskell jus 2.3.1
cpptools ms- 0.12.1
debugger-for-chrome msj 3.1.6
cmake twx 0.0.17
cmake-tools vec 0.10.2
debug web 0.20.0
c-cpp-snippets wlh 0.1.0

Hello. Thank you for the great tool - I'm using vscode/cpptools everyday and happy with it.

Now to the problem. I have the following task in tasks.json:

{
    "taskName": "docker build&run",
    "linux": {
        "args": [
            "\"docker run --rm --privileged -p 2222:2222 -v ~/path/:/path/ -w /path/build cpp_tools bash -c 'cmake --build . && gdbserver localhost:2222 ./app'\""
        ]
    },
    "group": {
        "kind": "build",
        "isDefault": true
    }
}

As you can see, it starts a docker container that builds an executable and runs gdbserver inside.

Here's my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) remote",
            "type": "cppdbg",
            "request": "launch",
            "preLaunchTask": "docker build&run",
            "program": "${workspaceRoot}/build/app",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}/build",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:2222",
            "sourceFileMap": {
                "/path/": "~/path/"
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

I want to build an app and start the debug session with F5 button. The problem is that I need to press F5 twice - the first press builds an app and starts the debug server in docker container and the second press launches my application (which successfully connects). The problem appears both for F5 and Start Debugging button in GUI.
Also I have to press stop button 3 (three) times in order to stop an application (both for Shift+F5 and the Stop button in GUI).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior using the tasks.json and launch.json configurations, pressing F5 and then stopping the session as described. Start by tracing the preLaunchTask and debug-session lifecycle in the extension; done means one F5 starts the task and debugger, and one stop action ends the application and server.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, docker
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.