10

I am trying to debug a C++ application on Windows that has been started by a python script. I am able to attach to the process using GDB from command line and everything works fine.

However, when trying to use VS Code to attach GDB, it manages attach, but all the breakpoints are stuck on Attempting to bind to the breakpoint... and trying to execute a command in the debug console returns Unable to perform this action because the process is running..

This is my launch.json configuration:

{ 
        "name": "(gdb) Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "${workspaceFolder}\\build\\program.exe",
        "processId": "${command:pickProcess}",
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }

I assume that VS code is doing something extra/weird when starting GDB, is there a way to fix this?

1
  • I am hitting the exact same issue. Was wondering if you have found a work around here. What I have noticed is possibly the same. If you attach or launch with the breakpoint enabled then vs-code works just fine however if you are running and you set a breakpoint etc then this doesn't work. I was hoping that at least there would be a way to pause the debugger with a ctrl-c thereby allowing me to set the necessary breakpoint. Commented Jan 7, 2021 at 17:38

2 Answers 2

0

I know this is an old question but I was facing the same issue which landed me here.
For me the culprit was in the "miDebuggerPath" in launch.json
Even though the path looked right when I checked it countless times, it was not the same one invoked from the command line (I am working on a Linux machine in an environment with lots of gdb versions installed)
Try to find the gdb path invoked from the command line and add that to the above mentioned parameter in debug configuration file.

Sign up to request clarification or add additional context in comments.

Comments

-2

GDB on MinGW has some limitations:

GDB on Cygwin and MinGW cannot break a running process. To set a breakpoint when the application is running (not stopped under the debugger), or to pause the application being debugged, press Ctrl-C in the application's terminal.

Make sure to stop the application with Ctrl-C before setting breakpoints in VS Code. See also a relevant issue: https://github.com/Microsoft/vscode-cpptools/issues/595.

2 Comments

This is clearly not caused by the GDB limitation. As described in the original question, I am able to use the exact same GDB to debug from command line. So it is clearly either a bug in VS Code or a VS Code configuration issue.
How does one issue a ctrl-c to the application via vscode?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.