VSCode debugging and source management

How debugger/platform agnostic is launch.json?

Should .vscode/launch.json be added to source control if the project is cross platform and is developed/debugged using both CodeLLDB and using the "Microsoft C/C++" plugin's debugger. Will one need to add duplicate entries for each debugger? Will VSCode filter out the entries that apply to the current runtime environment?

Is there any benefit to using the Microsoft C/C++ plugin, over CodeLLDB, for debugging Rust code on Windows?

I have learned a few things.

The CodeLLDB marketplace page states, concerning Windows support:

DWARF debug info format recommended, limited support for MS PDB.

I thought that perhaps it's better to go with Microsoft tools on Windows, based on the assumption that it would handle PDB better/properly.

How would one go about using the same launch.json for Linux, macOS and Windows? Well, it turns out one can create platform-specific blocks in the config:

  "foo": "hello",
   "windows": {
    "foo": "world"
  }

This would (presumably) cause "foo" to expand to "world" on Windows, and "hello" on other platforms.

How would one switch debuggers? Easy, just set a default debugger type and override it for non-CodeLLDB platforms:

  "type": "lldb",
   "windows": {
    "type": "cppvsdbg"
  }

Snag: type is special, and can't be overridden. :neutral_face:

It seems like it's possible to set the type in the user's global config instead. So perhaps one should simply wipe the type from the launch.json and force the user to configure it globally instead. Though I don't like having to force developers to make global configuration changes which might affect other projects..

Another slightly annoying issue with using the "Microsoft C/C++" plugin instead of "CodeLLDB" is that the latter seems to be aware of that .rs is code, while the former (for natural reasons?) doesn't. This means that when CodeLLDB is installed you can set breakpoints in Rust code, while with Microsoft C/C++ you need to change a configuration option in VSCode which allows you to sprinkle breakpoints in any kind of file. :neutral_face:

I don't actually use Visual Studio Code myself, but I need to support our developers that do, which is why I'm on this adventure. I don't know what CodeLLDB having "limited" support for PDB actually means, but I don't want the other developers to run into weird debugging limitations down the road. But at this point I'd say that for multiplatform Rust projects it's simply much better to use CodeLLDB on Windows as well -- it seems to be much less hassle.

Hopefully the "limited PDB support" won't rear its ugly head for our developers. With the few limited tests I have done it seems to work just fine. Anyone know where one might run into limitations?

For example, the PDB format does not have a first-class representation for discriminated unions aka Rust enums. Rustc attempts to output an approximation using unions and structs, but it falls short.
Also, LLDB's interpretation of PDB is more buggy than DWARF, though that seems to slowly improve over time.
Unless something is forcing you you use -msvc, my recommendation would be to stick with the -gnu target.

1 Like