From patchwork Sun Nov 25 19:20:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30291 Received: (qmail 29661 invoked by alias); 25 Nov 2018 19:20:54 -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 29506 invoked by uid 89); 25 Nov 2018 19:20:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=5367 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; Sun, 25 Nov 2018 19:20:48 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 379B44277 for ; Sun, 25 Nov 2018 13:20:47 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QzxXgS0qyBcCXQzxXgXuPG; Sun, 25 Nov 2018 13:20:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1r6KK+a4Ps1dBgBEQof0DHc3Ge45N6RkC8UHye0UnJU=; b=PvZj9qxBCbGKQx8p0J9DiKKzxy bQWwfXInye3P69DgY1+ZRi0shC0MRRG6+kUI66n3oO1Ba0lefikDZ5f7hu2gb8SGguMr8+8quRGXp f58D1uxoATfLxKauh2BUkmL5g; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:52060 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQzxX-001TOx-0O; Sun, 25 Nov 2018 13:20:47 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 03/12] Simplify calls to init_psymbol_list Date: Sun, 25 Nov 2018 12:20:34 -0700 Message-Id: <20181125192043.8405-4-tom@tromey.com> In-Reply-To: <20181125192043.8405-1-tom@tromey.com> References: <20181125192043.8405-1-tom@tromey.com> Existing callers to init_psymbol_list were checking to see if psymbols had already been initialized. It seemed better to me to do this check directly in init_psymbol_list, simplifying the callers. gdb/ChangeLog 2018-11-25 Tom Tromey * xcoffread.c (xcoff_initial_scan): Unconditionally call init_psymbol_list. * psymtab.c (init_psymbol_list): Do nothing if already called. * psympriv.h (init_psymbol_list): Add comment. * dwarf2read.c (dwarf2_build_psymtabs): Unconditionally call init_psymbol_list. * dbxread.c (dbx_symfile_read): Unconditionally call init_psymbol_list. --- gdb/ChangeLog | 11 +++++++++++ gdb/dbxread.c | 4 +--- gdb/dwarf2read.c | 4 +--- gdb/psympriv.h | 6 +++++- gdb/psymtab.c | 21 +++++++++++---------- gdb/xcoffread.c | 13 +++++-------- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index abcd2f9048..7130bb13b4 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -536,9 +536,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) perror_with_name (objfile_name (objfile)); /* Size the symbol table. */ - if (objfile->global_psymbols.capacity () == 0 - && objfile->static_psymbols.capacity () == 0) - init_psymbol_list (objfile, DBX_SYMCOUNT (objfile)); + init_psymbol_list (objfile, DBX_SYMCOUNT (objfile)); symbol_size = DBX_SYMBOL_SIZE (objfile); symbol_table_offset = DBX_SYMTAB_OFFSET (objfile); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 355015865d..9fceb9e7cc 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6293,9 +6293,7 @@ dwarf2_build_psymtabs (struct objfile *objfile) struct dwarf2_per_objfile *dwarf2_per_objfile = get_dwarf2_per_objfile (objfile); - if (objfile->global_psymbols.capacity () == 0 - && objfile->static_psymbols.capacity () == 0) - init_psymbol_list (objfile, 1024); + init_psymbol_list (objfile, 1024); TRY { diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 03d666740e..b28c946a87 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -290,7 +290,11 @@ extern void add_psymbol_to_list (const char *, int, CORE_ADDR, enum language, struct objfile *); -extern void init_psymbol_list (struct objfile *, int); +/* Initialize storage for partial symbols. If partial symbol storage + has already been initialized, this does nothing. TOTAL_SYMBOLS is + an estimate of how many symbols there will be. */ + +extern void init_psymbol_list (struct objfile *objfile, int total_symbols); extern struct partial_symtab *start_psymtab_common (struct objfile *, const char *, CORE_ADDR); diff --git a/gdb/psymtab.c b/gdb/psymtab.c index b157603396..31c0d4d6a2 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1704,20 +1704,21 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name, append_psymbol_to_list (list, psym, objfile); } -/* Initialize storage for partial symbols. */ +/* See psympriv.h. */ void init_psymbol_list (struct objfile *objfile, int total_symbols) { - /* Free any previously allocated psymbol lists. */ - objfile->global_psymbols.clear (); - objfile->static_psymbols.clear (); - - /* Current best guess is that approximately a twentieth - of the total symbols (in a debugging file) are global or static - oriented symbols, then multiply that by slop factor of two. */ - objfile->global_psymbols.reserve (total_symbols / 10); - objfile->static_psymbols.reserve (total_symbols / 10); + if (objfile->global_psymbols.capacity () == 0 + && objfile->static_psymbols.capacity () == 0) + { + /* Current best guess is that approximately a twentieth of the + total symbols (in a debugging file) are global or static + oriented symbols, then multiply that by slop factor of + two. */ + objfile->global_psymbols.reserve (total_symbols / 10); + objfile->static_psymbols.reserve (total_symbols / 10); + } } /* See psympriv.h. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 029f3546aa..daff10db43 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2991,14 +2991,11 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags) if (val != size) perror_with_name (_("reading symbol table")); - /* If we are reinitializing, or if we have never loaded syms yet, init. */ - if (objfile->global_psymbols.capacity () == 0 - && objfile->static_psymbols.capacity () == 0) - /* I'm not sure how how good num_symbols is; the rule of thumb in - init_psymbol_list was developed for a.out. On the one hand, - num_symbols includes auxents. On the other hand, it doesn't - include N_SLINE. */ - init_psymbol_list (objfile, num_symbols); + /* I'm not sure how how good num_symbols is; the rule of thumb in + init_psymbol_list was developed for a.out. On the one hand, + num_symbols includes auxents. On the other hand, it doesn't + include N_SLINE. */ + init_psymbol_list (objfile, num_symbols); scoped_free_pendings free_pending; minimal_symbol_reader reader (objfile);