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

ghost avatar Oct 22 '18 09:10 ghost

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.

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

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

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

jeremyong avatar Nov 19 '22 19:11 jeremyong

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.

Trass3r avatar Nov 19 '22 20:11 Trass3r

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.

jeremyong avatar Nov 21 '22 06:11 jeremyong

The need is still there :disappointed:

S377 avatar Jan 10 '23 09:01 S377

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

sean-mcmanus avatar Mar 16 '23 14:03 sean-mcmanus

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.

RoscoP avatar Apr 22 '23 00:04 RoscoP

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

sean-mcmanus avatar May 01 '23 23:05 sean-mcmanus

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

WardenGnaw avatar May 02 '23 00:05 WardenGnaw

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

Zylann avatar May 02 '23 01:05 Zylann

I created a new bug to track that feature.

WardenGnaw avatar May 03 '23 20:05 WardenGnaw

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?

carterols avatar Jan 29 '24 15:01 carterols