26#include "splay-tree.h"
77#define DCACHE_DEFAULT_SIZE 4096
83#define DCACHE_DEFAULT_LINE_SIZE 64
89#define LINE_SIZE_MASK(dcache) ((dcache->line_size - 1))
90#define XFORM(dcache, x) ((x) & LINE_SIZE_MASK (dcache))
91#define MASK(dcache, x) ((x) & ~LINE_SIZE_MASK (dcache))
154 block->next = *blist;
155 block->prev = (*blist)->prev;
157 (*blist)->prev =
block;
186 *blist =
block->next;
210 while (*blist && db != *blist);
226 splay_tree_delete (dcache->
tree);
242 splay_tree_remove (dcache->
tree, (splay_tree_key)
block->addr);
255 dcache->
ptid = null_ptid;
278 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
293 splay_tree_node node = splay_tree_lookup (dcache->
tree,
294 (splay_tree_key)
MASK (dcache,
addr));
326 if (region->
hi == 0 || memaddr + len < region->
hi)
329 reg_len = region->
hi - memaddr;
367 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
388 splay_tree_insert (dcache->
tree, (splay_tree_key) db->
addr,
389 (splay_tree_value) db);
460 dcache->
ptid = null_ptid;
474 CORE_ADDR memaddr, gdb_byte *myaddr,
475 ULONGEST len, ULONGEST *xfered_len)
490 for (i = 0; i < len; i++)
530 CORE_ADDR memaddr,
const gdb_byte *myaddr,
535 for (i = 0; i < len; i++)
561 n = splay_tree_min (dcache->
tree);
563 for (i = index; i > 0; --i)
567 n = splay_tree_successor (dcache->
tree, n->key);
572 gdb_printf (_(
"No such cache line exists.\n"));
578 gdb_printf (_(
"Line %d: address %s [%d hits]\n"),
586 if ((j % 16 == 15) && (j != dcache->
line_size - 1))
604 i = strtol (exp, &linestart, 10);
605 if (linestart == exp || i < 0)
607 gdb_printf (_(
"Usage: info dcache [LINENUMBER]\n"));
615 gdb_printf (_(
"Dcache %u lines of %u bytes each.\n"),
620 if (dcache == NULL || dcache->
ptid == null_ptid)
631 n = splay_tree_min (dcache->
tree);
638 gdb_printf (_(
"Line %d: address %s [%d hits]\n"),
641 refcount += db->
refs;
643 n = splay_tree_successor (dcache->
tree, n->key);
646 gdb_printf (_(
"Cache state: %d active lines, %d hits\n"), i, refcount);
662 error (_(
"Dcache size must be greater than 0."));
676 error (_(
"Invalid dcache line size: %u (must be power of 2)."), d);
687Set cache use for remote targets."), _(
"\
688Show cache use for remote targets."), _(
"\
689This used to enable the data cache for remote targets. The cache\n\
690functionality is now controlled by the memory region system and the\n\
691\"stack-cache\" flag; \"remotecache\" now does nothing and\n\
692exists only for compatibility reasons."),
699Print information on the dcache performance.\n\
700Usage: info dcache [LINENUMBER]\n\
701With no arguments, this command prints the cache configuration and a\n\
702summary of each line in the cache. With an argument, dump\"\n\
703the contents of the given line."));
707Use this command to set number of lines in dcache and line-size."),
708 (
"Show dcache settings."),
714Set dcache line size in bytes (must be power of 2)."), _(
"\
715Show dcache line size."),
722Set number of dcache lines."), _(
"\
723Show number of dcache lines."),
struct gdbarch * target_gdbarch(void)
struct process_stratum_target * process_target()
struct cmd_list_element * showlist
struct cmd_list_element * setlist
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void append_block(struct dcache_block **blist, struct dcache_block *block)
static void set_dcache_size(const char *args, int from_tty, struct cmd_list_element *c)
static struct dcache_block * dcache_hit(DCACHE *dcache, CORE_ADDR addr)
static unsigned dcache_line_size
DCACHE * dcache_init(void)
static void dcache_poke_byte(DCACHE *dcache, CORE_ADDR addr, const gdb_byte *ptr)
static void dcache_invalidate_line(DCACHE *dcache, CORE_ADDR addr)
void dcache_invalidate(DCACHE *dcache)
static void show_dcache_enabled_p(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void _initialize_dcache()
static void info_dcache_command(const char *exp, int tty)
static int dcache_splay_tree_compare(splay_tree_key a, splay_tree_key b)
static struct cmd_list_element * dcache_show_list
static int dcache_read_line(DCACHE *dcache, struct dcache_block *db)
#define DCACHE_DEFAULT_SIZE
static void for_each_block(struct dcache_block **blist, block_func *func, void *param)
static void remove_block(struct dcache_block **blist, struct dcache_block *block)
static struct dcache_block * dcache_alloc(DCACHE *dcache, CORE_ADDR addr)
static void dcache_info_1(DCACHE *dcache, const char *exp)
void dcache_update(DCACHE *dcache, enum target_xfer_status status, CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len)
enum target_xfer_status dcache_read_memory_partial(struct target_ops *ops, DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len)
static void dcache_print_line(DCACHE *dcache, int index)
static int dcache_peek_byte(DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
static void set_dcache_line_size(const char *args, int from_tty, struct cmd_list_element *c)
#define DCACHE_DEFAULT_LINE_SIZE
void dcache_free(DCACHE *dcache)
static void invalidate_block(struct dcache_block *block, void *param)
static bool dcache_enabled_p
static void free_block(struct dcache_block *block, void *param)
void block_func(struct dcache_block *block, void *param)
static struct cmd_list_element * dcache_set_list
static unsigned dcache_size
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
struct inferior * current_inferior(void)
struct mem_region * lookup_mem_region(CORE_ADDR addr)
void(* func)(remote_target *remote, char *)
struct dcache_block * next
struct dcache_block * prev
struct dcache_block * freelist
struct dcache_block * oldest
process_stratum_target * proc_target
enum mem_access_mode mode
void target_dcache_invalidate(void)
DCACHE * target_dcache_get(void)
enum target_xfer_status raw_memory_xfer_partial(struct target_ops *ops, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len, ULONGEST *xfered_len)
int target_read_raw_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
std::string target_pid_to_str(ptid_t ptid)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)