public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Mark Wielaard <mjw@redhat.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tromey@redhat.com>
Subject: Re: [PATCH] DWARFv5 DW_TAG_aligned_type.
Date: Wed, 30 Jul 2014 18:26:00 -0000	[thread overview]
Message-ID: <20140730165934.GD14672@adacore.com> (raw)
In-Reply-To: <1405635906.17759.210.camel@bordewijk.wildebeest.org>

Hi Mark,

> Forgot to ask...
> 
> On Fri, 2014-07-18 at 00:19 +0200, Mark Wielaard wrote:
> > On Fri, 2014-07-11 at 07:42 -0700, Joel Brobecker wrote:
> > > My only question is regarding the checks for alignments to be stricter
> > > than the alignment of their base types. Why are they needed? I am asking
> > > because, in Ada, it is allowed to be specifying an alignment which is
> > > less strict than the standard alignment. We can ask for byte-aligned
> > > integers, for instance.
> 
> Could you post an example Ada source code example so I can test a bit
> how my gcc and gdb patches interact for an user aligned Ada type?

Here it is (credits to Eric Botcazou):

        package P is

          type My_Integer is new Integer;
          for My_Integer'Alignment use 1;

          C : Character;
          I : My_Integer;

        end P;

Save the code in a file called p.ads, and then compile it using:

        % gcc -c -g p.ads

Variable "C" is just there to prevent variable "I" from being
default-aligned by accident.

If you look at the debugging info, you'll find that our variable
is called "p__i". The alignment is handled via putting it inside
a ___PAD struct as a component called "F". Eg:

        .uleb128 0x6    # (DIE (0x70) DW_TAG_variable)
        .long   .LASF1  # DW_AT_name: "p__i"
        .long   0x1d    # DW_AT_type

Following the type of that variable gives us:

        .uleb128 0x2    # (DIE (0x1d) DW_TAG_structure_type)
        .long   .LASF5  # DW_AT_name: "p__my_integer___PAD"
        [...]
        .uleb128 0x3    # (DIE (0x29) DW_TAG_member)
        .ascii "F\0"    # DW_AT_name
        .long   0x38    # DW_AT_type

Following then the type of member "F" yields a subrange type:

        .uleb128 0x4    # (DIE (0x38) DW_TAG_subrange_type)
        .long   0x80000000      # DW_AT_lower_bound
        .long   0x7fffffff      # DW_AT_upper_bound
        .long   .LASF6  # DW_AT_name: "p__my_integer"
        .long   0x4b    # DW_AT_type
        .byte   0x1     # DW_AT_artificial

... which points to the integer base type:

        .uleb128 0x5    # (DIE (0x4b) DW_TAG_base_type)
        .byte   0x4     # DW_AT_byte_size
        .byte   0x5     # DW_AT_encoding
        .long   .LASF7  # DW_AT_name: "p__Tmy_integerB"
        .byte   0x1     # DW_AT_artificial

Ideally, it'd be better if variable I was described without the PAD
wrapper. We may be headed towards that in the long run, not sure.
But, in the meantime, I think the logical location for adding the
alignment info would probably be the PAD struct?

-- 
Joel

  reply	other threads:[~2014-07-30 16:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 22:21 Mark Wielaard
2014-07-11 15:23 ` Joel Brobecker
2014-07-17 22:25   ` Mark Wielaard
2014-07-17 22:36     ` Mark Wielaard
2014-07-30 18:26       ` Joel Brobecker [this message]
2014-09-29 15:17         ` Mark Wielaard
2014-10-02 17:08           ` Joel Brobecker
2014-07-18 15:39     ` Tom Tromey
2014-07-11 15:26 ` Tom Tromey
2014-07-17 23:11   ` Mark Wielaard
2014-07-18 15:41     ` 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=20140730165934.GD14672@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mjw@redhat.com \
    --cc=tromey@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).