Skip to content

Natvis intrinsic support#1558

Open
lugerard wants to merge 3 commits into
microsoft:mainfrom
lugerard:natvis-intrinsic-support
Open

Natvis intrinsic support#1558
lugerard wants to merge 3 commits into
microsoft:mainfrom
lugerard:natvis-intrinsic-support

Conversation

@lugerard
Copy link
Copy Markdown

@lugerard lugerard commented May 7, 2026

This PR adds two improvements to the NatVis engine for GDB/LLDB.

Strip dll!-qualified module prefixes

NatVis files targeting Windows often qualify type names with a module prefix (e.g. Qt6Cored.dll!) to disambiguate types. These prefixes are meaningless to GDB and LLDB and cause expression evaluation to fail on Linux/macOS. ReplaceNamesInExpression now strips them before any expression is sent to the debugger.

Intrinsic support

elements define named inline expressions within a block that can be called by name (with optional parameters) in any DisplayString or Expand expression in the same block. MIEngine previously ignored them silently, causing visualizers that rely on intrinsics to fall back to raw view. This change collects intrinsics from the block and resolves calls before expression evaluation. The schema (natvis.xsd) and generated types (NatvisXsdTypes.cs) are updated accordingly.

Added tests.

@lugerard
Copy link
Copy Markdown
Author

lugerard commented May 8, 2026 via email

@lugerard
Copy link
Copy Markdown
Author

lugerard commented May 8, 2026 via email

@lugerard
Copy link
Copy Markdown
Author

lugerard commented May 8, 2026

@Waan @greggm would appreciate a review when you have a moment.

Comment thread src/MIDebugEngine/Natvis.Impl/natvis.xsd Outdated
Comment thread src/MIDebugEngine/Natvis.Impl/Natvis.cs Outdated
Comment thread src/MIDebugEngine/Natvis.Impl/Natvis.cs Outdated
Comment thread src/MIDebugEngine/Natvis.Impl/Natvis.cs Outdated
lugerard added 3 commits May 13, 2026 12:29
Expressions in NatVis files often reference Windows-specific module
prefixes such as Qt6Cored.dll! to disambiguate types. These prefixes
are meaningless to GDB and LLDB and cause evaluation failure on
Linux/macOS. ReplaceNamesInExpression now strips them before any
expression is sent to the debugger.
NatVis <Intrinsic> elements define named inline expressions that can be
called by name in any subsequent expression within the same <Type> block.
MIEngine previously ignored them silently; this change makes them work.
- Rename ParameterType -> IntrinsicParameterType in natvis.xsd and
  NatvisXsdTypes.cs to match the Visual Studio natvis.xsd
- Make Intrinsics property get-only (assigned only in constructor)
- Rename s_dllQualifiedPrefix -> s_moduleQualifiedPrefix; extend regex
  to match .exe! in addition to .dll!, add RegexOptions.IgnoreCase,
  and use non-capturing groups
- Broaden s_intrinsicCallPattern identifier from [A-Za-z_]\w* to \w+
  to support non-Latin identifiers
@WardenGnaw WardenGnaw force-pushed the natvis-intrinsic-support branch from 0251b33 to 5fbcde3 Compare May 13, 2026 19:29
@WardenGnaw
Copy link
Copy Markdown
Member

@lugerard I rebased this PR on top of main, but from the builds theres a couple of code analysis build failures, do you mind fixing them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants