/* Caching code for GDB, the GNU debugger.
- Copyright (C) 1992-2020 Free Software Foundation, Inc.
+ Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of GDB.
/* The ptid of last inferior to use cache or null_ptid. */
ptid_t ptid;
+
+ /* The process target of last inferior to use the cache or
+ nullptr. */
+ process_stratum_target *proc_target;
};
typedef void (block_func) (struct dcache_block *block, void *param);
show_dcache_enabled_p (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- fprintf_filtered (file, _("Deprecated remotecache flag is %s.\n"), value);
+ gdb_printf (file, _("Deprecated remotecache flag is %s.\n"), value);
}
/* Add BLOCK to circular block list BLIST, behind the block at *BLIST.
dcache->oldest = NULL;
dcache->size = 0;
dcache->ptid = null_ptid;
+ dcache->proc_target = nullptr;
if (dcache->line_size != dcache_line_size)
{
reg_len = region->hi - memaddr;
/* Skip non-readable regions. The cache attribute can be ignored,
- since we may be loading this for a stack access. */
+ since we may be loading this for a stack access. */
if (region->attrib.mode == MEM_WO)
{
memaddr += reg_len;
db = dcache_alloc (dcache, addr);
if (!dcache_read_line (dcache, db))
- return 0;
+ return 0;
}
*ptr = db->data[XFORM (dcache, addr)];
dcache->size = 0;
dcache->line_size = dcache_line_size;
dcache->ptid = null_ptid;
+ dcache->proc_target = nullptr;
return dcache;
}
{
ULONGEST i;
- /* If this is a different inferior from what we've recorded,
- flush the cache. */
+ /* If this is a different thread from what we've recorded, flush the
+ cache. */
- if (inferior_ptid != dcache->ptid)
+ process_stratum_target *proc_target = current_inferior ()->process_target ();
+ if (proc_target != dcache->proc_target || inferior_ptid != dcache->ptid)
{
dcache_invalidate (dcache);
dcache->ptid = inferior_ptid;
+ dcache->proc_target = proc_target;
}
for (i = 0; i < len; i++)
if (dcache == NULL)
{
- printf_filtered (_("No data cache available.\n"));
+ gdb_printf (_("No data cache available.\n"));
return;
}
if (!n)
{
- printf_filtered (_("No such cache line exists.\n"));
+ gdb_printf (_("No such cache line exists.\n"));
return;
}
db = (struct dcache_block *) n->value;
- printf_filtered (_("Line %d: address %s [%d hits]\n"),
- index, paddress (target_gdbarch (), db->addr), db->refs);
+ gdb_printf (_("Line %d: address %s [%d hits]\n"),
+ index, paddress (target_gdbarch (), db->addr), db->refs);
for (j = 0; j < dcache->line_size; j++)
{
- printf_filtered ("%02x ", db->data[j]);
+ gdb_printf ("%02x ", db->data[j]);
/* Print a newline every 16 bytes (48 characters). */
if ((j % 16 == 15) && (j != dcache->line_size - 1))
- printf_filtered ("\n");
+ gdb_printf ("\n");
}
- printf_filtered ("\n");
+ gdb_printf ("\n");
}
/* Parse EXP and show the info about DCACHE. */
i = strtol (exp, &linestart, 10);
if (linestart == exp || i < 0)
{
- printf_filtered (_("Usage: info dcache [LINENUMBER]\n"));
- return;
+ gdb_printf (_("Usage: info dcache [LINENUMBER]\n"));
+ return;
}
dcache_print_line (dcache, i);
return;
}
- printf_filtered (_("Dcache %u lines of %u bytes each.\n"),
- dcache_size,
- dcache ? (unsigned) dcache->line_size
- : dcache_line_size);
+ gdb_printf (_("Dcache %u lines of %u bytes each.\n"),
+ dcache_size,
+ dcache ? (unsigned) dcache->line_size
+ : dcache_line_size);
if (dcache == NULL || dcache->ptid == null_ptid)
{
- printf_filtered (_("No data cache available.\n"));
+ gdb_printf (_("No data cache available.\n"));
return;
}
- printf_filtered (_("Contains data for %s\n"),
- target_pid_to_str (dcache->ptid).c_str ());
+ gdb_printf (_("Contains data for %s\n"),
+ target_pid_to_str (dcache->ptid).c_str ());
refcount = 0;
{
struct dcache_block *db = (struct dcache_block *) n->value;
- printf_filtered (_("Line %d: address %s [%d hits]\n"),
- i, paddress (target_gdbarch (), db->addr), db->refs);
+ gdb_printf (_("Line %d: address %s [%d hits]\n"),
+ i, paddress (target_gdbarch (), db->addr), db->refs);
i++;
refcount += db->refs;
n = splay_tree_successor (dcache->tree, n->key);
}
- printf_filtered (_("Cache state: %d active lines, %d hits\n"), i, refcount);
+ gdb_printf (_("Cache state: %d active lines, %d hits\n"), i, refcount);
}
static void
summary of each line in the cache. With an argument, dump\"\n\
the contents of the given line."));
- add_basic_prefix_cmd ("dcache", class_obscure, _("\
+ add_setshow_prefix_cmd ("dcache", class_obscure,
+ _("\
Use this command to set number of lines in dcache and line-size."),
- &dcache_set_list, "set dcache ", /*allow_unknown*/0,
- &setlist);
- add_show_prefix_cmd ("dcache", class_obscure, _("\
-Show dcachesettings."),
- &dcache_show_list, "show dcache ", /*allow_unknown*/0,
- &showlist);
+ ("Show dcache settings."),
+ &dcache_set_list, &dcache_show_list,
+ &setlist, &showlist);
add_setshow_zuinteger_cmd ("line-size", class_obscure,
&dcache_line_size, _("\