From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9zC1JID/+GiUEwMAWB0awg (envelope-from ) for ; Wed, 22 Oct 2025 12:00:00 -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=ZLI5CxXc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 891F91E0BC; Wed, 22 Oct 2025 12:00:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AD7C31E04C for ; Wed, 22 Oct 2025 11:59:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39942385841C for ; Wed, 22 Oct 2025 15:59:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39942385841C 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=ZLI5CxXc Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id EB5413858C2A for ; Wed, 22 Oct 2025 15:59:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB5413858C2A 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 EB5413858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761148767; cv=none; b=iwu4r4RN4x8YLu10wXRzihXXpBLpP/G/4M9I2BIYdZAqVFfDnBYc6wtex9ckl5x5t9JdeMRU1nfgMA1gkJP4t3s2nXrXjkO9XQS1AOGk8QO2dFBbhmQUWMI3s8ZgsDNIHK11w2Sc528EFTDM5Wb8XaECc7lma7Dy4E4M37wq6xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761148767; c=relaxed/simple; bh=ccblN1qQLENyYcE/3nkxntovNx5Azb+wCuRYXpkacGc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GgqJaVm0jGki6d6e27PeB01Nau8WX6XXPZqqLcyYTDMmQcDVwFzOLmnJPG5GOE+6nBfhsB6PefbAtRUrLJzN0q5CW2UCu0DjNiVkrJIDSIqVq9RczWi5eWhxvXUMopXotNTfx7S38PPxARigZOdOUSLJ2xuqe1phXITdg8wBvQE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB5413858C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761148766; 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: in-reply-to:in-reply-to:references:references; bh=fAP89B8DxfY05mkF0tZbL1smOcvU8+9B2j8oIPg1QL8=; b=ZLI5CxXcYdnMDVWp3RGI5GzdqDdsbSSMJyBn2Q3vzWDb/faCWqc6hnKl0sB9gz7vDI+lNa zM/FeTwT1wADjb3mRE3jVd1zdEKFo9Q1dQCv3JDrKiwGaUmmuhW1VqEfXkB59q7sF87RU0 jSIg5M5o5Z2Y6lBZrVKDOvqRc1ga0D0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-hyKObRRNONeGHxHRCJVoRw-1; Wed, 22 Oct 2025 11:59:22 -0400 X-MC-Unique: hyKObRRNONeGHxHRCJVoRw-1 X-Mimecast-MFC-AGG-ID: hyKObRRNONeGHxHRCJVoRw_1761148761 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-470fd5ba449so3448055e9.0 for ; Wed, 22 Oct 2025 08:59:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761148761; x=1761753561; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fAP89B8DxfY05mkF0tZbL1smOcvU8+9B2j8oIPg1QL8=; b=iVJ3FCnI+18u0v4koF65BRSrzPoavsmZuWT0j1N5amIKbsnPJiZKpe0vxSw8nQqkjz 525KqLj2/rZCpJW0zW4WQDbm9q+tT+ZSs8/rrPh2ZpSZwfD+qxbRiirlVAvGpCFcmRHE qDNgs3wys5vvgr1Oxn7E15/nOztebPKM1JixCZzm6AfPpwPH6Ql9THhQwgvYoeXEcWEi xSwo8be8e++vTmlsont3afujEk26YLSzbnqfG8h1SrZnQJtek8tfY/cx0HaqsW5eKBkG rdEBYUR1cCIVk81W0rQi17ldLC6eG1DNkj6/KOj/ypY59xR0bf87oOiYpapDK/MJ4X24 HXzg== X-Gm-Message-State: AOJu0Yygs8E6zjfkLAO9aIFYEfSJ15Uc7uEBRXomgQ26E5CwKwRyHkaL TJsULGQjYn994E0DIVv/FwWroCMawtxfNZPEXYZB82/urRZt3PH4JMdTYt10OHYDrpLNA6T4j1Y lZXZbZsUT6fYNrugRo7PuQiOvroDa5JsSIbaOG0+X1VjLYbQcRbltVHkdkk3/IsM= X-Gm-Gg: ASbGnct3bZhqdCbZOTK7pCco83FlPKeXqy508uC4ugPCa3QldbQ3YOqi2l/XkCEk0BA ekQ4WkbM/6OoneOVMZIG35spV0MpVOIVPFCLFkK1kzQJC+rdTg8/EA1sf6svuvIw0m2Rpgmjbpz yfXjbMAhnm8MHZh+qEXQKZBMl59PynEbQvtHisgxs9QrLLR0U+ws5jJjPI0DqEwbTuQIuw5HUT0 80a82az+9mHBwdeooC0vrgQDyVb49n6+0944xA2j8DDf3O886GZ/UxOv0je8dM+vAwfTnmLFk40 IoR+YClQQqn+7+eFcK+nHloRR2syMM2YtHMzuyxJI5JFpJyIAKRQrSuiJmAhCs2GQChMlw== X-Received: by 2002:a05:600c:3505:b0:46e:59bd:f7e2 with SMTP id 5b1f17b1804b1-475c3fcb2fbmr28426355e9.11.1761148761325; Wed, 22 Oct 2025 08:59:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBh429lnEafBqlPRD5s6SBbbng3cDs6rH+Lyw5iGzcfqjECpenNef0PwkgmrzsQYOk+3g7Uw== X-Received: by 2002:a05:600c:3505:b0:46e:59bd:f7e2 with SMTP id 5b1f17b1804b1-475c3fcb2fbmr28426195e9.11.1761148760885; Wed, 22 Oct 2025 08:59:20 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427ea5b3c56sm25966579f8f.18.2025.10.22.08.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 08:59:20 -0700 (PDT) From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv3] gdb: remove attempted type de-duplication when building gdb-index In-Reply-To: <87cy6fkltn.fsf@tromey.com> References: <5fb2ed381ab0f96c5057f1644ca67dceebcdf3b7.1760638029.git.aburgess@redhat.com> <87cy6fkltn.fsf@tromey.com> Date: Wed, 22 Oct 2025 16:59:19 +0100 Message-ID: <87ldl3c4h4.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HJdLT14Ee4DJETNeEILg7CIKSKshU-SaCIOZ5BNG7FE_1761148761 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Tom Tromey writes: >>>>>> "Andrew" == Andrew Burgess writes: > > Andrew> In v3: > Andrew> - Fixed test failure in gdb.cp/stub-array-size.exp when using > Andrew> cc-with-gdb-index, using more recent versions of gcc. This did > Andrew> require additional changes in dwarf2/read-gdb-index.c, and removal > Andrew> of a test that is now out of date. The commit message has been > Andrew> updated with a full description. > > Thanks. I think this is ok. See below for commentary but there's > nothing you need to change. > > Approved-By: Tom Tromey > > Andrew> NOTE: Obviously a program doing this (defining a type differently in > Andrew> different CUs) would need to be mindful of the One Definition Rule, > Andrew> but so long as the type doesn't escape outside of a single CU then > Andrew> reusing a type name isn't, as I understand it, wrong. And even if > Andrew> it is, the fact that it compiles, and could be a source of bugs, > Andrew> means (in my opinion) that GDB should handle this case to enable > Andrew> debugging of it. > > Also ODR only applies to C++ and in C it's ok to have different > definitions of an opaque type in different CUs. gdb itself used to use > this technique. > > Andrew> This test has two CUs, and a type 'A'. The test description says: > Andrew> Test size of arrays of stubbed types (structures where the full > Andrew> definition is not immediately available). > Andrew> Which I don't really understand given the test's source code. > > I think the relevant difference in the DWARF is: > > Andrew> <1><4a>: Abbrev Number: 8 (DW_TAG_structure_type) > Andrew> <4b> DW_AT_name : A > Andrew> <4d> DW_AT_declaration : 1 > Andrew> <4d> DW_AT_sibling : <0x6d> > > Andrew> while in the second CU, the type looks like this: > > Andrew> <1><178>: Abbrev Number: 4 (DW_TAG_structure_type) > Andrew> <179> DW_AT_name : A > Andrew> <17b> DW_AT_byte_size : 8 > > ... that the second one has the size. > > Andrew> So, for reasons that I don't understand, the type, despite (as far as > Andrew> I can see) having its full definition available, is recorded only as > Andrew> declared in one CU. > > I think this is something the C++ compilers do, which is only emit the > full definition when the "key method" (in this case the destructor) is > also being emitted. > > I don't really recall the details. Basically it's a workaround / > optimization to avoid exploding the debuginfo due to the separate > compilation/header file model. Thank you! That exactly explains what's going on. The test does specifically put just the destructor into a separate .cc file, which corresponds to the CU where we get the full type, with size. > > Andrew> To be clear; the performance issue mentioned in PR gold/15646 is now > Andrew> back again. But my claim is that gold was right all along to include > Andrew> the duplicate index entries, and any performance hit we see as a > Andrew> result, though unfortunate, is just a consequence of doing it right. > > Yes. To some extent I think this was a workaround for the broken C > parser and best_symbol behavior. I.e., addressing a symptom of > excessive CU expansion rather than the (admittedly much more difficult) > cause. > > For the completion issue you pointed out: > > Andrew> The problem specifically called out in the bug report is that > Andrew> namespaces can appear in multiple CUs, and that trying to complete > Andrew> 'ns::misspelled' would expand every CU containing namespace 'ns' due > Andrew> to the duplicate 'ns' type symbols. > > ... do we have a bug for this? I don't know. I'll check, and if not open a new bug report, adding a 'Bug:' tag to the commit message of this patch before pushing. > This also seems like something that could be fixed. For instance > completion could be done from the index as first pass. To be clear, this isn't just a completion issue. The example in PR gold/15646 is for 'break namespace_foo::misspelled', where this is also going to trigger expansion of many CUs. But maybe there's information that we could track better that would allow us to only expand a single CU in some cases? Thanks, Andrew