vscode-cpptools
vscode-cpptools copied to clipboard
support multiple natvis files in visualizerFile launch configuration
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
Or support "visualizerFileDirectory" and load each natvis files under it.
Any update on this? I'd also appreciate the feature
So would I. Thanks!
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.
I also would be grateful for this feature :)
Any update? Hitting this as well, especially since the extension doesnt seem to look in the user directory(%USERPROFILE%\Documents\Visual Studio 2017\Visualizers
)
I would also love this kind of functionality !
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
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.
Please allow adding a custom folder with visualizers. I want to use the same visualizers with Visual Studio 2019.
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.
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)
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
}
}
]
}
+1, this would be an amazing addition
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).
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.
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.
@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.
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.
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.
The need is still there :disappointed:
The fix is available with 1.15.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.0
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.
@WardenGnaw Is this fixed or not (with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.4 )?
Multiple natvis file was only added for cppdbg
, not cppvsdbg
.
I use cppvsdbg
. Will it get support for multplie natvis files, or should that issue remain open/be created again?
I created a new bug to track that feature.
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?