[01/14] gdb: use objfile::pspace in objfile::unlink

Message ID 20240711195307.1544451-2-simon.marchi@polymtl.ca
State New
Headers
Series Some random program space cleanups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply

Commit Message

Simon Marchi July 11, 2024, 7:51 p.m. UTC
  I think it would make sense to use objfile::pspace instead of the
current program space here.  It reduces the risks of calling this
method with the wrong current program space set.

Change-Id: Id4f3644719f232640c83a1c7f4aa92eaa6af6c5c
---
 gdb/objfiles.c | 2 +-
 gdb/objfiles.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 368e129b49d3..d2917c5323cc 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -463,7 +463,7 @@  objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_,
 void
 objfile::unlink ()
 {
-  current_program_space->remove_objfile (this);
+  this->pspace->remove_objfile (this);
 }
 
 /* Free all separate debug objfile of OBJFILE, but don't free OBJFILE
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 88dfb33e45c9..ea511459627c 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -439,7 +439,7 @@  struct objfile
   static objfile *make (gdb_bfd_ref_ptr bfd_, const char *name_,
 			objfile_flags flags_, objfile *parent = nullptr);
 
-  /* Remove an objfile from the current program space, and free
+  /* Remove this objfile from its program space's objfile list, and frees
      it.  */
   void unlink ();