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

support multiple natvis files in visualizerFile launch configuration

Open peter-frentrup opened this issue 6 years ago • 17 comments

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

peter-frentrup avatar Jul 27 '17 14:07 peter-frentrup

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

xbcnn avatar Dec 05 '17 07:12 xbcnn

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

MontyBlenheim avatar Jun 18 '18 11:06 MontyBlenheim

So would I. Thanks!

stephanreiter avatar Aug 12 '18 16:08 stephanreiter

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.

IanMDay avatar Oct 22 '18 09:10 IanMDay

I also would be grateful for this feature :)

vsamy avatar Mar 20 '19 05:03 vsamy

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

DianaNites avatar Mar 26 '19 18:03 DianaNites

I would also love this kind of functionality !

dcourtois avatar Apr 06 '19 12:04 dcourtois

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

eternalphane avatar Feb 26 '20 15:02 eternalphane

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.

Trass3r avatar Sep 02 '20 19:09 Trass3r

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

KindDragon avatar Sep 23 '20 17:09 KindDragon

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.

Zylann avatar Apr 28 '21 23:04 Zylann

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)

iboB avatar Oct 04 '21 12:10 iboB

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
      }
    }
  ]
}

panwarab avatar Feb 23 '22 20:02 panwarab

+1, this would be an amazing addition

EmilianC avatar Apr 10 '22 03:04 EmilianC

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

jeremyong avatar Jun 17 '22 11:06 jeremyong

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.

Trass3r avatar Jun 17 '22 12:06 Trass3r

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.

abglassford avatar Sep 22 '22 00:09 abglassford