From patchwork Fri Jun 7 21:03:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33049 Received: (qmail 83784 invoked by alias); 7 Jun 2019 21:03:30 -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 83775 invoked by uid 89); 7 Jun 2019 21:03:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=secret, demangleh, UD:demangle.h, demangle.h X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Jun 2019 21:03:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7D54656108; Fri, 7 Jun 2019 17:03:26 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id w5ZE7vdQlHKc; Fri, 7 Jun 2019 17:03:26 -0400 (EDT) Received: from murgatroyd.Home (174-29-48-168.hlrn.qwest.net [174.29.48.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 26B9556107; Fri, 7 Jun 2019 17:03:26 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Delay allocation of dbx_symfile_info Date: Fri, 7 Jun 2019 15:03:24 -0600 Message-Id: <20190607210324.6294-1-tromey@adacore.com> MIME-Version: 1.0 I noticed that elfread.c always allocates a dbx_symfile_info, even though this is only ever needed in the unusual case of reading stabs in ELF. This patch moves the allocation into dbxread.c, and applies the same treatment to similar code in coffread.c. Regression tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-07 Tom Tromey * elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile data. (elf_new_init): Don't call stabsread_new_init. * dbxread.c (coffstab_build_psymtabs): Set dbx objfile data. (elfstab_build_psymtabs): Likewise. Call stabsread_new_init. * coffread.c (coff_symfile_init): Don't set the dbx objfile data. --- gdb/ChangeLog | 9 +++++++++ gdb/coffread.c | 7 ------- gdb/dbxread.c | 10 ++++++++++ gdb/elfread.c | 12 +----------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 0956f3897b4..6e379dd1e52 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -31,7 +31,6 @@ #include "libcoff.h" /* FIXME secret internal data from BFD */ #include "objfiles.h" #include "buildsym-legacy.h" -#include "gdb-stabs.h" #include "stabsread.h" #include "complaints.h" #include "target.h" @@ -484,12 +483,6 @@ record_minimal_symbol (minimal_symbol_reader &reader, static void coff_symfile_init (struct objfile *objfile) { - struct dbx_symfile_info *dbx; - - /* Allocate struct to keep track of stab reading. */ - dbx = XCNEW (struct dbx_symfile_info); - set_objfile_data (objfile, dbx_objfile_data_key, dbx); - /* Allocate struct to keep track of the symfile. */ coff_objfile_data_key.emplace (objfile); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index ad2edc3ff4b..307debd2824 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2951,6 +2951,10 @@ coffstab_build_psymtabs (struct objfile *objfile, char *name = bfd_get_filename (sym_bfd); unsigned int stabsize; + /* Allocate struct to keep track of stab reading. */ + struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info); + set_objfile_data (objfile, dbx_objfile_data_key, dbx); + DBX_TEXT_ADDR (objfile) = textaddr; DBX_TEXT_SIZE (objfile) = textsize; @@ -3034,6 +3038,12 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect, bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); + stabsread_new_init (); + + /* Allocate struct to keep track of stab reading. */ + struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info); + set_objfile_data (objfile, dbx_objfile_data_key, dbx); + /* Find the first and last text address. dbx_symfile_read seems to want this. */ find_text_range (sym_bfd, objfile); diff --git a/gdb/elfread.c b/gdb/elfread.c index cb98b83f74b..630550b80dc 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -29,7 +29,6 @@ #include "symfile.h" #include "objfiles.h" #include "stabsread.h" -#include "gdb-stabs.h" #include "complaints.h" #include "demangle.h" #include "psympriv.h" @@ -1039,7 +1038,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, long symcount = 0, dynsymcount = 0, synthcount, storage_needed; asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; asymbol *synthsyms; - struct dbx_symfile_info *dbx; if (symtab_create_debug) { @@ -1065,10 +1063,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, minimal_symbol_reader reader (objfile); - /* Allocate struct to keep track of the symfile. */ - dbx = XCNEW (struct dbx_symfile_info); - set_objfile_data (objfile, dbx_objfile_data_key, dbx); - /* Process the normal ELF symbol table first. */ storage_needed = bfd_get_symtab_upper_bound (objfile->obfd); @@ -1316,15 +1310,11 @@ read_psyms (struct objfile *objfile) /* Initialize anything that needs initializing when a completely new symbol file is specified (not just adding some symbols from another file, e.g. a - shared library). - - We reinitialize buildsym, since we may be reading stabs from an ELF - file. */ + shared library). */ static void elf_new_init (struct objfile *ignore) { - stabsread_new_init (); } /* Perform any local cleanups required when we are done with a particular