26 #include "splay-tree.h" 76 #define DCACHE_DEFAULT_SIZE 4096 82 #define DCACHE_DEFAULT_LINE_SIZE 64 88 #define LINE_SIZE_MASK(dcache) ((dcache->line_size - 1)) 89 #define XFORM(dcache, x) ((x) & LINE_SIZE_MASK (dcache)) 90 #define MASK(dcache, x) ((x) & ~LINE_SIZE_MASK (dcache)) 149 block->next = *blist;
150 block->prev = (*blist)->prev;
152 (*blist)->prev =
block;
181 *blist =
block->next;
205 while (*blist && db != *blist);
221 splay_tree_delete (dcache->
tree);
237 splay_tree_remove (dcache->
tree, (splay_tree_key)
block->addr);
272 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
287 splay_tree_node node = splay_tree_lookup (dcache->
tree,
288 (splay_tree_key)
MASK (dcache,
addr));
320 if (region->
hi == 0 || memaddr + len < region->
hi)
323 reg_len = region->
hi - memaddr;
361 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
382 splay_tree_insert (dcache->
tree, (splay_tree_key) db->
addr,
383 (splay_tree_value) db);
481 for (i = 0; i < len; i++)
526 for (i = 0; i < len; i++)
552 n = splay_tree_min (dcache->
tree);
554 for (i = index; i > 0; --i)
558 n = splay_tree_successor (dcache->
tree, n->key);
577 if ((j % 16 == 15) && (j != dcache->
line_size - 1))
595 i = strtol (exp, &linestart, 10);
596 if (linestart == exp || i < 0)
622 n = splay_tree_min (dcache->
tree);
632 refcount += db->
refs;
634 n = splay_tree_successor (dcache->
tree, n->key);
637 printf_filtered (
_(
"Cache state: %d active lines, %d hits\n"), i, refcount);
653 error (
_(
"Dcache size must be greater than 0."));
667 error (
_(
"Invalid dcache line size: %u (must be power of 2)."), d);
676 "\"set dcache\" must be followed by the name of a subcommand.\n");
691 Set cache use for remote targets."),
_(
"\ 692 Show cache use for remote targets."),
_(
"\ 693 This used to enable the data cache for remote targets. The cache\n\ 694 functionality is now controlled by the memory region system and the\n\ 695 \"stack-cache\" flag; \"remotecache\" now does nothing and\n\ 696 exists only for compatibility reasons."),
703 Print information on the dcache performance.\n\ 704 With no arguments, this command prints the cache configuration and a\n\ 705 summary of each line in the cache. Use \"info dcache <lineno> to dump\"\n\ 706 the contents of a given line."));
709 Use this command to set number of lines in dcache and line-size."),
712 Show dcachesettings."),
717 Set dcache line size in bytes (must be power of 2)."),
_(
"\ 718 Show dcache line size."),
725 Set number of dcache lines."),
_(
"\ 726 Show number of dcache lines."),
struct gdbarch * target_gdbarch(void)
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 show_dcache_enabled_p(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int dcache_enabled_p
static void set_dcache_line_size(const char *args, int from_tty, struct cmd_list_element *c)
DCACHE * dcache_init(void)
static struct cmd_list_element * dcache_show_list
static int dcache_splay_tree_compare(splay_tree_key a, splay_tree_key b)
#define DCACHE_DEFAULT_LINE_SIZE
void dcache_free(DCACHE *dcache)
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
static void set_dcache_command(const char *arg, int from_tty)
static void set_dcache_size(const char *args, int from_tty, struct cmd_list_element *c)
static struct dcache_block * dcache_alloc(DCACHE *dcache, CORE_ADDR addr)
struct dcache_block * oldest
static void append_block(struct dcache_block **blist, struct dcache_block *block)
static struct cmd_list_element * dcache_set_list
void printf_filtered(const char *format,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * setlist
void target_dcache_invalidate(void)
static void dcache_invalidate_line(DCACHE *dcache, CORE_ADDR addr)
static void remove_block(struct dcache_block **blist, struct dcache_block *block)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct dcache_block * prev
struct mem_region * lookup_mem_region(CORE_ADDR addr)
static void dcache_info_1(DCACHE *dcache, const char *exp)
struct cmd_list_element * showlist
static void dcache_poke_byte(DCACHE *dcache, CORE_ADDR addr, const gdb_byte *ptr)
static int dcache_read_line(DCACHE *dcache, struct dcache_block *db)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static void for_each_block(struct dcache_block **blist, block_func *func, void *param)
void printf_unfiltered(const char *format,...)
static void show_dcache_command(const char *args, int from_tty)
static void info_dcache_command(const char *exp, int tty)
#define DCACHE_DEFAULT_SIZE
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
static unsigned dcache_line_size
int target_read_raw_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void dcache_invalidate(DCACHE *dcache)
static unsigned dcache_size
static int dcache_peek_byte(DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void _initialize_dcache(void)
static void free_block(struct dcache_block *block, void *param)
const char * target_pid_to_str(ptid_t ptid)
void() block_func(struct dcache_block *block, void *param)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
unsigned long long ULONGEST
static struct dcache_block * dcache_hit(DCACHE *dcache, CORE_ADDR addr)
struct dcache_block * freelist
struct dcache_block * next
static void invalidate_block(struct dcache_block *block, void *param)
void dcache_update(DCACHE *dcache, enum target_xfer_status status, CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len)
DCACHE * target_dcache_get(void)
void error(const char *fmt,...)
static void dcache_print_line(DCACHE *dcache, int index)
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)
enum mem_access_mode mode