microsoft / vscode-cpptools

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

support multiple natvis files in visualizerFile launch configuration #925

Closed peter-frentrup closed 1 year ago

peter-frentrup commented 7 years ago

Hello, I have a project with some DLLs and an EXE. The DLLs link their own .natvis files, say "dllA.natvis" and "dllB.natvis". The .exe also has an "exe.natvis" file. Since VSCode does not recognize the embedded .natvis resources from the DLLs/EXE, I manually specify "visualizerFile" in my launch configuration. However, I can only specify one .natvis file for "visualizerFile", so I have to create an ad-hoc "all.natvis" which is basically the union of "dllA.natvis", "dllB.natvis" and "exe.natvis". I also have to remember to change "all.natvis" whenever I update one of the other *.natvis files.

This is cumbersome, I would prefer to just put

"visualizerFile": [
  "${workspaceRoot}/dllA/dllA.natvis", 
  "${workspaceRoot}/dllB/dllB.natvis", 
  "${workspaceRoot}/exe/exe.natvis", 
]

Could you please provide such a feature?

Best regards, Peter

xbcnn commented 6 years ago

Or support "visualizerFileDirectory" and load each natvis files under it.

MontyBlenheim commented 6 years ago

Any update on this? I'd also appreciate the feature

stephanreiter commented 6 years ago

So would I. Thanks!

ghost commented 5 years ago

Indeed. I have natvis files in folders where their associated code lives, using CMake under Windows I add any found natvis to the projects, so VS proper uses all of them. Would be great to just use any it finds in an opened folder.

vsamy commented 5 years ago

I also would be grateful for this feature :)

DianaNites commented 5 years ago

Any update? Hitting this as well, especially since the extension doesnt seem to look in the user directory(%USERPROFILE%\Documents\Visual Studio 2017\Visualizers)

dcourtois commented 5 years ago

I would also love this kind of functionality !

eternalphane commented 4 years ago

currently the only workaround is to copy custom natvis files to GlobalVisualizersDirectory, which is ~/.vscode(-insiders)/extensions/ms-vscode.cpptools-x.y.z/debugAdapters/vsdbg/bin/Visualizers.

Ref: https://github.com/microsoft/MIEngine/blob/7afd062458dc8533fbfb6b6bb9a15cdab5d1029e/src/DebugEngineHost.VSCode/HostConfigurationStore.cs#L45-L50

Trass3r commented 4 years ago

currently the only workaround is to copy custom natvis files to GlobalVisualizersDirectory, which is ~/.vscode(-insiders)/extensions/ms-vscode.cpptools-x.y.z/debugAdapters/vsdbg/bin/Visualizers.

Looking at the code, that won't work for other backends though.

KindDragon commented 3 years ago

Please allow adding a custom folder with visualizers. I want to use the same visualizers with Visual Studio 2019.

Zylann commented 3 years ago

Just started looking into natvis files and this issue is one of the first I have. I'm contributing a module to an existing project and I can't modify that project's natvis file to include my module's natvis stuff, so I have to work with two files, yet can't use both.

Edit: considered using EnTT in a project, found it provides multiple natvis files, which pretty much requires being able to register them.

iboB commented 2 years ago

As a workaround to this issue, I created this tool: https://github.com/iboB/natvis-join

I'll probably add some more features in the coming days (one that comes to mind is automatic generation of a cmake file, which creates a custom target for the combined natvis file, based on existing ones)

panwarab commented 2 years ago

same issue I am facing. natvis file not being picked up.

{
  // 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": "${workspaceFolder}/build/executable",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "/usr/bin/gdb",
      "showDisplayString": true,
      "visualizerFile": "${workspaceFolder}/visual.natvis",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
        {
          "text": "-gdb-set follow-fork-mode child"
        }
      ],
      "logging": {
        "trace": false,
        "traceResponse": false,
        "engineLogging": false
      }
    }
  ]
}
EmilianC commented 2 years ago

+1, this would be an amazing addition

jeremyong commented 2 years ago

Bumping again, would be great to understand if this is being looked at, or understanding how a motivated individual could help. This is one of the major drawbacks to the C++ debugging experience in VSCode vs Visual Studio. Coming from the game dev world, we don't have 1 natvis file. We have dozens to hundreds in a given project. Furthermore, the CMake workflow in Visual Studio is such that adding natvis files to target_sources of a given target automatically enables that natvis file during subsequent debugging sessions. Compared to needing to manually tag natvis files with the visualizerFile property for every target, something more automatic would be even better if possible (again, happy to help but could use a minimal starting point to understand where this functionality exists).

Trass3r commented 2 years ago

how a motivated individual could help

Well, creating a PR. Starting point: https://github.com/microsoft/MIEngine/blob/de8db64a055ca00d7d38fa4d53b749dd9d493c60/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs#L546

the CMake workflow in Visual Studio is such that adding natvis files to target_sources of a given target automatically enables that natvis file during subsequent debugging sessions.

The CMake VS generator creates an entry in the project file and VS does the rest. In VSCode you don't have project files. I can't imagine how this should work with the Ninja generator.

abglassford commented 1 year ago

Keeping this alive. I'm just having trouble getting one .natvis file to work with MSVC, but my project has 3 that I need to implement.

jeremyong commented 1 year ago

@Trass3r What I am finding is that even when a natvis file is embedded in the PDB using the standard /NATVIS:file MSVC linker option, the natvis file is simply not picked up. I'm not sure whether this can be resolved within this extension or not.

Trass3r commented 1 year ago

Yeah I don't know how exactly it's handled on Windows, what's done by the debugger and what's handled by VS etc.

jeremyong commented 1 year ago

https://github.com/microsoft/vscode-cpptools/issues/10175 I filed this as a separate issue actually because it's a separate problem from the configuration-driven natvis specification.

S377 commented 1 year ago

The need is still there :disappointed:

sean-mcmanus commented 1 year ago

The fix is available with 1.15.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.0

RoscoP commented 1 year ago

I tried using multiple natvis on the prerelease (V1.15.2) with windows and it doesn't appear to be working (I tried with a single natvis file in the array). Using a single natvis file (no array) does work. I'm not familiar with the OptionsSchema, but does it need to be modified for CppdbgAttachOptions, CppvsdbgLaunchOptions, and CppvsdbgAttachOptions in addition?

Thanks for addressing the issue, it is appreciated.

sean-mcmanus commented 1 year ago

@WardenGnaw Is this fixed or not (with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.4 )?

WardenGnaw commented 1 year ago

Multiple natvis file was only added for cppdbg, not cppvsdbg.

Zylann commented 1 year ago

I use cppvsdbg. Will it get support for multplie natvis files, or should that issue remain open/be created again?

WardenGnaw commented 1 year ago

I created a new bug to track that feature.

carterols commented 7 months ago

Hi @WardenGnaw I see this was only added to the "launch" request and not "attach" requests. Is this on purpose? If not, could you please add this capability when attaching to programs for cppdbg types?