gdb: Memory Region Attributes
10.17 Memory Region Attributes
==============================
"Memory region attributes" allow you to describe special handling
required by regions of your target's memory. GDB uses attributes to
determine whether to allow certain types of memory accesses; whether to
use specific width accesses; and whether to cache target memory. By
default the description of memory regions is fetched from the target (if
the current target supports this), but the user can override the fetched
regions.
Defined memory regions can be individually enabled and disabled.
When a memory region is disabled, GDB uses the default attributes when
accessing memory in that region. Similarly, if no memory regions have
been defined, GDB uses the default attributes when accessing all memory.
When a memory region is defined, it is given a number to identify it;
to enable, disable, or remove a memory region, you specify that number.
'mem LOWER UPPER ATTRIBUTES...'
Define a memory region bounded by LOWER and UPPER with attributes
ATTRIBUTES..., and add it to the list of regions monitored by GDB.
Note that UPPER == 0 is a special case: it is treated as the
target's maximum memory address. (0xffff on 16 bit targets,
0xffffffff on 32 bit targets, etc.)
'mem auto'
Discard any user changes to the memory regions and use
target-supplied regions, if available, or no regions if the target
does not support.
'delete mem NUMS...'
Remove memory regions NUMS... from the list of regions monitored by
GDB.
'disable mem NUMS...'
Disable monitoring of memory regions NUMS.... A disabled memory
region is not forgotten. It may be enabled again later.
'enable mem NUMS...'
Enable monitoring of memory regions NUMS....
'info mem'
Print a table of all defined memory regions, with the following
columns for each region:
_Memory Region Number_
_Enabled or Disabled._
Enabled memory regions are marked with 'y'. Disabled memory
regions are marked with 'n'.
_Lo Address_
The address defining the inclusive lower bound of the memory
region.
_Hi Address_
The address defining the exclusive upper bound of the memory
region.
_Attributes_
The list of attributes set for this memory region.
10.17.1 Attributes
------------------
10.17.1.1 Memory Access Mode
............................
The access mode attributes set whether GDB may make read or write
accesses to a memory region.
While these attributes prevent GDB from performing invalid memory
accesses, they do nothing to prevent the target system, I/O DMA, etc.
from accessing memory.
'ro'
Memory is read only.
'wo'
Memory is write only.
'rw'
Memory is read/write. This is the default.
10.17.1.2 Memory Access Size
............................
The access size attribute tells GDB to use specific sized accesses in
the memory region. Often memory mapped device registers require
specific sized accesses. If no access size attribute is specified, GDB
may use accesses of any size.
'8'
Use 8 bit memory accesses.
'16'
Use 16 bit memory accesses.
'32'
Use 32 bit memory accesses.
'64'
Use 64 bit memory accesses.
10.17.1.3 Data Cache
....................
The data cache attributes set whether GDB will cache target memory.
While this generally improves performance by reducing debug protocol
overhead, it can lead to incorrect results because GDB does not know
about volatile variables or memory mapped device registers.
'cache'
Enable GDB to cache target memory.
'nocache'
Disable GDB from caching target memory. This is the default.
10.17.2 Memory Access Checking
------------------------------
GDB can be instructed to refuse accesses to memory that is not
explicitly described. This can be useful if accessing such regions has
undesired effects for a specific target, or to provide better error
checking. The following commands control this behaviour.
'set mem inaccessible-by-default [on|off]'
If 'on' is specified, make GDB treat memory not explicitly
described by the memory ranges as non-existent and refuse accesses
to such memory. The checks are only performed if there's at least
one memory range defined. If 'off' is specified, make GDB treat
the memory not explicitly described by the memory ranges as RAM.
The default value is 'on'.
'show mem inaccessible-by-default'
Show the current handling of accesses to unknown memory.