public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] Introduce program_space::add_objfile
@ 2019-11-04  1:35 Tom Tromey (Code Review)
  2019-11-04  5:31 ` Christian Biesinger (Code Review)
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ 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/+/495
......................................................................

Introduce program_space::add_objfile

This introduces a new method, program_space::add_objfile, that adds an
objfile to the program space's list of objfiles.  It also changes the
obfile's constructor so that linking an objfile into this list is not
done here.

The former is an improvement because it makes more sense to treat the
program space as a container holding objfiles -- so manipulation of
the list belongs there.

The latter is not strictly needed, but seemed better both because it
is removing a global side effect from a constructor, and for symmetry
reasons, as a subsequent patch will remove unlinking from the
destructor.

gdb/ChangeLog
2019-11-03  Tom Tromey  <tom@tromey.com>

	* progspace.h (struct program_space) <add_objfile>: Declare
	method.
	* progspace.c (program_space::add_objfile): New method.
	* objfiles.c (~objfile): Don't unlink objfile.
	(put_objfile_before): Remove.
	(add_separate_debug_objfile): Don't call put_objfile_before.
	(objfile::make): Call add_objfile.  Set new_objfiles_available on
	the per-program-space data.

Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
---
M gdb/ChangeLog
M gdb/objfiles.c
M gdb/progspace.c
M gdb/progspace.h
4 files changed, 45 insertions(+), 45 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94dcac6..9efaa24 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
 2019-11-03  Tom Tromey  <tom@tromey.com>
 
+	* progspace.h (struct program_space) <add_objfile>: Declare
+	method.
+	* progspace.c (program_space::add_objfile): New method.
+	* objfiles.c (~objfile): Don't unlink objfile.
+	(put_objfile_before): Remove.
+	(add_separate_debug_objfile): Don't call put_objfile_before.
+	(objfile::make): Call add_objfile.  Set new_objfiles_available on
+	the per-program-space data.
+
+2019-11-03  Tom Tromey  <tom@tromey.com>
+
 	* symfile.c (syms_from_objfile_1): Use objfile_up.
 	(syms_from_objfile_1, remove_symbol_file_command): Call unlink
 	method.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a635f77..b4fb6f2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -371,23 +371,6 @@
     }
 
   per_bfd = get_objfile_bfd_data (this, abfd);
-
-  /* Add this file onto the tail of the linked list of other such files.  */
-
-  if (object_files == NULL)
-    object_files = this;
-  else
-    {
-      struct objfile *last_one;
-
-      for (last_one = object_files;
-	   last_one->next;
-	   last_one = last_one->next);
-      last_one->next = this;
-    }
-
-  /* Rebuild section map next time we need it.  */
-  get_objfile_pspace_data (pspace)->new_objfiles_available = 1;
 }
 
 /* Retrieve the gdbarch associated with OBJFILE.  */
@@ -494,30 +477,6 @@
 		  _("unlink_objfile: objfile already unlinked"));
 }
 
-/* Put one object file before a specified on in the global list.
-   This can be used to make sure an object file is destroyed before
-   another when using objfiles_safe to free all objfiles.  */
-static void
-put_objfile_before (struct objfile *objfile, struct objfile *before_this)
-{
-  struct objfile **objp;
-
-  unlink_objfile (objfile);
-  
-  for (objp = &object_files; *objp != NULL; objp = &((*objp)->next))
-    {
-      if (*objp == before_this)
-	{
-	  objfile->next = *objp;
-	  *objp = objfile;
-	  return;
-	}
-    }
-  
-  internal_error (__FILE__, __LINE__,
-		  _("put_objfile_before: before objfile not in list"));
-}
-
 /* Add OBJFILE as a separate debug objfile of PARENT.  */
 
 static void
@@ -535,10 +494,6 @@
   objfile->separate_debug_objfile_backlink = parent;
   objfile->separate_debug_objfile_link = parent->separate_debug_objfile;
   parent->separate_debug_objfile = objfile;
-
-  /* Put the separate debug object before the normal one, this is so that
-     usage of objfiles_safe will stay safe.  */
-  put_objfile_before (objfile, parent);
 }
 
 /* See objfiles.h.  */
@@ -550,6 +505,12 @@
   objfile *result = new objfile (bfd_, name_, flags_);
   if (parent != nullptr)
     add_separate_debug_objfile (result, parent);
+
+  current_program_space->add_objfile (result, parent);
+
+  /* Rebuild section map next time we need it.  */
+  get_objfile_pspace_data (current_program_space)->new_objfiles_available = 1;
+
   return result;
 }
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 366de54..5aa7a3d 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -153,6 +153,28 @@
   program_space_free_data (this);
 }
 
+/* See progspace.h.  */
+
+void
+program_space::add_objfile (struct objfile *objfile, struct objfile *before)
+{
+  for (struct objfile **objp = &objfiles_head;
+       *objp != NULL;
+       objp = &((*objp)->next))
+    {
+      if (*objp == before)
+	{
+	  objfile->next = *objp;
+	  *objp = objfile;
+	  return;
+	}
+    }
+
+  internal_error (__FILE__, __LINE__,
+		  _("put_objfile_before: before objfile not in list"));
+
+}
+
 /* Copies program space SRC to DEST.  Copies the main executable file,
    and the main symbol file.  Returns DEST.  */
 
diff --git a/gdb/progspace.h b/gdb/progspace.h
index c281648..bb10c4b 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -165,6 +165,12 @@
     return objfiles_safe_range (objfiles_head);
   }
 
+  /* Add OBJFILE to the list of objfiles, putting it just before
+     BEFORE.  If BEFORE is nullptr, it will go at the end of the
+     list.  */
+  void add_objfile (struct objfile *objfile, struct objfile *before);
+
+
   /* Pointer to next in linked list.  */
   struct program_space *next = NULL;
 

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

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

* [review] Introduce program_space::add_objfile
  2019-11-04  1:35 [review] Introduce program_space::add_objfile Tom Tromey (Code Review)
@ 2019-11-04  5:31 ` Christian Biesinger (Code Review)
  2019-11-04 17:16 ` Tom Tromey (Code Review)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-11-04  5:31 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Christian Biesinger

Christian Biesinger has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495
......................................................................


Patch Set 1:

(1 comment)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495/1/gdb/objfiles.c 
File gdb/objfiles.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495/1/gdb/objfiles.c@512 
PS1, Line 512: 
502 | objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_,
    | ...
507 |     add_separate_debug_objfile (result, parent);
508 | 
509 |   current_program_space->add_objfile (result, parent);
510 | 
511 |   /* Rebuild section map next time we need it.  */
512 >   get_objfile_pspace_data (current_program_space)->new_objfiles_available = 1;
513 | 
514 |   return result;
515 | }
516 | 
517 | /* See objfiles.h.  */

Maybe this should be done by add_objfile instead?



-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
Gerrit-Change-Number: 495
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-Comment-Date: Mon, 04 Nov 2019 05:31:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

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

* [review] Introduce program_space::add_objfile
  2019-11-04  1:35 [review] Introduce program_space::add_objfile Tom Tromey (Code Review)
  2019-11-04  5:31 ` Christian Biesinger (Code Review)
@ 2019-11-04 17:16 ` Tom Tromey (Code Review)
  2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  2019-12-12 23:56 ` Sourceware to Gerrit sync (Code Review)
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-04 17:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495
......................................................................


Patch Set 1:

(1 comment)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495/1/gdb/objfiles.c 
File gdb/objfiles.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495/1/gdb/objfiles.c@512 
PS1, Line 512: 
502 | objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_,
    | ...
507 |     add_separate_debug_objfile (result, parent);
508 | 
509 |   current_program_space->add_objfile (result, parent);
510 | 
511 |   /* Rebuild section map next time we need it.  */
512 >   get_objfile_pspace_data (current_program_space)->new_objfiles_available = 1;
513 | 
514 |   return result;
515 | }
516 | 
517 | /* See objfiles.h.  */

> Maybe this should be done by add_objfile instead?

The objfile module stores some state on the program space, so 
I think it's probably something that should be kept here.
At least, for the time being; maybe this should just be a field
on the program space instead of a side object; I am not sure.



-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
Gerrit-Change-Number: 495
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-Comment-Date: Mon, 04 Nov 2019 17:16:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: comment

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

* [pushed] Introduce program_space::add_objfile
  2019-11-04  1:35 [review] Introduce program_space::add_objfile Tom Tromey (Code Review)
  2019-11-04  5:31 ` Christian Biesinger (Code Review)
  2019-11-04 17:16 ` Tom Tromey (Code Review)
@ 2019-12-12 23:50 ` Sourceware to Gerrit sync (Code Review)
  2019-12-12 23:56 ` Sourceware to Gerrit sync (Code Review)
  3 siblings, 0 replies; 5+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-12-12 23:50 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Christian Biesinger

The original change was created by Tom Tromey.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495
......................................................................

Introduce program_space::add_objfile

This introduces a new method, program_space::add_objfile, that adds an
objfile to the program space's list of objfiles.  It also changes the
obfile's constructor so that linking an objfile into this list is not
done here.

The former is an improvement because it makes more sense to treat the
program space as a container holding objfiles -- so manipulation of
the list belongs there.

The latter is not strictly needed, but seemed better both because it
is removing a global side effect from a constructor, and for symmetry
reasons, as a subsequent patch will remove unlinking from the
destructor.

gdb/ChangeLog
2019-12-12  Tom Tromey  <tom@tromey.com>

	* progspace.h (struct program_space) <add_objfile>: Declare
	method.
	* progspace.c (program_space::add_objfile): New method.
	* objfiles.c (~objfile): Don't unlink objfile.
	(put_objfile_before): Remove.
	(add_separate_debug_objfile): Don't call put_objfile_before.
	(objfile::make): Call add_objfile.  Set new_objfiles_available on
	the per-program-space data.

Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
---
M gdb/ChangeLog
M gdb/objfiles.c
M gdb/progspace.c
M gdb/progspace.h
4 files changed, 45 insertions(+), 45 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 07d679b..0163611 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
 2019-12-12  Tom Tromey  <tom@tromey.com>
 
+	* progspace.h (struct program_space) <add_objfile>: Declare
+	method.
+	* progspace.c (program_space::add_objfile): New method.
+	* objfiles.c (~objfile): Don't unlink objfile.
+	(put_objfile_before): Remove.
+	(add_separate_debug_objfile): Don't call put_objfile_before.
+	(objfile::make): Call add_objfile.  Set new_objfiles_available on
+	the per-program-space data.
+
+2019-12-12  Tom Tromey  <tom@tromey.com>
+
 	* symfile.c (syms_from_objfile_1): Use objfile_up.
 	(syms_from_objfile_1, remove_symbol_file_command): Call unlink
 	method.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a635f77..b4fb6f2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -371,23 +371,6 @@
     }
 
   per_bfd = get_objfile_bfd_data (this, abfd);
-
-  /* Add this file onto the tail of the linked list of other such files.  */
-
-  if (object_files == NULL)
-    object_files = this;
-  else
-    {
-      struct objfile *last_one;
-
-      for (last_one = object_files;
-	   last_one->next;
-	   last_one = last_one->next);
-      last_one->next = this;
-    }
-
-  /* Rebuild section map next time we need it.  */
-  get_objfile_pspace_data (pspace)->new_objfiles_available = 1;
 }
 
 /* Retrieve the gdbarch associated with OBJFILE.  */
@@ -494,30 +477,6 @@
 		  _("unlink_objfile: objfile already unlinked"));
 }
 
-/* Put one object file before a specified on in the global list.
-   This can be used to make sure an object file is destroyed before
-   another when using objfiles_safe to free all objfiles.  */
-static void
-put_objfile_before (struct objfile *objfile, struct objfile *before_this)
-{
-  struct objfile **objp;
-
-  unlink_objfile (objfile);
-  
-  for (objp = &object_files; *objp != NULL; objp = &((*objp)->next))
-    {
-      if (*objp == before_this)
-	{
-	  objfile->next = *objp;
-	  *objp = objfile;
-	  return;
-	}
-    }
-  
-  internal_error (__FILE__, __LINE__,
-		  _("put_objfile_before: before objfile not in list"));
-}
-
 /* Add OBJFILE as a separate debug objfile of PARENT.  */
 
 static void
@@ -535,10 +494,6 @@
   objfile->separate_debug_objfile_backlink = parent;
   objfile->separate_debug_objfile_link = parent->separate_debug_objfile;
   parent->separate_debug_objfile = objfile;
-
-  /* Put the separate debug object before the normal one, this is so that
-     usage of objfiles_safe will stay safe.  */
-  put_objfile_before (objfile, parent);
 }
 
 /* See objfiles.h.  */
@@ -550,6 +505,12 @@
   objfile *result = new objfile (bfd_, name_, flags_);
   if (parent != nullptr)
     add_separate_debug_objfile (result, parent);
+
+  current_program_space->add_objfile (result, parent);
+
+  /* Rebuild section map next time we need it.  */
+  get_objfile_pspace_data (current_program_space)->new_objfiles_available = 1;
+
   return result;
 }
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 366de54..5aa7a3d 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -153,6 +153,28 @@
   program_space_free_data (this);
 }
 
+/* See progspace.h.  */
+
+void
+program_space::add_objfile (struct objfile *objfile, struct objfile *before)
+{
+  for (struct objfile **objp = &objfiles_head;
+       *objp != NULL;
+       objp = &((*objp)->next))
+    {
+      if (*objp == before)
+	{
+	  objfile->next = *objp;
+	  *objp = objfile;
+	  return;
+	}
+    }
+
+  internal_error (__FILE__, __LINE__,
+		  _("put_objfile_before: before objfile not in list"));
+
+}
+
 /* Copies program space SRC to DEST.  Copies the main executable file,
    and the main symbol file.  Returns DEST.  */
 
diff --git a/gdb/progspace.h b/gdb/progspace.h
index c281648..bb10c4b 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -165,6 +165,12 @@
     return objfiles_safe_range (objfiles_head);
   }
 
+  /* Add OBJFILE to the list of objfiles, putting it just before
+     BEFORE.  If BEFORE is nullptr, it will go at the end of the
+     list.  */
+  void add_objfile (struct objfile *objfile, struct objfile *before);
+
+
   /* Pointer to next in linked list.  */
   struct program_space *next = NULL;
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
Gerrit-Change-Number: 495
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: newpatchset

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

* [pushed] Introduce program_space::add_objfile
  2019-11-04  1:35 [review] Introduce program_space::add_objfile Tom Tromey (Code Review)
                   ` (2 preceding siblings ...)
  2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-12-12 23:56 ` Sourceware to Gerrit sync (Code Review)
  3 siblings, 0 replies; 5+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-12-12 23:56 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Christian Biesinger

Sourceware to Gerrit sync has submitted this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/495
......................................................................

Introduce program_space::add_objfile

This introduces a new method, program_space::add_objfile, that adds an
objfile to the program space's list of objfiles.  It also changes the
obfile's constructor so that linking an objfile into this list is not
done here.

The former is an improvement because it makes more sense to treat the
program space as a container holding objfiles -- so manipulation of
the list belongs there.

The latter is not strictly needed, but seemed better both because it
is removing a global side effect from a constructor, and for symmetry
reasons, as a subsequent patch will remove unlinking from the
destructor.

gdb/ChangeLog
2019-12-12  Tom Tromey  <tom@tromey.com>

	* progspace.h (struct program_space) <add_objfile>: Declare
	method.
	* progspace.c (program_space::add_objfile): New method.
	* objfiles.c (~objfile): Don't unlink objfile.
	(put_objfile_before): Remove.
	(add_separate_debug_objfile): Don't call put_objfile_before.
	(objfile::make): Call add_objfile.  Set new_objfiles_available on
	the per-program-space data.

Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
---
M gdb/ChangeLog
M gdb/objfiles.c
M gdb/progspace.c
M gdb/progspace.h
4 files changed, 45 insertions(+), 45 deletions(-)


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 07d679b..0163611 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
 2019-12-12  Tom Tromey  <tom@tromey.com>
 
+	* progspace.h (struct program_space) <add_objfile>: Declare
+	method.
+	* progspace.c (program_space::add_objfile): New method.
+	* objfiles.c (~objfile): Don't unlink objfile.
+	(put_objfile_before): Remove.
+	(add_separate_debug_objfile): Don't call put_objfile_before.
+	(objfile::make): Call add_objfile.  Set new_objfiles_available on
+	the per-program-space data.
+
+2019-12-12  Tom Tromey  <tom@tromey.com>
+
 	* symfile.c (syms_from_objfile_1): Use objfile_up.
 	(syms_from_objfile_1, remove_symbol_file_command): Call unlink
 	method.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a635f77..b4fb6f2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -371,23 +371,6 @@
     }
 
   per_bfd = get_objfile_bfd_data (this, abfd);
-
-  /* Add this file onto the tail of the linked list of other such files.  */
-
-  if (object_files == NULL)
-    object_files = this;
-  else
-    {
-      struct objfile *last_one;
-
-      for (last_one = object_files;
-	   last_one->next;
-	   last_one = last_one->next);
-      last_one->next = this;
-    }
-
-  /* Rebuild section map next time we need it.  */
-  get_objfile_pspace_data (pspace)->new_objfiles_available = 1;
 }
 
 /* Retrieve the gdbarch associated with OBJFILE.  */
@@ -494,30 +477,6 @@
 		  _("unlink_objfile: objfile already unlinked"));
 }
 
-/* Put one object file before a specified on in the global list.
-   This can be used to make sure an object file is destroyed before
-   another when using objfiles_safe to free all objfiles.  */
-static void
-put_objfile_before (struct objfile *objfile, struct objfile *before_this)
-{
-  struct objfile **objp;
-
-  unlink_objfile (objfile);
-  
-  for (objp = &object_files; *objp != NULL; objp = &((*objp)->next))
-    {
-      if (*objp == before_this)
-	{
-	  objfile->next = *objp;
-	  *objp = objfile;
-	  return;
-	}
-    }
-  
-  internal_error (__FILE__, __LINE__,
-		  _("put_objfile_before: before objfile not in list"));
-}
-
 /* Add OBJFILE as a separate debug objfile of PARENT.  */
 
 static void
@@ -535,10 +494,6 @@
   objfile->separate_debug_objfile_backlink = parent;
   objfile->separate_debug_objfile_link = parent->separate_debug_objfile;
   parent->separate_debug_objfile = objfile;
-
-  /* Put the separate debug object before the normal one, this is so that
-     usage of objfiles_safe will stay safe.  */
-  put_objfile_before (objfile, parent);
 }
 
 /* See objfiles.h.  */
@@ -550,6 +505,12 @@
   objfile *result = new objfile (bfd_, name_, flags_);
   if (parent != nullptr)
     add_separate_debug_objfile (result, parent);
+
+  current_program_space->add_objfile (result, parent);
+
+  /* Rebuild section map next time we need it.  */
+  get_objfile_pspace_data (current_program_space)->new_objfiles_available = 1;
+
   return result;
 }
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 366de54..5aa7a3d 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -153,6 +153,28 @@
   program_space_free_data (this);
 }
 
+/* See progspace.h.  */
+
+void
+program_space::add_objfile (struct objfile *objfile, struct objfile *before)
+{
+  for (struct objfile **objp = &objfiles_head;
+       *objp != NULL;
+       objp = &((*objp)->next))
+    {
+      if (*objp == before)
+	{
+	  objfile->next = *objp;
+	  *objp = objfile;
+	  return;
+	}
+    }
+
+  internal_error (__FILE__, __LINE__,
+		  _("put_objfile_before: before objfile not in list"));
+
+}
+
 /* Copies program space SRC to DEST.  Copies the main executable file,
    and the main symbol file.  Returns DEST.  */
 
diff --git a/gdb/progspace.h b/gdb/progspace.h
index c281648..bb10c4b 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -165,6 +165,12 @@
     return objfiles_safe_range (objfiles_head);
   }
 
+  /* Add OBJFILE to the list of objfiles, putting it just before
+     BEFORE.  If BEFORE is nullptr, it will go at the end of the
+     list.  */
+  void add_objfile (struct objfile *objfile, struct objfile *before);
+
+
   /* Pointer to next in linked list.  */
   struct program_space *next = NULL;
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
Gerrit-Change-Number: 495
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: merged

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04  1:35 [review] Introduce program_space::add_objfile Tom Tromey (Code Review)
2019-11-04  5:31 ` Christian Biesinger (Code Review)
2019-11-04 17:16 ` Tom Tromey (Code Review)
2019-12-12 23:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-12-12 23:56 ` 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).