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: [RFA] Fix PR gdb/11702, printing of static const member variables


On Mon, Jun 28, 2010 at 4:02 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Sun, 27 Jun 2010 20:24:42 +0200, Doug Evans wrote:
>> btw, the dwarf4 standard, as I read it, says static member variables are
>> identified by having DW_AT_external. ?[4.1 Data Object Entries]
>> However, dwarf2_add_field is calling die_is_declaration.
>
> echo 'class C { static const float i = 1; } c;'|g++ -c -o 1.o -Wall -g -x c++ -
> ? ?< c> ? DW_AT_producer ? ?: (indirect string, offset: 0x11): GNU C++ 4.6.0 20100628 (experimental)
> ?<2><33>: Abbrev Number: 3 (DW_TAG_member)
> ? ?<34> ? DW_AT_name ? ? ? ?: i
> ? ?<38> ? DW_AT_type ? ? ? ?: <0x45>
> ? ?<3c> ? DW_AT_external ? ?: 1
> ? ?<3d> ? DW_AT_accessibility: 3 ? ? ? (private)
> ? ?<3e> ? DW_AT_declaration : 1
> ? ?<3f> ? DW_AT_const_value : 4 byte block: 0 0 80 3f
>
> Isn't it primarily a bug in GCC? ?There is no other DIE for `i' and it is
> a complete definition so there is no place for DW_AT_declaration there.
>
> Just such GCC change will be incompatible with existing GDBs, maybe to make
> the GCC change only for -gdwarf-4 upwards which is incompatible with older
> GDBs anyway?

I guess one can think of it as two separate issues: What does gcc emit
and what does gdb look for.
I was *only* addressing the latter.
You are correct that if gcc stopped emitting DW_AT_declaration
(assuming that's the correct thing to do), then enabling it via some
flag in order to not break debugging with older debuggers would be
reasonable (although if the context is just static const member
variables - they're completely broken in gdb 7.1 anyway, and perhaps
all the older gdb's that we care about).
It may be too late to add such a change to -gdwarf-4, I'm not sure.

[And, for completeness sake, there's the issue of needing to consider
what other compilers gdb is used with.]

>> This seems wrong, but I didn't address this here, other than to add
>> a note pointing this out (because some new code in new_symbol should match).
>
> I agree it is an issue for a different patch.
>
>
>> Also, I added a case to new_symbol to handle DW_TAG_member.
>> gcc uses DW_TAG_variable but the correct way AIUI is DW_TAG_member,
>
> 4.4.5 20100627 uses DW_TAG_variable but 4.5.1 20100627 uses DW_TAG_member.
>
>
> Otherwise - for the second patch - there are some needless whitespace changes.
> Also I would test also `float' const field there using LOC_CONST_BYTES; it
> works but just to test it, based on your IRC comments about LOC_CONST_BYTES.

I have committed the following.
I'll update the pr shortly.

2010-06-29  Doug Evans  <dje@google.com>

        PR c++/11702
        * NEWS: Add entry.
        * dwarf2read.c (dwarf2_add_field): If DW_AT_const_value is present,
        create a symbol for the field and record the value.
        (new_symbol): Handle DW_TAG_member.
        * gdbtypes.c (field_is_static): Remove FIXME.
        * symtab.c (search_symbols): When searching for VARIABLES_DOMAIN,
        only ignore LOC_CONST symbols that are enums.

        testsuite/
        Test PR c++/11702.
        * gdb.cp/m-static.exp: Add testcase.
        * gdb.cp/m-static.h (gnu_obj_4): Add initialized static const member.

Attachment: gdb-100629-static-const-member-3.patch.txt
Description: Text document


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