From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id NOKIIBTsx2rLXBgAWB0awg (envelope-from ) for ; Thu, 08 Oct 2026 15:16:36 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AomSRi/C; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 566D41E051; Thu, 08 Oct 2026 15:16:36 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 87C531E04E for ; Thu, 08 Oct 2026 15:16:35 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A940B4BA2E1A for ; Thu, 8 Oct 2026 19:16:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A940B4BA2E1A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AomSRi/C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id EC75C4BA2E06 for ; Thu, 8 Oct 2026 19:16:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC75C4BA2E06 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EC75C4BA2E06 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791486968; cv=none; b=b2Z1RHIQM73GssoM7G2QTMYv/TG7nmlqYccajAbjiQW4opN7vruamrIHF1AGT96C2Xs4Hy6wGr3c55eL9O28UMEWfKGlWux5ML4wds0il9pbHXf+Zy1ORWgKVwrt9M28hj8RwvaQkRdGTJMXCqaNukfF4taAGh3ggBjQd93oTDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791486968; c=relaxed/simple; bh=Dcr3lm/pQbfaMQ2y8W5nnypIYWNz0XqgtAfPp0ArxLo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=dMr3rbv32qAFoFVHrO0etjKZ39TT+mV8y8GOyNxvAMg5zpis5ofuTKr28ICxhBTd/yHbrMeUw7amSbiSKQF51iohlli+TLw+PxbztSLZp2e0AMAmlWP4GTSGrTEQ+4OG0uS9T4hmmoF/qZPrFjAUarn4TE8MyFV/poDwATjH39s= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AomSRi/C DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC75C4BA2E06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791486967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fk6Dxgso2DwInNzi8DONEZplrdo4/Q/EODUPl2tMUpA=; b=AomSRi/Cq1MZA/nbS+HML9X6iLkE1826OVJRwSSd3wug2JU2NBfa+SJxXHFlcwJm08Vg6I iQJJcljmAxN6QmGUeus/itVAXi2ky2b3ZTstSrwT2nUx8iRoqMgZVAa7KM94CLdFATVpYC Ot+lMpariOHAjzc+lgmQlmVy7P3xTN0= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-k4-Ml0bGOp28mMFGfil80w-1; Thu, 08 Oct 2026 15:16:04 -0400 X-MC-Unique: k4-Ml0bGOp28mMFGfil80w-1 X-Mimecast-MFC-AGG-ID: k4-Ml0bGOp28mMFGfil80w_1791486963 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3aaf955db5fso1485639a91.0 for ; Thu, 08 Oct 2026 12:16:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791486963; x=1792091763; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Fk6Dxgso2DwInNzi8DONEZplrdo4/Q/EODUPl2tMUpA=; b=fjoXAz6lSNR5HTMGErEEfDdFvghDiBOaKV+YbPg7yZgy68QCcUKpf1iHXMAwZKF9Ql 3X38TprgF62l4dEHzfo86S5IrT1pQaf7kfcHFp4JZL/sXAVr47K6CjrGjDIqLa8GCaq+ pIH1Nc5FSnLp8+qe8nQTsagn+yA5hp5ctilLcm1hNJ+EaMN2kH1ED+tD9dbH51F9VgVg iCilwp75uQdmOTV+Coj+12jYtvBAaBUSmPDyQ+CoPo8+xv1bdESqoIsjJA3qvjKSp7Eq bSP6CtwI921ka6yfudz55yfxUEABi/Bk7vT47rme8qGD1XvGMl5RZRkJC4cvLaFS9FII 0zDw== X-Forwarded-Encrypted: i=1; AKwUvBwMg486YoRgIKrh9aFtfNDtM36u3EvAtURIuVVvAFOIK1fo2IXFrZLXE4E0EvKolnYZAA8NkyA70rz08Q==@sourceware.org X-Gm-Message-State: AFq9FYI52Wy5TGZiQQWcgAr6qo5/3hOo3+shJrvwVFi0aR82Gc3Giwv8 M16afegJr/OKlYNhllekzJvu0p7o4zJXOrJlaXocjBkYQ/Dd1lD/nRkYiaLAOugBGAd/IbnoGbI fzrWc/iXVW/D1US4mm2Dpuoisff6pO9mGdoKk5XRBSjWSapJlb238JXZBNeZZM+LQg9tDW/w= X-Gm-Gg: AYBFou2oCwHvdYqosI4RZ1E2PvuJcLi7tT2LrZYJXGZD1rsa2HtmfTPcHnD9Ng1Fv2P 7oUQSSYukCO7XgiMd70s9ex9dWg5bCCPKkaT3B1p7FU3A2HDjsoK69fQnlJ1DQn+8K+pRJJkaEV g9vE6jxGQ/J/vtc5d84sBHssY8jbSOgpn0LQm0iAfrPmnwIv+VPTcuvOU0u+rmN42wA4UT8Nus4 i8Ycq8Y3h/tQqE4pftqH2gLnjh1P069oeY+VdEDuEK9+1mhAdBzjSKRry3Jo434B6x0gYeeA+Mn iYKhWRTri5sfiVjCz/hVCUFRe8Ze1OeBGVWKhV/CXbKJ+yl6NRaHzUhUVbS5AVMmdsfMWJe1V7Z 4aa/ZLQ== X-Received: by 2002:a17:90b:5746:b0:39e:6c6a:657f with SMTP id 98e67ed59e1d1-3a8a151f08fmr5224654a91.66.1791486963249; Thu, 08 Oct 2026 12:16:03 -0700 (PDT) X-Received: by 2002:a17:90b:5746:b0:39e:6c6a:657f with SMTP id 98e67ed59e1d1-3a8a151f08fmr5224628a91.66.1791486962609; Thu, 08 Oct 2026 12:16:02 -0700 (PDT) Received: from [150.1.200.157] ([172.56.109.14]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ab36dddac2sm57235a91.16.2026.10.08.12.16.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2026 12:16:02 -0700 (PDT) Message-ID: <5afb25c6-cdb8-4f6c-8944-26ad1acb7497@redhat.com> Date: Thu, 8 Oct 2026 12:16:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: fix path expression for anonymous union members To: Stephan Rohr , gdb-patches@sourceware.org References: <20261007082731.728382-1-stephan.rohr@intel.com> From: Keith Seitz In-Reply-To: <20261007082731.728382-1-stephan.rohr@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oimjWc_IVluAPxFmtbRkQ4KT4AMH7MEdI_Rz1aqu5AU_1791486963 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi, Thanks for the patch. On 10/7/26 1:27 AM, Stephan Rohr wrote: > > Extract the required logic from cplus_describe_child and use it to get > the correct index of the field within the parent type. With this change > the path expression is computed correctly: > > interpret mi "-var-info-path-expression var1.public.1_anonymous.public.c" > ^done,path_expr="((s).c)" > I think this is the correct approach. > I modified the related test to include both base type and access layers. > However, to correctly parse the base types within the MI var tree I had to > introduce a heuristic that if the child's type is equal to child's name > then it is a base type, and the path expression is different in this case. Let's look at this a bit in the actual change: > diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp > index cd7e0a61189..465cf3fd69c 100644 > --- a/gdb/testsuite/lib/mi-support.exp > +++ b/gdb/testsuite/lib/mi-support.exp > @@ -2401,6 +2401,10 @@ namespace eval ::varobj_tree { > set is_compound 0 > } > > + if {$type eq $name} { > + # This is the base type. > + return "((class $type) $path_parent(path_expr))" > + } > if {[string index $parent(type) end] == "\]"} { > # Parent is an array. > return "($path_parent(path_expr))\[$name\]" IIUC, if we have a construct like: class Outer { public: struct Inner { int x; }; Inner Inner; }; Outer o; Then the proposed heuristic change would return "((class Inner) o)". However, the real path should be "((o).Inner)". While this is probably unlikely to actually affect anything, perhaps we can tighten this a little bit by applying the heuristic only if its parent is not one of these artificial access parents? That is, something like: proc is_cplus_fake_child {variable} { upvar #0 $variable varobj return [string equal $varobj(type) ""] } # Note that proc get_path_expr walks parent_variable -- we need to save # it before that. if {$type eq $name && is_cplus_fake_child $saved_parent} { return #... } That might be a simple change to mitigate some future frustration. Keith