gdb: pass address_space to target dcache functions

A simple refactor to make the reference to current_program_space bubble
up one level.  No behavior changes expected.

Change-Id: I237cf2f45ae73c35bcb433ce40e3c03cef6b87e2
This commit is contained in:
Simon Marchi 2023-11-05 04:52:39 +00:00
parent 9c742269ec
commit 4133662031
8 changed files with 36 additions and 32 deletions

View 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 ();

View 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);

View 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')
{

View 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"));
}

View file

@ -20,13 +20,15 @@
#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);

View 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);

View file

@ -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 ();
}

View 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);