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: 35391 Received: (qmail 123470 invoked by alias); 28 Oct 2019 02:10:56 -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 123456 invoked by uid 89); 28 Oct 2019 02:10:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=aside 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 C224920E5E; Sun, 27 Oct 2019 22:03:22 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id BDE1F2105B 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 928622A7DA 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] Change allocate_psymtab to be a constructor X-Gerrit-Change-Id: Iffeae64c925050b90b9916cbc36e15b26ff42226 X-Gerrit-Change-Number: 377 X-Gerrit-ChangeURL: X-Gerrit-Commit: 9ff78c698f28ade8c4cfb06647b924ba6b649518 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/+/377 ...................................................................... Change allocate_psymtab to be a constructor This is the next step in getting the symbol readers to allocate psymtabs themselves: change allocate_psymtab to be an ordinary constructor, and then use "new" at the previous call sites. Note that this doesn't get us all the way -- start_psymtab_common is still allocating a partial symtab. gdb/ChangeLog 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. Update. * psympriv.h (struct partial_symtab): Add parameters to constructor. Don't inline. (allocate_psymtab): Don't declare. * mdebugread.c (new_psymtab): Use new. * dwarf2read.c (dwarf2_create_include_psymtab): Use new. * dbxread.c (dbx_end_psymtab): Use new. Change-Id: Iffeae64c925050b90b9916cbc36e15b26ff42226 --- M gdb/ChangeLog M gdb/dbxread.c M gdb/dwarf2read.c M gdb/mdebugread.c M gdb/psympriv.h M gdb/psymtab.c M gdb/xcoffread.c 7 files changed, 35 insertions(+), 31 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6cfcad9..0eabe55 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 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. + Update. + * psympriv.h (struct partial_symtab): Add parameters to + constructor. Don't inline. + (allocate_psymtab): Don't declare. + * mdebugread.c (new_psymtab): Use new. + * dwarf2read.c (dwarf2_create_include_psymtab): Use new. + * dbxread.c (dbx_end_psymtab): Use new. + +2019-10-27 Tom Tromey + * psymtab.h (class psymtab_storage) : Rename from allocate_psymtab. Update documentation. * psymtab.c (psymtab_storage::install_psymtab): Rename from diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 3f20ba9..18a7ae7 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2027,7 +2027,7 @@ for (i = 0; i < num_includes; i++) { struct partial_symtab *subpst = - allocate_psymtab (include_list[i], objfile); + new partial_symtab (include_list[i], objfile); subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 15c6f9d..9880efd 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6633,7 +6633,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst, struct objfile *objfile) { - struct partial_symtab *subpst = allocate_psymtab (name, objfile); + struct partial_symtab *subpst = new partial_symtab (name, objfile); if (!IS_ABSOLUTE_PATH (subpst->filename)) { diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 01eedbd..f9b33c6 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4663,7 +4663,7 @@ { struct partial_symtab *psymtab; - psymtab = allocate_psymtab (name, objfile); + psymtab = new partial_symtab (name, objfile); /* Keep a backpointer to the file's symbols. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 923d9fa..86f2764 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -104,12 +104,14 @@ struct partial_symtab { - partial_symtab () - : searched_flag (PST_NOT_SEARCHED), - text_low_valid (0), - text_high_valid (0) - { - } + /* Allocate a new partial symbol table associated with OBJFILE. + FILENAME (which must be non-NULL) is the filename of this partial + symbol table; it is copied into the appropriate storage. The + partial symtab will also be installed using + psymtab_storage::install. */ + + partial_symtab (const char *filename, struct objfile *objfile) + ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3); /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const @@ -331,16 +333,6 @@ extern void end_psymtab_common (struct objfile *, struct partial_symtab *); -/* Allocate a new partial symbol table associated with OBJFILE. - FILENAME (which must be non-NULL) is the filename of this partial - symbol table; it is copied into the appropriate storage. A new - partial symbol table is returned; aside from "next" and "filename", - its fields are initialized to zero. */ - -extern struct partial_symtab *allocate_psymtab (const char *filename, - struct objfile *objfile) - ATTRIBUTE_NONNULL (1); - static inline void discard_psymtab (struct objfile *objfile, struct partial_symtab *pst) { diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 8351c6a..285ab13 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1486,7 +1486,7 @@ { struct partial_symtab *psymtab; - psymtab = allocate_psymtab (filename, objfile); + 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 (); @@ -1648,16 +1648,17 @@ /* See psympriv.h. */ -struct partial_symtab * -allocate_psymtab (const char *filename, struct objfile *objfile) +partial_symtab::partial_symtab (const char *filename_, struct objfile *objfile) + : searched_flag (PST_NOT_SEARCHED), + text_low_valid (0), + text_high_valid (0) { - struct partial_symtab *psymtab = new partial_symtab; - objfile->partial_symtabs->install_psymtab (psymtab); + objfile->partial_symtabs->install_psymtab (this); - psymtab->filename + filename = ((const char *) objfile->per_bfd->filename_cache.insert - (filename, strlen (filename) + 1)); - psymtab->compunit_symtab = NULL; + (filename_, strlen (filename_) + 1)); + compunit_symtab = NULL; if (symtab_create_debug) { @@ -1676,10 +1677,8 @@ } fprintf_filtered (gdb_stdlog, "Created psymtab %s for module %s.\n", - host_address_to_string (psymtab), filename); + host_address_to_string (this), filename); } - - return psymtab; } void diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 2d7ff75..e5bc2d2 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2070,7 +2070,7 @@ for (i = 0; i < num_includes; i++) { struct partial_symtab *subpst = - allocate_psymtab (include_list[i], objfile); + new partial_symtab (include_list[i], objfile); subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc); ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;