54 static int mem_number = 0;
59 static int mem_use_target = 1;
64 static int target_mem_regions_valid;
69 static int inaccessible_by_default = 1;
72 show_inaccessible_by_default (
struct ui_file *file,
int from_tty,
76 if (inaccessible_by_default)
78 "be treated as inaccessible.\n"));
81 "will be treated as RAM.\n"));
92 return lhs->
lo < rhs->
lo;
104 if (lhs->
lo < rhs->
lo)
106 else if (lhs->
lo == rhs->
lo)
117 memset (newobj, 0,
sizeof (
struct mem_region));
142 if (mem_region_list == NULL)
147 warning (
_(
"Switching to manual control of memory regions; use "
148 "\"mem auto\" to fetch regions from the target again."));
165 if (mem_use_target && !target_mem_regions_valid)
167 target_mem_regions_valid = 1;
168 target_mem_region_list = target_memory_map ();
169 mem_region_list = target_mem_region_list;
181 if (lo >= hi && hi != 0)
197 for (i = ix - 1; i < ix + 1; i++)
208 if ((lo >= n->
lo && (lo < n->hi || n->
hi == 0))
209 || (hi > n->
lo && (hi <= n->hi || n->
hi == 0))
210 || (lo <= n->lo && ((hi >= n->
hi && n->
hi != 0) || hi == 0)))
217 newobj.
number = ++mem_number;
259 if (addr >= m->
lo && (addr < m->hi || m->
hi == 0))
265 if (addr >= m->
hi && lo < m->hi)
271 if (addr <= m->lo && (hi == 0 || hi > m->
lo))
285 region.
attrib = unknown_mem_attrib;
287 region.
attrib = default_mem_attrib;
297 if (!target_mem_regions_valid)
300 target_mem_regions_valid = 0;
303 mem_region_list = NULL;
326 if (strcmp (args,
"auto") == 0)
331 if (mem_region_list != target_mem_region_list)
334 mem_region_list = target_mem_region_list;
343 tok = strtok (args,
" \t");
345 error (
_(
"no lo address"));
348 tok = strtok (NULL,
" \t");
350 error (
_(
"no hi address"));
354 while ((tok = strtok (NULL,
" \t")) != NULL)
356 if (strcmp (tok,
"rw") == 0)
358 else if (strcmp (tok,
"ro") == 0)
360 else if (strcmp (tok,
"wo") == 0)
363 else if (strcmp (tok,
"8") == 0)
365 else if (strcmp (tok,
"16") == 0)
367 if ((lo % 2 != 0) || (hi % 2 != 0))
368 error (
_(
"region bounds not 16 bit aligned"));
371 else if (strcmp (tok,
"32") == 0)
373 if ((lo % 4 != 0) || (hi % 4 != 0))
374 error (
_(
"region bounds not 32 bit aligned"));
377 else if (strcmp (tok,
"64") == 0)
379 if ((lo % 8 != 0) || (hi % 8 != 0))
380 error (
_(
"region bounds not 64 bit aligned"));
385 else if (strcmp (tok,
"hwbreak") == 0)
387 else if (strcmp (tok,
"swbreak") == 0)
391 else if (strcmp (tok,
"cache") == 0)
393 else if (strcmp (tok,
"nocache") == 0)
397 else if (strcmp (tok,
"verify") == 0)
399 else if (strcmp (tok,
"noverify") == 0)
404 error (
_(
"unknown attribute: %s"), tok);
425 if (!mem_region_list)
466 tmp =
"0x10000000000000000";
486 switch (attrib->
mode)
502 switch (attrib->
width)
574 if (args == NULL || *args ==
'\0')
621 if (args == NULL || *args ==
'\0')
647 if (!mem_region_list)
676 if (args == NULL || *args ==
'\0')
678 if (
query (
_(
"Delete all memory regions? ")))
708 Define attributes for memory region or reset memory region handling to\n\
711 mem <lo addr> <hi addr> [<mode> <width> <cache>],\n\
712 where <mode> may be rw (read/write), ro (read-only) or wo (write-only),\n\
713 <width> may be 8, 16, 32, or 64, and\n\
714 <cache> may be cache or nocache"));
717 Enable memory region.\n\
718 Arguments are the code numbers of the memory regions to enable.\n\
719 Usage: enable mem <code number>...\n\
720 Do \"info mem\" to see current list of code numbers."), &
enablelist);
723 Disable memory region.\n\
724 Arguments are the code numbers of the memory regions to disable.\n\
725 Usage: disable mem <code number>...\n\
726 Do \"info mem\" to see current list of code numbers."), &
disablelist);
729 Delete memory region.\n\
730 Arguments are the code numbers of the memory regions to delete.\n\
731 Usage: delete mem <code number>...\n\
732 Do \"info mem\" to see current list of code numbers."), &
deletelist);
735 _(
"Memory region attributes"));
738 Memory regions settings"),
739 &mem_set_cmdlist,
"set mem ",
742 Memory regions settings"),
743 &mem_show_cmdlist,
"show mem ",
747 &inaccessible_by_default,
_(
"\
748 Set handling of unknown memory regions."),
_(
"\
749 Show handling of unknown memory regions."),
_(
"\
750 If on, and some memory map is defined, debugger will emit errors on\n\
751 accesses to memory not defined in the memory map. If off, accesses to all\n\
752 memory addresses will be allowed."),
754 show_inaccessible_by_default,
void error_no_arg(const char *why)
struct gdbarch * target_gdbarch(void)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static void mem_info_command(char *args, int from_tty)
static void mem_enable(int num)
struct cmd_list_element * enablelist
void warning(const char *fmt,...)
int query(const char *ctlstr,...)
struct ui_file * gdb_stdout
struct cmd_list_element * deletelist
static void mem_disable(int num)
static void dummy_cmd(char *args, int from_tty)
#define VEC_lower_bound(T, V, O, LT)
const struct mem_attrib default_mem_attrib
#define VEC_quick_push(T, V, O)
static void require_user_regions(int from_tty)
void mem_region_init(struct mem_region *newobj)
void printf_filtered(const char *format,...)
initialize_file_ftype _initialize_mem
static struct cmd_list_element * mem_show_cmdlist
static void create_mem_region(CORE_ADDR lo, CORE_ADDR hi, const struct mem_attrib *attrib)
struct cmd_list_element * setlist
#define VEC_iterate(T, V, I, P)
void target_dcache_invalidate(void)
void initialize_file_ftype(void)
static void mem_disable_command(char *args, int from_tty)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct mem_region * lookup_mem_region(CORE_ADDR addr)
struct cmd_list_element * showlist
static int mem_region_lessthan(const struct mem_region *lhs, const struct mem_region *rhs)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
static void mem_delete(int num)
#define VEC_index(T, V, I)
struct cmd_list_element * add_info(const char *name, cmd_cfunc_ftype *fun, const char *doc)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
void printf_unfiltered(const char *format,...)
static struct cmd_list_element * mem_set_cmdlist
struct cmd_list_element * disablelist
static void mem_enable_command(char *args, int from_tty)
static void mem_delete_command(char *args, int from_tty)
char * hex_string_custom(LONGEST num, int width)
static void mem_clear(void)
CORE_ADDR parse_and_eval_address(const char *exp)
static void mem_command(char *args, int from_tty)
#define VEC_safe_insert(T, V, I, O)
void gdb_flush(struct ui_file *file)
int get_number_or_range(struct get_number_or_range_state *state)
void invalidate_target_mem_regions(void)
enum mem_access_width width
void error(const char *fmt,...)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
void init_number_or_range(struct get_number_or_range_state *state, const char *string)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int mem_region_cmp(const void *untyped_lhs, const void *untyped_rhs)
enum mem_access_mode mode
#define VEC_ordered_remove(T, V, I)
static void require_target_regions(void)