GDB Internals - Host Definition

Go to the first, previous, next, last section, table of contents.

# Host Definition

With the advent of autoconf, it's rarely necessary to have host definition machinery anymore.

## Adding a New Host

Most of GDB's host configuration support happens via autoconf. It should be rare to need new host-specific definitions. GDB still uses the host-specific definitions and files listed below, but these mostly exist for historical reasons, and should eventually disappear.

Several files control GDB's configuration for host systems:

``gdb/config/arch/xyz.mh'`
  Specifies Makefile fragments needed when hosting on machine xyz. In particular, this lists the required machine-dependent object files, by defining ``XDEPFILES=...'`. Also specifies the header file which describes host xyz, by defining `XM_FILE= xm-xyz.h`. You can also define `CC`, `SYSV_DEFINE`, `XM_CFLAGS`, `XM_ADD_FILES`, `XM_CLIBS`, `XM_CDEPS`, etc.; see ``Makefile.in'`.
``gdb/config/arch/xm-xyz.h'`
  (``xm.h'` is a link to this file, created by configure). Contains C macro definitions describing the host system environment, such as byte order, host C compiler and library.
``gdb/xyz-xdep.c'`
  Contains any miscellaneous C code required for this machine as a host. On most machines it doesn't exist at all. If it does exist, put ``xyz-xdep.o'` into the `XDEPFILES` line in ``gdb/config/arch/xyz.mh'`.

### Generic Host Support Files

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 ``xm-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 `XDEPFILES`.

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-xdep.c`, and put `xyz-xdep.o` into `XDEPFILES`.

``ser-unix.c'`
  This contains serial line support for Unix systems. This is always included, via the makefile variable `SER_HARDWIRE`; override this variable in the ``.mh'` file to avoid it.
``ser-go32.c'`
  This contains serial line support for 32-bit programs running under DOS, using the GO32 execution environment.
``ser-tcp.c'`
  This contains generic TCP support using sockets.

## Host Conditionals

When GDB is configured and compiled, various macros are defined or left undefined, to control compilation based on the attributes of the host system. These macros and their meanings (or if the meaning is not documented here, then one of the source files where they are used is indicated) are:

`GDBINIT_FILENAME`
  The default name of GDB's initialization file (normally ``.gdbinit'`).
`MEM_FNS_DECLARED`
  Your host config file defines this if it includes declarations of `memcpy` and `memset`. Define this to avoid conflicts between the native include files and the declarations in ``defs.h'`.
`NO_STD_REGS`
  This macro is deprecated.
`NO_SYS_FILE`
  Define this if your system does not have a `<sys/file.h>`.
`SIGWINCH_HANDLER`
  If your host defines `SIGWINCH`, you can define this to be the name of a function to be called if `SIGWINCH` is received.
`SIGWINCH_HANDLER_BODY`
  Define this to expand into code that will define the function named by the expansion of `SIGWINCH_HANDLER`.
`ALIGN_STACK_ON_STARTUP`
  Define this if your system is of a sort that will crash in `tgetent` if the stack happens not to be longword-aligned when `main` is called. This is a rare situation, but is known to occur on several different types of systems.
`CRLF_SOURCE_FILES`
  Define this if host files use `\r\n` rather than `\n` as a line terminator. This will cause source file listings to omit `\r` characters when printing and it will allow \r\n line endings of files which are "sourced" by gdb. It must be possible to open files in binary mode using `O_BINARY` or, for fopen, `"rb"`.
`DEFAULT_PROMPT`
  The default value of the prompt string (normally `"(gdb) "`).
`DEV_TTY`
  The name of the generic TTY device, defaults to `"/dev/tty"`.
`FCLOSE_PROVIDED`
  Define this if the system declares `fclose` in the headers included in `defs.h`. This isn't needed unless your compiler is unusually anal.
`FOPEN_RB`
  Define this if binary files are opened the same way as text files.
`GETENV_PROVIDED`
  Define this if the system declares `getenv` in its headers included in `defs.h`. This isn't needed unless your compiler is unusually anal.
`HAVE_MMAP`
  In some cases, use the system call `mmap` for reading symbol tables. For some machines this allows for sharing and quick updates.
`HAVE_SIGSETMASK`
  Define this if the host system has job control, but does not define `sigsetmask()`. Currently, this is only true of the RS/6000.
`HAVE_TERMIO`
  Define this if the host system has `termio.h`.
`HOST_BYTE_ORDER`
  The ordering of bytes in the host. This must be defined to be either `BIG_ENDIAN` or `LITTLE_ENDIAN`.
`INT_MAX`
`INT_MIN`
`LONG_MAX`
`UINT_MAX`
`ULONG_MAX`
  Values for host-side constants.
`ISATTY`
  Substitute for isatty, if not available.
`LONGEST`
  This is the longest integer type available on the host. If not defined, it will default to `long long` or `long`, depending on `CC_HAS_LONG_LONG`.
`CC_HAS_LONG_LONG`
  Define this if the host C compiler supports "long long". This is set by the configure script.
`PRINTF_HAS_LONG_LONG`
  Define this if the host can handle printing of long long integers via the printf format directive "ll". This is set by the configure script.
`HAVE_LONG_DOUBLE`
  Define this if the host C compiler supports "long double". This is set by the configure script.
`PRINTF_HAS_LONG_DOUBLE`
  Define this if the host can handle printing of long double float-point numbers via the printf format directive "Lg". This is set by the configure script.
`SCANF_HAS_LONG_DOUBLE`
  Define this if the host can handle the parsing of long double float-point numbers via the scanf format directive directive "Lg". This is set by the configure script.
`LSEEK_NOT_LINEAR`
  Define this if `lseek (n)` does not necessarily move to byte number `n` in the file. This is only used when reading source files. It is normally faster to define `CRLF_SOURCE_FILES` when possible.
`L_SET`
  This macro is used as the argument to lseek (or, most commonly, bfd_seek). FIXME, should be replaced by SEEK_SET instead, which is the POSIX equivalent.
`MALLOC_INCOMPATIBLE`
  Define this if the system's prototype for `malloc` differs from the ANSI definition.
`MMAP_BASE_ADDRESS`
  When using HAVE_MMAP, the first mapping should go at this address.
`MMAP_INCREMENT`
  when using HAVE_MMAP, this is the increment between mappings.
`NEED_POSIX_SETPGID`
  Define this to use the POSIX version of `setpgid` to determine whether job control is available.
`NORETURN`
  If defined, this should be one or more tokens, such as `volatile`, that can be used in both the declaration and definition of functions to indicate that they never return. The default is already set correctly if compiling with GCC. This will almost never need to be defined.
`ATTR_NORETURN`
  If defined, this should be one or more tokens, such as `__attribute__ ((noreturn))`, that can be used in the declarations of functions to indicate that they never return. The default is already set correctly if compiling with GCC. This will almost never need to be defined.
`USE_GENERIC_DUMMY_FRAMES`
  Define this to 1 if the target is using the generic inferior function call code. See `blockframe.c` for more information.
`USE_MMALLOC`
  GDB will use the `mmalloc` library for memory allocation for symbol reading if this symbol is defined. Be careful defining it since there are systems on which `mmalloc` does not work for some reason. One example is the DECstation, where its RPC library can't cope with our redefinition of `malloc` to call `mmalloc`. When defining `USE_MMALLOC`, you will also have to set `MMALLOC` in the Makefile, to point to the mmalloc library. This define is set when you configure with --with-mmalloc.
`NO_MMCHECK`
  Define this if you are using `mmalloc`, but don't want the overhead of checking the heap with `mmcheck`. Note that on some systems, the C runtime makes calls to malloc prior to calling `main`, and if `free` is ever called with these pointers after calling `mmcheck` to enable checking, a memory corruption abort is certain to occur. These systems can still use mmalloc, but must define NO_MMCHECK.
`MMCHECK_FORCE`
  Define this to 1 if the C runtime allocates memory prior to `mmcheck` being called, but that memory is never freed so we don't have to worry about it triggering a memory corruption abort. The default is 0, which means that `mmcheck` will only install the heap checking functions if there has not yet been any memory allocation calls, and if it fails to install the functions, gdb will issue a warning. This is currently defined if you configure using --with-mmalloc.
`NO_SIGINTERRUPT`
  Define this to indicate that siginterrupt() is not available.
`R_OK`
  Define if this is not in a system .h file.
`SEEK_CUR`
`SEEK_SET`
  Define these to appropriate value for the system lseek(), if not already defined.
`STOP_SIGNAL`
  This is the signal for stopping GDB. Defaults to SIGTSTP. (Only redefined for the Convex.)
`USE_O_NOCTTY`
  Define this if the interior's tty should be opened with the O_NOCTTY flag. (FIXME: This should be a native-only flag, but ``inflow.c'` is always linked in.)
`USG`
  Means that System V (prior to SVR4) include files are in use. (FIXME: This symbol is abused in ``infrun.c'`, ``regex.c'`, ``remote-nindy.c'`, and ``utils.c'` for other things, at the moment.)
`lint`
  Define this to help placate lint in some situations.
`volatile`
  Define this to override the defaults of `__volatile__` or `/**/`.

Go to the first, previous, next, last section, table of contents.