From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC 3/8] Add output styles to gdb
Date: Mon, 08 Oct 2018 11:10:00 -0000 [thread overview]
Message-ID: <a0de80102b0f0aea1421667c3ac2f091@simark.ca> (raw)
In-Reply-To: <87lg79cfup.fsf@tromey.com>
On 2018-10-07 22:49, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>
> Simon> Ok, so I'd like to understand better the idea of the
> format-based
> Simon> approach, maybe I don't quite get what you mean. It would be
> easier
> Simon> to comment on something concrete (even without code, just a
> relatively
> Simon> well-defined description of the format).
>
> The minimum, I think, is to have something that encompasses the
> formatting, but not the titling, emitted by table headers. So instead
> of:
>
> uiout->table_header (10, ui_left, "refcount", "Refcount");
>
> the example I gave said
>
> "{refcount<10}"
>
> where the idea is that "refcount" is the field name, "<" says to
> left-justify, and "10" is the field size. I pictured using ">" for
> right justification, and something like "|" for center and ":" or "="
> for "none".
>
> Anything outside of {} would be plain text that is just emitted
> directly.
Do we pass in the values as with printf? Something like
ui_out->format ("{refcount<10}{addr<18}{filename<40}\n", refcount,
addr, filename);
How does the underlying implementation of format knows that the refcount
variable is an int, and that addr and filename are char*? We go by
field name too? Or should the format specifier contain the data type?
> Exactly how to spell the formatting can be debated, like should there
> be a lead-in character ("set extended-prompt" uses backslash, C uses
> %).
>
> So, something like maintenance_info_bfds currently reads:
>
> ui_out_emit_table table_emitter (uiout, 3, -1, "bfds");
> uiout->table_header (10, ui_left, "refcount", "Refcount");
> uiout->table_header (18, ui_left, "addr", "Address");
> uiout->table_header (40, ui_left, "filename", "Filename");
>
> ... but in the format approach the first 2 arguments of each call could
> be removed.
>
> Then when printing the body:
>
> ui_out_emit_tuple tuple_emitter (uiout, NULL);
> uiout->field_int ("refcount", gdata->refc);
> uiout->field_string ("addr", host_address_to_string (abfd));
> uiout->field_string ("filename", bfd_get_filename (abfd));
> uiout->text ("\n");
>
> Here the ->text call could be removed and the text put into the format
> string.
>
>
> I didn't do an exhaustive survey of lists or tuples in the way that I
> looked at tables. There are probably difficult cases lurking in there,
> just as there were for tables. And, the difficult table cases remain
> unsolved -- I haven't really given them much thought.
>
> Maybe another tricky case is handling indentation of elided stack
> frames.
>
>
> Something I like about the approach I implemented is that it's
> relatively easy to explain and use.
>
> The upside of the foramtting approach is that it gives more power to
> users. For example maybe there are things that are currently hidden
> behind mi-like-p that could be exposed; or at least users could arrange
> to drop fields they are not interested in.
I tend to think that introducing a format-based system like this is
relatively orthogonal to the coloring/styling issue. I see it as
syntactic sugar over the field_* methods. Something would parse that
format string and do the appropriate field_* calls for you under the
hood. If we color based on field names, as the current patch does, then
it wouldn't make any difference. If we provide a way for the caller to
override the element type (on which the color/style choice is based),
then we need to consider that in the format string syntax. If field
"foo" is a filename, we can have something like
"{foo<40:filename}"
So my opinion is that introducing something like this isn't in the way
of introducing coloring with the current system.
Simon
next prev parent reply other threads:[~2018-10-08 11:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 21:13 [RFC 0/8] add terminal styling " Tom Tromey
2018-09-06 21:13 ` [RFC 3/8] Add output styles " Tom Tromey
2018-10-06 15:53 ` Simon Marchi
2018-10-06 19:06 ` Tom Tromey
2018-10-07 21:58 ` Simon Marchi
2018-10-08 0:23 ` Tom Tromey
2018-10-08 2:02 ` Simon Marchi
2018-10-08 2:49 ` Tom Tromey
2018-10-08 11:10 ` Simon Marchi [this message]
2018-10-08 22:17 ` Tom Tromey
2018-09-06 21:13 ` [RFC 1/8] Change wrap buffering to use a std::string Tom Tromey
2018-10-06 15:19 ` Simon Marchi
2018-10-08 22:04 ` Tom Tromey
2018-10-18 22:16 ` Tom Tromey
2018-09-06 21:13 ` [RFC 7/8] Style the gdb welcome message Tom Tromey
2018-09-06 21:13 ` [RFC 6/8] Style print_address_symbolic Tom Tromey
2018-09-06 21:13 ` [RFC 4/8] Add variable name styling Tom Tromey
2018-10-06 16:34 ` Simon Marchi
2018-09-06 21:13 ` [RFC 2/8] Add a "context" argument to add_setshow_enum_cmd Tom Tromey
2018-09-06 21:14 ` [RFC 8/8] Style the "Reading symbols" message Tom Tromey
2018-09-06 21:14 ` [RFC 5/8] Style locations when setting a breakpoint Tom Tromey
2018-10-06 16:36 ` Simon Marchi
2018-09-07 6:23 ` [RFC 0/8] add terminal styling to gdb Eli Zaretskii
2018-09-07 14:36 ` Tom Tromey
2018-09-07 14:56 ` Eli Zaretskii
2018-09-07 15:01 ` Eli Zaretskii
2018-09-07 7:25 ` Joel Brobecker
2018-10-04 13:11 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0de80102b0f0aea1421667c3ac2f091@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).