From patchwork Sat May 12 15:51:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27257 Received: (qmail 44114 invoked by alias); 12 May 2018 15:51:38 -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 44096 invoked by uid 89); 12 May 2018 15:51:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=independently, resubmit, UD:c_str, claims X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.160.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 May 2018 15:51:36 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id C4D404989 for ; Sat, 12 May 2018 10:51:34 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id HWo2fkCv6WCOCHWo2fbkBn; Sat, 12 May 2018 10:51:34 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:36646 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fHWo2-000H4N-Ib; Sat, 12 May 2018 10:51:34 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Use a distinguishing name for minidebug objfile Date: Sat, 12 May 2018 09:51:32 -0600 Message-Id: <20180512155132.1335-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fHWo2-000H4N-Ib X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:36646 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This patch was formerly submitted as part of a series to fix PR cli/19951. I never made the requested changes to that series, but this patch is useful independently, so I thought I would resubmit it. One part of PR cli/19951 is that the mini debug info objfile reuses the name of the main objfile from which it comes. This can be seen because gdb claims to be reading symbols from the same file two times, like: Reading symbols from /bin/gdb...Reading symbols from /bin/gdb...(no debugging symbols found)...done. I think this would be less confusing if the minidebug objfile were given a different name. That is what this patch implements. It also arranges for the minidebug objfile to be marked OBJF_NOT_FILENAME. After this patch the output looks like: Reading symbols from /bin/gdb...Reading symbols from .gnu_debugdata for /usr/libexec/gdb...(no debugging symbols found)...done. Tested by the buildbot. ChangeLog 2018-05-12 Tom Tromey PR cli/19551: * symfile-add-flags.h (enum symfile_add_flags) : New constant. * symfile.c (read_symbols): Use SYMFILE_NOT_FILENAME. Get objfile name from BFD. (symbol_file_add_with_addrs): Check SYMFILE_NOT_FILENAME. * minidebug.c (find_separate_debug_file_in_section): Put ".gnu_debugdata" into BFD's file name. --- gdb/ChangeLog | 11 +++++++++++ gdb/minidebug.c | 5 ++++- gdb/symfile-add-flags.h | 7 +++++-- gdb/symfile.c | 7 +++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gdb/minidebug.c b/gdb/minidebug.c index 693c715d25..7979cb74b5 100644 --- a/gdb/minidebug.c +++ b/gdb/minidebug.c @@ -269,7 +269,10 @@ find_separate_debug_file_in_section (struct objfile *objfile) return NULL; #ifdef HAVE_LIBLZMA - abfd = gdb_bfd_openr_iovec (objfile_name (objfile), gnutarget, lzma_open, + std::string filename = (std::string (".gnu_debugdata for ") + + objfile_name (objfile)); + + abfd = gdb_bfd_openr_iovec (filename.c_str (), gnutarget, lzma_open, section, lzma_pread, lzma_close, lzma_stat); if (abfd == NULL) return NULL; diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h index f07ba7924b..3c07513e39 100644 --- a/gdb/symfile-add-flags.h +++ b/gdb/symfile-add-flags.h @@ -40,8 +40,11 @@ enum symfile_add_flag /* Do not immediately read symbols for this file. By default, symbols are read when the objfile is created. */ - SYMFILE_NO_READ = 1 << 4 - }; + SYMFILE_NO_READ = 1 << 4, + + /* The new objfile should be marked OBJF_NOT_FILENAME. */ + SYMFILE_NOT_FILENAME = 1 << 5, + }; DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags); diff --git a/gdb/symfile.c b/gdb/symfile.c index b0a5f11834..1f5d761877 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -808,8 +808,9 @@ read_symbols (struct objfile *objfile, symfile_add_flags add_flags) virtual section-as-bfd like the bfd filename containing the section. Therefore use also non-canonical name form for the same file containing the section. */ - symbol_file_add_separate (abfd.get (), objfile->original_name, - add_flags, objfile); + symbol_file_add_separate (abfd.get (), + bfd_get_filename (abfd.get ()), + add_flags | SYMFILE_NOT_FILENAME, objfile); } } if ((add_flags & SYMFILE_NO_READ) == 0) @@ -1079,6 +1080,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, flags |= OBJF_READNEVER; add_flags |= SYMFILE_NO_READ; } + if ((add_flags & SYMFILE_NOT_FILENAME) != 0) + flags |= OBJF_NOT_FILENAME; /* Give user a chance to burp if we'd be interactively wiping out any existing symbols. */