Skip to content

Add error_code, error_category support to visualizer#3204

Merged
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
cmazakas:natvis-error-updates
Dec 6, 2022
Merged

Add error_code, error_category support to visualizer#3204
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
cmazakas:natvis-error-updates

Conversation

@cmazakas
Copy link
Contributor

This PR aims to implement the requested fixes outlined in https://github.com/microsoft/STL/pull/3044/files

In general, I prefer the approach of requiring function evaluation as it helps keep the visualizer code layout-independent.

Let me know if there's anything to be changed!

@cmazakas cmazakas requested a review from a team as a code owner November 10, 2022 16:02
@cmazakas
Copy link
Contributor Author

@microsoft-github-policy-service agree

@StephanTLavavej StephanTLavavej added the visualizer How the VS debugger displays STL types label Nov 10, 2022
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me (although I have not tested it in the debugger). Thanks!

@strega-nil-ms strega-nil-ms self-assigned this Nov 14, 2022
@strega-nil-ms
Copy link
Contributor

strega-nil-ms commented Nov 14, 2022

I'll take a look at this tomorrow in the debugger. I got COVID, whee

taking a look tomorrow (12-01)

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is how error_code looks:

{ value=0, category=[???] }

and if you click the little circle-y thing, you get

{ value=0, category=[system] }

For error_condition, instead you get:

{_Myval=2 _Mycat=0x00007ff60b389008 {OptionalDebuggerIssues.exe!std::_Generic_error_category _Static} [generic] }

which seems like the name() call doesn't work; what's going on here? am I missing something?

@strega-nil-ms strega-nil-ms removed their assignment Dec 1, 2022
@cmazakas
Copy link
Contributor Author

cmazakas commented Dec 2, 2022

Huh, error_condtion?

I was using the test template that was suggested in the other PR so I wound up using this:

#include <future>
#include <ios>
#include <string>
#include <system_error>

struct my_error_category : public std::error_category {
	const char* name() const noexcept override {
		return "potato";
	}

	std::string message(int) const override {
		return "message goes here";
	}
};

int main() {
	auto& generic_cat = std::generic_category();
	auto& system_cat = std::system_category();
	auto& iostream_cat = std::iostream_category();
	auto& future_cat = std::future_category();
	const auto& my_cat = my_error_category();

	std::error_code generic(42, generic_cat);
	std::error_code system(42, system_cat);
	std::error_code iostream(42, iostream_cat);
	std::error_code future(42, future_cat);
	std::error_code my(42, my_cat);
}

On my install of VS, this winds up looking like this:
Screenshot_20221202_121423

Enabling functions calls in value formatting winds up looking like this:
Screenshot_20221202_121720

So I don't think I'm replicating what you're seeing. Would you mind sharing your code/some screenshots so I have a better idea of what's going on?

@strega-nil-ms
Copy link
Contributor

I misunderstood! I misread error_category as error_condition somehow; this does seem reasonable to me, then, although I don't know how comfortable people generally are with function calls in visualizers...

@StephanTLavavej StephanTLavavej self-assigned this Dec 5, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit fba515c into microsoft:main Dec 6, 2022
@StephanTLavavej
Copy link
Member

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

We've merged this to the GitHub and MSVC-internal repos, but we still need to "triple-mirror" our accumulated visualizer changes to the VS repo so they will actually take effect in the IDE. I believe that @CaseyCarter will be looking into doing that soon.

@cmazakas cmazakas deleted the natvis-error-updates branch December 6, 2022 22:34
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.

4 participants