From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mSRbIVTd8WHTOAAAWB0awg (envelope-from ) for ; Wed, 26 Jan 2022 18:46:28 -0500 Received: by simark.ca (Postfix, from userid 112) id 743531F3B6; Wed, 26 Jan 2022 18:46:28 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D77201EA69 for ; Wed, 26 Jan 2022 18:46:27 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 580CE3945C3D for ; Wed, 26 Jan 2022 23:46:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 580CE3945C3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643240787; bh=9iJFay2mdIacOXxQzesIHLPUsZVTagv4P1IXgSLxZoU=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UkuPmsnnCGEZX3KHom2iSJZYOOKgFMiAfR5mIutVhvunTvRepAe8TbwyOkzq4hQ41 qkCjH7nZeYMyMrzOniqMSXtyfTt1nCfrDiSmu18GZlQ8EW2HvVeA3aYUPlSP9PSHk/ SQZTLI4sPwBmcnFKzI7ynyHeq1R+3PCX2HrUR10Y= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 6FE493858D20 for ; Wed, 26 Jan 2022 23:46:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6FE493858D20 Received: from Plymouth (unknown [IPv6:2a02:390:9086:0:6b51:4d95:4db1:8544]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 67A6F86280; Wed, 26 Jan 2022 23:46:03 +0000 (UTC) Date: Wed, 26 Jan 2022 23:46:00 +0000 To: Simon Marchi Subject: Re: [PATCH v2] gdb: work around negative DW_AT_data_member_location GCC 11 bug Message-ID: <20220126234600.c3jjbqwkwdazajpp@Plymouth> References: <20220126195547.1891750-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220126195547.1891750-1-simon.marchi@polymtl.ca> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Wed, 26 Jan 2022 23:46:03 +0000 (UTC) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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). > 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. > + > + 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 . */ > + > +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. Best, Lancelot.