public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: remove solib::pspace field
@ 2023-09-27 20:39 Simon Marchi
  2023-10-02 15:41 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2023-09-27 20:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This backlink is not necessary, we always know the program space from
the context.  Pass it down the solib_unloaded observer.

Change-Id: I45a503472dc791f517558b8141901472634e0556
---
 gdb/breakpoint.c  |  4 ++--
 gdb/bsd-uthread.c |  2 +-
 gdb/observable.h  |  7 ++++---
 gdb/solib.c       | 10 ++++------
 gdb/solist.h      |  3 ---
 5 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f9b20a7d62d1..f378edf865ea 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8018,7 +8018,7 @@ disable_breakpoints_in_shlibs (void)
    disabled ones can just stay disabled.  */
 
 static void
-disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
+disable_breakpoints_in_unloaded_shlib (program_space *pspace, so_list *solib)
 {
   bool disabled_shlib_breaks = false;
 
@@ -8027,7 +8027,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
       /* ALL_BP_LOCATIONS bp_location has LOC->OWNER always non-NULL.  */
       struct breakpoint *b = loc->owner;
 
-      if (solib->pspace == loc->pspace
+      if (pspace == loc->pspace
 	  && !loc->shlib_disabled
 	  && (((b->type == bp_breakpoint
 		|| b->type == bp_jit_event
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index d5c6fdd36395..e27e88add869 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -294,7 +294,7 @@ bsd_uthread_solib_loaded (struct so_list *so)
 }
 
 static void
-bsd_uthread_solib_unloaded (struct so_list *so)
+bsd_uthread_solib_unloaded (program_space *pspace, so_list *so)
 {
   if (!bsd_uthread_solib_name)
     return;
diff --git a/gdb/observable.h b/gdb/observable.h
index 4ea203c6fc38..b57c3a201741 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -93,10 +93,11 @@ extern observable<inferior */* parent_inf */, inferior */* child_inf */,
    haven't been loaded yet.  */
 extern observable<struct so_list */* solib */> solib_loaded;
 
-/* The shared library specified by SOLIB has been unloaded.  Note
-   that when gdb calls this observer, the library's symbols have not
+/* The shared library SOLIB has been unloaded from program space PSPACE.
+   Note  when gdb calls this observer, the library's symbols have not
    been unloaded yet, and thus are still available.  */
-extern observable<struct so_list */* solib */> solib_unloaded;
+extern observable<struct program_space */* pspace */, struct so_list */* solib */>
+  solib_unloaded;
 
 /* The symbol file specified by OBJFILE has been loaded.  Called
    with OBJFILE equal to NULL to indicate previously loaded symbol
diff --git a/gdb/solib.c b/gdb/solib.c
index 771954e51c8f..f2735b37927e 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -769,10 +769,10 @@ notify_solib_loaded (so_list *so)
 /* Notify interpreters and observers that solib SO has been unloaded.  */
 
 static void
-notify_solib_unloaded (so_list *so)
+notify_solib_unloaded (program_space *pspace, so_list *so)
 {
   interps_notify_solib_unloaded (so);
-  gdb::observers::solib_unloaded.notify (so);
+  gdb::observers::solib_unloaded.notify (pspace, so);
 }
 
 /* See solib.h.  */
@@ -875,7 +875,7 @@ update_solib_list (int from_tty)
 	{
 	  /* Notify any observer that the shared object has been
 	     unloaded before we remove it from GDB's tables.  */
-	  notify_solib_unloaded (gdb);
+	  notify_solib_unloaded (current_program_space, gdb);
 
 	  current_program_space->deleted_solibs.push_back (gdb->so_name);
 
@@ -911,8 +911,6 @@ update_solib_list (int from_tty)
       /* Fill in the rest of each of the `struct so_list' nodes.  */
       for (i = inferior; i; i = i->next)
 	{
-
-	  i->pspace = current_program_space;
 	  current_program_space->added_solibs.push_back (i);
 
 	  try
@@ -1243,7 +1241,7 @@ clear_solib (void)
       struct so_list *so = current_program_space->so_list;
 
       current_program_space->so_list = so->next;
-      notify_solib_unloaded (so);
+      notify_solib_unloaded (current_program_space, so);
       current_program_space->remove_target_sections (so);
       free_so (so);
     }
diff --git a/gdb/solist.h b/gdb/solist.h
index 5275a79d811c..0f764b264f74 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -55,9 +55,6 @@ struct so_list
   /* Shared object file name, expanded to something GDB can open.  */
   char so_name[SO_NAME_MAX_PATH_SIZE];
 
-  /* Program space this shared library belongs to.  */
-  struct program_space *pspace;
-
   /* The following fields of the structure are built from
      information gathered from the shared object file itself, and
      are set when we actually add it to our symbol tables.

base-commit: 28bc495137bcc824167c92dd5d049576f11a3ed3
-- 
2.42.0


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

* Re: [PATCH] gdb: remove solib::pspace field
  2023-09-27 20:39 [PATCH] gdb: remove solib::pspace field Simon Marchi
@ 2023-10-02 15:41 ` Tom Tromey
  2023-10-02 16:01   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-10-02 15:41 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> This backlink is not necessary, we always know the program space from
Simon> the context.  Pass it down the solib_unloaded observer.

Looks good.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

* Re: [PATCH] gdb: remove solib::pspace field
  2023-10-02 15:41 ` Tom Tromey
@ 2023-10-02 16:01   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2023-10-02 16:01 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi

On 10/2/23 11:41, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> This backlink is not necessary, we always know the program space from
> Simon> the context.  Pass it down the solib_unloaded observer.
> 
> Looks good.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks, pushed.

Simon

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

end of thread, other threads:[~2023-10-02 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 20:39 [PATCH] gdb: remove solib::pspace field Simon Marchi
2023-10-02 15:41 ` Tom Tromey
2023-10-02 16:01   ` Simon Marchi

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).