[PATCH] Differentiate empty vs. opaque types

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Differentiate empty vs. opaque types

Jan Kratochvil-2
Hi,

attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
the DWARF flag `DW_AT_declaration':
# DWARF3: An incomplete structure, union or class type is represented by
# a structure, union or class entry that does not have a byte size attribute
# and that has a DW_AT_declaration attribute.

The attachment then fixes GDB to make the testcase pass.

Patch goes the regression-safe way by introducing OBJF_HAVE_TYPE_STUB currently
being set only by DWARF/DWARF2.  It should be probably also set at least by
STABS but I tested the code only on DWARF2.  Unaware how feasible would be
unconditional TYPE_STUB() dependency nowadays.


Regards,
Jan

gdb-empty-is-not-opaque.patch (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Differentiate empty vs. opaque types

Daniel Jacobowitz-2
On Sun, Mar 11, 2007 at 11:55:19PM +0100, Jan Kratochvil wrote:
> Hi,
>
> attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
> the DWARF flag `DW_AT_declaration':
> # DWARF3: An incomplete structure, union or class type is represented by
> # a structure, union or class entry that does not have a byte size attribute
> # and that has a DW_AT_declaration attribute.
>
> The attachment then fixes GDB to make the testcase pass.

Does this happen in HEAD?  It sounds just like the problem Joel fixed
for Ada:

2007-01-05  Joel Brobecker  <[hidden email]>

        * dwarf2read.c (partial_die_info): Add field has_byte_size.
        (add_partial_symbol): Correct identification of external
        references.
        (process_structure_scope): Likewise.
        (read_partial_die): Handle DW_AT_byte_size attribute.

There's an Ada testcase for this, and it passes now.

> Patch goes the regression-safe way by introducing OBJF_HAVE_TYPE_STUB currently
> being set only by DWARF/DWARF2.

An objfile flag is usually not right - this is per-compilation-unit,
not per objfile.

--
Daniel Jacobowitz
CodeSourcery
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Differentiate empty vs. opaque types

Jan Kratochvil-2
On Mon, 12 Mar 2007 04:35:29 +0100, Daniel Jacobowitz wrote:
> On Sun, Mar 11, 2007 at 11:55:19PM +0100, Jan Kratochvil wrote:
> > attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
> > the DWARF flag `DW_AT_declaration':
...
> Does this happen in HEAD?

Yes.


> It sounds just like the problem Joel fixed
> for Ada:
>
> 2007-01-05  Joel Brobecker  <[hidden email]>
>
>         * dwarf2read.c (partial_die_info): Add field has_byte_size.
>         (add_partial_symbol): Correct identification of external
>         references.
>         (process_structure_scope): Likewise.
>         (read_partial_die): Handle DW_AT_byte_size attribute.
>
> There's an Ada testcase for this, and it passes now.
I was not aware of it, I checked it now, it looks really related.

But that patch / testcase is orthogonal to my patch / testcase below.
Joel's patch targets DWARF->symbols phase while my patch targets symbols found
in different object files (executable vs. shared library).

...
> An objfile flag is usually not right - this is per-compilation-unit,
> not per objfile.

You are right. Updated, as there is no compilation-unit info reachable from
`struct type *' I had to use a new flag in each type there.


Regards,
Jan

gdb-empty-is-not-opaque-v2.patch (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Differentiate empty vs. opaque types

Daniel Jacobowitz-2
On Mon, Mar 12, 2007 at 10:36:12PM +0100, Jan Kratochvil wrote:

> 2007-03-12  Jan Kratochvil  <[hidden email]>
>
> * gdbtypes.h (TYPE_FLAG_STUB_SUPPORTED, TYPE_STUB_SUPPORTED): New
> macros.
> (TYPE_IS_OPAQUE): Empty vs. opaque structures are now
> distinct on the TYPE_STUB_SUPPORTED debug targets.
> * dwarf2read.c (read_structure_type): Set TYPE_FLAG_STUB_SUPPORTED.
> * dwarfread.c (struct_type): New comment on TYPE_FLAG_STUB_SUPPORTED.
>
> 2007-03-12  Jan Kratochvil  <[hidden email]>
>
> * gdb.base/type-opaque-lib.c, gdb.base/type-opaque-main.c,
> gdb.base/type-opaque.exp: New files.

Sorry I didn't get back to you; I wanted to finish deleting
dwarfread.c first.

This is OK, without the bit for dwarfread.c, which is now gone.

--
Daniel Jacobowitz
CodeSourcery