From patchwork Fri Dec 21 22:19:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 30812 Received: (qmail 71172 invoked by alias); 21 Dec 2018 22:19:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 71155 invoked by uid 89); 21 Dec 2018 22:19:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=yes!, candidate, 987, buildid X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Dec 2018 22:19:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1545430747; x=1548022747; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2dIxYBEDIK+AcAkjlpBFU9cUDlUzUwMtviE3Apj3DVw=; b=bf8xlnwYdwR/NFvg3S8jUpC3ziwQELPoHPUgYpo0PsgR68R2E3xfGJQigcUIemTM f6/+lc7aN3XpV2mTfyCAxJTszu/R6OsxbU+jCN4FAoL/d25r4dr6DY4tnDzmBlWn 4/z+y208d48+ISUwl4NuyQvUfVLW4iXG7X0mMWJar0A=; Received: from ESESSMB504.ericsson.se (Unknown_Domain [153.88.183.122]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 29.CA.13660.BD66D1C5; Fri, 21 Dec 2018 23:19:07 +0100 (CET) Received: from ESESBMR502.ericsson.se (153.88.183.134) by ESESSMB504.ericsson.se (153.88.183.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 21 Dec 2018 23:19:07 +0100 Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESBMR502.ericsson.se (153.88.183.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 21 Dec 2018 23:19:07 +0100 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Fri, 21 Dec 2018 23:19:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2dIxYBEDIK+AcAkjlpBFU9cUDlUzUwMtviE3Apj3DVw=; b=kuVOEcSCxzXw1r7IdMWqwkl84DRbcr9n3lw4TNhBMkVuNRn34qzz3K3zDpFM3hXxt5upUAvOsZi8hIrzEsZEFR5o0PoC5ZQEy+SFwEhkL5roSbLBPGLNpvC5A0kqWgZiK7Q2FPfAix+24/aPteKYrs4uBBSOllKeAwQ+aap8qss= Received: from BYAPR15MB2390.namprd15.prod.outlook.com (52.135.198.30) by BYAPR15MB2437.namprd15.prod.outlook.com (52.135.198.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Fri, 21 Dec 2018 22:19:05 +0000 Received: from BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::a143:f30c:dd42:3af9]) by BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::a143:f30c:dd42:3af9%4]) with mapi id 15.20.1425.025; Fri, 21 Dec 2018 22:19:05 +0000 From: Simon Marchi To: "gdb-patches@sourceware.org" CC: Simon Marchi Subject: [PATCH] Improve "set debug separate-debug-file" Date: Fri, 21 Dec 2018 22:19:05 +0000 Message-ID: <20181221221852.2960-1-simon.marchi@ericsson.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com X-IsSubscribed: yes "set debug separate-debug-file" shows which candidates are considered, when trying to find separate debug info. But it's not clear if GDB used a certain candidate, and if not, why not. This patch adds some precision: Before: Looking for separate debug info (debug link) for /lib/x86_64-linux-gnu/libc.so.6 Trying /lib/x86_64-linux-gnu/libc-2.23.so Trying /lib/x86_64-linux-gnu/.debug/libc-2.23.so Trying /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.23.so After: Looking for separate debug info (debug link) for /lib/x86_64-linux-gnu/libc.so.6 Trying /lib/x86_64-linux-gnu/libc-2.23.so... no, same file as the objfile. Trying /lib/x86_64-linux-gnu/.debug/libc-2.23.so... no, unable to open. Trying /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.23.so... yes! gdb/ChangeLog: * build-id.c (build_id_to_debug_bfd): Enhance debug output. * symfile.c (separate_debug_file_exists): Likewise. --- gdb/build-id.c | 28 ++++++++++++++++++++++++---- gdb/symfile.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/gdb/build-id.c b/gdb/build-id.c index c8eacbd1e81..1211d88a8ad 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -98,7 +98,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) link += ".debug"; if (separate_debug_file_debug) - printf_unfiltered (_(" Trying %s\n"), link.c_str ()); + printf_unfiltered (_(" Trying %s..."), link.c_str ()); /* lrealpath() is expensive even for the usually non-existent files. */ gdb::unique_xmalloc_ptr filename; @@ -106,16 +106,36 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) filename.reset (lrealpath (link.c_str ())); if (filename == NULL) - continue; + { + if (separate_debug_file_debug) + printf_unfiltered (_(" no, unable to compute real path\n")); + + continue; + } /* We expect to be silent on the non-existing files. */ abfd = gdb_bfd_open (filename.get (), gnutarget, -1); if (abfd == NULL) - continue; + { + if (separate_debug_file_debug) + printf_unfiltered (_(" no, unable to open.\n")); + + continue; + } if (build_id_verify (abfd.get(), build_id_len, build_id)) - break; + { + if (separate_debug_file_debug) + printf_unfiltered (_(" yes!\n")); + + break; + } + else + { + if (separate_debug_file_debug) + printf_unfiltered (_(" no, build-id does not match.\n")); + } abfd.release (); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 8ab6a25de7c..c5e2661415f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1285,12 +1285,17 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, return 0; if (separate_debug_file_debug) - printf_filtered (_(" Trying %s\n"), name.c_str ()); + printf_filtered (_(" Trying %s..."), name.c_str ()); gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1)); if (abfd == NULL) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, unable to open.\n")); + + return 0; + } /* Verify symlinks were not the cause of filename_cmp name difference above. @@ -1309,7 +1314,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, { if (abfd_stat.st_dev == parent_stat.st_dev && abfd_stat.st_ino == parent_stat.st_ino) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, same file as the objfile.\n")); + + return 0; + } verified_as_different = 1; } else @@ -1318,7 +1328,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, file_crc_p = gdb_bfd_crc (abfd.get (), &file_crc); if (!file_crc_p) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, error computing CRC.\n")); + + return 0; + } if (crc != file_crc) { @@ -1331,7 +1346,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, if (!verified_as_different) { if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc)) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, error computing CRC.\n")); + + return 0; + } } if (verified_as_different || parent_crc != file_crc) @@ -1339,9 +1359,15 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, " does not match \"%s\" (CRC mismatch).\n"), name.c_str (), objfile_name (parent_objfile)); + if (separate_debug_file_debug) + printf_filtered (_(" no, CRC doesn't match.\n")); + return 0; } + if (separate_debug_file_debug) + printf_filtered (_(" yes!\n")); + return 1; }