Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
Subject: Re: [RFA 0/2] Support ptype/o in Rust
Date: Wed, 27 Jun 2018 02:59:00 -0000	[thread overview]
Message-ID: <87bmbxrl31.fsf@tromey.com> (raw)
In-Reply-To: <87woup9ifk.fsf@redhat.com> (Sergio Durigan Junior's message of	"Sat, 23 Jun 2018 19:44:47 -0400")

>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:

Sergio> Even though it's a bit uglier than your solution, IMO it's easier to
Sergio> understand and correlate the sizes with their respective structs.
Sergio> Compare this to:

Sergio>   (gdb) ptype /o struct c
Sergio>   /* offset    |  size */  type = struct c {
Sergio>   /*    0      |    12 */    struct a {
Sergio>   /*    0      |     4 */        int a1;
Sergio>   /*    4      |     1 */        char a2;
Sergio>   /* XXX  3-byte hole */
Sergio>   /*    8      |     4 */        int a3;
Sergio>   /* total size (bytes):   12 */
Sergio>                              } c1;
Sergio>   /*   12      |    20 */    struct b {
Sergio>   /*   12      |    12 */        struct a {
Sergio>   /*   12      |     4 */            int a1;
Sergio>   /*   16      |     1 */            char a2;
Sergio>   /* XXX  3-byte hole */
Sergio>   /*   20      |     4 */            int a3;
Sergio>   /* total size (bytes):   12 */
Sergio>                                  } b1;
Sergio>   /*   24      |     4 */        int b2;
Sergio>   /*   28      |     1 */        char b3;
Sergio>   /* XXX  3-byte padding */
Sergio>   /* total size (bytes):   20 */
Sergio>                              } c2;
Sergio>   /*   32      |     1 */    char c3;
Sergio>   /* XXX  3-byte hole */
Sergio>   /*   36      |     4 */    int c4;
Sergio>   /* total size (bytes):   40 */
Sergio>                            }

My idea was to line up the total size with the "}" so it would instead
appear as:

  (gdb) ptype /o struct c
  /* offset    |  size */  type = struct c {
  /*    0      |    12 */    struct a {
  /*    0      |     4 */        int a1;
  /*    4      |     1 */        char a2;
  /* XXX  3-byte hole */
  /*    8      |     4 */        int a3;
  /* total size:    12 */    } c1;
  /*   12      |    20 */    struct b {
  /*   12      |    12 */        struct a {
  /*   12      |     4 */            int a1;
  /*   16      |     1 */            char a2;
  /* XXX  3-byte hole */
  /*   20      |     4 */            int a3;
  /* total size:    12 */    } b1;
  /*   24      |     4 */        int b2;
  /*   28      |     1 */        char b3;
  /* XXX  3-byte padding */
  /* total size:    20 */    } c2;
  /*   32      |     1 */    char c3;
  /* XXX  3-byte hole */
  /*   36      |     4 */    int c4;
  /* total size:    40 */  }

But yeah, maybe that's a bit harder to read than the status quo.

Sergio> Anyway, TBH I don't have a strong opinion here.  If you want to indent
Sergio> the outermost fields by 4 spaces, I won't oppose.

I'm on the fence.  It works ok now; it just made some of the code a
little uglier.

Tom


      reply	other threads:[~2018-06-27  2:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-23 20:22 Tom Tromey
2018-06-23 20:22 ` [RFA 2/2] " Tom Tromey
2018-06-26 19:08   ` Simon Marchi
2018-06-26 20:55     ` Tom Tromey
2018-06-23 20:22 ` [RFA 1/2] Move ptype/o printing code to typeprint.c Tom Tromey
2018-06-23 23:51   ` Sergio Durigan Junior
2018-06-26 20:54     ` Tom Tromey
2018-06-23 23:44 ` [RFA 0/2] Support ptype/o in Rust Sergio Durigan Junior
2018-06-27  2:59   ` Tom Tromey [this message]

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=87bmbxrl31.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.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