]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: pass address_space to target dcache functions
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 5 Nov 2023 04:52:39 +0000 (04:52 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 17 Nov 2023 20:03:05 +0000 (20:03 +0000)
A simple refactor to make the reference to current_program_space bubble
up one level.  No behavior changes expected.

Change-Id: I237cf2f45ae73c35bcb433ce40e3c03cef6b87e2

gdb/dcache.c
gdb/infrun.c
gdb/memattr.c
gdb/target-dcache.c
gdb/target-dcache.h
gdb/target.c
gdb/top.c
gdb/tracepoint.c

index 8a5fb13acf5cd09492568db36cc0d996e9f11260..229c13f8b5f7448c9245d9041d3159faa4cc82a0 100644 (file)
@@ -651,7 +651,7 @@ dcache_info_1 (DCACHE *dcache, const char *exp)
 static void
 info_dcache_command (const char *exp, int tty)
 {
-  dcache_info_1 (target_dcache_get (), exp);
+  dcache_info_1 (target_dcache_get (current_program_space->aspace), exp);
 }
 
 static void
@@ -663,7 +663,7 @@ set_dcache_size (const char *args, int from_tty,
       dcache_size = DCACHE_DEFAULT_SIZE;
       error (_("Dcache size must be greater than 0."));
     }
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 }
 
 static void
@@ -677,7 +677,7 @@ set_dcache_line_size (const char *args, int from_tty,
       dcache_line_size = DCACHE_DEFAULT_LINE_SIZE;
       error (_("Invalid dcache line size: %u (must be power of 2)."), d);
     }
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 }
 
 void _initialize_dcache ();
index 4138d00b0f440b1330c1a553ce9b24a990e89220..08c39eb76f31a3cf2fcbaafa71cbf8107716ad38 100644 (file)
@@ -4356,7 +4356,7 @@ wait_for_inferior (inferior *inf)
         Target was running and cache could be stale.  This is just a
         heuristic.  Running threads may modify target memory, but we
         don't get any event.  */
-      target_dcache_invalidate ();
+      target_dcache_invalidate (current_program_space->aspace);
 
       ecs.ptid = do_target_wait_1 (inf, minus_one_ptid, &ecs.ws, 0);
       ecs.target = inf->process_target ();
@@ -4605,7 +4605,7 @@ fetch_inferior_event ()
        was running and cache could be stale.  This is just a heuristic.
        Running threads may modify target memory, but we don't get any
        event.  */
-    target_dcache_invalidate ();
+    target_dcache_invalidate (current_program_space->aspace);
 
     scoped_restore save_exec_dir
       = make_scoped_restore (&execution_direction,
@@ -5184,7 +5184,7 @@ poll_one_curr_target (struct target_waitstatus *ws)
      Target was running and cache could be stale.  This is just a
      heuristic.  Running threads may modify target memory, but we
      don't get any event.  */
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   event_ptid = target_wait (minus_one_ptid, ws, TARGET_WNOHANG);
 
index 8b0e3ef7b7eab5a1fe3207a3a7865062d5612f50..44ccd9f6cd10905438dffb578b18e590b680608f 100644 (file)
@@ -30,6 +30,7 @@
 #include <algorithm>
 #include "gdbarch.h"
 #include "inferior.h"
+#include "progspace.h"
 
 static std::vector<mem_region> user_mem_region_list, target_mem_region_list;
 static std::vector<mem_region> *mem_region_list = &target_mem_region_list;
@@ -483,7 +484,7 @@ enable_mem_command (const char *args, int from_tty)
 {
   require_user_regions (from_tty);
 
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   if (args == NULL || *args == '\0')
     { /* Enable all mem regions.  */
@@ -521,7 +522,7 @@ disable_mem_command (const char *args, int from_tty)
 {
   require_user_regions (from_tty);
 
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   if (args == NULL || *args == '\0')
     {
@@ -567,7 +568,7 @@ delete_mem_command (const char *args, int from_tty)
 {
   require_user_regions (from_tty);
 
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   if (args == NULL || *args == '\0')
     {
index 13c2888e7ea8e6def7a1f1a3851123650a992e66..4c4fef902c4a4313c29e9f00095207aef12e11f1 100644 (file)
@@ -30,10 +30,10 @@ static const registry<address_space>::key<DCACHE, dcache_deleter>
 /* Target dcache is initialized or not.  */
 
 int
-target_dcache_init_p (void)
+target_dcache_init_p (address_space *aspace)
 {
   DCACHE *dcache
-    = target_dcache_aspace_key.get (current_program_space->aspace);
+    = target_dcache_aspace_key.get (aspace);
 
   return (dcache != NULL);
 }
@@ -41,10 +41,10 @@ target_dcache_init_p (void)
 /* Invalidate the target dcache.  */
 
 void
-target_dcache_invalidate (void)
+target_dcache_invalidate (address_space *aspace)
 {
   DCACHE *dcache
-    = target_dcache_aspace_key.get (current_program_space->aspace);
+    = target_dcache_aspace_key.get (aspace);
 
   if (dcache != NULL)
     dcache_invalidate (dcache);
@@ -54,24 +54,24 @@ target_dcache_invalidate (void)
    initialized yet.  */
 
 DCACHE *
-target_dcache_get (void)
+target_dcache_get (address_space *aspace)
 {
-  return target_dcache_aspace_key.get (current_program_space->aspace);
+  return target_dcache_aspace_key.get (aspace);
 }
 
 /* Return the target dcache.  If it is not initialized yet, initialize
    it.  */
 
 DCACHE *
-target_dcache_get_or_init (void)
+target_dcache_get_or_init (address_space *aspace)
 {
   DCACHE *dcache
-    = target_dcache_aspace_key.get (current_program_space->aspace);
+    = target_dcache_aspace_key.get (aspace);
 
   if (dcache == NULL)
     {
       dcache = dcache_init ();
-      target_dcache_aspace_key.set (current_program_space->aspace, dcache);
+      target_dcache_aspace_key.set (aspace, dcache);
     }
 
   return dcache;
@@ -93,7 +93,7 @@ static void
 set_stack_cache (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (stack_cache_enabled != stack_cache_enabled_1)
-    target_dcache_invalidate ();
+    target_dcache_invalidate (current_program_space->aspace);
 
   stack_cache_enabled = stack_cache_enabled_1;
 }
@@ -131,7 +131,7 @@ static void
 set_code_cache (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (code_cache_enabled != code_cache_enabled_1)
-    target_dcache_invalidate ();
+    target_dcache_invalidate (current_program_space->aspace);
 
   code_cache_enabled = code_cache_enabled_1;
 }
@@ -158,7 +158,7 @@ code_cache_enabled_p (void)
 static void
 maint_flush_dcache_command (const char *command, int from_tty)
 {
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
   if (from_tty)
     gdb_printf (_("The dcache was flushed.\n"));
 }
index 1e9e9725f9501fc9c249c77c83a1b098e11b6be5..4693b388110ede00e890b372b5eafd5d999a9ee3 100644 (file)
 
 #include "dcache.h"
 
-extern void target_dcache_invalidate (void);
+struct address_space;
 
-extern DCACHE *target_dcache_get (void);
+extern void target_dcache_invalidate (address_space *aspace);
 
-extern DCACHE *target_dcache_get_or_init (void);
+extern DCACHE *target_dcache_get (address_space *aspace);
 
-extern int target_dcache_init_p (void);
+extern DCACHE *target_dcache_get_or_init (address_space *aspace);
+
+extern int target_dcache_init_p (address_space *aspace);
 
 extern int stack_cache_enabled_p (void);
 
index a93740bbbddd227a4ebe4665c229dd3a373c4ec3..8e5c934b4578f80ae5a08e7a1fec0c2bfc4e4bd0 100644 (file)
@@ -893,7 +893,7 @@ target_kill (void)
 void
 target_load (const char *arg, int from_tty)
 {
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
   current_inferior ()->top_target ()->load (arg, from_tty);
 }
 
@@ -1473,10 +1473,10 @@ raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
      that never made it to the target.  */
   if (writebuf != NULL
       && inferior_ptid != null_ptid
-      && target_dcache_init_p ()
+      && target_dcache_init_p (current_program_space->aspace)
       && (stack_cache_enabled_p () || code_cache_enabled_p ()))
     {
-      DCACHE *dcache = target_dcache_get ();
+      DCACHE *dcache = target_dcache_get (current_program_space->aspace);
 
       /* Note that writing to an area of memory which wasn't present
         in the cache doesn't cause it to be loaded in.  */
@@ -1559,7 +1559,8 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
          || (stack_cache_enabled_p () && object == TARGET_OBJECT_STACK_MEMORY)
          || (code_cache_enabled_p () && object == TARGET_OBJECT_CODE_MEMORY)))
     {
-      DCACHE *dcache = target_dcache_get_or_init ();
+      DCACHE *dcache
+       = target_dcache_get_or_init (current_program_space->aspace);
 
       return dcache_read_memory_partial (ops, dcache, memaddr, readbuf,
                                         reg_len, xfered_len);
@@ -2632,7 +2633,7 @@ target_resume (ptid_t scope_ptid, int step, enum gdb_signal signal)
   gdb_assert (inferior_ptid != null_ptid);
   gdb_assert (inferior_ptid.matches (scope_ptid));
 
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   current_inferior ()->top_target ()->resume (scope_ptid, step, signal);
 
index 5028440b67116de5d9cde3134654c1e75f9e8162..d211f1b08be8fb32c37f474ee3c7b29ee4d9ed82 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -360,7 +360,7 @@ prepare_execute_command ()
      it.  For the duration of the command, though, use the dcache to
      help things like backtrace.  */
   if (non_stop)
-    target_dcache_invalidate ();
+    target_dcache_invalidate (current_program_space->aspace);
 
   return scoped_value_mark ();
 }
index d5f29eb8b108522bbfde03c739507ead65fe4762..750185341ea367333b472ae19663bdb6d30fb476 100644 (file)
@@ -2131,7 +2131,7 @@ tfind_1 (enum trace_find_type type, int num,
   tp = get_tracepoint_by_number_on_target (target_tracept);
 
   reinit_frame_cache ();
-  target_dcache_invalidate ();
+  target_dcache_invalidate (current_program_space->aspace);
 
   set_tracepoint_num (tp ? tp->number : target_tracept);