This page was produced by an automated import process, and may have formatting errors; feel free to fix. [Using-Different-Register-and-Memory-Data-Representations ]

Using Different Register and Memory Data Representations

Some architectures have different representations of data objects, depending whether the object is held in a register or memory. For example:

In general, the register representation of a data type is determined by the architecture, or GDB’s interface to the architecture, while the memory representation is determined by the Application Binary Interface.

For almost all data types on almost all architectures, the two representations are identical, and no special handling is needed. However, they do occasionally differ. An architecture may define the following struct gdbarch functions to request conversions between the register and memory representations of a data type:

Architecture Function: ''int'' gdbarch_convert_register_p ''(struct gdbarch *''gdbarch'', int ''reg'')''

Return non-zero (true) if the representation of a data value stored in this register may be different to the representation of that same data value when stored in memory. The default value is NULL (undefined).

If this function is defined and returns non-zero, the struct gdbarch functions gdbarch_register_to_value and gdbarch_value_to_register (see below) should be used to perform any necessary conversion.

If defined, this function should return zero for the register’s native type, when no conversion is necessary.

Architecture Function: ''void'' gdbarch_register_to_value ''(struct gdbarch *''gdbarch'', int ''reg'', struct type *''type'', char *''from'', char *''to'')''

Convert the value of register number reg to a data object of type type. The buffer at from holds the register’s value in raw format; the converted value should be placed in the buffer at to.

Note: gdbarch_register_to_value and gdbarch_value_to_register take their reg and type arguments in different orders.

gdbarch_register_to_value should only be used with registers for which the gdbarch_convert_register_p function returns a non-zero value.

Architecture Function: ''void'' gdbarch_value_to_register ''(struct gdbarch *''gdbarch'', struct type *''type'', int ''reg'', char *''from'', char *''to'')''

Convert a data value of type type to register number reg’ raw format.

Note: gdbarch_register_to_value and gdbarch_value_to_register take their reg and type arguments in different orders.

gdbarch_value_to_register should only be used with registers for which the gdbarch_convert_register_p function returns a non-zero value.

None: Internals Register-and-Memory-Data (last edited 2013-08-20 23:41:19 by StanShebs)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.