Next: Adding a New Target, Previous: Compiler Characteristics, Up: Target Architecture Definition
This section describes the macros and functions that you can use to define the target machine.
CORE_ADDR gdbarch_addr_bits_remove (
gdbarch,
addr)
For example, the two low-order bits of the PC on the Hewlett-Packard PA
2.0 architecture contain the privilege level of the corresponding
instruction. Since instructions must always be aligned on four-byte
boundaries, the processor masks out these bits to generate the actual
address of the instruction. gdbarch_addr_bits_remove
would then for
example look like that:
arch_addr_bits_remove (CORE_ADDR addr) { return (addr &= ~0x3); }
int address_class_name_to_type_flags (
gdbarch,
name,
type_flags_ptr)
int
referenced by type_flags_ptr to the mask representing the qualifier
and return 1. If name is not a valid address class qualifier name,
return 0.
The value for type_flags_ptr should be one of
TYPE_FLAG_ADDRESS_CLASS_1
, TYPE_FLAG_ADDRESS_CLASS_2
, or
possibly some combination of these values or'd together.
See Address Classes.
int address_class_name_to_type_flags_p (
gdbarch)
address_class_name_to_type_flags
has been defined.
int gdbarch_address_class_type_flags (
gdbarch,
byte_size,
dwarf2_addr_class)
DW_AT_address_class
value, return the type flags
used by gdb to represent this address class. The value
returned should be one of TYPE_FLAG_ADDRESS_CLASS_1
,
TYPE_FLAG_ADDRESS_CLASS_2
, or possibly some combination of these
values or'd together.
See Address Classes.
int gdbarch_address_class_type_flags_p (
gdbarch)
gdbarch_address_class_type_flags_p
has
been defined.
const char *gdbarch_address_class_type_flags_to_name (
gdbarch,
type_flags)
int gdbarch_address_class_type_flags_to_name_p (
gdbarch)
gdbarch_address_class_type_flags_to_name
has been defined.
See Address Classes.
void gdbarch_address_to_pointer (
gdbarch,
type,
buf,
addr)
int gdbarch_believe_pcc_promotion (
gdbarch)
short
or char
parameter to an int
, but still reports the parameter as its
original type, rather than the promoted type.
BITS_BIG_ENDIAN
BREAKPOINT
BREAKPOINT
has been deprecated in favor of
gdbarch_breakpoint_from_pc
.
BIG_BREAKPOINT
LITTLE_BREAKPOINT
BIG_BREAKPOINT
and LITTLE_BREAKPOINT
have been deprecated in
favor of gdbarch_breakpoint_from_pc
.
const gdb_byte *gdbarch_breakpoint_from_pc (
gdbarch,
pcptr,
lenptr)
*
lenptr, and adjusts the program
counter (if necessary) to point to the actual memory location where the
breakpoint should be inserted.
Although it is common to use a trap instruction for a breakpoint, it's not required; for instance, the bit pattern could be an invalid instruction. The breakpoint must be no longer than the shortest instruction of the architecture.
Replaces all the other BREAKPOINT macros.
int gdbarch_memory_insert_breakpoint (
gdbarch,
bp_tgt)
gdbarch_memory_remove_breakpoint (
gdbarch,
bp_tgt)
default_memory_insert_breakpoint
and
default_memory_remove_breakpoint
respectively) have been
provided so that it is not necessary to set these for most
architectures. Architectures which may want to set
gdbarch_memory_insert_breakpoint
and gdbarch_memory_remove_breakpoint
will likely have instructions that are oddly sized or are not stored in a
conventional manner.
It may also be desirable (from an efficiency standpoint) to define
custom breakpoint insertion and removal routines if
gdbarch_breakpoint_from_pc
needs to read the target's memory for some
reason.
CORE_ADDR gdbarch_adjust_breakpoint_address (
gdbarch,
bpaddr)
The FR-V target (see frv-tdep.c) requires this method. The FR-V is a VLIW architecture in which a number of RISC-like instructions are grouped (packed) together into an aggregate instruction or instruction bundle. When the processor executes one of these bundles, the component instructions are executed in parallel.
In the course of optimization, the compiler may group instructions from distinct source statements into the same bundle. The line number information associated with one of the latter statements will likely refer to some instruction other than the first one in the bundle. So, if the user attempts to place a breakpoint on one of these latter statements, gdb must be careful to not place the break instruction on any instruction other than the first one in the bundle. (Remember though that the instructions within a bundle execute in parallel, so the first instruction is the instruction at the lowest address and has nothing to do with execution order.)
The FR-V's gdbarch_adjust_breakpoint_address
method will adjust a
breakpoint's address by scanning backwards for the beginning of
the bundle, returning the address of the bundle.
Since the adjustment of a breakpoint may significantly alter a user's
expectation, gdb prints a warning when an adjusted breakpoint
is initially set and each time that that breakpoint is hit.
int gdbarch_call_dummy_location (
gdbarch)
This method has been replaced by gdbarch_push_dummy_code
(see gdbarch_push_dummy_code).
int gdbarch_cannot_fetch_register (
gdbarch,
regum)
FETCH_INFERIOR_REGISTERS
is not defined.
int gdbarch_cannot_store_register (
gdbarch,
regnum)
int gdbarch_convert_register_p (
gdbarch,
regnum, struct type *
type)
CORE_ADDR gdbarch_decr_pc_after_break (
gdbarch)
BREAKPOINT
, though not always. For most targets this value will be 0.
DISABLE_UNSETTABLE_BREAK (
addr)
void gdbarch_print_float_info (
gdbarch,
file,
frame,
args)
void gdbarch_print_registers_info (
gdbarch,
frame,
regnum,
all)
The default method prints one register per line, and if all is
zero omits floating-point registers.
int gdbarch_print_vector_info (
gdbarch,
file,
frame,
args)
By default, the `info vector' command will print all vector
registers (the register's type having the vector attribute).
int gdbarch_dwarf_reg_to_regnum (
gdbarch,
dwarf_regnr)
int gdbarch_dwarf2_reg_to_regnum (
gdbarch,
dwarf2_regnr)
int gdbarch_ecoff_reg_to_regnum (
gdbarch,
ecoff_regnr)
DEPRECATED_FP_REGNUM
This should only need to be defined if DEPRECATED_TARGET_READ_FP
is not defined.
DEPRECATED_FRAMELESS_FUNCTION_INVOCATION(
fi)
CORE_ADDR frame_align (
gdbarch,
address)
This function is used to ensure that, when creating a dummy frame, both the initial stack pointer and (if needed) the address of the return value are correctly aligned.
This function always adjusts the address in the direction of stack growth.
By default, no frame based stack alignment is performed.
int gdbarch_frame_red_zone_size (
gdbarch)
When performing an inferior function call, to ensure that it does not modify this area, gdb adjusts the innermost-stack-address by gdbarch_frame_red_zone_size bytes before pushing parameters onto the stack.
By default, zero bytes are allocated. The value must be aligned (see frame_align).
The amd64 (nee x86-64) abi documentation refers to the
red zone when describing this scratch area.
DEPRECATED_FRAME_CHAIN(
frame)
DEPRECATED_FRAME_CHAIN_VALID(
chain,
thisframe)
NULL
chain pointers, dummy frames, and frames whose PC values are inside the
startup file (e.g. crt0.o), inside main
, or inside
_start
.
DEPRECATED_FRAME_INIT_SAVED_REGS(
frame)
frame->saved_regs
. Space for
frame->saved_regs
shall be allocated by
DEPRECATED_FRAME_INIT_SAVED_REGS
using
frame_saved_regs_zalloc
.
FRAME_FIND_SAVED_REGS
is deprecated.
int gdbarch_frame_num_args (
gdbarch,
frame)
-1
.
DEPRECATED_FRAME_SAVED_PC(
frame)
This method is deprecated. See gdbarch_unwind_pc.
CORE_ADDR gdbarch_unwind_pc (
next_frame)
The implementation, which must be frame agnostic (work with any frame), is typically no more than:
ULONGEST pc; pc = frame_unwind_register_unsigned (next_frame, S390_PC_REGNUM); return gdbarch_addr_bits_remove (gdbarch, pc);
See DEPRECATED_FRAME_SAVED_PC, which this method replaces.
CORE_ADDR gdbarch_unwind_sp (
gdbarch,
next_frame)
The implementation, which must be frame agnostic (work with any frame), is typically no more than:
ULONGEST sp; sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM); return gdbarch_addr_bits_remove (gdbarch, sp);
See TARGET_READ_SP, which this method replaces.
FUNCTION_EPILOGUE_SIZE
x_sym.x_misc.x_fsize
field of the
function end symbol is 0. For such targets, you must define
FUNCTION_EPILOGUE_SIZE
to expand into the standard size of a
function's epilogue.
DEPRECATED_FUNCTION_START_OFFSET
This is zero on almost all machines: the function's address is usually
the address of its first instruction. However, on the VAX, for
example, each function starts with two bytes containing a bitmask
indicating which registers to save upon entry to the function. The
VAX call
instructions check this value, and save the
appropriate registers automatically. Thus, since the offset from the
function's address to its first instruction is two bytes,
DEPRECATED_FUNCTION_START_OFFSET
would be 2 on the VAX.
GCC_COMPILED_FLAG_SYMBOL
GCC2_COMPILED_FLAG_SYMBOL
gcc_compiled.
and gcc2_compiled.
,
respectively. (Currently only defined for the Delta 68.)
gdbarch_get_longjmp_target
This macro determines the target PC address that longjmp
will jump to,
assuming that we have just stopped at a longjmp
breakpoint. It takes a
CORE_ADDR *
as argument, and stores the target PC value through this
pointer. It examines the current state of the machine as needed.
DEPRECATED_IBM6000_TARGET
I386_USE_GENERIC_WATCHPOINTS
int gdbarch_inner_than (
gdbarch,
lhs,
rhs)
lhs < rhs
if the target's stack grows downward in memory, or
lhs > rsh
if the stack grows upward.
gdbarch_in_function_epilogue_p (
gdbarch,
addr)
int gdbarch_in_solib_return_trampoline (
gdbarch,
pc,
name)
IN_SOLIB_DYNSYM_RESOLVE_CODE (
pc)
SKIP_SOLIB_RESOLVER (
pc)
CORE_ADDR gdbarch_integer_to_address (
gdbarch,
type,
buf)
Pragmatics: When the user copies a well defined expression from
their source code and passes it, as a parameter, to gdb's
print
command, they should get the same value as would have been
computed by the target program. Any deviation from this rule can cause
major confusion and annoyance, and needs to be justified carefully. In
other words, gdb doesn't really have the freedom to do these
conversions in clever and useful ways. It has, however, been pointed
out that users aren't complaining about how gdb casts integers
to pointers; they are complaining that they can't take an address from a
disassembly listing and give it to x/i
. Adding an architecture
method like gdbarch_integer_to_address
certainly makes it possible for
gdb to “get it right” in all circumstances.
CORE_ADDR gdbarch_pointer_to_address (
gdbarch,
type,
buf)
void gdbarch_register_to_value(
gdbarch,
frame,
regnum,
type,
fur)
register_reggroup_p (
gdbarch,
regnum,
reggroup)
By default, registers are grouped as follows:
float_reggroup
vector_reggroup
general_reggroup
save_reggroup
restore_reggroup
all_reggroup
DEPRECATED_REGISTER_VIRTUAL_SIZE (
reg)
DEPRECATED_REGISTER_VIRTUAL_TYPE (
reg)
struct type *register_type (
gdbarch,
reg)
DEPRECATED_REGISTER_VIRTUAL_TYPE
. See Raw and Virtual Register Representations.
REGISTER_CONVERT_TO_VIRTUAL(
reg,
type,
from,
to)
REGISTER_CONVERT_TO_RAW(
type,
reg,
from,
to)
const struct regset *regset_from_core_section (struct gdbarch *
gdbarch, const char *
sect_name, size_t
sect_size)
SOFTWARE_SINGLE_STEP_P()
SOFTWARE_SINGLE_STEP
must also be defined.
SOFTWARE_SINGLE_STEP(
signal,
insert_breakpoints_p)
set_gdbarch_sofun_address_maybe_missing (
gdbarch,
set)
Calling set_gdbarch_sofun_address_maybe_missing
with a non-zero
argument set indicates that a particular set of hacks of this sort
are in use, affecting N_SO
and N_FUN
entries in stabs-format
debugging information. N_SO
stabs mark the beginning and ending
addresses of compilation units in the text segment. N_FUN
stabs
mark the starts and ends of functions.
In this case, gdb assumes two things:
N_FUN
stabs have an address of zero. Instead of using those
addresses, you should find the address where the function starts by
taking the function name from the stab, and then looking that up in the
minsyms (the linker/assembler symbol table). In other words, the stab
has the name, and the linker/assembler symbol table is the only place
that carries the address.
N_SO
stabs have an address of zero, too. You just look at the
N_FUN
stabs that appear before and after the N_SO
stab, and
guess the starting and ending addresses of the compilation unit from them.
int gdbarch_pc_regnum (
gdbarch)
This should only need to be defined if gdbarch_read_pc
and
gdbarch_write_pc
are not defined.
int gdbarch_stabs_argument_has_addr (
gdbarch,
type)
PROCESS_LINENUMBER_HOOK
gdbarch_ps_regnum (
gdbarchCORE_ADDR gdbarch_push_dummy_call (
gdbarch,
function,
regcache,
bp_addr,
nargs,
args,
sp,
struct_return,
struct_addr)
function is a pointer to a struct value
; on architectures that use
function descriptors, this contains the function descriptor value.
Returns the updated top-of-stack pointer.
This method replaces DEPRECATED_PUSH_ARGUMENTS
.
CORE_ADDR gdbarch_push_dummy_code (
gdbarch,
sp,
funaddr,
using_gcc,
args,
nargs,
value_type,
real_pc,
bp_addr,
regcache)
Set bp_addr to the address at which the breakpoint instruction should be inserted, real_pc to the resume address when starting the call sequence, and return the updated inner-most stack address.
By default, the stack is grown sufficient to hold a frame-aligned (see frame_align) breakpoint, bp_addr is set to the address reserved for that breakpoint, and real_pc set to funaddr.
This method replaces gdbarch_call_dummy_location (
gdbarch)
and
DEPRECATED_REGISTER_SIZE
.
const char *gdbarch_register_name (
gdbarch,
regnr)
NULL
to indicate that regnr is not a valid register.
SAVE_DUMMY_FRAME_TOS (
sp)
SP
after both the dummy frame and space for parameters/results have been
allocated on the stack. See gdbarch_unwind_dummy_id.
int gdbarch_sdb_reg_to_regnum (
gdbarch,
sdb_regnr)
enum return_value_convention gdbarch_return_value (struct gdbarch *
gdbarch, struct type *
valtype, struct regcache *
regcache, void *
readbuf, const void *
writebuf)
gdb currently recognizes two function return-value conventions:
RETURN_VALUE_REGISTER_CONVENTION
where the return value is found
in registers; and RETURN_VALUE_STRUCT_CONVENTION
where the return
value is found in memory and the address of that memory location is
passed in as the function's first parameter.
If the register convention is being used, and writebuf is
non-NULL
, also copy the return-value in writebuf into
regcache.
If the register convention is being used, and readbuf is
non-NULL
, also copy the return value from regcache into
readbuf (regcache contains a copy of the registers from the
just returned function).
Maintainer note: This method replaces separate predicate, extract, store methods. By having only one method, the logic needed to determine the return-value convention need only be implemented in one place. If gdb were written in an oo language, this method would instead return an object that knew how to perform the register return-value extract and store.
Maintainer note: This method does not take a gcc_p
parameter, and such a parameter should not be added. If an architecture
that requires per-compiler or per-function information be identified,
then the replacement of rettype with struct value
function should be pursued.
Maintainer note: The regcache parameter limits this methods
to the inner most frame. While replacing regcache with a
struct frame_info
frame parameter would remove that
limitation there has yet to be a demonstrated need for such a change.
void gdbarch_skip_permanent_breakpoint (
gdbarch,
regcache)
gdbarch_skip_permanent_breakpoint
adjusts the
processor's state so that execution will resume just after the breakpoint.
This function does the right thing even when the breakpoint is in the delay slot
of a branch or jump.
CORE_ADDR gdbarch_skip_prologue (
gdbarch,
ip)
CORE_ADDR gdbarch_skip_trampoline_code (
gdbarch,
frame,
pc)
int gdbarch_sp_regnum (
gdbarch)
int gdbarch_stab_reg_to_regnum (
gdbarch,
stab_regnr)
SYMBOL_RELOADING_DEFAULT
TARGET_CHAR_BIT
int gdbarch_char_signed (
gdbarch)
char
is normally signed on this architecture; zero if
it should be unsigned.
The ISO C standard requires the compiler to treat char
as
equivalent to either signed char
or unsigned char
; any
character in the standard execution set is supposed to be positive.
Most compilers treat char
as signed, but char
is unsigned
on the IBM S/390, RS6000, and PowerPC targets.
int gdbarch_double_bit (
gdbarch)
8 * TARGET_CHAR_BIT
.
int gdbarch_float_bit (
gdbarch)
4 * TARGET_CHAR_BIT
.
int gdbarch_int_bit (
gdbarch)
4 * TARGET_CHAR_BIT
.
int gdbarch_long_bit (
gdbarch)
4 * TARGET_CHAR_BIT
.
int gdbarch_long_double_bit (
gdbarch)
2 * gdbarch_double_bit (
gdbarch)
.
int gdbarch_long_long_bit (
gdbarch)
2 * gdbarch_long_bit (
gdbarch)
.
int gdbarch_ptr_bit (
gdbarch)
gdbarch_int_bit (
gdbarch)
.
int gdbarch_short_bit (
gdbarch)
2 * TARGET_CHAR_BIT
.
CORE_ADDR gdbarch_read_pc (
gdbarch,
regcache)
gdbarch_write_pc (
gdbarch,
regcache,
val)
TARGET_READ_SP
TARGET_READ_FP
gdbarch_read_pc
,
gdbarch_write_pc
, and read_sp
. For most targets, these may be
left undefined. gdb will call the read and write register
functions with the relevant _REGNUM
argument.
These macros and functions are useful when a target keeps one of these registers in a hard to get at place; for example, part in a segment register and part in an ordinary register.
See gdbarch_unwind_sp, which replaces TARGET_READ_SP
.
void gdbarch_virtual_frame_pointer (
gdbarch,
pc,
frame_regnum,
frame_offset)
(register, offset)
pair representing the virtual frame
pointer in use at the code address pc. If virtual frame pointers
are not used, a default definition simply returns
DEPRECATED_FP_REGNUM
, with an offset of zero.
TARGET_HAS_HARDWARE_WATCHPOINTS
int gdbarch_print_insn (
gdbarch,
vma,
info)
deprecated_tm_print_insn
. This usually points to a function in
the opcodes
library (see Opcodes).
info is a structure (of type disassemble_info
) defined in
include/dis-asm.h used to pass information to the instruction
decoding routine.
frame_id gdbarch_unwind_dummy_id (
gdbarch,
frame)
struct frame_id
that uniquely identifies an inferior function call's dummy
frame. The value returned must match the dummy frame stack value
previously saved using SAVE_DUMMY_FRAME_TOS
.
See SAVE_DUMMY_FRAME_TOS.
DEPRECATED_USE_STRUCT_CONVENTION (
gcc_p,
type)
This method has been deprecated in favour of gdbarch_return_value
(see gdbarch_return_value).
void gdbarch_value_to_register (
gdbarch,
frame,
type,
buf)
Motorola M68K target conditionals.
BPT_VECTOR
0xf
.
REMOTE_BPT_VECTOR
1
.
const char *gdbarch_name_of_malloc (
gdbarch)