/* Memory attributes support, for GDB.
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2019 Free Software Foundation, Inc.
This file is part of GDB.
static void
require_user_regions (int from_tty)
{
- struct mem_region *m;
- int ix, length;
-
/* If we're already using a user-provided list, nothing to do. */
if (!mem_use_target ())
return;
lookup_mem_region (CORE_ADDR addr)
{
static struct mem_region region (0, 0);
- struct mem_region *m;
CORE_ADDR lo;
CORE_ADDR hi;
- int ix;
require_target_regions ();
\f
static void
-mem_command (char *args, int from_tty)
+mem_command (const char *args, int from_tty)
{
CORE_ADDR lo, hi;
- char *tok;
if (!args)
error_no_arg (_("No mem"));
require_user_regions (from_tty);
- tok = strtok (args, " \t");
- if (!tok)
+ std::string tok = extract_arg (&args);
+ if (tok == "")
error (_("no lo address"));
- lo = parse_and_eval_address (tok);
+ lo = parse_and_eval_address (tok.c_str ());
- tok = strtok (NULL, " \t");
- if (!tok)
+ tok = extract_arg (&args);
+ if (tok == "")
error (_("no hi address"));
- hi = parse_and_eval_address (tok);
+ hi = parse_and_eval_address (tok.c_str ());
mem_attrib attrib;
- while ((tok = strtok (NULL, " \t")) != NULL)
+ while ((tok = extract_arg (&args)) != "")
{
- if (strcmp (tok, "rw") == 0)
+ if (tok == "rw")
attrib.mode = MEM_RW;
- else if (strcmp (tok, "ro") == 0)
+ else if (tok == "ro")
attrib.mode = MEM_RO;
- else if (strcmp (tok, "wo") == 0)
+ else if (tok == "wo")
attrib.mode = MEM_WO;
- else if (strcmp (tok, "8") == 0)
+ else if (tok == "8")
attrib.width = MEM_WIDTH_8;
- else if (strcmp (tok, "16") == 0)
+ else if (tok == "16")
{
if ((lo % 2 != 0) || (hi % 2 != 0))
error (_("region bounds not 16 bit aligned"));
attrib.width = MEM_WIDTH_16;
}
- else if (strcmp (tok, "32") == 0)
+ else if (tok == "32")
{
if ((lo % 4 != 0) || (hi % 4 != 0))
error (_("region bounds not 32 bit aligned"));
attrib.width = MEM_WIDTH_32;
}
- else if (strcmp (tok, "64") == 0)
+ else if (tok == "64")
{
if ((lo % 8 != 0) || (hi % 8 != 0))
error (_("region bounds not 64 bit aligned"));
}
#if 0
- else if (strcmp (tok, "hwbreak") == 0)
+ else if (tok == "hwbreak")
attrib.hwbreak = 1;
- else if (strcmp (tok, "swbreak") == 0)
+ else if (tok == "swbreak")
attrib.hwbreak = 0;
#endif
- else if (strcmp (tok, "cache") == 0)
+ else if (tok == "cache")
attrib.cache = 1;
- else if (strcmp (tok, "nocache") == 0)
+ else if (tok == "nocache")
attrib.cache = 0;
#if 0
- else if (strcmp (tok, "verify") == 0)
+ else if (tok == "verify")
attrib.verify = 1;
- else if (strcmp (tok, "noverify") == 0)
+ else if (tok == "noverify")
attrib.verify = 0;
#endif
else
- error (_("unknown attribute: %s"), tok);
+ error (_("unknown attribute: %s"), tok.c_str ());
}
create_user_mem_region (lo, hi, attrib);
\f
static void
-info_mem_command (char *args, int from_tty)
+info_mem_command (const char *args, int from_tty)
{
if (mem_use_target ())
printf_filtered (_("Using memory regions provided by the target.\n"));
if (args == NULL || *args == '\0')
{
- struct mem_region *m;
- int ix;
-
for (mem_region &m : *mem_region_list)
m.enabled_p = false;
}
static void
mem_delete (int num)
{
- struct mem_region *m;
- int ix;
-
if (!mem_region_list)
{
printf_unfiltered (_("No memory region number %d.\n"), num);
Define attributes for memory region or reset memory region handling to\n\
target-based.\n\
Usage: mem auto\n\
- mem <lo addr> <hi addr> [<mode> <width> <cache>],\n\
-where <mode> may be rw (read/write), ro (read-only) or wo (write-only),\n\
- <width> may be 8, 16, 32, or 64, and\n\
- <cache> may be cache or nocache"));
+ mem LOW HIGH [MODE WIDTH CACHE],\n\
+where MODE may be rw (read/write), ro (read-only) or wo (write-only),\n\
+ WIDTH may be 8, 16, 32, or 64, and\n\
+ CACHE may be cache or nocache"));
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);
+Arguments are the IDs of the memory regions to enable.\n\
+Usage: enable mem [ID]...\n\
+Do \"info mem\" to see current list of IDs."), &enablelist);
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);
+Arguments are the IDs of the memory regions to disable.\n\
+Usage: disable mem [ID]...\n\
+Do \"info mem\" to see current list of IDs."), &disablelist);
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);
+Arguments are the IDs of the memory regions to delete.\n\
+Usage: delete mem [ID]...\n\
+Do \"info mem\" to see current list of IDs."), &deletelist);
add_info ("mem", info_mem_command,
_("Memory region attributes"));