From patchwork Wed Dec 26 16:52: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: 30847 Received: (qmail 87510 invoked by alias); 26 Dec 2018 16:52:18 -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 86438 invoked by uid 89); 26 Dec 2018 16:52:17 -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_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=certain, significant, candidate, enhance X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Dec 2018 16:52:15 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id wBQGq6M0016070 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Dec 2018 11:52:10 -0500 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E4B851E059; Wed, 26 Dec 2018 11:52:05 -0500 (EST) From: Simon Marchi Subject: Re: [PATCH] Improve "set debug separate-debug-file" To: Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org References: <20181221221852.2960-1-simon.marchi@ericsson.com> <874lb2r6is.fsf@tromey.com> Message-ID: Date: Wed, 26 Dec 2018 11:52:05 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <874lb2r6is.fsf@tromey.com> X-IsSubscribed: yes On 2018-12-24 15:53, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> "set debug separate-debug-file" shows which candidates are > considered, > Simon> when trying to find separate debug info. But it's not clear if > GDB used > Simon> a certain candidate, and if not, why not. This patch adds some > Simon> precision: > > This seems good to me. > > Simon> if (separate_debug_file_debug) > Simon> - printf_unfiltered (_(" Trying %s\n"), link.c_str ()); > Simon> + printf_unfiltered (_(" Trying %s..."), link.c_str ()); > > It probably (?) doesn't matter here but normally there should be a call > to gdb_flush as well. Yeah, I didn't add it because I know it was always going to be following with another printf with a \n. And there should not be significant time between both are printed. I was going to add a comment explaining why there was no flush, but at this point I thought it would just be simpler to add the flush :). Here's what I pushed: From 50794b45a2a7330fc32b118bff584a3a2e649ac5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 26 Dec 2018 11:49:51 -0500 Subject: [PATCH] Improve "set debug separate-debug-file" "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/ChangeLog | 5 +++++ gdb/build-id.c | 31 +++++++++++++++++++++++++++---- gdb/symfile.c | 39 ++++++++++++++++++++++++++++++++++----- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c37e281740b5..425429e07f86 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-12-26 Simon Marchi + + * build-id.c (build_id_to_debug_bfd): Enhance debug output. + * symfile.c (separate_debug_file_exists): Likewise. + 2018-12-24 Andrew Burgess * c-exp.y (field_name): Allow DOUBLE_KEYWORD, INT_KEYWORD, LONG, diff --git a/gdb/build-id.c b/gdb/build-id.c index c8eacbd1e81c..ea6b61db0abd 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -98,7 +98,10 @@ 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 ()); + gdb_flush (gdb_stdout); + } /* lrealpath() is expensive even for the usually non-existent files. */ gdb::unique_xmalloc_ptr filename; @@ -106,16 +109,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 8ab6a25de7c3..991b71fc7727 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1285,12 +1285,20 @@ 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_flush (gdb_stdout); + } 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 +1317,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 +1331,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 +1349,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 +1362,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; }