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 7F7CC3935DCE for ; Wed, 5 Jun 2024 13:15:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F7CC3935DCE Authentication-Results: sourceware.org; dmarc=pass (p=none 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 7F7CC3935DCE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717593331; cv=none; b=VAo9WvN4sFSr/WhhAyahHcQeRksWMFreHKTQcoUlnfINvVlirj7zJCk0q7YbgqIV93y+gXc3KdWTBUPDBbpV6nd7xV2vW6RYoIjImmNAGo4At+T1xaQbvjPiKqxYdx1+Ull/4OSYJg0uZjaJ19L3bXdJULcKAHqLY3o1k/f5wKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717593331; c=relaxed/simple; bh=fnmN5HpMp5rUsoBEnYOVyXqDgceCBaUA1Aa/rEgjPtw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ju1VGNfM96mkoEZfH4xMT9FZQ0yNAybvyRL615blK6EM7/pu4mJS0P0wgOzaFIvgKPpLZFu3+nFfDE+wjlaXSJr3MXr7vGErmWCS15aXikHin2RXaqrGmiCtY89fLVPE0ux9BkxxPEaz8p9w+Cp0N2daLV5m7G0Y+H6aPOwnQv8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717593327; 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=CpsCX5tAjGn+ew/NxSq+eWbuR0Ru0I6tMJFDUzJ/uNg=; b=AkweE+nFsE/v34/hEBU8mK7fMDjEmyDjJo++P1YkREo/CUBrghWb00CIpYbUImXf2EjS6M aNVUaXFkiC+0pTUMTXii5oPsdvHuqgOWFPsc2L86J0/GXOiHG8GpN3bthyKXX6WSFd5x9Q cvT/b/wr3dfZ97rXuO0mVyLaqIlAp5o= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-Rs-o6DVKP6CspSIoZGg4Ew-1; Wed, 05 Jun 2024 09:15:25 -0400 X-MC-Unique: Rs-o6DVKP6CspSIoZGg4Ew-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-35dced40d17so1562415f8f.2 for ; Wed, 05 Jun 2024 06:15:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717593323; x=1718198123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CpsCX5tAjGn+ew/NxSq+eWbuR0Ru0I6tMJFDUzJ/uNg=; b=aWffPRz3F6eB7kkITrl+12QpQZjEm4q8ZbG1M12HpMDnDaKn1axZOFy3B6xWZmv7Nk oA77/FdOQHh53laCvXaJlNow29spItV0wAWnc0fa3pKEFITzwtEkcsDrWLz79nj524as Oyu2bPWIIvH+mFY3Zqj4q2EQLY0ZTuhH5KNpnvGciPE7T8TLYzBT/7AEpR5eF7kzhzce D3rsiZiYwY2qproDkmy9TnsYn36WS1jCG77wQjPjbdKdrk1YxnGH+UV65Q7tIU8pZPYq rT+9FHduflhkVBWpcvipVESvgCWX6FCDNc9ZjhIr61NbNfqJfmeHcbXWFDq+TIPcO7fy SFRA== X-Gm-Message-State: AOJu0YxvTSUTp+WQ2osV9Xa7jbbk5BKtIl913RYO1bl7Vicql39CX5J5 5jX+YjfeAskEwF7sB47AQtMHpEyRGdp/ej8r55Fmyc3bgpO6uvgMOfkopWcTsw3HxdIGE0E32Fw y7uARPYc1ifR4qfNBOJSuDULsPckObtBZku6QIWQr7w/gdvt5E/XpnmbSZWhltjee6L94lA+pEm FY5xLaBk0A0DG1x19bXaHiOdmylu6SeS0RMGAdYW1oTvQ= X-Received: by 2002:a05:6000:d0e:b0:352:e4d5:5e12 with SMTP id ffacd0b85a97d-35e883384bdmr1876466f8f.20.1717593322992; Wed, 05 Jun 2024 06:15:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhiZrivyI9VhRR3xyWBqVBpCv6KCnSbps3OGT38mR2nibisKh0zs+9lpf16WSRwTo+V+kK4w== X-Received: by 2002:a05:6000:d0e:b0:352:e4d5:5e12 with SMTP id ffacd0b85a97d-35e883384bdmr1876442f8f.20.1717593322478; Wed, 05 Jun 2024 06:15:22 -0700 (PDT) Received: from localhost ([31.111.84.186]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04d94f1sm14434374f8f.49.2024.06.05.06.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:15:21 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/8] gdb: avoid duplicate search in build_id_to_bfd_suffix Date: Wed, 5 Jun 2024 14:15:09 +0100 Message-Id: <73ed48bbf664b57cb76402b54558fd9ad8ae7d92.1717592684.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.4 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_H4,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: In build_id_to_bfd_suffix we look in each debug-file-directory for a file matching the required build-id. If we don't find one then we add the sysroot and perform the search again. However, the default sysroot is 'target:', and for a native target this just means to search on the local machine. So by default, if the debug information is not present, then we end up searching each location twice. I think we only need to perform the "with sysroot" check if either: 1. The sysroot is something other than 'target:'. If the user has set it to '/some/directory' then we should check this sysroot. Or if the user has set it to 'target:/some/other_directory', this is also worth checking. 2. If the sysroot is 'target:', but the target's filesystem is not local (i.e. the user is connected to a remote target), then we should check using the sysroot as this will be looking on the remote machine. There's no tests for this as the whole point here is that I'm removing duplicate work. No test regressions were seen though. There should be no user visible changes after this commit. --- gdb/build-id.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/build-id.c b/gdb/build-id.c index 41667d5e5cf..fe0494ae54e 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -176,9 +176,15 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, /* Try to look under the sysroot as well. If the sysroot is "/the/sysroot", it will give - "/the/sysroot/usr/lib/debug/.build-id/ab/cdef.debug". */ + "/the/sysroot/usr/lib/debug/.build-id/ab/cdef.debug". - if (!gdb_sysroot.empty ()) + If the sysroot is 'target:' and the target filesystem is local to + GDB then 'target:/path/to/check' becomes '/path/to/check' which + we just checked above. */ + + if (!gdb_sysroot.empty () + && (gdb_sysroot != TARGET_SYSROOT_PREFIX + || !target_filesystem_is_local ())) { link = gdb_sysroot + link; debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id); -- 2.25.4