From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686523992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zle467Qe/Kz6sCp4RFnqnpd+EnptJlQ9oTr3KexUWo0=; b=cU3Qw7GTFfMDZkAAVsNzE3Mnif7mg1gD8dJBXVX016d/J2Pcihp1NwqFeDehNR6ZN2ThVU 7TLk9jiaOgJ666NjestzuzrMMlXNA1B/fI7UmzL1UvDHR7tCwU0LOWNWtuFi5ZB8VPdZl5 dKZ73voQEFhYZlN/P7a2Mk7TJQEakAY= 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 From: Kevin Buettner 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 List-Id: 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;