Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: work around negative DW_AT_data_member_location GCC 11 bug
Date: Thu, 27 Jan 2022 12:14:47 -0500	[thread overview]
Message-ID: <0597e6a6-e3ec-f496-3bbb-3444cd2f5ff5@polymtl.ca> (raw)
In-Reply-To: <20220126234600.c3jjbqwkwdazajpp@Plymouth>



On 2022-01-26 18:46, Lancelot SIX wrote:
> Hi,
> 
> I have minor comments below:
> 
>> diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
>> index 019165f6e6c5..20aecd4da4d6 100644
>> --- a/gdb/dwarf2/cu.c
>> +++ b/gdb/dwarf2/cu.c
>> @@ -31,7 +31,8 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
>>      has_loclist (false),
>>      checked_producer (false),
>>      producer_is_gxx_lt_4_6 (false),
>> -    producer_is_gcc_lt_4_3 (false),
>> +	producer_is_gcc_lt_4_3 (false),
>> +	producer_is_gcc_11 (false),
>    ^
> 
> You seem to be changing the indentation here (this changes 4 spaces for
> 1 tab).

Ah, thanks.  That's what happens when you work on multiple projects in
parallel, I had the wrong config loaded.

>>      producer_is_icc (false),
>>      producer_is_icc_lt_14 (false),
>>      producer_is_codewarrior (false),
>> diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
>> index 078479a56988..bce0a3de63a4 100644
>> --- a/gdb/dwarf2/cu.h
>> +++ b/gdb/dwarf2/cu.h
>> @@ -253,6 +253,7 @@ struct dwarf2_cu
>>    bool checked_producer : 1;
>>    bool producer_is_gxx_lt_4_6 : 1;
>>    bool producer_is_gcc_lt_4_3 : 1;
>> +  bool producer_is_gcc_11 : 1;
>>    bool producer_is_icc : 1;
>>    bool producer_is_icc_lt_14 : 1;
>>    bool producer_is_codewarrior : 1;
>> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
>> index f7cb95b40cba..1a749eac334f 100644
>> --- a/gdb/dwarf2/read.c
>> +++ b/gdb/dwarf2/read.c
>> @@ -14320,6 +14320,7 @@ check_producer (struct dwarf2_cu *cu)
>>      {
>>        cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6);
>>        cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3);
>> +      cu->producer_is_gcc_11 = major == 11;
>>      }
>>    else if (producer_is_icc (cu->producer, &major, &minor))
>>      {
>> @@ -14464,6 +14465,19 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
>>        if (attr->form_is_constant ())
>>  	{
>>  	  LONGEST offset = attr->constant_value (0);
>> +
>> +	  /* Work around this GCC 11 bug, where it would erroneously use -1
>> +	     data member locations, instead of 0:
>> +
>> +	       Negative DW_AT_data_member_location
>> +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378
>> +	     */
>> +	  if (offset == -1 && cu->producer_is_gcc_11)
>> +	    {
>> +	      complaint (_("DW_AT_data_member_location value of -1, assuming 0"));
>> +	      offset = 0;
>> +	    }
>> +
>>  	  field->set_loc_bitpos (offset * bits_per_byte);
>>  	}
>>        else if (attr->form_is_section_offset ())
>> diff --git a/gdb/testsuite/gdb.dwarf2/negative-data-member-location.c b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.c
>> new file mode 100644
>> index 000000000000..4871b2f12036
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.c
>> @@ -0,0 +1,29 @@
>> +/* Copyright (C) 2021 Free Software Foundation, Inc.
> 
> The year needs to be updated to 2021-2022.

Done.

> 
>> +
>> +   This file is part of GDB.
>> +
>> +   This program is free software; you can redistribute it and/or modify
>> +   it under the terms of the GNU General Public License as published by
>> +   the Free Software Foundation; either version 3 of the License, or
>> +   (at your option) any later version.
>> +
>> +   This program is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +   GNU General Public License for more details.
>> +
>> +   You should have received a copy of the GNU General Public License
>> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>> +
>> +struct the_struct
>> +{
>> +  char x[4];
>> +};
>> +
>> +struct the_struct s = { { 0x11, 0x22, 0x22, 0x11 } };
>> +
>> +int
>> +main (void)
>> +{
>> +  return 0;
>> +}
>> diff --git a/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp
>> new file mode 100644
>> index 000000000000..9d05f208958b
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp
>> @@ -0,0 +1,77 @@
>> +# Copyright 2021 Free Software Foundation, Inc.
> Same, update the year from 2021 to 2021-2022.

Done.

Simon

  reply	other threads:[~2022-01-27 17:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 19:55 Simon Marchi via Gdb-patches
2022-01-26 23:46 ` Lancelot SIX via Gdb-patches
2022-01-27 17:14   ` Simon Marchi via Gdb-patches [this message]
2022-01-27 20:45 ` Tom Tromey
2022-01-27 20:46   ` Simon Marchi via Gdb-patches

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=0597e6a6-e3ec-f496-3bbb-3444cd2f5ff5@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=simon.marchi@polymtl.ca \
    /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