This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] DWARFv5 DW_TAG_aligned_type.


> My apologies it took so long before I made time to look at your example.

No worries. I have been busy too! (still am :-)).

> Something that does surprise me is that ptype in gdb seems to always
> just give the valid subrange of the variables I, I2, I3, not their
> actual type.
> 
> (gdb) ptype P.I3
> type = range -2147483648 .. 2147483647

That's typical for an integral type described as a subrange of
another type. I don't know that you can actually get access to
the subtype from the debugger, but you can use "whatis" to get
the name of the type instead of the range, and you can also use
the 'size attribute if, what you're looking for, is the size
of the type.

    (gdb) p p.i3'size
    $1 = 32
    (gdb) whatis p.i3
    type = p.your_integer

> While my changes for C types were so that ptype would produce a type
> that you could in theory just pass into the compiler again to get you
> the same thing. Is the above a deliberate choice for Ada? Hmmm, it seems
> the above "type Another_Integer is new My_Integer" construct does not
> result in any DWARF output that would make it possible to say
> Another_Integer is a subtype of My_Integer?

The Ada mode, as currently implemented, does not try to do that, no.

Note that, technically speaking, in the example above, Another_Integer
is _not_ a subtype of My_Integer, but a logically distinct types.
If you try to assign a value of type My_Integer to a variable of
type Another_Integer without an explicit type conversion, the compiler
should fail. To create a subtype, we use the subtype keyword. Eg:

    subtype Full_Type is My_Integer;

Or, if you want to add constraints to your subtype:

    subtype Positive_Type is My_Integer range 1 .. My_Integer'Last;

Regardless, I believe that at the debugging info level, both full
(new) type and subtypes are described the same way. So I don't see
us handling both differently for the time being.

> In my example above do see a PAD for some (the first) variable type, but
> not others. Those just point directly to the named DW_TAG_subrange_type.
> I think I would expect it to be on the (named) subrange_type either
> inside or outside the "PAD" (what does that stand for BTW?) struct.

That's a tricky question for me to answer. The scenario I have in
mind where this is going to be particularly useful is when trying
to call a function from the debugger with one of the parameters having
a non-standard alignment. I would be easier to handle if the PAD type
was the type with the alignment info, but I think it's just a detail
that we can deal with later on.

I am not sure whether PAD stands for anything other than "padding".
BMT (Before My Time)! :-)

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]