14 Native Debugging
Several files control gdb's configuration for native support:
- gdb/config/arch/xyz.mh
- Specifies Makefile fragments needed by a native configuration on
machine xyz. In particular, this lists the required
native-dependent object files, by defining ‘NATDEPFILES=...’.
Also specifies the header file which describes native support on
xyz, by defining ‘NAT_FILE= nm-xyz.h’. You can also
define ‘NAT_CFLAGS’, ‘NAT_ADD_FILES’, ‘NAT_CLIBS’,
‘NAT_CDEPS’, ‘NAT_GENERATED_FILES’, etc.; see Makefile.in.
Maintainer's note: The .mh suffix is because this file
originally contained Makefile fragments for hosting gdb
on machine xyz. While the file is no longer used for this
purpose, the .mh suffix remains. Perhaps someone will
eventually rename these fragments so that they have a .mn
suffix.
- gdb/config/arch/nm-xyz.h
- (nm.h is a link to this file, created by
configure
). Contains C
macro definitions describing the native system environment, such as
child process control and core file support.
- gdb/xyz-nat.c
- Contains any miscellaneous C code required for this native support of
this machine. On some machines it doesn't exist at all.
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-xyz.h file. If these routines work for
the xyz 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 xyz-nat.c, and put xyz-nat.o
into NATDEPFILES
.
- inftarg.c
- This contains the target_ops vector that supports Unix child
processes on systems which use ptrace and wait to control the child.
- procfs.c
- This contains the target_ops vector that supports Unix child
processes on systems which use /proc to control the child.
- fork-child.c
- This does the low-level grunge that uses Unix system calls to do a “fork
and exec” to start up a child process.
- infptrace.c
- This is the low level interface to inferior processes for systems using
the Unix
ptrace
call in a vanilla way.
14.1 ptrace
14.2 /proc
14.3 win32
14.4 shared libraries
14.5 Native Conditionals
When gdb is configured and compiled, various macros are
defined or left undefined, to control compilation when the host and
target systems are the same. These macros should be defined (or left
undefined) in nm-system.h.
I386_USE_GENERIC_WATCHPOINTS
- An x86-based machine can define this to use the generic x86 watchpoint
support; see I386_USE_GENERIC_WATCHPOINTS.
SOLIB_ADD (
filename,
from_tty,
targ,
readsyms)
- Define this to expand into an expression that will cause the symbols in
filename to be added to gdb's symbol table. If
readsyms is zero symbols are not read but any necessary low level
processing for filename is still done.
SOLIB_CREATE_INFERIOR_HOOK
- Define this to expand into any shared-library-relocation code that you
want to be run just after the child process has been forked.
START_INFERIOR_TRAPS_EXPECTED
- When starting an inferior, gdb normally expects to trap
twice; once when
the shell execs, and once when the program itself execs. If the actual
number of traps is something other than 2, then define this macro to
expand into the number expected.