If you are making GDB run native on the xxx machine, you have plenty more work to do. Several files control GDB's configuration for native support:
There are some "generic" versions of routines that can be used by
various systems. These can be customized in various ways by macros
defined in your `nm-xxx.h' file. If these routines work for
the xxx host, you can just include the generic file's name (with
`.o', not `.c') in NATDEPFILES
.
Otherwise, if your machine needs custom support routines, you will need
to write routines that perform the same functions as the generic file.
Put them into xxx-nat.c
, and put xxx-nat.o
into NATDEPFILES
.
ptrace
call in a vanilla way.
register_addr()
, see below.
Now that BFD is used to read core files, virtually all machines should
use coredep.c
, and should just provide fetch_core_registers
in
xxx-nat.c
(or REGISTER_U_ADDR
in nm-xxx.h
).
nm-xxx.h
file defines the macro
REGISTER_U_ADDR(addr, blockend, regno)
, it should be defined to
set addr
to the offset within the `user'
struct of GDB register number regno
. blockend
is the
offset within the "upage" of u.u_ar0
.
If REGISTER_U_ADDR
is defined,
`coredep.c' will define the register_addr()
function and use
the macro in it. If you do not define REGISTER_U_ADDR
, but you
are using the standard fetch_core_registers()
, you will need to
define your own version of register_addr()
, put it into your
xxx-nat.c
file, and be sure xxx-nat.o
is in
the NATDEPFILES
list. If you have your own
fetch_core_registers()
, you may not need a separate
register_addr()
. Many custom fetch_core_registers()
implementations simply locate the registers themselves.
When making GDB run native on a new operating system,
to make it possible to debug
core files, you will need to either write specific code for parsing your
OS's core files, or customize `bfd/trad-core.c'. First, use
whatever #include
files your machine uses to define the struct of
registers that is accessible (possibly in the u-area) in a core file
(rather than `machine/reg.h'), and an include file that defines whatever
header exists on a core file (e.g. the u-area or a `struct core'). Then
modify trad_unix_core_file_p()
to use these values to set up the
section information for the data segment, stack segment, any other
segments in the core file (perhaps shared library contents or control
information), "registers" segment, and if there are two discontiguous
sets of registers (e.g. integer and float), the "reg2" segment. This
section information basically delimits areas in the core file in a
standard way, which the section-reading routines in BFD know how to seek
around in.
Then back in GDB, you need a matching routine called
fetch_core_registers()
. If you can use the generic one, it's in
`coredep.c'; if not, it's in your `xxx-nat.c' file.
It will be passed a char pointer to the entire "registers" segment,
its length, and a zero; or a char pointer to the entire "regs2"
segment, its length, and a 2. The routine should suck out the supplied
register values and install them into GDB's "registers" array.
(See section Defining a New Host or Target Architecture,
for more info about this.)
If your system uses `/proc' to control processes, and uses ELF format core files, then you may be able to use the same routines for reading the registers out of processes and out of core files.