public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] Make the objfile constructor private
@ 2019-11-04  1:35 Tom Tromey (Code Review)
  2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-04  1:35 UTC (permalink / raw)
  To: gdb-patches

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-11-03  Tom Tromey  <tom@tromey.com>

	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
	* objfiles.h (struct objfile): Make constructor private.
	<make>: 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 34e332b..bfb60c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-03  Tom Tromey  <tom@tromey.com>
+
+	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
+	* objfiles.h (struct objfile): Make constructor private.
+	<make>: New static method.
+	* jit.c (jit_object_close_impl): Update.
+
 2019-11-01  Tom Tromey  <tromey@adacore.com>
 
 	* utils.c (print_sys_errmsg): Simplify.
diff --git a/gdb/jit.c b/gdb/jit.c
index 08fd862..970f6c6 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 0c04458..eb47cad 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 c5d226e..b14f291 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);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29
Gerrit-Change-Number: 492
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed] Make the objfile constructor private
  2019-11-04  1:35 [review] Make the objfile constructor private Tom Tromey (Code Review)
@ 2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)
  2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)
  1 sibling, 0 replies; 3+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-12-12 23:50 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Sourceware to Gerrit sync has submitted this change.

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  <tom@tromey.com>

	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
	* objfiles.h (struct objfile): Make constructor private.
	<make>: 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  <tom@tromey.com>
+
+	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
+	* objfiles.h (struct objfile): Make constructor private.
+	<make>: New static method.
+	* jit.c (jit_object_close_impl): Update.
+
 2019-12-12  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* 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);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29
Gerrit-Change-Number: 492
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed] Make the objfile constructor private
  2019-11-04  1:35 [review] Make the objfile constructor private Tom Tromey (Code Review)
  2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)
  1 sibling, 0 replies; 3+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-12-12 23:50 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

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  <tom@tromey.com>

	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
	* objfiles.h (struct objfile): Make constructor private.
	<make>: 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  <tom@tromey.com>
+
+	* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
+	* objfiles.h (struct objfile): Make constructor private.
+	<make>: New static method.
+	* jit.c (jit_object_close_impl): Update.
+
 2019-12-12  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* 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);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29
Gerrit-Change-Number: 492
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-12 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04  1:35 [review] Make the objfile constructor private Tom Tromey (Code Review)
2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).