]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/memattr.c
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / memattr.c
CommitLineData
80629b1b 1/* Memory attributes support, for GDB.
14a5e767 2
ecd75fc8 3 Copyright (C) 2001-2014 Free Software Foundation, Inc.
80629b1b
EZ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
80629b1b
EZ
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
80629b1b 19
29e57380
C
20#include "defs.h"
21#include "command.h"
22#include "gdbcmd.h"
23#include "memattr.h"
24#include "target.h"
68c765e2 25#include "target-dcache.h"
29e57380
C
26#include "value.h"
27#include "language.h"
c96fc75e 28#include "vec.h"
0e9f083f 29#include <string.h>
fbcb778d 30#include "breakpoint.h"
197f0a60 31#include "cli/cli-utils.h"
29e57380 32
29e57380
C
33const struct mem_attrib default_mem_attrib =
34{
35 MEM_RW, /* mode */
36 MEM_WIDTH_UNSPECIFIED,
81a9a963
AC
37 0, /* hwbreak */
38 0, /* cache */
fd79ecee
DJ
39 0, /* verify */
40 -1 /* Flash blocksize not specified. */
29e57380
C
41};
42
4b5752d0
VP
43const struct mem_attrib unknown_mem_attrib =
44{
45 MEM_NONE, /* mode */
46 MEM_WIDTH_UNSPECIFIED,
47 0, /* hwbreak */
48 0, /* cache */
49 0, /* verify */
50 -1 /* Flash blocksize not specified. */
51};
52
53
fd79ecee 54VEC(mem_region_s) *mem_region_list, *target_mem_region_list;
f4d650ec 55static int mem_number = 0;
29e57380 56
fd79ecee
DJ
57/* If this flag is set, the memory region list should be automatically
58 updated from the target. If it is clear, the list is user-controlled
59 and should be left alone. */
60static int mem_use_target = 1;
61
62/* If this flag is set, we have tried to fetch the target memory regions
63 since the last time it was invalidated. If that list is still
64 empty, then the target can't supply memory regions. */
65static int target_mem_regions_valid;
66
4b5752d0
VP
67/* If this flag is set, gdb will assume that memory ranges not
68 specified by the memory map have type MEM_NONE, and will
69 emit errors on all accesses to that memory. */
56cf5405 70static int inaccessible_by_default = 1;
4b5752d0
VP
71
72static void
73show_inaccessible_by_default (struct ui_file *file, int from_tty,
74 struct cmd_list_element *c,
75 const char *value)
76{
77 if (inaccessible_by_default)
3e43a32a
MS
78 fprintf_filtered (file, _("Unknown memory addresses will "
79 "be treated as inaccessible.\n"));
4b5752d0 80 else
3e43a32a
MS
81 fprintf_filtered (file, _("Unknown memory addresses "
82 "will be treated as RAM.\n"));
4b5752d0
VP
83}
84
85
c96fc75e
DJ
86/* Predicate function which returns true if LHS should sort before RHS
87 in a list of memory regions, useful for VEC_lower_bound. */
88
89static int
90mem_region_lessthan (const struct mem_region *lhs,
91 const struct mem_region *rhs)
92{
93 return lhs->lo < rhs->lo;
94}
95
fd79ecee
DJ
96/* A helper function suitable for qsort, used to sort a
97 VEC(mem_region_s) by starting address. */
98
99int
100mem_region_cmp (const void *untyped_lhs, const void *untyped_rhs)
101{
102 const struct mem_region *lhs = untyped_lhs;
103 const struct mem_region *rhs = untyped_rhs;
104
105 if (lhs->lo < rhs->lo)
106 return -1;
107 else if (lhs->lo == rhs->lo)
108 return 0;
109 else
110 return 1;
111}
112
113/* Allocate a new memory region, with default settings. */
114
115void
116mem_region_init (struct mem_region *new)
117{
118 memset (new, 0, sizeof (struct mem_region));
119 new->enabled_p = 1;
120 new->attrib = default_mem_attrib;
121}
122
123/* This function should be called before any command which would
124 modify the memory region list. It will handle switching from
125 a target-provided list to a local list, if necessary. */
126
127static void
128require_user_regions (int from_tty)
129{
130 struct mem_region *m;
131 int ix, length;
132
133 /* If we're already using a user-provided list, nothing to do. */
134 if (!mem_use_target)
135 return;
136
137 /* Switch to a user-provided list (possibly a copy of the current
138 one). */
139 mem_use_target = 0;
140
141 /* If we don't have a target-provided region list yet, then
142 no need to warn. */
143 if (mem_region_list == NULL)
144 return;
145
146 /* Otherwise, let the user know how to get back. */
147 if (from_tty)
148 warning (_("Switching to manual control of memory regions; use "
149 "\"mem auto\" to fetch regions from the target again."));
150
151 /* And create a new list for the user to modify. */
152 length = VEC_length (mem_region_s, target_mem_region_list);
153 mem_region_list = VEC_alloc (mem_region_s, length);
154 for (ix = 0; VEC_iterate (mem_region_s, target_mem_region_list, ix, m); ix++)
155 VEC_quick_push (mem_region_s, mem_region_list, m);
156}
157
158/* This function should be called before any command which would
159 read the memory region list, other than those which call
160 require_user_regions. It will handle fetching the
161 target-provided list, if necessary. */
162
163static void
164require_target_regions (void)
165{
166 if (mem_use_target && !target_mem_regions_valid)
167 {
168 target_mem_regions_valid = 1;
169 target_mem_region_list = target_memory_map ();
170 mem_region_list = target_mem_region_list;
171 }
172}
173
c96fc75e 174static void
29e57380
C
175create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
176 const struct mem_attrib *attrib)
177{
c96fc75e
DJ
178 struct mem_region new;
179 int i, ix;
29e57380 180
025bb325 181 /* lo == hi is a useless empty region. */
2b236d82 182 if (lo >= hi && hi != 0)
29e57380 183 {
a3f17187 184 printf_unfiltered (_("invalid memory region: low >= high\n"));
c96fc75e 185 return;
29e57380
C
186 }
187
fd79ecee 188 mem_region_init (&new);
c96fc75e
DJ
189 new.lo = lo;
190 new.hi = hi;
191
192 ix = VEC_lower_bound (mem_region_s, mem_region_list, &new,
193 mem_region_lessthan);
194
195 /* Check for an overlapping memory region. We only need to check
196 in the vicinity - at most one before and one after the
197 insertion point. */
198 for (i = ix - 1; i < ix + 1; i++)
29e57380 199 {
c96fc75e
DJ
200 struct mem_region *n;
201
202 if (i < 0)
203 continue;
204 if (i >= VEC_length (mem_region_s, mem_region_list))
205 continue;
206
207 n = VEC_index (mem_region_s, mem_region_list, i);
208
2b236d82
DH
209 if ((lo >= n->lo && (lo < n->hi || n->hi == 0))
210 || (hi > n->lo && (hi <= n->hi || n->hi == 0))
1591a1e8 211 || (lo <= n->lo && ((hi >= n->hi && n->hi != 0) || hi == 0)))
29e57380 212 {
a3f17187 213 printf_unfiltered (_("overlapping memory region\n"));
c96fc75e 214 return;
29e57380
C
215 }
216 }
217
c96fc75e 218 new.number = ++mem_number;
c96fc75e
DJ
219 new.attrib = *attrib;
220 VEC_safe_insert (mem_region_s, mem_region_list, ix, &new);
29e57380
C
221}
222
223/*
224 * Look up the memory region cooresponding to ADDR.
225 */
226struct mem_region *
227lookup_mem_region (CORE_ADDR addr)
228{
229 static struct mem_region region;
230 struct mem_region *m;
231 CORE_ADDR lo;
232 CORE_ADDR hi;
c96fc75e 233 int ix;
29e57380 234
fd79ecee
DJ
235 require_target_regions ();
236
29e57380
C
237 /* First we initialize LO and HI so that they describe the entire
238 memory space. As we process the memory region chain, they are
239 redefined to describe the minimal region containing ADDR. LO
240 and HI are used in the case where no memory region is defined
241 that contains ADDR. If a memory region is disabled, it is
a76d924d
DJ
242 treated as if it does not exist. The initial values for LO
243 and HI represent the bottom and top of memory. */
29e57380 244
a76d924d
DJ
245 lo = 0;
246 hi = 0;
29e57380 247
4b5752d0
VP
248 /* Either find memory range containing ADDRESS, or set LO and HI
249 to the nearest boundaries of an existing memory range.
250
251 If we ever want to support a huge list of memory regions, this
c96fc75e
DJ
252 check should be replaced with a binary search (probably using
253 VEC_lower_bound). */
254 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
29e57380 255 {
b5de0fa7 256 if (m->enabled_p == 1)
29e57380 257 {
3e43a32a
MS
258 /* If the address is in the memory region, return that
259 memory range. */
2b236d82 260 if (addr >= m->lo && (addr < m->hi || m->hi == 0))
29e57380
C
261 return m;
262
a76d924d
DJ
263 /* This (correctly) won't match if m->hi == 0, representing
264 the top of the address space, because CORE_ADDR is unsigned;
265 no value of LO is less than zero. */
29e57380
C
266 if (addr >= m->hi && lo < m->hi)
267 lo = m->hi;
268
a76d924d
DJ
269 /* This will never set HI to zero; if we're here and ADDR
270 is at or below M, and the region starts at zero, then ADDR
271 would have been in the region. */
272 if (addr <= m->lo && (hi == 0 || hi > m->lo))
29e57380
C
273 hi = m->lo;
274 }
275 }
276
277 /* Because no region was found, we must cons up one based on what
278 was learned above. */
279 region.lo = lo;
280 region.hi = hi;
4b5752d0
VP
281
282 /* When no memory map is defined at all, we always return
283 'default_mem_attrib', so that we do not make all memory
284 inaccessible for targets that don't provide a memory map. */
285 if (inaccessible_by_default && !VEC_empty (mem_region_s, mem_region_list))
286 region.attrib = unknown_mem_attrib;
287 else
288 region.attrib = default_mem_attrib;
289
29e57380
C
290 return &region;
291}
fd79ecee
DJ
292
293/* Invalidate any memory regions fetched from the target. */
294
295void
296invalidate_target_mem_regions (void)
297{
fd79ecee
DJ
298 if (!target_mem_regions_valid)
299 return;
300
301 target_mem_regions_valid = 0;
302 VEC_free (mem_region_s, target_mem_region_list);
303 if (mem_use_target)
304 mem_region_list = NULL;
305}
306
025bb325 307/* Clear memory region list. */
fd79ecee
DJ
308
309static void
310mem_clear (void)
311{
312 VEC_free (mem_region_s, mem_region_list);
313}
29e57380
C
314\f
315
316static void
317mem_command (char *args, int from_tty)
318{
319 CORE_ADDR lo, hi;
320 char *tok;
321 struct mem_attrib attrib;
322
323 if (!args)
e2e0b3e5 324 error_no_arg (_("No mem"));
29e57380 325
fd79ecee
DJ
326 /* For "mem auto", switch back to using a target provided list. */
327 if (strcmp (args, "auto") == 0)
328 {
329 if (mem_use_target)
330 return;
331
332 if (mem_region_list != target_mem_region_list)
333 {
334 mem_clear ();
335 mem_region_list = target_mem_region_list;
336 }
337
338 mem_use_target = 1;
339 return;
340 }
341
342 require_user_regions (from_tty);
343
29e57380
C
344 tok = strtok (args, " \t");
345 if (!tok)
8a3fe4f8 346 error (_("no lo address"));
29e57380
C
347 lo = parse_and_eval_address (tok);
348
349 tok = strtok (NULL, " \t");
350 if (!tok)
8a3fe4f8 351 error (_("no hi address"));
29e57380
C
352 hi = parse_and_eval_address (tok);
353
354 attrib = default_mem_attrib;
355 while ((tok = strtok (NULL, " \t")) != NULL)
356 {
357 if (strcmp (tok, "rw") == 0)
358 attrib.mode = MEM_RW;
359 else if (strcmp (tok, "ro") == 0)
360 attrib.mode = MEM_RO;
361 else if (strcmp (tok, "wo") == 0)
362 attrib.mode = MEM_WO;
363
364 else if (strcmp (tok, "8") == 0)
365 attrib.width = MEM_WIDTH_8;
366 else if (strcmp (tok, "16") == 0)
367 {
368 if ((lo % 2 != 0) || (hi % 2 != 0))
8a3fe4f8 369 error (_("region bounds not 16 bit aligned"));
29e57380
C
370 attrib.width = MEM_WIDTH_16;
371 }
372 else if (strcmp (tok, "32") == 0)
373 {
374 if ((lo % 4 != 0) || (hi % 4 != 0))
8a3fe4f8 375 error (_("region bounds not 32 bit aligned"));
29e57380
C
376 attrib.width = MEM_WIDTH_32;
377 }
378 else if (strcmp (tok, "64") == 0)
379 {
380 if ((lo % 8 != 0) || (hi % 8 != 0))
8a3fe4f8 381 error (_("region bounds not 64 bit aligned"));
29e57380
C
382 attrib.width = MEM_WIDTH_64;
383 }
384
385#if 0
386 else if (strcmp (tok, "hwbreak") == 0)
81a9a963 387 attrib.hwbreak = 1;
29e57380 388 else if (strcmp (tok, "swbreak") == 0)
81a9a963 389 attrib.hwbreak = 0;
29e57380
C
390#endif
391
392 else if (strcmp (tok, "cache") == 0)
81a9a963 393 attrib.cache = 1;
29e57380 394 else if (strcmp (tok, "nocache") == 0)
81a9a963 395 attrib.cache = 0;
29e57380
C
396
397#if 0
398 else if (strcmp (tok, "verify") == 0)
81a9a963 399 attrib.verify = 1;
29e57380 400 else if (strcmp (tok, "noverify") == 0)
81a9a963 401 attrib.verify = 0;
29e57380
C
402#endif
403
404 else
8a3fe4f8 405 error (_("unknown attribute: %s"), tok);
29e57380
C
406 }
407
408 create_mem_region (lo, hi, &attrib);
409}
410\f
411
412static void
413mem_info_command (char *args, int from_tty)
414{
415 struct mem_region *m;
416 struct mem_attrib *attrib;
c96fc75e 417 int ix;
29e57380 418
fd79ecee
DJ
419 if (mem_use_target)
420 printf_filtered (_("Using memory regions provided by the target.\n"));
421 else
422 printf_filtered (_("Using user-defined memory regions.\n"));
423
424 require_target_regions ();
425
c96fc75e 426 if (!mem_region_list)
29e57380 427 {
a3f17187 428 printf_unfiltered (_("There are no memory regions defined.\n"));
29e57380
C
429 return;
430 }
431
ab35b611
EZ
432 printf_filtered ("Num ");
433 printf_filtered ("Enb ");
434 printf_filtered ("Low Addr ");
f5656ead 435 if (gdbarch_addr_bit (target_gdbarch ()) > 32)
ab35b611
EZ
436 printf_filtered (" ");
437 printf_filtered ("High Addr ");
f5656ead 438 if (gdbarch_addr_bit (target_gdbarch ()) > 32)
ab35b611
EZ
439 printf_filtered (" ");
440 printf_filtered ("Attrs ");
441 printf_filtered ("\n");
442
c96fc75e 443 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
29e57380 444 {
ab35b611 445 char *tmp;
b8d56208 446
ab35b611 447 printf_filtered ("%-3d %-3c\t",
29e57380 448 m->number,
b5de0fa7 449 m->enabled_p ? 'y' : 'n');
f5656ead 450 if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
bb599908 451 tmp = hex_string_custom ((unsigned long) m->lo, 8);
ab35b611 452 else
bb599908 453 tmp = hex_string_custom ((unsigned long) m->lo, 16);
ab35b611
EZ
454
455 printf_filtered ("%s ", tmp);
2b236d82 456
f5656ead 457 if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
2163ab9d 458 {
b8d56208
MS
459 if (m->hi == 0)
460 tmp = "0x100000000";
461 else
462 tmp = hex_string_custom ((unsigned long) m->hi, 8);
2163ab9d 463 }
ab35b611 464 else
2163ab9d 465 {
b8d56208
MS
466 if (m->hi == 0)
467 tmp = "0x10000000000000000";
468 else
469 tmp = hex_string_custom ((unsigned long) m->hi, 16);
2163ab9d
DH
470 }
471
ab35b611 472 printf_filtered ("%s ", tmp);
29e57380
C
473
474 /* Print a token for each attribute.
475
476 * FIXME: Should we output a comma after each token? It may
477 * make it easier for users to read, but we'd lose the ability
478 * to cut-and-paste the list of attributes when defining a new
479 * region. Perhaps that is not important.
480 *
481 * FIXME: If more attributes are added to GDB, the output may
482 * become cluttered and difficult for users to read. At that
483 * time, we may want to consider printing tokens only if they
484 * are different from the default attribute. */
485
486 attrib = &m->attrib;
487 switch (attrib->mode)
488 {
489 case MEM_RW:
490 printf_filtered ("rw ");
491 break;
492 case MEM_RO:
493 printf_filtered ("ro ");
494 break;
495 case MEM_WO:
496 printf_filtered ("wo ");
497 break;
fd79ecee
DJ
498 case MEM_FLASH:
499 printf_filtered ("flash blocksize 0x%x ", attrib->blocksize);
500 break;
29e57380
C
501 }
502
503 switch (attrib->width)
504 {
505 case MEM_WIDTH_8:
506 printf_filtered ("8 ");
507 break;
508 case MEM_WIDTH_16:
509 printf_filtered ("16 ");
510 break;
511 case MEM_WIDTH_32:
512 printf_filtered ("32 ");
513 break;
514 case MEM_WIDTH_64:
515 printf_filtered ("64 ");
516 break;
517 case MEM_WIDTH_UNSPECIFIED:
518 break;
519 }
520
521#if 0
522 if (attrib->hwbreak)
523 printf_filtered ("hwbreak");
524 else
525 printf_filtered ("swbreak");
526#endif
527
528 if (attrib->cache)
529 printf_filtered ("cache ");
530 else
531 printf_filtered ("nocache ");
532
533#if 0
534 if (attrib->verify)
535 printf_filtered ("verify ");
536 else
537 printf_filtered ("noverify ");
538#endif
539
540 printf_filtered ("\n");
541
542 gdb_flush (gdb_stdout);
543 }
544}
545\f
546
025bb325 547/* Enable the memory region number NUM. */
29e57380
C
548
549static void
550mem_enable (int num)
551{
552 struct mem_region *m;
c96fc75e 553 int ix;
29e57380 554
c96fc75e 555 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
29e57380
C
556 if (m->number == num)
557 {
b5de0fa7 558 m->enabled_p = 1;
29e57380
C
559 return;
560 }
a3f17187 561 printf_unfiltered (_("No memory region number %d.\n"), num);
29e57380
C
562}
563
564static void
565mem_enable_command (char *args, int from_tty)
566{
29e57380
C
567 int num;
568 struct mem_region *m;
c96fc75e 569 int ix;
29e57380 570
fd79ecee
DJ
571 require_user_regions (from_tty);
572
4e5d721f 573 target_dcache_invalidate ();
29e57380 574
fbcb778d
MS
575 if (args == NULL || *args == '\0')
576 { /* Enable all mem regions. */
c96fc75e 577 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
b5de0fa7 578 m->enabled_p = 1;
29e57380
C
579 }
580 else
197f0a60
TT
581 {
582 struct get_number_or_range_state state;
583
584 init_number_or_range (&state, args);
585 while (!state.finished)
586 {
587 num = get_number_or_range (&state);
588 mem_enable (num);
589 }
590 }
29e57380
C
591}
592\f
593
025bb325 594/* Disable the memory region number NUM. */
29e57380
C
595
596static void
597mem_disable (int num)
598{
599 struct mem_region *m;
c96fc75e 600 int ix;
29e57380 601
c96fc75e 602 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
29e57380
C
603 if (m->number == num)
604 {
b5de0fa7 605 m->enabled_p = 0;
29e57380
C
606 return;
607 }
a3f17187 608 printf_unfiltered (_("No memory region number %d.\n"), num);
29e57380
C
609}
610
611static void
612mem_disable_command (char *args, int from_tty)
613{
29e57380
C
614 int num;
615 struct mem_region *m;
c96fc75e 616 int ix;
29e57380 617
fd79ecee
DJ
618 require_user_regions (from_tty);
619
4e5d721f 620 target_dcache_invalidate ();
29e57380 621
fbcb778d 622 if (args == NULL || *args == '\0')
29e57380 623 {
c96fc75e 624 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
b5de0fa7 625 m->enabled_p = 0;
29e57380
C
626 }
627 else
197f0a60
TT
628 {
629 struct get_number_or_range_state state;
630
631 init_number_or_range (&state, args);
632 while (!state.finished)
633 {
634 num = get_number_or_range (&state);
635 mem_disable (num);
636 }
637 }
29e57380
C
638}
639
025bb325 640/* Delete the memory region number NUM. */
29e57380
C
641
642static void
643mem_delete (int num)
644{
6b4398f7 645 struct mem_region *m;
c96fc75e 646 int ix;
29e57380 647
c96fc75e 648 if (!mem_region_list)
29e57380 649 {
a3f17187 650 printf_unfiltered (_("No memory region number %d.\n"), num);
29e57380
C
651 return;
652 }
653
c96fc75e
DJ
654 for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
655 if (m->number == num)
656 break;
657
658 if (m == NULL)
29e57380 659 {
c96fc75e
DJ
660 printf_unfiltered (_("No memory region number %d.\n"), num);
661 return;
29e57380 662 }
c96fc75e
DJ
663
664 VEC_ordered_remove (mem_region_s, mem_region_list, ix);
29e57380
C
665}
666
667static void
668mem_delete_command (char *args, int from_tty)
669{
29e57380 670 int num;
197f0a60 671 struct get_number_or_range_state state;
29e57380 672
fd79ecee
DJ
673 require_user_regions (from_tty);
674
4e5d721f 675 target_dcache_invalidate ();
29e57380 676
fbcb778d 677 if (args == NULL || *args == '\0')
29e57380 678 {
9e2f0ad4 679 if (query (_("Delete all memory regions? ")))
29e57380
C
680 mem_clear ();
681 dont_repeat ();
682 return;
683 }
684
197f0a60
TT
685 init_number_or_range (&state, args);
686 while (!state.finished)
29e57380 687 {
197f0a60 688 num = get_number_or_range (&state);
29e57380 689 mem_delete (num);
29e57380
C
690 }
691
692 dont_repeat ();
693}
4b5752d0
VP
694
695static void
696dummy_cmd (char *args, int from_tty)
697{
698}
29e57380 699\f
b9362cc7
AC
700extern initialize_file_ftype _initialize_mem; /* -Wmissing-prototype */
701
4b5752d0
VP
702static struct cmd_list_element *mem_set_cmdlist;
703static struct cmd_list_element *mem_show_cmdlist;
704
29e57380 705void
5ae5f592 706_initialize_mem (void)
29e57380 707{
1bedd215 708 add_com ("mem", class_vars, mem_command, _("\
fd79ecee
DJ
709Define attributes for memory region or reset memory region handling to\n\
710target-based.\n\
711Usage: mem auto\n\
cce7e648
PA
712 mem <lo addr> <hi addr> [<mode> <width> <cache>],\n\
713where <mode> may be rw (read/write), ro (read-only) or wo (write-only),\n\
714 <width> may be 8, 16, 32, or 64, and\n\
1bedd215 715 <cache> may be cache or nocache"));
29e57380 716
1a966eab
AC
717 add_cmd ("mem", class_vars, mem_enable_command, _("\
718Enable memory region.\n\
29e57380 719Arguments are the code numbers of the memory regions to enable.\n\
fbcb778d 720Usage: enable mem <code number>...\n\
1a966eab 721Do \"info mem\" to see current list of code numbers."), &enablelist);
29e57380 722
1a966eab
AC
723 add_cmd ("mem", class_vars, mem_disable_command, _("\
724Disable memory region.\n\
29e57380 725Arguments are the code numbers of the memory regions to disable.\n\
fbcb778d 726Usage: disable mem <code number>...\n\
1a966eab 727Do \"info mem\" to see current list of code numbers."), &disablelist);
29e57380 728
1a966eab
AC
729 add_cmd ("mem", class_vars, mem_delete_command, _("\
730Delete memory region.\n\
29e57380 731Arguments are the code numbers of the memory regions to delete.\n\
fbcb778d 732Usage: delete mem <code number>...\n\
1a966eab 733Do \"info mem\" to see current list of code numbers."), &deletelist);
29e57380
C
734
735 add_info ("mem", mem_info_command,
1bedd215 736 _("Memory region attributes"));
4b5752d0
VP
737
738 add_prefix_cmd ("mem", class_vars, dummy_cmd, _("\
739Memory regions settings"),
740 &mem_set_cmdlist, "set mem ",
741 0/* allow-unknown */, &setlist);
742 add_prefix_cmd ("mem", class_vars, dummy_cmd, _("\
743Memory regions settings"),
744 &mem_show_cmdlist, "show mem ",
745 0/* allow-unknown */, &showlist);
746
747 add_setshow_boolean_cmd ("inaccessible-by-default", no_class,
748 &inaccessible_by_default, _("\
749Set handling of unknown memory regions."), _("\
750Show handling of unknown memory regions."), _("\
751If on, and some memory map is defined, debugger will emit errors on\n\
752accesses to memory not defined in the memory map. If off, accesses to all\n\
753memory addresses will be allowed."),
754 NULL,
755 show_inaccessible_by_default,
756 &mem_set_cmdlist,
757 &mem_show_cmdlist);
29e57380 758}