From patchwork Mon Oct 28 02:03:17 2019 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: 35393 Received: (qmail 123565 invoked by alias); 28 Oct 2019 02:10:57 -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 123457 invoked by uid 89); 28 Oct 2019 02:10:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=328, 9, finishing, 3289 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; Mon, 28 Oct 2019 02:10:52 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id F3C23211BA; Sun, 27 Oct 2019 22:03:22 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id EC0B9210A7 for ; Sun, 27 Oct 2019 22:03:17 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id BD34020AF6 for ; Sun, 27 Oct 2019 22:03:17 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Sun, 27 Oct 2019 22:03:17 -0400 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Turn start_psymtab_common into a constructor X-Gerrit-Change-Id: I5a0217bcb52bcfa442559771954bb66bd9ccbf02 X-Gerrit-Change-Number: 378 X-Gerrit-ChangeURL: X-Gerrit-Commit: 5e744d04708b8e863949ba14cfe27544bea412e0 References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-74-g460fb0f7e9 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/378 ...................................................................... Turn start_psymtab_common into a constructor This turns start_psymtab_common into a constructor, and then changes the callers to use "new" directly. This completes the psymtab allocation transition -- now it is possible for symbol readers to subclass struct partial_symtab. gdb/ChangeLog 2019-10-27 Tom Tromey * xcoffread.c (xcoff_start_psymtab): Use new. * psymtab.c (partial_symtab::partial_symtab): New constructor, renamed from start_psymtab_common. * psympriv.h (struct partial_symtab): Add new constructor. (start_psymtab_common): Don't declare. * mdebugread.c (parse_partial_symbols): Use new. * dwarf2read.c (create_partial_symtab): Use new. * dbxread.c (start_psymtab): Use new. * ctfread.c (create_partial_symtab): Use new. Change-Id: I5a0217bcb52bcfa442559771954bb66bd9ccbf02 --- M gdb/ChangeLog M gdb/ctfread.c M gdb/dbxread.c M gdb/dwarf2read.c M gdb/mdebugread.c M gdb/psympriv.h M gdb/psymtab.c M gdb/xcoffread.c 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0eabe55..7918ec3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2019-10-27 Tom Tromey + * xcoffread.c (xcoff_start_psymtab): Use new. + * psymtab.c (partial_symtab::partial_symtab): New constructor, + renamed from start_psymtab_common. + * psympriv.h (struct partial_symtab): Add new constructor. + (start_psymtab_common): Don't declare. + * mdebugread.c (parse_partial_symbols): Use new. + * dwarf2read.c (create_partial_symtab): Use new. + * dbxread.c (start_psymtab): Use new. + * ctfread.c (create_partial_symtab): Use new. + +2019-10-27 Tom Tromey + * xcoffread.c (xcoff_end_psymtab): Use new. * psymtab.c (start_psymtab_common): Use new. (partial_symtab::partial_symtab): Rename from allocate_psymtab. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 90a1b8c..3e3e318 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -1302,7 +1302,7 @@ struct partial_symtab *pst; ctf_context_t *ccx; - pst = start_psymtab_common (objfile, name, 0); + pst = new partial_symtab (name, objfile, 0); ccx = XOBNEW (&objfile->objfile_obstack, ctf_context_t); ccx->fp = cfp; diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 18a7ae7..c7a862a 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1905,8 +1905,8 @@ start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow, int ldsymoff) { - struct partial_symtab *result = - start_psymtab_common (objfile, filename, textlow); + struct partial_symtab *result = new partial_symtab (filename, objfile, + textlow); result->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 9880efd..3127c48 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -7984,7 +7984,7 @@ struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; struct partial_symtab *pst; - pst = start_psymtab_common (objfile, name, 0); + pst = new partial_symtab (name, objfile, 0); pst->psymtabs_addrmap_supported = true; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index f9b33c6..2319b35 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2614,9 +2614,7 @@ textlow = fh->adr; else textlow = 0; - pst = start_psymtab_common (objfile, - fdr_name (fh), - textlow); + pst = new partial_symtab (fdr_name (fh), objfile, textlow); pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc); memset (pst->read_symtab_private, 0, sizeof (struct symloc)); diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 86f2764..0dc6141 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -113,6 +113,14 @@ partial_symtab (const char *filename, struct objfile *objfile) ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3); + /* Like the above, but also sets the initial text low and text high + from the ADDR argument, and sets the global- and + static-offsets. */ + + partial_symtab (const char *filename, struct objfile *objfile, + CORE_ADDR addr) + ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3); + /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const { @@ -328,9 +336,6 @@ extern void init_psymbol_list (struct objfile *objfile, int total_symbols); -extern struct partial_symtab *start_psymtab_common (struct objfile *, - const char *, CORE_ADDR); - extern void end_psymtab_common (struct objfile *, struct partial_symtab *); static inline void diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 285ab13..b44b6c0 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1474,24 +1474,18 @@ }); } -/* Allocate and partially fill a partial symtab. It will be - completely filled at the end of the symbol list. +/* Partially fill a partial symtab. It will be completely filled at + the end of the symbol list. */ - FILENAME is the name of the symbol-file we are reading from. */ - -struct partial_symtab * -start_psymtab_common (struct objfile *objfile, - const char *filename, - CORE_ADDR textlow) +partial_symtab::partial_symtab (const char *filename, + struct objfile *objfile, + CORE_ADDR textlow) + : partial_symtab (filename, objfile) { - struct partial_symtab *psymtab; - - psymtab = new partial_symtab (filename, objfile); - psymtab->set_text_low (textlow); - psymtab->set_text_high (psymtab->raw_text_low ()); /* default */ - psymtab->globals_offset = objfile->partial_symtabs->global_psymbols.size (); - psymtab->statics_offset = objfile->partial_symtabs->static_psymbols.size (); - return psymtab; + set_text_low (textlow); + set_text_high (raw_text_low ()); /* default */ + globals_offset = objfile->partial_symtabs->global_psymbols.size (); + statics_offset = objfile->partial_symtabs->static_psymbols.size (); } /* Perform "finishing up" operations of a partial symtab. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index e5bc2d2..1230cfb 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2012,11 +2012,8 @@ xcoff_start_psymtab (struct objfile *objfile, const char *filename, int first_symnum) { - struct partial_symtab *result = - start_psymtab_common (objfile, - filename, - /* We fill in textlow later. */ - 0); + /* We fill in textlow later. */ + struct partial_symtab *result = new partial_symtab (filename, objfile, 0); result->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc);