From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2AB3C3857C56 for ; Wed, 26 Jan 2022 19:34:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AB3C3857C56 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 20QJYBZY020992 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jan 2022 14:34:16 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 20QJYBZY020992 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 95DD21EE18; Wed, 26 Jan 2022 14:34:11 -0500 (EST) Message-ID: Date: Wed, 26 Jan 2022 14:34:11 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] gdb: work around negative DW_AT_data_member_location GCC 11 bug Content-Language: en-US To: Keith Seitz , Simon Marchi , gdb-patches@sourceware.org References: <20211129153725.1499053-1-simon.marchi@efficios.com> <844ce501-7a0d-2806-2a57-d08c71e8bcb4@polymtl.ca> <53f71b5f-a989-7eef-0178-9a96a414ece8@redhat.com> <09e59830-968a-0054-b5be-03e2bbe153dc@redhat.com> From: Simon Marchi In-Reply-To: <09e59830-968a-0054-b5be-03e2bbe153dc@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 26 Jan 2022 19:34:11 +0000 X-Spam-Status: No, score=-3039.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 26 Jan 2022 19:34:20 -0000 On 2022-01-26 13:30, Keith Seitz wrote: > On 1/26/22 10:17, Keith Seitz via Gdb-patches wrote: >> On 1/26/22 09:45, Simon Marchi via Gdb-patches wrote: >>>> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c >>>> index 737d8a4c81b..0c66a6daf97 100644 >>>> --- a/gdb/dwarf2/read.c >>>> +++ b/gdb/dwarf2/read.c >>>> @@ -14489,6 +14489,16 @@ 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) >>>> + offset = 0; >>>> + > > I apologize, I forgot to ask: would the more general " < 0" be > appropriate to catch other related bugs, such as fuzzing? In this case, we want to handle a very specific known bug by a specific compiler. We know that GCC meant 0 and not -1. But I wouldn't turn any negative value into 0, because that might not be the value the compiler intended. For example, another compiler could put -4 when it meant 4. If we turned that into 0, we would just add to the confusion. In fact, I am tempted to add a producer check and only apply the fixup if the producer is gcc 11. Since GDB doesn't know how to handle negative data member offsets (if that's even possible), I think that if we encounter a negative offset (other than the case above), we should just emit a complaint and leave the field's location as unknown. Simon