Vscode-cpptools: miDebuggerPath invalid

Created on 13 Dec 2018  ·  13Comments  ·  Source: microsoft/vscode-cpptools

I am unable to find out, why miDebuggerPath is invalid.

Setup:

OS: Windows 10
I am coding in C
C/C++ Extension by Microsoft is installed
MinGW installed

Issue:

image

my launch.json

image

location of gdb.exe

image

So with all these working together I have no clue why it is unable to find the gdb.exe
Any help appreciated!
Thanks ~Phil

debugger more info needed

Most helpful comment

I just copied your launch.json, and I also got the same failure.

There is no visible difference between the two strings so I wrote a simple program to see whats going on.

image

Your string printed out character by character is:

"miDebuggerPath": "?C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 8234 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

When the expected is:

"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

Theres a weird 8234 character in your string, which printing it rendered it as '?'.

Try replacing this string below with your current one:
"miDebuggerPath": "C:\MinGWbin\gdb.exe"

I had the exact same problem and was struggling. It really is wierd.

Looks like manually editing file in JSON in vs code introduces extra invisible characters. This would be a question to developers?

All 13 comments

Can you get the engine logging and paste it here?

1: (85) LaunchOptions WorkingDirectory='C:\QS_SurfacePro\FHS\SWE'
--> E (output): {"event":"output","body":{"category":"console","output":"1: (85) LaunchOptions ExeArguments=''\r\n"},"seq":8,"type":"event"}
1: (85) LaunchOptions ExeArguments=''
--> E (output): {"event":"output","body":{"category":"console","output":"1: (85) LaunchOptions MIMode='gdb'\r\n"},"seq":10,"type":"event"}
1: (85) LaunchOptions MIMode='gdb'
--> E (output): {"event":"output","body":{"category":"console","output":"1: (85) LaunchOptions MIDebuggerPath='‪‪‪C:\MinGW\bin\gdb.exe'\r\n"},"seq":12,"type":"event"}
1: (85) LaunchOptions MIDebuggerPath='‪‪‪C:\MinGWbin\gdb.exe'
--> E (output): {"event":"output","body":{"category":"console","output":"1: (85) LaunchOptions WaitDynamicLibLoad='false'\r\n"},"seq":14,"type":"event"}
1: (85) LaunchOptions WaitDynamicLibLoad='false'
--> E (output): {"event":"output","body":{"category":"console","output":"1: (86) LaunchOptions ExternalConsole='true'\r\n"},"seq":16,"type":"event"}
1: (86) LaunchOptions ExternalConsole='true'
--> E (output): {"event":"output","body":{"category":"console","output":"1: (86) LaunchOptions>\r\n"},"seq":18,"type":"event"}
1: (86) LaunchOptions>
--> E (output): {"event":"output","body":{"category":"console","output":"1: (86) LaunchOptions \r\n"},"seq":20,"type":"event"}
1: (86) LaunchOptions
--> E (output): {"event":"output","body":{"category":"console","output":"1: (86) LaunchOptions -enable-pretty-printing\r\n"},"seq":22,"type":"event"}
1: (86) LaunchOptions -enable-pretty-printing
--> E (output): {"event":"output","body":{"category":"console","output":"1: (87) LaunchOptions
\r\n"},"seq":24,"type":"event"}
1: (87) LaunchOptions

--> E (output): {"event":"output","body":{"category":"console","output":"1: (87) LaunchOptions\r\n"},"seq":26,"type":"event"}
1: (87) LaunchOptions
--> E (output): {"event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.51030.1","VS.Diagnostics.Debugger.HostVersion":"14.0.51030.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.ErrorCode":1005,"VS.Diagnostics.Debugger.Launch.IsError":true}},"seq":28,"type":"event"}
--> R (launch-2): {"request_seq":2,"success":false,"command":"launch","message":"Unable to start debugging. The value of miDebuggerPath is invalid","body":{"error":{"id":1005,"format":"Unable to start debugging. The value of miDebuggerPath is invalid"}},"seq":30,"type":"response"}

I'm quite stumped, too. The error message The value of miDebuggerPath is invalid only appears if that file does not exist.

Can you try running C:\MinGW\bin\gdb.exe --interpreter=mi in a command prompt and see if that works?

image

I have tried to setup Visual Code with MinGW the same way on my computer, and got the same results.
The walktrhorugh is:

  • install MinGW

    • mingw32-base-bin

    • mingw32-gcc-g++-bin

    • adding mingw to PATH

  • install Visual Code
  • setup tasks in Visual Code (gcc -g FILE -o FILE.exe)

    • "command": "gcc",

    • "args": ["-g", "${file}", "-o", "${workspaceRoot}\${fileBasename}.exe"]

  • install ms-vscode.cpptools
  • setup launch

    • path to gdb.exe

    • add "compile task" as pretask

Sadly I still can't repro the issue with your provided steps. Can you copy the launch.json file you were using here?

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}\\${fileBasename}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "‪C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Build",
        }
    ]
}

task.json
```
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${workspaceRoot}\${fileBasename}.exe"
],
"group": {
"kind": "build",
"isDefault": true
},
},
{
"label": "RunCFile",
"type": "shell",
"command": ".\${fileBasename}.exe",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
````

Maybe dump MinGW for something else?

I just copied your launch.json, and I also got the same failure.

There is no visible difference between the two strings so I wrote a simple program to see whats going on.

image

Your string printed out character by character is:

"miDebuggerPath": "?C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 8234 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

When the expected is:

"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

Theres a weird 8234 character in your string, which printing it rendered it as '?'.

Try replacing this string below with your current one:
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe"

I copied your string, and get a Syntax-Error:
image

But after adding '\' it works!! :D i am so happy right now!
image

THANK YOU! ❤️
I will look into this char element, since I edited the launch.json manually on PC and on my Surface...

I just copied your launch.json, and I also got the same failure.

There is no visible difference between the two strings so I wrote a simple program to see whats going on.

image

Your string printed out character by character is:

"miDebuggerPath": "?C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 8234 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

When the expected is:

"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
34 109 105 68 101 98 117 103 103 101 114 80 97 116 104 34 58 32 34 67 58 92 92 77 105 110 71 87 92 92 98 105 110 92 92 103 100 98 46 101 120 101 34 44

Theres a weird 8234 character in your string, which printing it rendered it as '?'.

Try replacing this string below with your current one:
"miDebuggerPath": "C:\MinGWbin\gdb.exe"

I had the exact same problem and was struggling. It really is wierd.

Looks like manually editing file in JSON in vs code introduces extra invisible characters. This would be a question to developers?

thank god!
in my opinion, it may be somthiing about ANSI coding

Was this page helpful?
0 / 5 - 0 ratings