From patchwork Sun Jan 26 23:41:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 37563 Received: (qmail 43256 invoked by alias); 26 Jan 2020 23:41:36 -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 42723 invoked by uid 89); 26 Jan 2020 23:41:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.1 spammy=dwarf2_cu X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Jan 2020 23:41:29 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 9528E20456; Sun, 26 Jan 2020 18:41:28 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 015DB20A75; Sun, 26 Jan 2020 18:41:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id D7F2E20AF7; Sun, 26 Jan 2020 18:41:10 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Sun, 26 Jan 2020 18:41:07 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] Introduce partial_symtab::expand_psymtab method X-Gerrit-Change-Id: Ic39a2d7aa7b424088d910b59dbd21271fa1c3430 X-Gerrit-Change-Number: 381 X-Gerrit-ChangeURL: X-Gerrit-Commit: 8566b89b737eef50f67bf23329b4606cf7973de1 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20200126234110.D7F2E20AF7@gnutoolchain-gerrit.osci.io> The original change was created by Tom Tromey. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/381 ...................................................................... Introduce partial_symtab::expand_psymtab method The symbol readers generally used two functions to expand a partial symtab: an outer function (now the "read_symtab" method), and an inner function, typically named something like "psymtab_to_symtab". This patch changes this second step to be a method on partial_symtab, and updates all the callers. For legacy_psymtab, a new function pointer member is introduced. This patch enables a subsequent cleanup. gdb/ChangeLog 2020-01-26 Tom Tromey * xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (xcoff_read_symtab): Call expand_psymtab. (xcoff_start_psymtab, xcoff_end_psymtab): Set legacy_expand_psymtab. * psympriv.h (struct partial_symtab) : New method. (struct legacy_psymtab) : Implement. : New member. * mdebugread.c (mdebug_read_symtab): Call expand_psymtab. (parse_partial_symbols): Set legacy_expand_psymtab. (psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (new_psymtab): Set legacy_expand_psymtab. * dwarf2read.h (struct dwarf2_psymtab) : Declare. * dwarf2read.c (dwarf2_psymtab::read_symtab): Call expand_psymtab. (dwarf2_psymtab::expand_psymtab): Rename from psymtab_to_symtab_1. Call expand_psymtab. * dbxread.c (start_psymtab): Set legacy_expand_psymtab. (dbx_end_psymtab): Likewise. (dbx_psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (dbx_read_symtab): Call expand_psymtab. * ctfread.c (struct ctf_psymtab) : Declare. (ctf_psymtab::expand_psymtab): Rename from psymtab_to_symtab. (ctf_psymtab::read_symtab): Call expand_psymtab. Change-Id: Ic39a2d7aa7b424088d910b59dbd21271fa1c3430 --- M gdb/ChangeLog M gdb/ctfread.c M gdb/dbxread.c M gdb/dwarf2read.c M gdb/dwarf2read.h M gdb/mdebugread.c M gdb/psympriv.h M gdb/xcoffread.c 8 files changed, 82 insertions(+), 38 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ed3b97b..c6a0251 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,35 @@ 2020-01-26 Tom Tromey + * xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order. + Call expand_psymtab. + (xcoff_read_symtab): Call expand_psymtab. + (xcoff_start_psymtab, xcoff_end_psymtab): Set + legacy_expand_psymtab. + * psympriv.h (struct partial_symtab) : New + method. + (struct legacy_psymtab) : Implement. + : New member. + * mdebugread.c (mdebug_read_symtab): Call expand_psymtab. + (parse_partial_symbols): Set legacy_expand_psymtab. + (psymtab_to_symtab_1): Change argument order. Call + expand_psymtab. + (new_psymtab): Set legacy_expand_psymtab. + * dwarf2read.h (struct dwarf2_psymtab) : Declare. + * dwarf2read.c (dwarf2_psymtab::read_symtab): Call + expand_psymtab. + (dwarf2_psymtab::expand_psymtab): Rename from + psymtab_to_symtab_1. Call expand_psymtab. + * dbxread.c (start_psymtab): Set legacy_expand_psymtab. + (dbx_end_psymtab): Likewise. + (dbx_psymtab_to_symtab_1): Change argument order. Call + expand_psymtab. + (dbx_read_symtab): Call expand_psymtab. + * ctfread.c (struct ctf_psymtab) : Declare. + (ctf_psymtab::expand_psymtab): Rename from psymtab_to_symtab. + (ctf_psymtab::read_symtab): Call expand_psymtab. + +2020-01-26 Tom Tromey + * xcoffread.c (xcoff_read_symtab): Remove prints. Add assert. * psymtab.c (psymtab_to_symtab): Print verbose "Reading" messages. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 120c7b4..77cdcd4 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -124,6 +124,7 @@ } void read_symtab (struct objfile *) override; + void expand_psymtab (struct objfile *) override; struct ctf_context *context; }; @@ -160,8 +161,6 @@ /* Local function prototypes */ -static void psymtab_to_symtab (ctf_psymtab *); - static int ctf_add_type_cb (ctf_id_t tid, void *arg); static struct type *read_array_type (struct ctf_context *cp, ctf_id_t tid); @@ -1216,15 +1215,15 @@ /* Read in full symbols for PST, and anything it depends on. */ -static void -psymtab_to_symtab (ctf_psymtab *pst) +void +ctf_psymtab::expand_psymtab (struct objfile *objfile) { struct symbol *sym; struct ctf_context *ccp; - gdb_assert (!pst->readin); + gdb_assert (!readin); - ccp = pst->context; + ccp = context; /* Iterate over entries in data types section. */ if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR) @@ -1254,7 +1253,7 @@ set_symbol_address (ccp->of, sym, sym->linkage_name ()); } - pst->readin = true; + readin = true; } /* Expand partial symbol table PST into a full symbol table. @@ -1279,7 +1278,7 @@ offset = get_objfile_text_range (objfile, &tsize); ctf_start_symtab (this, objfile, offset); - psymtab_to_symtab (this); + expand_psymtab (objfile); set_text_low (offset); set_text_high (offset + tsize); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 9d8d938..2711ea8 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -268,7 +268,7 @@ static void dbx_read_symtab (legacy_psymtab *self, struct objfile *objfile); -static void dbx_psymtab_to_symtab_1 (struct objfile *, legacy_psymtab *); +static void dbx_psymtab_to_symtab_1 (legacy_psymtab *, struct objfile *); static void read_dbx_symtab (minimal_symbol_reader &, struct objfile *); @@ -1909,6 +1909,7 @@ XOBNEW (&objfile->objfile_obstack, struct symloc); LDSYMOFF (result) = ldsymoff; result->legacy_read_symtab = dbx_read_symtab; + result->legacy_expand_psymtab = dbx_psymtab_to_symtab_1; SYMBOL_SIZE (result) = symbol_size; SYMBOL_OFFSET (result) = symbol_table_offset; STRING_OFFSET (result) = string_table_offset; @@ -2039,6 +2040,7 @@ subpst->number_of_dependencies = 1; subpst->legacy_read_symtab = pst->legacy_read_symtab; + subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab; } if (num_includes == 0 @@ -2064,7 +2066,7 @@ } static void -dbx_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst) +dbx_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile) { int i; @@ -2091,8 +2093,7 @@ wrap_here (""); /* Flush output. */ gdb_flush (gdb_stdout); } - dbx_psymtab_to_symtab_1 (objfile, - (legacy_psymtab *) pst->dependencies[i]); + pst->dependencies[i]->expand_psymtab (objfile); } if (LDSYMLEN (pst)) /* Otherwise it's a dummy. */ @@ -2135,7 +2136,7 @@ data_holder.reset (stabs_data); } - dbx_psymtab_to_symtab_1 (objfile, self); + self->expand_psymtab (objfile); } /* Match with global symbols. This only needs to be done once, diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 9942270..c3e0866 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1513,8 +1513,6 @@ CORE_ADDR *lowpc, CORE_ADDR *highpc, int need_pc, struct dwarf2_cu *cu); -static void psymtab_to_symtab_1 (dwarf2_psymtab *); - static abbrev_table_up abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *, sect_offset); @@ -9510,7 +9508,7 @@ dwarf2_per_objfile->reading_partial_symbols = 0; - psymtab_to_symtab_1 (this); + expand_psymtab (objfile); process_cu_includes (dwarf2_per_objfile); } @@ -9661,18 +9659,18 @@ /* Read in full symbols for PST, and anything it depends on. */ -static void -psymtab_to_symtab_1 (dwarf2_psymtab *pst) +void +dwarf2_psymtab::expand_psymtab (struct objfile *objfile) { struct dwarf2_per_cu_data *per_cu; int i; - if (pst->readin) + if (readin) return; - for (i = 0; i < pst->number_of_dependencies; i++) - if (!pst->dependencies[i]->readin - && pst->dependencies[i]->user == NULL) + for (i = 0; i < number_of_dependencies; i++) + if (!dependencies[i]->readin + && dependencies[i]->user == NULL) { /* Inform about additional files that need to be read in. */ if (info_verbose) @@ -9682,20 +9680,20 @@ wrap_here (""); fputs_filtered ("and ", gdb_stdout); wrap_here (""); - printf_filtered ("%s...", pst->dependencies[i]->filename); + printf_filtered ("%s...", dependencies[i]->filename); wrap_here (""); /* Flush output. */ gdb_flush (gdb_stdout); } - psymtab_to_symtab_1 ((dwarf2_psymtab *) pst->dependencies[i]); + dependencies[i]->expand_psymtab (objfile); } - per_cu = pst->per_cu_data; + per_cu = per_cu_data; if (per_cu == NULL) { /* It's an include file, no symbols to read for it. Everything is in the parent symtab. */ - pst->readin = true; + readin = true; return; } diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 06bd908..c5b6902 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -285,6 +285,7 @@ } void read_symtab (struct objfile *) override; + void expand_psymtab (struct objfile *) override; struct dwarf2_per_cu_data *per_cu_data; }; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4b32a5a..1d0a0fc 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -253,8 +253,8 @@ static legacy_psymtab *new_psymtab (const char *, struct objfile *); -static void psymtab_to_symtab_1 (struct objfile *objfile, - legacy_psymtab *, const char *); +static void psymtab_to_symtab_1 (legacy_psymtab *pst, + struct objfile *objfile); static void add_block (struct block *, struct symtab *); @@ -279,7 +279,7 @@ { next_symbol_text_func = mdebug_next_symbol_text; - psymtab_to_symtab_1 (objfile, self, self->filename); + self->expand_psymtab (objfile); /* Match with global symbols. This only needs to be done once, after all of the symtabs and dependencies have been read in. */ @@ -2613,6 +2613,7 @@ /* The way to turn this into a symtab is to call... */ pst->legacy_read_symtab = mdebug_read_symtab; + pst->legacy_expand_psymtab = psymtab_to_symtab_1; /* Set up language for the pst. The language from the FDR is used if it is unambigious (e.g. cfront @@ -3834,8 +3835,7 @@ The flow of control and even the memory allocation differs. FIXME. */ static void -psymtab_to_symtab_1 (struct objfile *objfile, - legacy_psymtab *pst, const char *filename) +psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile) { bfd_size_type external_sym_size; bfd_size_type external_pdr_size; @@ -3872,9 +3872,7 @@ wrap_here (""); /* Flush output */ gdb_flush (gdb_stdout); } - /* We only pass the filename for debug purposes. */ - psymtab_to_symtab_1 (objfile, (legacy_psymtab *) pst->dependencies[i], - pst->dependencies[i]->filename); + pst->dependencies[i]->expand_psymtab (objfile); } /* Do nothing if this is a dummy psymtab. */ @@ -4664,6 +4662,7 @@ /* The way to turn this into a symtab is to call... */ psymtab->legacy_read_symtab = mdebug_read_symtab; + psymtab->legacy_expand_psymtab = psymtab_to_symtab_1; return (psymtab); } diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 4c189aa..ae98a69 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -129,6 +129,11 @@ table. */ virtual void read_symtab (struct objfile *) = 0; + /* Psymtab expansion is done in two steps. The first step is a call + to read_symtab; but while that is in progress, calls to + expand_psymtab can be made. */ + virtual void expand_psymtab (struct objfile *) = 0; + /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const { @@ -311,11 +316,21 @@ (*legacy_read_symtab) (this, objf); } + void expand_psymtab (struct objfile *objf) override + { + (*legacy_expand_psymtab) (this, objf); + } + /* Pointer to function which will read in the symtab corresponding to this psymtab. */ void (*legacy_read_symtab) (legacy_psymtab *, struct objfile *) = nullptr; + /* Pointer to function which will actually expand this psymtab into + a full symtab. */ + + void (*legacy_expand_psymtab) (legacy_psymtab *, struct objfile *) = nullptr; + /* Information that lets read_symtab() locate the part of the symbol table that this psymtab corresponds to. This information is private to the format-dependent symbol reading routines. For further detail examine diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 66d6b9a..1c0db67 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1817,7 +1817,7 @@ } static void -xcoff_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst) +xcoff_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile) { int i; @@ -1847,8 +1847,7 @@ wrap_here (""); /* Flush output */ gdb_flush (gdb_stdout); } - xcoff_psymtab_to_symtab_1 (objfile, - (legacy_psymtab *) pst->dependencies[i]); + pst->dependencies[i]->expand_psymtab (objfile); } if (((struct symloc *) pst->read_symtab_private)->numsyms != 0) @@ -1876,7 +1875,7 @@ { next_symbol_text_func = xcoff_next_symbol_text; - xcoff_psymtab_to_symtab_1 (objfile, self); + self->expand_psymtab (objfile); /* Match with global symbols. This only needs to be done once, after all of the symtabs and dependencies have been read in. */ @@ -1997,6 +1996,7 @@ XOBNEW (&objfile->objfile_obstack, struct symloc); ((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum; result->legacy_read_symtab = xcoff_read_symtab; + result->legacy_expand_psymtab = xcoff_psymtab_to_symtab_1; /* Deduce the source language from the filename for this psymtab. */ psymtab_language = deduce_language_from_filename (filename); @@ -2059,6 +2059,7 @@ subpst->number_of_dependencies = 1; subpst->legacy_read_symtab = pst->legacy_read_symtab; + subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab; } if (num_includes == 0