From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id se4tFnNQhmT4dAEAWB0awg (envelope-from ) for ; Sun, 11 Jun 2023 18:53:39 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=xVlUXyOA; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4FD101E0BB; Sun, 11 Jun 2023 18:53:39 -0400 (EDT) Received: from sourceware.org (ip-8-43-85-97.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 3C30D1E00F for ; Sun, 11 Jun 2023 18:53:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 595533858C30 for ; Sun, 11 Jun 2023 22:53:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 595533858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686524015; bh=Zle467Qe/Kz6sCp4RFnqnpd+EnptJlQ9oTr3KexUWo0=; h=Date:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xVlUXyOAaQCKHK20BQX9rjTG0rEr/efXqWzgjUWEiR0osj5sRPMTVYwefYSTPRLDD ZFk4rbdLTEI1iLxB8zpxoqZV9S8yBw6Q9+i8oTYnVmk6ujMa62OdT99kXXqFicosnB cEwb74SResW3yy5Quweb7Sl2DS4/727Eu2/xrq9U= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 576093858D20 for ; Sun, 11 Jun 2023 22:53:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 576093858D20 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-83_2fOj7OEWVFCURlYIK3w-1; Sun, 11 Jun 2023 18:53:09 -0400 X-MC-Unique: 83_2fOj7OEWVFCURlYIK3w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9630101A531; Sun, 11 Jun 2023 22:53:08 +0000 (UTC) Received: from f38-zws-nv (unknown [10.22.32.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97AF1140E954; Sun, 11 Jun 2023 22:53:08 +0000 (UTC) Date: Sun, 11 Jun 2023 15:53:06 -0700 To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Permit DW_OP_GNU_uninit to be used with DW_OP_piece Message-ID: <20230611155306.54bc163b@f38-zws-nv> In-Reply-To: <877csit5ez.fsf@tromey.com> References: <20230603183158.70474-1-kevinb@redhat.com> <877csit5ez.fsf@tromey.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , From: Kevin Buettner via Gdb-patches Reply-To: Kevin Buettner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Mon, 05 Jun 2023 07:17:08 -0600 Tom Tromey wrote: > >>>>> "Kevin" == Kevin Buettner via Gdb-patches writes: > > Kevin> The test case in that bug report involved running gdb against the 'jq' > Kevin> program (which is a command-line JSON processor) on Fedora 37. Since > Kevin> the debug info is compiler (and compile-time option) dependent, it > Kevin> won't necessarily show up in other distributions or even past or > Kevin> future versions of Fedora. (E.g. when trying the example shown below > Kevin> on Fedora 38, GDB says that the value of 'value' has been optimized > Kevin> out. I.e. it does not demonstrate the same DWARF error that can be > Kevin> see when using Fedora 37.) > > Ages ago, during one of the rewrites of the DWARF expression evaluator, > I found out that DW_OP_GNU_uninit was not really documented. So, I just > made it continue to work the way it had been described in the gdb > sources. > > My recollection is that it required a special compiler argument to even > get gcc to emit it. It's still undocumented as far as I can tell. > > So I'd suggest perhaps you could get someone to remove it from GCC, or > from the jq build. It's barely used and IMO not really useful. > > That said, it's fine by me if you want to keep it around. So long as there's a producer for it, even if only rarely used, I think we should keep it around. > > Kevin> case DW_OP_GNU_uninit: > Kevin> - if (op_ptr != op_end) > Kevin> + if (op_ptr != op_end && *op_ptr != DW_OP_piece) > Kevin> error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always " > Kevin> "be the very last op.")); > > If DW_OP_GNU_uninit can end a piece then the error message here should > be updated. I've updated the error message - see below. > Also did you look at the other spots that understand DWARF expressions? > There are 3 or 4 in gdb. I found another spot in gdb/dwarf2/expr.c which deals DW_OP_GNU_uninit. It has already been updated to handle both DW_OP_piece and DW_OP_bit_piece. I updated my patch to also handle DW_OP_bit_piece. The other occurrences of DW_OP_GNU_uninit also didn't need updating. They were just cases in switch statements. > Aside from this the patch is OK. Thanks - I've pushed it. The test case stayed the same, but this is what the change to gdb/dwarf2/expr.c ended up looking like: diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ccdd87f3a55..7e1666165d7 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -2200,9 +2200,11 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, goto no_push; case DW_OP_GNU_uninit: - if (op_ptr != op_end) + if (op_ptr != op_end && *op_ptr != DW_OP_piece + && *op_ptr != DW_OP_bit_piece) error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always " - "be the very last op.")); + "be the very last op in a DWARF expression or " + "DW_OP_piece/DW_OP_bit_piece piece.")); this->m_initialized = false; goto no_push;