From: Pedro Alves <palves@redhat.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] gdb: Show type summary for anonymous structures from c_print_typedef
Date: Fri, 19 Jul 2019 12:38:00 -0000 [thread overview]
Message-ID: <3df72c85-469b-de6d-adb3-7e7d9ffd8278@redhat.com> (raw)
In-Reply-To: <4b4c8db945d3fbd3334b303b7acfa6d2c71b6bf6.1562931337.git.andrew.burgess@embecosm.com>
On 7/12/19 12:37 PM, Andrew Burgess wrote:
> Currently each language has a la_print_typedef method, this is only
> used for the "info types" command.
>
> The documentation for "info types" says:
>
> Print a brief description of all types whose names match the regular
> expression @var{regexp} (or all types in your program, if you supply
> no argument).
>
> However, if we consider this C code:
>
> typedef struct {
> int a;
> } my_type;
>
> Then currently with "info types" this will be printed like this:
>
> 3: typedef struct {
> int a;
> } my_type;
>
> I see two problems with this, first the indentation is clearly broken,
> second, if the struct contained more fields then the it feels like the
> actual type names could easily get lost in the noise.
Something odd in "then the it feels"?
>
> Given that "info types" is about discovering type names, I think there
> is an argument to be made that we should focus on giving _only_ the
> briefest summary for "info types", and if the user wants to know more
> they can take the type name and plug it into "ptype". As such, I
> propose that a better output would be:
>
> 3: typedef struct {...} my_type;
>
I think the same rationale applies to enums too? We currently
print anonymous enums like:
16: typedef enum {A, B, C} EEE;
The difference here is that we don't print newline between
each enumerator.
It's as if we printed your struct example like this:
3: typedef struct {int a;} my_type;
which would be a bit more reasonable than the current output.
I did the 0 -> -1 change locally, and your patch addresses
enums as well already:
16: typedef enum {...} EEE;
But I think you should add that to the testcase.
> The user understands that there is a type called `my_type`, and that
> it's an alias for an anonymous structure type.
It's worth explicitly showing (in the commit log, IMO) that this
only affects anonymous structs/enums. For named structs/enums, we do
print an abbreviated form with no fields/enumerators:
11: struct named_struct;
18: enum named_enum;
So it makes sense to me to be consistent and use an abbreviated
form for anonymous types too, like in your patch.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2019-07-19 12:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 11:37 [PATCH 0/3] Improving "info types" command Andrew Burgess
2019-07-12 11:37 ` [PATCH 3/3] gdb: Show type summary for anonymous structures from c_print_typedef Andrew Burgess
2019-07-19 12:38 ` Pedro Alves [this message]
2019-07-19 21:06 ` Andrew Burgess
2019-07-20 13:47 ` Pedro Alves
2019-07-22 14:10 ` Tom Tromey
2019-07-12 11:37 ` [PATCH 2/3] gdb: Improve output from "info types" commad Andrew Burgess
2019-07-18 20:07 ` Pedro Alves
2019-07-19 19:43 ` Andrew Burgess
2019-07-19 19:54 ` Pedro Alves
2019-07-20 13:47 ` Pedro Alves
2019-07-12 11:37 ` [PATCH 1/3] gdb: Switch "info types" over to use the gdb::options framework Andrew Burgess
2019-07-12 12:48 ` Eli Zaretskii
2019-07-19 14:50 ` Andrew Burgess
2019-07-18 20:07 ` Pedro Alves
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=3df72c85-469b-de6d-adb3-7e7d9ffd8278@redhat.com \
--to=palves@redhat.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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