Skip to content

Natvis: strip address prefix from string pointer DisplayStrings"#1573

Merged
WardenGnaw merged 2 commits into
microsoft:mainfrom
lugerard:natvis-sub-specifier-cleanup
Jun 8, 2026
Merged

Natvis: strip address prefix from string pointer DisplayStrings"#1573
WardenGnaw merged 2 commits into
microsoft:mainfrom
lugerard:natvis-sub-specifier-cleanup

Conversation

@lugerard

Copy link
Copy Markdown
Contributor

GDB and LLDB prefix string pointer results with the pointer address when evaluating ,sub, ,su or ,sb format specifiers. This causes the address to appear inline in the display value.

Add StripFormatSpecifier() and ExtractFormatSpecifier() to parse format specifiers from NatVis expressions. Add CleanUtf16StringValue() to strip the address and surrounding u"..." quotes for ,sub / ,su, and CleanAsciiStringValue() to strip the address for ,sb. Call each in FormatValue for the corresponding specifier. All new functions include unit tests.

Comment thread src/MIDebugEngine/Natvis.Impl/Natvis.cs Outdated
Comment thread src/MIDebugEngine/Natvis.Impl/Natvis.cs Outdated
@WardenGnaw WardenGnaw force-pushed the natvis-sub-specifier-cleanup branch from 5d05d41 to b978182 Compare June 6, 2026 18:00
lugerard added 2 commits June 8, 2026 09:56
…ings

GDB and LLDB prefix string pointer results with the pointer address when
evaluating ,sub, ,su or ,sb format specifiers. This causes the address
to appear inline in the display value.

Add StripFormatSpecifier() and ExtractFormatSpecifier() to parse format
specifiers from NatVis expressions. Add CleanUtf16StringValue() to strip
the address and surrounding u"..." quotes for ,sub / ,su, and
CleanAsciiStringValue() to strip the address for ,sb. Call each in
FormatValue for the corresponding specifier. All new functions include
unit tests.
…iStringValue

Remove StripFormatSpecifier and its tests: the method is dead code.
Format specifiers are already handled by ProcessFormatSpecifiers in
VariableInformation, which transforms them into valid C++ casts before
evaluation by GDB/LLDB.

Fix CleanAsciiStringValue to also strip the surrounding "..." quotes,
matching CleanUtf16StringValue's behaviour. VS evaluates {ptr,sb} to
bare text without quotes; leaving the GDB/LLDB-returned quotes in place
caused QByteArray to display as ""Hello World!"" instead of "Hello World!".
@WardenGnaw WardenGnaw force-pushed the natvis-sub-specifier-cleanup branch from 74e185f to 5233b25 Compare June 8, 2026 16:56
@WardenGnaw WardenGnaw merged commit 376dbaa into microsoft:main Jun 8, 2026
6 checks passed
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.

2 participants