/* Memory attributes support, for GDB.
- Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbcmd.h"
#include "memattr.h"
#include "target.h"
+#include "target-dcache.h"
#include "value.h"
#include "language.h"
#include "vec.h"
-#include "gdb_string.h"
#include "breakpoint.h"
#include "cli/cli-utils.h"
int
mem_region_cmp (const void *untyped_lhs, const void *untyped_rhs)
{
- const struct mem_region *lhs = untyped_lhs;
- const struct mem_region *rhs = untyped_rhs;
+ const struct mem_region *lhs = (const struct mem_region *) untyped_lhs;
+ const struct mem_region *rhs = (const struct mem_region *) untyped_rhs;
if (lhs->lo < rhs->lo)
return -1;
/* Allocate a new memory region, with default settings. */
void
-mem_region_init (struct mem_region *new)
+mem_region_init (struct mem_region *newobj)
{
- memset (new, 0, sizeof (struct mem_region));
- new->enabled_p = 1;
- new->attrib = default_mem_attrib;
+ memset (newobj, 0, sizeof (struct mem_region));
+ newobj->enabled_p = 1;
+ newobj->attrib = default_mem_attrib;
}
/* This function should be called before any command which would
create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
const struct mem_attrib *attrib)
{
- struct mem_region new;
+ struct mem_region newobj;
int i, ix;
/* lo == hi is a useless empty region. */
return;
}
- mem_region_init (&new);
- new.lo = lo;
- new.hi = hi;
+ mem_region_init (&newobj);
+ newobj.lo = lo;
+ newobj.hi = hi;
- ix = VEC_lower_bound (mem_region_s, mem_region_list, &new,
+ ix = VEC_lower_bound (mem_region_s, mem_region_list, &newobj,
mem_region_lessthan);
/* Check for an overlapping memory region. We only need to check
}
}
- new.number = ++mem_number;
- new.attrib = *attrib;
- VEC_safe_insert (mem_region_s, mem_region_list, ix, &new);
+ newobj.number = ++mem_number;
+ newobj.attrib = *attrib;
+ VEC_safe_insert (mem_region_s, mem_region_list, ix, &newobj);
}
/*
\f
static void
-mem_info_command (char *args, int from_tty)
+info_mem_command (char *args, int from_tty)
{
struct mem_region *m;
struct mem_attrib *attrib;
printf_filtered ("Num ");
printf_filtered ("Enb ");
printf_filtered ("Low Addr ");
- if (gdbarch_addr_bit (target_gdbarch) > 32)
+ if (gdbarch_addr_bit (target_gdbarch ()) > 32)
printf_filtered (" ");
printf_filtered ("High Addr ");
- if (gdbarch_addr_bit (target_gdbarch) > 32)
+ if (gdbarch_addr_bit (target_gdbarch ()) > 32)
printf_filtered (" ");
printf_filtered ("Attrs ");
printf_filtered ("\n");
for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
{
- char *tmp;
+ const char *tmp;
printf_filtered ("%-3d %-3c\t",
m->number,
m->enabled_p ? 'y' : 'n');
- if (gdbarch_addr_bit (target_gdbarch) <= 32)
- tmp = hex_string_custom ((unsigned long) m->lo, 8);
+ if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
+ tmp = hex_string_custom (m->lo, 8);
else
- tmp = hex_string_custom ((unsigned long) m->lo, 16);
+ tmp = hex_string_custom (m->lo, 16);
printf_filtered ("%s ", tmp);
- if (gdbarch_addr_bit (target_gdbarch) <= 32)
+ if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
{
if (m->hi == 0)
tmp = "0x100000000";
else
- tmp = hex_string_custom ((unsigned long) m->hi, 8);
+ tmp = hex_string_custom (m->hi, 8);
}
else
{
if (m->hi == 0)
tmp = "0x10000000000000000";
else
- tmp = hex_string_custom ((unsigned long) m->hi, 16);
+ tmp = hex_string_custom (m->hi, 16);
}
printf_filtered ("%s ", tmp);
}
static void
-mem_enable_command (char *args, int from_tty)
+enable_mem_command (char *args, int from_tty)
{
int num;
struct mem_region *m;
}
else
{
- struct get_number_or_range_state state;
-
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
+ num = parser.get_number ();
mem_enable (num);
}
}
}
static void
-mem_disable_command (char *args, int from_tty)
+disable_mem_command (char *args, int from_tty)
{
- int num;
- struct mem_region *m;
- int ix;
-
require_user_regions (from_tty);
target_dcache_invalidate ();
if (args == NULL || *args == '\0')
{
+ struct mem_region *m;
+ int ix;
+
for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
m->enabled_p = 0;
}
else
{
- struct get_number_or_range_state state;
-
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
+ int num = parser.get_number ();
mem_disable (num);
}
}
}
static void
-mem_delete_command (char *args, int from_tty)
+delete_mem_command (char *args, int from_tty)
{
- int num;
- struct get_number_or_range_state state;
-
require_user_regions (from_tty);
target_dcache_invalidate ();
return;
}
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
+ int num = parser.get_number ();
mem_delete (num);
}
<width> may be 8, 16, 32, or 64, and\n\
<cache> may be cache or nocache"));
- add_cmd ("mem", class_vars, mem_enable_command, _("\
+ add_cmd ("mem", class_vars, enable_mem_command, _("\
Enable memory region.\n\
Arguments are the code numbers of the memory regions to enable.\n\
Usage: enable mem <code number>...\n\
Do \"info mem\" to see current list of code numbers."), &enablelist);
- add_cmd ("mem", class_vars, mem_disable_command, _("\
+ add_cmd ("mem", class_vars, disable_mem_command, _("\
Disable memory region.\n\
Arguments are the code numbers of the memory regions to disable.\n\
Usage: disable mem <code number>...\n\
Do \"info mem\" to see current list of code numbers."), &disablelist);
- add_cmd ("mem", class_vars, mem_delete_command, _("\
+ add_cmd ("mem", class_vars, delete_mem_command, _("\
Delete memory region.\n\
Arguments are the code numbers of the memory regions to delete.\n\
Usage: delete mem <code number>...\n\
Do \"info mem\" to see current list of code numbers."), &deletelist);
- add_info ("mem", mem_info_command,
+ add_info ("mem", info_mem_command,
_("Memory region attributes"));
add_prefix_cmd ("mem", class_vars, dummy_cmd, _("\