Next: Register and Memory Data, Previous: Address Classes, Up: Target Architecture Definition
Maintainer note: This section is pretty much obsolete. The functionality described here has largely been replaced by pseudo-registers and the mechanisms described in Using Different Register and Memory Data Representations. See also Bug Tracking Database and ARI Index for more up-to-date information.
Some architectures use one representation for a value when it lives in a
register, but use a different representation when it lives in memory.
In gdb's terminology, the raw representation is the one used in
the target registers, and the virtual representation is the one
used in memory, and within gdb struct value
objects.
Maintainer note: Notice that the same mechanism is being used to
both convert a register to a struct value
and alternative
register forms.
For almost all data types on almost all architectures, the virtual and raw representations are identical, and no special handling is needed. However, they do occasionally differ. For example:
long double
type. However, when
we store those values in memory, they occupy twelve bytes: the
floating-point number occupies the first ten, and the final two bytes
are unused. This keeps the values aligned on four-byte boundaries,
allowing more efficient access. Thus, the x86 80-bit floating-point
type is the raw representation, and the twelve-byte loosely-packed
arrangement is the virtual representation.
In general, the raw representation is determined by the architecture, or
gdb's interface to the architecture, while the virtual representation
can be chosen for gdb's convenience. gdb's register file,
registers
, holds the register contents in raw format, and the
gdb remote protocol transmits register values in raw format.
Your architecture may define the following macros to request conversions between the raw and virtual format:
Return non-zero if register number reg's value needs different raw and virtual formats.
You should not use
REGISTER_CONVERT_TO_VIRTUAL
for a register unless this macro returns a non-zero value for that register.
The size of register number reg's raw value. This is the number of bytes the register will occupy in
registers
, or in a gdb remote protocol packet.
The size of register number reg's value, in its virtual format. This is the size a
struct value
's buffer will have, holding that register's value.
This is the type of the virtual representation of register number reg. Note that there is no need for a macro giving a type for the register's raw form; once the register's value has been obtained, gdb always uses the virtual form.
Convert the value of register number reg to type, which should always be
DEPRECATED_REGISTER_VIRTUAL_TYPE (
reg)
. The buffer at from holds the register's value in raw format; the macro should convert the value to virtual format, and place it at to.Note that
REGISTER_CONVERT_TO_VIRTUAL
andREGISTER_CONVERT_TO_RAW
take their reg and type arguments in different orders.You should only use
REGISTER_CONVERT_TO_VIRTUAL
with registers for which theREGISTER_CONVERTIBLE
macro returns a non-zero value.
Convert the value of register number reg to type, which should always be
DEPRECATED_REGISTER_VIRTUAL_TYPE (
reg)
. The buffer at from holds the register's value in raw format; the macro should convert the value to virtual format, and place it at to.Note that REGISTER_CONVERT_TO_VIRTUAL and REGISTER_CONVERT_TO_RAW take their reg and type arguments in different orders.