This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> Also, since gcc expects a pointer for %p, and we want to pass an
Pedro> enum for the style, I added a small pointer-wrapper hack -- see the
Pedro> ptr function. Yay C++.
We could just remove the enum, move to passing pointers everywhere, and
convert the *_style objects to be pointers. This would streamline
things a bit; and we could use nullptr to mean "keep the default".
Another option would be to just add a ptr method to the _style objects,
so instead of ui_out_style_kind::VARIABLE you'd write variable_style.ptr ().
Pedro> I've not been paying much attention to the styling patches, so I can't
Pedro> off hand tell which places would benefit the most from this. So I just
Pedro> grepped for _styled and replaced a couple spots. Likely there are better
Pedro> examples.
There's my new patch and I have one more along those lines as well, but
a good existing one that was already deconstructed is in symfile.c:
puts_filtered (_("Reading symbols from "));
fputs_styled (name, file_name_style.style (), gdb_stdout);
puts_filtered ("...\n");
Pedro> For the seemingly common case of printing a string variable
Pedro> with a style, I'm thinking that a specific formatter would
Pedro> be better. I'll post a follow up patch for that.
I'm interested to see it.
Tom