microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.42k stars 1.52k forks source link

Allow breakpoints in other native languages source files #75

Open TurkeyMan opened 8 years ago

TurkeyMan commented 8 years ago

C/C++ plugin integrates native debugging. I'm working on a mixed C++ and D project, but the IDE won't let me place breakpoints in .d files. I can step into those languages as you expect from GDB. I suspect this may also be a problem for other native languages (rust, obj-c, etc?).

jhasse commented 8 years ago

I have the same problem with Fortran files (.f, .F90).

TurkeyMan commented 8 years ago

I just wanna ask if there's any movement on this? It's really holding up my work, and it seems like it should be a trivial fix?

jacdavis commented 7 years ago

VSCode debugger extensions have to declare what files they allow breakpoints to be set in. This exists in the package.json file for the extension. If you add file extensions for the languages you care about in this section of ~/.vscode/extensions/ms-vscode.cpptools-0.9.2/package.json: "debuggers": [ { "type": "cppdbg", "label": "C++ (GDB/LLDB)", "enableBreakpointsFor": { "languageIds": [ "cpp", "c", ".h", ".cc", ".cxx", ".hpp", ".hh", ".hxx" ] },

Do things work better? Note that your milage may vary here, because you mentioned, we really only test with C/C++ with this extension.

jhasse commented 7 years ago

I've added .F90, but still wasn't able to add breakpoints in .F90 files. I've disabled, reloaded, enabled, reloaded the C/C++ extension. Do I need to do anything else for these changes to take effect?

bobbrow commented 7 years ago

package.json is not the correct location for this. Have you tried manually adding an association to files.associations in your settings.json file? (File -> Preferences -> Settings)

{
  "files.associations": {
    "*.F90": "cpp",
    "*.d": "cpp"
  }
}

We can't override the default file set that maps to "c" and "cpp" languageIds in our extension, so if these extensions are already mapped by VSCode, it might not work. VSCode owns the mapping of file extensions to languageIds.

KytoDragon commented 7 years ago

You can circumvent this with the following: Got to File -> Preferences -> Settings -> Debug ->debug.allowBreakpointsEverywhere = true

Also #440 is a duplicate of this.

escape0707 commented 2 years ago

Wow, I'm surprised to see that this issue has been unsolved for so long.

Recently, I'm trying out Rust and Rust Analyzer recommend any C/C++ debugger extension for debugging, including vscode-cpptools. But it won't even let me add a breakpoint.

bobbrow commented 2 years ago

Did you try @KytoDragon's workaround?

escape0707 commented 2 years ago

It's just a workaround, we can't solve this someway? 😟

segevfiner commented 2 years ago

Same in Rust. The syntax in package.json seems to have changed a bit. It seems to be breakpoints now, which is an array of VS Code language IDs.

Maybe there should be some contribution point to declare native languages that could be debugged by any native debugger extension and as such should have breakpoints allowed if any native debugger is installed?

floooh commented 5 months ago

+1, same for ObjC files with .m file extension.

mrx23dot commented 2 weeks ago

You can always debug modules individually using native debuggers.