From patchwork Thu Dec 12 23:50:07 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: 36802 Received: (qmail 99447 invoked by alias); 12 Dec 2019 23:50:13 -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 99338 invoked by uid 89); 12 Dec 2019 23:50:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.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= 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; Thu, 12 Dec 2019 23:50:11 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id BDA3C20480; Thu, 12 Dec 2019 18:50:09 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 2CBD920307; Thu, 12 Dec 2019 18:50:08 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 236B420AF6; Thu, 12 Dec 2019 18:50:08 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Thu, 12 Dec 2019 18:50: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] Make the objfile constructor private X-Gerrit-Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29 X-Gerrit-Change-Number: 492 X-Gerrit-ChangeURL: X-Gerrit-Commit: bda13cdcf0db4d9cee648bfa0bfc7f1a4415d2a7 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: <20191212235008.236B420AF6@gnutoolchain-gerrit.osci.io> The original change was created by Tom Tromey. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/492 ...................................................................... Make the objfile constructor private This changes the objfile constructor to be private, changing the callers to use a factory method. This isn't perhaps strictly needed for the goal of this series -- changing the container model of objfiles -- but is a nice symmetry. gdb/ChangeLog 2019-12-12 Tom Tromey * symfile.c (symbol_file_add_with_addrs): Use objfile::make. * objfiles.h (struct objfile): Make constructor private. : New static method. * jit.c (jit_object_close_impl): Update. Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29 --- M gdb/ChangeLog M gdb/jit.c M gdb/objfiles.h M gdb/symfile.c 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 165ffda..393d43e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-12-12 Tom Tromey + + * symfile.c (symbol_file_add_with_addrs): Use objfile::make. + * objfiles.h (struct objfile): Make constructor private. + : New static method. + * jit.c (jit_object_close_impl): Update. + 2019-12-12 Simon Marchi * jit.c (jit_reader_try_read_symtab): Replace xmalloc/xfree with diff --git a/gdb/jit.c b/gdb/jit.c index b6e51e4..2018e2c 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -786,8 +786,8 @@ priv_data = (jit_dbg_reader_data *) cb->priv_data; - objfile = new struct objfile (NULL, "<< JIT compiled code >>", - OBJF_NOT_FILENAME); + objfile = objfile::make (nullptr, "<< JIT compiled code >>", + OBJF_NOT_FILENAME); objfile->per_bfd->gdbarch = target_gdbarch (); j = NULL; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 1601cfe..b5c04eb 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -394,7 +394,19 @@ struct objfile { +private: + + /* The only way to create an objfile is to call objfile::make. */ objfile (bfd *, const char *, objfile_flags); + +public: + + /* Create an objfile. */ + static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_) + { + return new objfile (bfd_, name_, flags_); + } + ~objfile (); DISABLE_COPY_AND_ASSIGN (objfile); diff --git a/gdb/symfile.c b/gdb/symfile.c index aec07d7..eef27a8 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1093,7 +1093,7 @@ if (mainline) flags |= OBJF_MAINLINE; - objfile = new struct objfile (abfd, name, flags); + objfile = objfile::make (abfd, name, flags); if (parent) add_separate_debug_objfile (objfile, parent);