vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Allow breakpoints in other native languages source files

Open TurkeyMan opened this issue 9 years ago • 11 comments

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?).

TurkeyMan avatar Jun 17 '16 06:06 TurkeyMan

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

jhasse avatar Jun 20 '16 14:06 jhasse

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?

TurkeyMan avatar Jul 17 '16 01:07 TurkeyMan

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.

jacdavis avatar Sep 29 '16 17:09 jacdavis

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?

jhasse avatar Dec 09 '16 08:12 jhasse

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.

bobbrow avatar Mar 09 '17 20:03 bobbrow

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

Also #440 is a duplicate of this.

KytoDragon avatar Apr 07 '17 21:04 KytoDragon

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.

escape0707 avatar Sep 14 '21 12:09 escape0707

Did you try @KytoDragon's workaround?

bobbrow avatar Sep 14 '21 17:09 bobbrow

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

escape0707 avatar Sep 14 '21 23:09 escape0707

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?

segevfiner avatar Jan 02 '22 23:01 segevfiner

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

floooh avatar Feb 18 '24 11:02 floooh

You can always debug modules individually using native debuggers.

mrx23dot avatar Jul 09 '24 08:07 mrx23dot