-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with natvis support #2836
Comments
I cannot. Are you launching both cdb and windbg from
Some variance between debugger versions is (sadly) common though. I'm not masochistic enough to attempt to unit test WinDbg or Visual Studio however. ...yet, at least.
No repro. The last time I encountered a similar issue, someone had enabled rustc 1.75.0 (82e1608df 2023-12-21) Using |
Slapping
I was able to verify hstring's visualizer seems to be working fine for VS2017VS2019VS2022 |
I'm not. I was using the tool formerly called "WinDbg Preview" that now goes by the name "WinDbg" and I'm struggling to disambiguate. With WinDbg from the Debugging Tools for Windows, everything works as expected. It never crossed my mind that "WinDbg" and "WinDbg" would behave differently, so thanks for that insight, @MaulingMonkey! Just to clarify, I did my testing using the tool that used to be called "WinDbg Preview", and things are failing with that still (and Visual Studio). The failure cases seem to be down to these two lines: windows-rs/crates/libs/core/windows.natvis Lines 30 to 31 in 0df3676
Avoiding |
Not seeing any issues here with WinDbg Preview, client 1.2308.2002.0 / engine 10.0.25921.1001. Be aware WinDbg Preview is moving away from Store distribution and is now updated via AppInstaller https://aka.ms/windbg/download. So if you were relying solely on the Store copy, you may be running a outdated copy. |
Ah, I can reproduce @tim-weis's reported behavior when I introduce an empty hstring. Something is definitely funky with the evaluation of |
Thank you, @riverar! At least it isn't just me anymore that's seeing things. The Removing the empty |
Seems like something @wesleywiser would know about. |
In the case of empty HSTRINGs, the @tim-weis Can you verify this works for you now? <Intrinsic Name="header" Expression="*((windows_core::strings::hstring::Header**)(uintptr_t)this)" ReturnType="windows_core::strings::hstring::Header *" /> |
Oh no, I'm discovering WinDbg, Visual Studio, and others evaluate slightly differently. |
@riverar This change has no effect for me in WinDbg Preview. The only way for me to get the visualizer to work in WinDbg Preview is with this <Intrinsic Name="header" Expression="(windows_core::strings::hstring::Header*)__0.tag" /> It appears as though Just to make sure we aren't talking past each other: The issue you (Rafael) are looking at and the issue I am observing are quite possibly distinct. While you are discovering (how, by the way?) that the expression Apparently, there's something peculiar about my specific environment. Footnotes
|
For reference, here's what C++/WinRT does: https://github.com/microsoft/cppwinrt/blob/master/natvis/cppwinrt.natvis#L56-L63 May be worth considering something similar to avoid these complications. |
Ack. I've encountered this with PIX previously, which I disambiguated with the terms:
I think for myself I'll start calling these different versions of WinDbg:
It's pretty horrifying! 👍 A previous rabbit hole of CDB version specific debugging: rust-lang/rust#76352 (and that was without an overhaul/rewrite between CDB versions!)
Both are C++ keywords (
While this somewhat undermines a goal of #2077 ("This allows for changes to the HSTRING data structure without breaking the Natvis."), I'd still embrace this change - debug visualizers are sadly brittle no matter what you do IME, so I'd prioritize doing the dumb simple thing that works over cleverness, and rely on CI unit tests to catch the inevitable breakage. |
Here's a simpler type block that should evaluate in VS and WinDbg for you that demonstrates <Type Name="windows_core::strings::hstring::HSTRING">
<DisplayString>hello {(void*)this}</DisplayString>
</Type> I believe there are several issues here commingling and making a mess. Please correct me if I'm wrong!
|
I'm not familiar with the natvis format, or its various dialects and variants, but I did notice that the one for the Rust standard library types doesn't use "this" at all. https://github.com/rust-lang/rust/blob/master/src/etc/natvis/libstd.natvis |
PR submitted w/ tweaked natvis. Works across VSpre, CDB, and WinDbg Preview. I've also verified it loads correctly when embedded in symbols. |
A compounding factor: when debugging
This does not appear to happen when using EDIT: reported upstream: rust-lang/rust#120913 |
Nice catch, I feel bad for @tim-weis. He was probably hit by every single bug/quirk we've documented in this thread here so far 😂 |
Originally posted by @tim-weis in #2023 (comment)
Thanks for the feedback. This has been rather insightful.
I went ahead and did some more research. The TL;DR is: The
HSTRING
visualizer works with CDB but not with other debuggers I tried (WinDbg, Visual Studio).First, though, the
windows::core
vs.windows_core
path discrepancy was down to me copy-pasting outdated expected test output from #2023. This has since been changed, and all debuggers (and visualizers) agree onwindows_core
as the package-relative path prefix. That turned out to be a red herring.For reference, here's the full repro (slightly modified from my previous comment).
Cargo.toml
.cargo/config.toml
src/main.rs
This is following a pattern I first discovered in Ridwan's debugger_test crate: It introduces a function (
__break()
) for the sole purpose of having a symbol to set a breakpoint on, providing a convenient way to insert checkpoints at which execution pauses. This works in combination with thebm
command (bm *!*::__break "gu"
) instructing the debugger to "Go Up" ("gu"
) whenever the function is hit, taking us back to the scope of interest.With the crate set up the following command line launches right into the CDB debugger:
Once in the debugger, we can set the breakpoint, run to the checkpoint and inspect the
HSTRING
s:That explains why the tests are succeeding. Moving to WinDbg had some surprises, though: Setting the breakpoint the same way as in CDB behaved differently. The
"gu"
command string went up (at least) one stack frame more than expected. I'm not sure what's up with that, but I just replaced the command string with"pt"
("Step to Next Return") which seemingly worked. For completeness:bm *!*::__break "pt"
.Once there, the debugger produced unexpected results for the
HSTRING
variables:Can anyone please verify my observations?
Rust: 1.75.0 (stable)
CDB: cdb version 10.0.22621.382
WinDbg: Debugger client version: 1.2308.2002.0; Debugger engine version: 10.0.25921.1001
Host OS: Windows 10 19045.3930
While this is starting to feel like I'm losing my mind, here are a few more things I tried to make sure I'm looking at the same thing the debugger is:
windows_natvis
towin_nv
to prevent any sort of name clashes in .natvis lookup..nvunloadall
followed by an explicit.nvload
with a copy ofwindows.natvis
from this repo..nvlist
.windows.natvis
from here).>
->>
) and reloaded the modified .natvis, just to be sure.None of the above had any observable effect so I'm confident that
windows.natvis
is actually loaded and evaluated.The text was updated successfully, but these errors were encountered: