Vscode-cpptools: "program" issue (New in VS Code)

Created on 26 May 2016  路  30Comments  路  Source: microsoft/vscode-cpptools

Hello,

ich have an issue when i try to debug my simple c++ file i got an error:
Unable to start debugging. Program path 'c:\Users\Zinyra\Desktop\C++\HelloWorld\main.cpp' is missing or invalid.

{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"miDebuggerPath":"c:/mingw/bin/gdb.exe",
"program": "${workspaceRoot}/main.cpp",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},

^^^^^^^^^^^^^^^^^
My launch.json

I don麓t know why. I hope anybody can help me.

Thanks !

Most helpful comment

I believe Gdb is not installed by default with cygwin. You need to use the Cygwin package manager to install it. If you do dir c:\cygwin64bin\gdb.exe
does it say it is there?

All 30 comments

Debugging is not yet supported on windows. See here: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

On the side below:

Windows

Debugging on Windows is currently only supported for Cygwin and MinGW.

Oh, I missed that completely. Now I notice they use backslashes instead of slashes for the path. Maybe try that and see if it works

User must manually set the path to GDB in launch.json if gdb is not on the path. For example: "miDebuggerPath":"c:\mingw\bin\gdb.exe" or "miDebuggerPath":"c:\cygwin64\bin\gdb.exe"

Thanks for the awsner. I already set the
"miDebuggerPath":"c:/mingw/bin/gdb.exe",

See it in my first post here.

I think the error is in the "program" section

I was suggesting
using
"miDebuggerPath":"c:\mingw\bin\gdb.exe",
instead of
"miDebuggerPath":"c:/mingw/bin/gdb.exe",

It's a longshot, but maybe that will work...

Nope now i got an error:

Unable to start debugging. Launch options string provided by the project system is invalid. ",hexadecimal value 0x08, is an invalid character. Line 6, Position 25.

Dumb question, do you have version
Version 0.6.0: May 24, 2016 ... Support for debugging with GDB on Cygwin.
For me at least, the extension repo still offers 0.5.0 to install.

I think i have instaled the version 0.6.0, I take a look later.

Edit: Yes i have the version 0.6.0

@Zinyra
There is currently a bug in the readme. The markdown didn't escape backslashes as expected. You will have to do the following:

"miDebuggerPath":"c:\cygwin64\bin\gdb.exe"

Also, if you are going to debug with Cygwin, your application must have been compiled with Cygwin. You won't be able to compile MVC compiled binaries with Cygwin, for example.

Also, it looks like your program is set to ${workspaceRoot}/main.cpp Is it a mistake? It looks like you are pointing it to a source file instead of a compiled binary.

Yes, i thougt the extension will compile my .cpp file to an program.
Can you tell me exactly what i must do ?

You need to compile it with Cygwin's GCC/G++ compiler. If it is a single source file, open the Cygwin console, and type something like this from the folder where your source is:
g++ -g main.cpp
This will produce a debug build of the source file named a.exe in that folder. Note that if you have more than one file, or want other options, this gets more complex.

Okay i have compiled the file now i have an executable. So now i tried to launch it in Visual Code.

But in the launch.json is the type wrong. "type": "cppdbg",

"type":"cppdbg" is correct. Did you change program to point to a.exe?

Yes.

This is the error message.
Unable to start debugging. Launch options string provided by the project system is invalid. ",hexadecimal value 0x08, is an invalid character. Line 6, Position 28.

Can you please attach you launch.json file here exactly as-is so I can take a look?

{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"miDebuggerPath":"c:\cygwin64bin\gdb.exe",
"program": "${workspaceRoot}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},
{
"name": "C++ Attach (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"program": "enter program name, for example ${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"processId": "enter program's process ID",
"externalConsole": false
}
]
}

Try double backslashes in the gdb path like this
"miDebuggerPath":"c:\cygwin64\bin\gdb.exe",

Now i have this issue.

Unable to start debugging. The value of miDebuggerPath is invalid

Is that the correct path to where you have Cygwin gdb installed? If not, please verify you have Cygwin installed and have installed gdb through the Cygwin package manager.

I had downloaded Cygwin there https://www.cygwin.com

And the cygwin64 folder is on c

I believe Gdb is not installed by default with cygwin. You need to use the Cygwin package manager to install it. If you do dir c:\cygwin64bin\gdb.exe
does it say it is there?

Oh no..... I don麓t see it.. I reinstall Cygwin at the moment. Thanks for the tipp!
I report later the status

When you install it, the installer will ask you which packages to install. You'll want to search for gdb. I believe the package is called Devel or something similar to that.

I selected install all.

Worked thanks.

But i have a question. Will the extension later support that feature without all that programs ? And can i compile my file later with the extension ?

Thanks for the feedback!

You can configure vscode to compile using Tasks. It isn't as automatic as it would be in IDE like the free Visual Studio Community.
This page goes through the details. https://code.visualstudio.com/Docs/editor/tasks

Closing as the original issue is resolved

and @jacdavis, answered the question about setting up build tasks

Thanks! I've solved the same problem following your advice.

Was this page helpful?
0 / 5 - 0 ratings