Skip to content
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

.natvis: Add view for unique_ptr/vector of chars #2843

Merged
merged 3 commits into from
Jul 8, 2022

Conversation

gregg-miskelly
Copy link
Member

This PR adds .natvis entries using std::unique_ptr/std::vector to hold various character types so that these are displayed as null terminated strings instead as generic arrays. This is useful when debugging code that uses one of these types as a character buffer, for example in order to call a Windows API.

NOTE: For std::vector, I considered setting the display string to use [size()] or similar as a format specifier in order to better handle the case that the string wasn't null terminated. But this winds up with a worse result if it is null terminated, so I wound up deciding to leave it as-is.

This PR adds .natvis entries using `std::unique_ptr`/`std::vector` to hold various character types so that these are displayed as null terminated strings instead as generic arrays. This is useful when debugging code that uses one of these types as a character buffer, for example in order to call a Windows API.

NOTE: For std::vector, I considered setting the display string to use `[size()]` or similar as a format specifier in order to better handle the case that the string wasn't null terminated. But this winds up with a worse result if it is null terminated, so I wound up deciding to leave it as-is.
@gregg-miskelly gregg-miskelly requested a review from a team as a code owner July 5, 2022 20:13
@gregg-miskelly
Copy link
Member Author

@StephanTLavavej StephanTLavavej added the visualizer How the VS debugger displays STL types label Jul 5, 2022
stl/debugger/STL.natvis Show resolved Hide resolved
stl/debugger/STL.natvis Show resolved Hide resolved
@strega-nil-ms strega-nil-ms removed their assignment Jul 7, 2022
@gregg-miskelly
Copy link
Member Author

In case it isn't obvious: I don't have merge rights, so when folks are ready, please merge for me.

@StephanTLavavej
Copy link
Member

I have triple-mirrored this as MSVC-PR-409524.

@gregg-miskelly, go ahead and complete your VS-PR when you're ready, and we'll merge the GitHub and MSVC PRs (you don't need to wait for the MSVC-PR's checks to pass, there's no way the natvis can break them, and GH is already green). There's a little bit of source divergence since we recently merged 3 GitHub PRs and a corresponding MSVC-PR without completing a VS PR yet, but as there are no merge conflicts I think we'll be able to sort things out.

@gregg-miskelly
Copy link
Member Author

@StephanTLavavej Thanks! VS PR is now merged.

@StephanTLavavej StephanTLavavej merged commit 0620026 into microsoft:main Jul 8, 2022
@StephanTLavavej
Copy link
Member

Thanks for improving these visualizers, and congratulations on your first microsoft/STL commit! 🎉 😸 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
visualizer How the VS debugger displays STL types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
  翻译: