Re: [Dwarf-Discuss] Proposal to add DW_AT_alignment

2014-06-02 Thread Mark Wielaard
On Wed, 2014-05-28 at 16:33 -0700, Joel Brobecker wrote:
> Very interesting proposal! Thanks for putting it together.

Thanks. BTW part of the reason to propose this was the new gcc/gdb
expression support for C as recently posted to the gcc and gdb lists:
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01286.html
https://sourceware.org/ml/gdb-patches/2014-05/msg00287.html
Having the actual alignment used around makes it more useful/reliable.

> I thought I would mention that Ada allows the user to specify
> stricter alignments for objects too. And also, GNAT sometimes
> decides on its own to use stricter alignments for certain objects.
> Perhaps we might want to add Ada as an another example where
> such source-level requirements can be used? It is not strictly
> necessary but I have a feeling that it would convey the idea
> that the concept is used a little more widely than just through
> C11 and GNU extensions.

Thanks, I didn't know that. The proposal was certainly written with the
above and the description C11 in mind. One thing I wanted to make clear
was that a producer only needs to add the alignment if it is different
from the default alignment as used for the language and abi. And that
the producer should only add the alignment actually used (since in C11
you can add multiple alignment requests for the same type but only the
strictest is used). Adding an example for both C11 and Ada is probably a
good idea in case such assumptions might be similar (or different)
between the languages.

> I don't understand yet why you think that having a new TAG
> is a better approach. Is that because you think the compiler
> will generate the debug info for the base type regardless,
> and so having a new TAG with just that attribute and a reference
> to the base type would save a little bit of space? Or maybe
> it better follows how other modifiers such as "volatile" are
> being described? (I just realized this while typing this email)

Yes, both of those reasons. I was going through all the TAGs that might
carry an alignment attribute and then stumbled upon the type modifier
TAGs like volatile and realized that was a more direct fit instead of
adding a separate attribute only.

> > DW_TAG_aligned_type). Figure 15 Type modifier tags add:
> > DW_TAG_aligned_type non-default alignment requirements of type.
> 
> Maybe it's just because of the formatting that got lost, but
> I don't understand what's being added.

Michael was so nice to send me a copy of the proposal as saved in the
web-submission-system that has most formatting as I originally submitted
it retained. Attached below. Hopefully that is more readable.

As Michael points out the official deadline for new proposals for DWARF
5 has passed. So maybe some of the later proposals don't make it for
DWARF 5.0 final if the committee is very strict about the dates. But the
important thing is that we review and discuss the proposal and make sure
any (GNU) extensions will be as close as possible to what gets adopted
into the standard eventually.

I'll try to prototype an implementation for GCC this week and see what
it looks like in practice so we can discuss things a bit more
concretely.

BTW. It would be nice if the sources of the spec were available. Then we
could just exchange patches, which might be easier to read in context.

Cheers,

Mark
--- Begin Message ---

On 05/28/14 07:24, DWARF Comment wrote:

Subject:  Add DW_TAG_aligned tag and DW_AT_alignment attribute
Section:  5.2, Page: 80

Background:

As discussed on the DWARF discuss list, it is useful for debuggers to know the alignment 
used for an data object in case they need to create an object for use with some 
expressions to be evaluated in the inferior and for type analyzers to know whether two 
types are compatible. In C11 (or through GNU attribute extensions) a user can declare the 
alignment of a type or variable. The below proposal adds a new DW_AT_alignment attribute 
and a DW_TAG_aligned_type type tag that can be "wrapped around" types. 
Originally the idea was to have just a DW_AT_alignment attribute that would be added to 
all possible type tags, but that seemed less natural than a new modifier tag. 
http://thread.gmane.org/gmane.comp.standards.dwarf/166

Proposal:

Figure 1, Tag names add:

DW_TAG_aligned_type.

Figure 2, Attribute names add:

DW_AT_alignment non-default alignment requirements of type.

In 5.2 Unspecified Type Entries add a paragraph:

A modified type entry describing a type with non-default alignment requirement 
(using DW_TAG_aligned_type) has a DW_AT_alignment attribute that describes the 
(non-default) alignment requirements of the type. DW_AT_alignment has a 
positive, non-zero, constant describing the strictest specified (non-default) 
alignment of the type. This constant describes the actual alignment used by the 
compiler (if there are multiple specified by the user, or if the user specified 
an alignment the compiler couldn't satisfy, then only the strictest alignment 

Re: [Dwarf-Discuss] Proposal to add DW_AT_alignment

2014-06-02 Thread Joel Brobecker
> Thanks, I didn't know that. The proposal was certainly written with the
> above and the description C11 in mind. One thing I wanted to make clear
> was that a producer only needs to add the alignment if it is different
> from the default alignment as used for the language and abi. And that
> the producer should only add the alignment actually used (since in C11
> you can add multiple alignment requests for the same type but only the
> strictest is used). Adding an example for both C11 and Ada is probably a
> good idea in case such assumptions might be similar (or different)
> between the languages.

AFAICT, the wording was fine also for Ada.

> As Michael points out the official deadline for new proposals for DWARF
> 5 has passed. So maybe some of the later proposals don't make it for
> DWARF 5.0 final if the committee is very strict about the dates. But the
> important thing is that we review and discuss the proposal and make sure
> any (GNU) extensions will be as close as possible to what gets adopted
> into the standard eventually.

Agreed. Even if it does not make it in v5, it'll be just as good if
it show up in the issue tracker as reviewed and accepted.

-- 
Joel
___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org