2 @setfilename gdbint.info
8 * Gdb-Internals: (gdbint). The GNU debugger's internals.
14 This file documents the internals of the GNU debugger GDB.
16 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
17 Contributed by Cygnus Support. Written by John Gilmore.
19 Permission is granted to make and distribute verbatim copies of
20 this manual provided the copyright notice and this permission notice
21 are preserved on all copies.
24 Permission is granted to process this file through Tex and print the
25 results, provided the printed document carries copying permission
26 notice identical to this one except for the removal of this paragraph
27 (this paragraph not being relevant to the printed manual).
30 Permission is granted to copy or distribute modified versions of this
31 manual under the terms of the GPL (for which purpose this text may be
32 regarded as a program in the language TeX).
35 @setchapternewpage off
36 @settitle GDB Internals
38 @title{Working in GDB}
39 @subtitle{A guide to the internals of the GNU debugger}
41 @author Cygnus Support
44 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
45 \xdef\manvers{\$Revision$} % For use in headers, footers too
47 \hfill Cygnus Support\par
49 \hfill \TeX{}info \texinfoversion\par
53 @vskip 0pt plus 1filll
54 Copyright @copyright{} 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
56 Permission is granted to make and distribute verbatim copies of
57 this manual provided the copyright notice and this permission notice
58 are preserved on all copies.
63 @c Perhaps this should be the title of the document (but only for info,
64 @c not for TeX). Existing GNU manuals seem inconsistent on this point.
65 @top Scope of this Document
67 This document documents the internals of the GNU debugger, GDB. It is
68 intended to document aspects of GDB which apply across many different
69 parts of GDB (for example, @pxref{Coding Style}), or which are global
70 aspects of design (for example, what are the major modules and which
71 files document them in detail?). Information which pertains to specific
72 data structures, functions, variables, etc., should be put in comments
73 in the source code, not here. It is more likely to get noticed and kept
74 up to date there. Some of the information in this document should
75 probably be moved into comments.
78 * README:: The README File
79 * Getting Started:: Getting started working on GDB
80 * Debugging GDB:: Debugging GDB with itself
81 * New Architectures:: Defining a New Host or Target Architecture
82 * Config:: Adding a New Configuration
83 * Host:: Adding a New Host
84 * Native:: Adding a New Native Configuration
85 * Target:: Adding a New Target
86 * Languages:: Defining New Source Languages
87 * Releases:: Configuring GDB for Release
88 * Partial Symbol Tables:: How GDB reads symbols quickly at startup
89 * Types:: How GDB keeps track of types
90 * BFD support for GDB:: How BFD and GDB interface
91 * Symbol Reading:: Defining New Symbol Readers
93 * Wrapping:: Wrapping Output Lines
94 * Frames:: Keeping track of function calls
95 * Remote Stubs:: Code that runs in targets and talks to GDB
96 * Longjmp Support:: Stepping through longjmp's in the target
97 * Coding Style:: Strunk and White for GDB maintainers
98 * Clean Design:: Frank Lloyd Wright for GDB maintainers
99 * Submitting Patches:: How to get your changes into GDB releases
100 * Host Conditionals:: What features exist in the host
101 * Target Conditionals:: What features exist in the target
102 * Native Conditionals:: Conditionals for when host and target are same
103 * Obsolete Conditionals:: Conditionals that don't exist any more
104 * XCOFF:: The Object file format used on IBM's RS/6000
108 @chapter The @file{README} File
110 Check the @file{README} file, it often has useful information that does not
111 appear anywhere else in the directory.
113 @node Getting Started
114 @chapter Getting Started Working on GDB
116 GDB is a large and complicated program, and if you first starting to
117 work on it, it can be hard to know where to start. Fortunately, if you
118 know how to go about it, there are ways to figure out what is going on:
122 This manual, the GDB Internals manual, has information which applies
123 generally to many parts of GDB.
126 Information about particular functions or data structures are located in
127 comments with those functions or data structures. If you run across a
128 function or a global variable which does not have a comment correctly
129 explaining what is does, this can be thought of as a bug in GDB; feel
130 free to submit a bug report, with a suggested comment if you can figure
131 out what the comment should say (@pxref{Submitting Patches}). If you
132 find a comment which is actually wrong, be especially sure to report that.
134 Comments explaining the function of macros defined in host, target, or
135 native dependent files can be in several places. Sometimes they are
136 repeated every place the macro is defined. Sometimes they are where the
137 macro is used. Sometimes there is a header file which supplies a
138 default definition of the macro, and the comment is there. This manual
139 also has a list of macros (@pxref{Host Conditionals}, @pxref{Target
140 Conditionals}, @pxref{Native Conditionals}, and @pxref{Obsolete
141 Conditionals}) with some documentation.
144 Start with the header files. Once you some idea of how GDB's internal
145 symbol tables are stored (see @file{symtab.h}, @file{gdbtypes.h}), you
146 will find it much easier to understand the code which uses and creates
150 You may wish to process the information you are getting somehow, to
151 enhance your understanding of it. Summarize it, translate it to another
152 language, add some (perhaps trivial or non-useful) feature to GDB, use
153 the code to predict what a test case would do and write the test case
154 and verify your prediction, etc. If you are reading code and your eyes
155 are starting to glaze over, this is a sign you need to use a more active
159 Once you have a part of GDB to start with, you can find more
160 specifically the part you are looking for by stepping through each
161 function with the @code{next} command. Do not use @code{step} or you
162 will quickly get distracted; when the function you are stepping through
163 calls another function try only to get a big-picture understanding
164 (perhaps using the comment at the beginning of the function being
165 called) of what it does. This way you can identify which of the
166 functions being called by the function you are stepping through is the
167 one which you are interested in. You may need to examine the data
168 structures generated at each stage, with reference to the comments in
169 the header files explaining what the data structures are supposed to
172 Of course, this same technique can be used if you are just reading the
173 code, rather than actually stepping through it. The same general
174 principle applies---when the code you are looking at calls something
175 else, just try to understand generally what the code being called does,
176 rather than worrying about all its details.
179 A good place to start when tracking down some particular area is with a
180 command which invokes that feature. Suppose you want to know how
181 single-stepping works. As a GDB user, you know that the @code{step}
182 command invokes single-stepping. The command is invoked via command
183 tables (see @file{command.h}); by convention the function which actually
184 performs the command is formed by taking the name of the command and
185 adding @samp{_command}, or in the case of an @code{info} subcommand,
186 @samp{_info}. For example, the @code{step} command invokes the
187 @code{step_command} function and the @code{info display} command invokes
188 @code{display_info}. When this convention is not followed, you might
189 have to use @code{grep} or @kbd{M-x tags-search} in emacs, or run GDB on
190 itself and set a breakpoint in @code{execute_command}.
193 If all of the above fail, it may be appropriate to ask for information
194 on @code{bug-gdb}. But @emph{never} post a generic question like ``I was
195 wondering if anyone could give me some tips about understanding
196 GDB''---if we had some magic secret we would put it in this manual.
197 Suggestions for improving the manual are always welcome, of course.
203 @chapter Debugging GDB with itself
204 If gdb is limping on your machine, this is the preferred way to get it
205 fully functional. Be warned that in some ancient Unix systems, like
206 Ultrix 4.2, a program can't be running in one process while it is being
207 debugged in another. Rather than typing the command @code{@w{./gdb
208 ./gdb}}, which works on Suns and such, you can copy @file{gdb} to
209 @file{gdb2} and then type @code{@w{./gdb ./gdb2}}.
211 When you run gdb in the gdb source directory, it will read a
212 @file{.gdbinit} file that sets up some simple things to make debugging
213 gdb easier. The @code{info} command, when executed without a subcommand
214 in a gdb being debugged by gdb, will pop you back up to the top level
215 gdb. See @file{.gdbinit} for details.
217 If you use emacs, you will probably want to do a @code{make TAGS} after
218 you configure your distribution; this will put the machine dependent
219 routines for your local machine where they will be accessed first by
222 Also, make sure that you've either compiled gdb with your local cc, or
223 have run @code{fixincludes} if you are compiling with gcc.
225 @node New Architectures
226 @chapter Defining a New Host or Target Architecture
228 When building support for a new host and/or target, much of the work you
229 need to do is handled by specifying configuration files;
230 @pxref{Config,,Adding a New Configuration}. Further work can be
231 divided into ``host-dependent'' (@pxref{Host,,Adding a New Host}) and
232 ``target-dependent'' (@pxref{Target,,Adding a New Target}). The
233 following discussion is meant to explain the difference between hosts
236 @heading What is considered ``host-dependent'' versus ``target-dependent''?
238 @dfn{Host} refers to attributes of the system where GDB runs.
239 @dfn{Target} refers to the system where the program being debugged
240 executes. In most cases they are the same machine, in which case
241 a third type of @dfn{Native} attributes come into play.
243 Defines and include files needed to build on the host are host support.
244 Examples are tty support, system defined types, host byte order, host
247 Defines and information needed to handle the target format are target
248 dependent. Examples are the stack frame format, instruction set,
249 breakpoint instruction, registers, and how to set up and tear down the stack
252 Information that is only needed when the host and target are the same,
253 is native dependent. One example is Unix child process support; if the
254 host and target are not the same, doing a fork to start the target
255 process is a bad idea. The various macros needed for finding the
256 registers in the @code{upage}, running @code{ptrace}, and such are all in the
257 native-dependent files.
259 Another example of native-dependent code is support for features
260 that are really part of the target environment, but which require
261 @code{#include} files that are only available on the host system.
262 Core file handling and @code{setjmp} handling are two common cases.
264 When you want to make GDB work ``native'' on a particular
265 machine, you have to include all three kinds of information.
267 The dependent information in GDB is organized into files by naming
273 Sets Makefile parameters
274 @item config/*/xm-*.h
275 Global #include's and #define's and definitions
277 Global variables and functions
280 Native-Dependent Files
283 Sets Makefile parameters (for @emph{both} host and native)
284 @item config/*/nm-*.h
285 #include's and #define's and definitions. This file
286 is only included by the small number of modules that need it,
287 so beware of doing feature-test #define's from its macros.
289 global variables and functions
292 Target-Dependent Files
295 Sets Makefile parameters
296 @item config/*/tm-*.h
297 Global #include's and #define's and definitions
299 Global variables and functions
302 At this writing, most supported hosts have had their host and native
303 dependencies sorted out properly. There are a few stragglers, which
304 can be recognized by the absence of NATDEPFILES lines in their
305 @file{config/*/*.mh}.
308 @chapter Adding a New Configuration
310 Most of the work in making GDB compile on a new machine is in specifying
311 the configuration of the machine. This is done in a dizzying variety of
312 header files and configuration scripts, which we hope to make more
313 sensible soon. Let's say your new host is called an @var{xxx} (e.g.
314 @samp{sun4}), and its full three-part configuration name is
315 @code{@var{xarch}-@var{xvend}-@var{xos}} (e.g. @samp{sparc-sun-sunos4}). In
318 In the top level directory, edit @file{config.sub} and add @var{xarch},
319 @var{xvend}, and @var{xos} to the lists of supported architectures,
320 vendors, and operating systems near the bottom of the file. Also, add
321 @var{xxx} as an alias that maps to
322 @code{@var{xarch}-@var{xvend}-@var{xos}}. You can test your changes by
326 ./config.sub @var{xxx}
331 ./config.sub @code{@var{xarch}-@var{xvend}-@var{xos}}
334 which should both respond with @code{@var{xarch}-@var{xvend}-@var{xos}}
335 and no error messages.
337 Now, go to the @file{bfd} directory and
338 create a new file @file{bfd/hosts/h-@var{xxx}.h}. Examine the
339 other @file{h-*.h} files as templates, and create one that brings in the
340 right include files for your system, and defines any host-specific
341 macros needed by BFD, the Binutils, GNU LD, or the Opcodes directories.
342 (They all share the bfd @file{hosts} directory and the @file{configure.host}
345 Then edit @file{bfd/configure.host}. Add a line to recognize your
346 @code{@var{xarch}-@var{xvend}-@var{xos}} configuration, and set
347 @code{my_host} to @var{xxx} when you recognize it. This will cause your
348 file @file{h-@var{xxx}.h} to be linked to @file{sysdep.h} at configuration
349 time. When creating the line that recognizes your configuration,
350 only match the fields that you really need to match; e.g. don't match
351 match the architecture or manufacturer if the OS is sufficient
352 to distinguish the configuration that your @file{h-@var{xxx}.h} file supports.
353 Don't match the manufacturer name unless you really need to.
354 This should make future ports easier.
356 Also, if this host requires any changes to the Makefile, create a file
357 @file{bfd/config/@var{xxx}.mh}, which includes the required lines.
359 It's possible that the @file{libiberty} and @file{readline} directories
360 won't need any changes for your configuration, but if they do, you can
361 change the @file{configure.in} file there to recognize your system and
362 map to an @file{mh-@var{xxx}} file. Then add @file{mh-@var{xxx}}
363 to the @file{config/} subdirectory, to set any makefile variables you
364 need. The only current options in there are things like @samp{-DSYSV}.
365 (This @file{mh-@var{xxx}} naming convention differs from elsewhere
366 in GDB, by historical accident. It should be cleaned up so that all
367 such files are called @file{@var{xxx}.mh}.)
369 Aha! Now to configure GDB itself! Edit
370 @file{gdb/configure.in} to recognize your system and set @code{gdb_host}
371 to @var{xxx}, and (unless your desired target is already available) also
372 set @code{gdb_target} to something appropriate (for instance,
373 @var{xxx}). To handle new hosts, modify the segment after the comment
374 @samp{# per-host}; to handle new targets, modify after @samp{#
376 @c Would it be simpler to just use different per-host and per-target
377 @c *scripts*, and call them from {configure} ?
379 Finally, you'll need to specify and define GDB's host-, native-, and
380 target-dependent @file{.h} and @file{.c} files used for your
381 configuration; the next two chapters discuss those.
385 @chapter Adding a New Host
387 Once you have specified a new configuration for your host
388 (@pxref{Config,,Adding a New Configuration}), there are three remaining
389 pieces to making GDB work on a new machine. First, you have to make it
390 host on the new machine (compile there, handle that machine's terminals
391 properly, etc). If you will be cross-debugging to some other kind of
392 system that's already supported, you are done.
394 If you want to use GDB to debug programs that run on the new machine,
395 you have to get it to understand the machine's object files, symbol
396 files, and interfaces to processes; @pxref{Target,,Adding a New Target}
397 and @pxref{Native,,Adding a New Native Configuration}
399 Several files control GDB's configuration for host systems:
402 @item gdb/config/@var{arch}/@var{xxx}.mh
403 Specifies Makefile fragments needed when hosting on machine @var{xxx}.
404 In particular, this lists the required machine-dependent object files,
405 by defining @samp{XDEPFILES=@dots{}}. Also
406 specifies the header file which describes host @var{xxx}, by defining
407 @code{XM_FILE= xm-@var{xxx}.h}. You can also define @code{CC},
408 @code{REGEX} and @code{REGEX1}, @code{SYSV_DEFINE}, @code{XM_CFLAGS},
409 @code{XM_ADD_FILES}, @code{XM_CLIBS}, @code{XM_CDEPS},
410 etc.; see @file{Makefile.in}.
412 @item gdb/config/@var{arch}/xm-@var{xxx}.h
413 (@file{xm.h} is a link to this file, created by configure).
414 Contains C macro definitions describing the host system environment,
415 such as byte order, host C compiler and library, ptrace support,
416 and core file structure. Crib from existing @file{xm-*.h} files
419 @item gdb/@var{xxx}-xdep.c
420 Contains any miscellaneous C code required for this machine
421 as a host. On many machines it doesn't exist at all. If it does
422 exist, put @file{@var{xxx}-xdep.o} into the @code{XDEPFILES} line
423 in @file{gdb/config/mh-@var{xxx}}.
426 @subheading Generic Host Support Files
428 There are some ``generic'' versions of routines that can be used by
429 various systems. These can be customized in various ways by macros
430 defined in your @file{xm-@var{xxx}.h} file. If these routines work for
431 the @var{xxx} host, you can just include the generic file's name (with
432 @samp{.o}, not @samp{.c}) in @code{XDEPFILES}.
434 Otherwise, if your machine needs custom support routines, you will need
435 to write routines that perform the same functions as the generic file.
436 Put them into @code{@var{xxx}-xdep.c}, and put @code{@var{xxx}-xdep.o}
437 into @code{XDEPFILES}.
441 This contains serial line support for Berkeley-derived Unix systems.
444 This contains serial line support for 32-bit programs running under DOS
445 using the GO32 execution environment.
448 This contains serial line support for System V-derived Unix systems.
451 Now, you are now ready to try configuring GDB to compile using your system
452 as its host. From the top level (above @file{bfd}, @file{gdb}, etc), do:
455 ./configure @var{xxx} +target=vxworks960
458 This will configure your system to cross-compile for VxWorks on
459 the Intel 960, which is probably not what you really want, but it's
460 a test case that works at this stage. (You haven't set up to be
461 able to debug programs that run @emph{on} @var{xxx} yet.)
463 If this succeeds, you can try building it all with:
469 Repeat until the program configures, compiles, links, and runs.
470 When run, it won't be able to do much (unless you have a VxWorks/960
471 board on your network) but you will know that the host support is
474 Good luck! Comments and suggestions about this section are particularly
475 welcome; send them to @samp{bug-gdb@@prep.ai.mit.edu}.
478 @chapter Adding a New Native Configuration
480 If you are making GDB run native on the @var{xxx} machine, you have
481 plenty more work to do. Several files control GDB's configuration for
485 @item gdb/config/@var{xarch}/@var{xxx}.mh
486 Specifies Makefile fragments needed when hosting @emph{or native}
487 on machine @var{xxx}.
488 In particular, this lists the required native-dependent object files,
489 by defining @samp{NATDEPFILES=@dots{}}. Also
490 specifies the header file which describes native support on @var{xxx},
491 by defining @samp{NAT_FILE= nm-@var{xxx}.h}.
492 You can also define @samp{NAT_CFLAGS},
493 @samp{NAT_ADD_FILES}, @samp{NAT_CLIBS}, @samp{NAT_CDEPS},
494 etc.; see @file{Makefile.in}.
496 @item gdb/config/@var{arch}/nm-@var{xxx}.h
497 (@file{nm.h} is a link to this file, created by configure).
498 Contains C macro definitions describing the native system environment,
499 such as child process control and core file support.
500 Crib from existing @file{nm-*.h} files to create a new one.
502 @item gdb/@var{xxx}-nat.c
503 Contains any miscellaneous C code required for this native support
504 of this machine. On some machines it doesn't exist at all.
507 @subheading Generic Native Support Files
509 There are some ``generic'' versions of routines that can be used by
510 various systems. These can be customized in various ways by macros
511 defined in your @file{nm-@var{xxx}.h} file. If these routines work for
512 the @var{xxx} host, you can just include the generic file's name (with
513 @samp{.o}, not @samp{.c}) in @code{NATDEPFILES}.
515 Otherwise, if your machine needs custom support routines, you will need
516 to write routines that perform the same functions as the generic file.
517 Put them into @code{@var{xxx}-nat.c}, and put @code{@var{xxx}-nat.o}
518 into @code{NATDEPFILES}.
523 This contains the @emph{target_ops vector} that supports Unix child
524 processes on systems which use ptrace and wait to control the child.
527 This contains the @emph{target_ops vector} that supports Unix child
528 processes on systems which use /proc to control the child.
531 This does the low-level grunge that uses Unix system calls
532 to do a "fork and exec" to start up a child process.
535 This is the low level interface to inferior processes for systems
536 using the Unix @code{ptrace} call in a vanilla way.
538 @item coredep.c::fetch_core_registers()
539 Support for reading registers out of a core file. This routine calls
540 @code{register_addr()}, see below.
541 Now that BFD is used to read core files, virtually all machines should
542 use @code{coredep.c}, and should just provide @code{fetch_core_registers} in
543 @code{@var{xxx}-nat.c} (or @code{REGISTER_U_ADDR} in @code{nm-@var{xxx}.h}).
545 @item coredep.c::register_addr()
546 If your @code{nm-@var{xxx}.h} file defines the macro
547 @code{REGISTER_U_ADDR(addr, blockend, regno)}, it should be defined to
548 set @code{addr} to the offset within the @samp{user}
549 struct of GDB register number @code{regno}. @code{blockend} is the
550 offset within the ``upage'' of @code{u.u_ar0}.
551 If @code{REGISTER_U_ADDR} is defined,
552 @file{coredep.c} will define the @code{register_addr()} function and use
553 the macro in it. If you do not define @code{REGISTER_U_ADDR}, but you
554 are using the standard @code{fetch_core_registers()}, you will need to
555 define your own version of @code{register_addr()}, put it into your
556 @code{@var{xxx}-nat.c} file, and be sure @code{@var{xxx}-nat.o} is in
557 the @code{NATDEPFILES} list. If you have your own
558 @code{fetch_core_registers()}, you may not need a separate
559 @code{register_addr()}. Many custom @code{fetch_core_registers()}
560 implementations simply locate the registers themselves.@refill
563 When making GDB run native on a new operating system,
564 to make it possible to debug
565 core files, you will need to either write specific code for parsing your
566 OS's core files, or customize @file{bfd/trad-core.c}. First, use
567 whatever @code{#include} files your machine uses to define the struct of
568 registers that is accessible (possibly in the u-area) in a core file
569 (rather than @file{machine/reg.h}), and an include file that defines whatever
570 header exists on a core file (e.g. the u-area or a @samp{struct core}). Then
571 modify @code{trad_unix_core_file_p()} to use these values to set up the
572 section information for the data segment, stack segment, any other
573 segments in the core file (perhaps shared library contents or control
574 information), ``registers'' segment, and if there are two discontiguous
575 sets of registers (e.g. integer and float), the ``reg2'' segment. This
576 section information basically delimits areas in the core file in a
577 standard way, which the section-reading routines in BFD know how to seek
580 Then back in GDB, you need a matching routine called
581 @code{fetch_core_registers()}. If you can use the generic one, it's in
582 @file{coredep.c}; if not, it's in your @file{@var{xxx}-nat.c} file.
583 It will be passed a char pointer to the entire ``registers'' segment,
584 its length, and a zero; or a char pointer to the entire ``regs2''
585 segment, its length, and a 2. The routine should suck out the supplied
586 register values and install them into GDB's ``registers'' array.
587 (@xref{New Architectures,,Defining a New Host or Target Architecture},
588 for more info about this.)
590 If your system uses @file{/proc} to control processes, and uses ELF
591 format core files, then you may be able to use the same routines
592 for reading the registers out of processes and out of core files.
595 @chapter Adding a New Target
597 For a new target called @var{ttt}, first specify the configuration as
598 described in @ref{Config,,Adding a New Configuration}. If your new
599 target is the same as your new host, you've probably already done that.
601 A variety of files specify attributes of the GDB target environment:
604 @item gdb/config/@var{arch}/@var{ttt}.mt
605 Contains a Makefile fragment specific to this target.
606 Specifies what object files are needed for target @var{ttt}, by
607 defining @samp{TDEPFILES=@dots{}}.
608 Also specifies the header file which describes @var{ttt}, by defining
609 @samp{TM_FILE= tm-@var{ttt}.h}. You can also define @samp{TM_CFLAGS},
610 @samp{TM_CLIBS}, @samp{TM_CDEPS},
611 and other Makefile variables here; see @file{Makefile.in}.
613 @item gdb/config/@var{arch}/tm-@var{ttt}.h
614 (@file{tm.h} is a link to this file, created by configure).
615 Contains macro definitions about the target machine's
616 registers, stack frame format and instructions.
617 Crib from existing @file{tm-*.h} files when building a new one.
619 @item gdb/@var{ttt}-tdep.c
620 Contains any miscellaneous code required for this target machine.
621 On some machines it doesn't exist at all. Sometimes the macros
622 in @file{tm-@var{ttt}.h} become very complicated, so they are
623 implemented as functions here instead, and the macro is simply
624 defined to call the function.
627 Defines functions for accessing files that are
628 executable on the target system. These functions open and examine an
629 exec file, extract data from one, write data to one, print information
630 about one, etc. Now that executable files are handled with BFD, every
631 target should be able to use the generic exec.c rather than its
634 @item gdb/@var{arch}-pinsn.c
635 Prints (disassembles) the target machine's instructions.
636 This file is usually shared with other target machines which use the
637 same processor, which is why it is @file{@var{arch}-pinsn.c} rather
638 than @file{@var{ttt}-pinsn.c}.
640 @item gdb/@var{arch}-opcode.h
641 Contains some large initialized
642 data structures describing the target machine's instructions.
643 This is a bit strange for a @file{.h} file, but it's OK since
644 it is only included in one place. @file{@var{arch}-opcode.h} is shared
645 between the debugger and the assembler, if the GNU assembler has been
646 ported to the target machine.
648 @item gdb/config/@var{arch}/tm-@var{arch}.h
649 This often exists to describe the basic layout of the target machine's
650 processor chip (registers, stack, etc).
651 If used, it is included by @file{tm-@var{xxx}.h}. It can
652 be shared among many targets that use the same processor.
654 @item gdb/@var{arch}-tdep.c
655 Similarly, there are often common subroutines that are shared by all
656 target machines that use this particular architecture.
659 When adding support for a new target machine, there are various areas
660 of support that might need change, or might be OK.
662 If you are using an existing object file format (a.out or COFF),
663 there is probably little to be done. See @file{bfd/doc/bfd.texinfo}
664 for more information on writing new a.out or COFF versions.
666 If you need to add a new object file format, you must first add it to
667 BFD. This is beyond the scope of this document right now. Basically
668 you must build a transfer vector (of type @code{bfd_target}), which will
669 mean writing all the required routines, and add it to the list in
670 @file{bfd/targets.c}.
672 You must then arrange for the BFD code to provide access to the
673 debugging symbols. Generally GDB will have to call swapping routines
674 from BFD and a few other BFD internal routines to locate the debugging
675 information. As much as possible, GDB should not depend on the BFD
676 internal data structures.
678 For some targets (e.g., COFF), there is a special transfer vector used
679 to call swapping routines, since the external data structures on various
680 platforms have different sizes and layouts. Specialized routines that
681 will only ever be implemented by one object file format may be called
682 directly. This interface should be described in a file
683 @file{bfd/libxxx.h}, which is included by GDB.
685 If you are adding a new operating system for an existing CPU chip, add a
686 @file{tm-@var{xos}.h} file that describes the operating system
687 facilities that are unusual (extra symbol table info; the breakpoint
688 instruction needed; etc). Then write a
689 @file{tm-@var{xarch}-@var{xos}.h} that just @code{#include}s
690 @file{tm-@var{xarch}.h} and @file{tm-@var{xos}.h}. (Now that we have
691 three-part configuration names, this will probably get revised to
692 separate the @var{xos} configuration from the @var{xarch}
697 @chapter Adding a Source Language to GDB
699 To add other languages to GDB's expression parser, follow the following steps:
702 @item Create the expression parser.
704 This should reside in a file @file{@var{lang}-exp.y}. Routines for building
705 parsed expressions into a @samp{union exp_element} list are in @file{parse.c}.
707 Since we can't depend upon everyone having Bison, and YACC produces
708 parsers that define a bunch of global names, the following lines
709 @emph{must} be included at the top of the YACC parser, to prevent
710 the various parsers from defining the same global names:
713 #define yyparse @var{lang}_parse
714 #define yylex @var{lang}_lex
715 #define yyerror @var{lang}_error
716 #define yylval @var{lang}_lval
717 #define yychar @var{lang}_char
718 #define yydebug @var{lang}_debug
719 #define yypact @var{lang}_pact
720 #define yyr1 @var{lang}_r1
721 #define yyr2 @var{lang}_r2
722 #define yydef @var{lang}_def
723 #define yychk @var{lang}_chk
724 #define yypgo @var{lang}_pgo
725 #define yyact @var{lang}_act
726 #define yyexca @var{lang}_exca
727 #define yyerrflag @var{lang}_errflag
728 #define yynerrs @var{lang}_nerrs
731 At the bottom of your parser, define a @code{struct language_defn} and
732 initialize it with the right values for your language. Define an
733 @code{initialize_@var{lang}} routine and have it call
734 @samp{add_language(@var{lang}_language_defn)} to tell the rest of GDB
735 that your language exists. You'll need some other supporting variables
736 and functions, which will be used via pointers from your
737 @code{@var{lang}_language_defn}. See the declaration of @code{struct
738 language_defn} in @file{language.h}, and the other @file{*-exp.y} files,
739 for more information.
741 @item Add any evaluation routines, if necessary
743 If you need new opcodes (that represent the operations of the language),
744 add them to the enumerated type in @file{expression.h}. Add support
745 code for these operations in @code{eval.c:evaluate_subexp()}. Add cases
746 for new opcodes in two functions from @file{parse.c}:
747 @code{prefixify_subexp()} and @code{length_of_subexp()}. These compute
748 the number of @code{exp_element}s that a given operation takes up.
750 @item Update some existing code
752 Add an enumerated identifier for your language to the enumerated type
753 @code{enum language} in @file{defs.h}.
755 Update the routines in @file{language.c} so your language is included. These
756 routines include type predicates and such, which (in some cases) are
757 language dependent. If your language does not appear in the switch
758 statement, an error is reported.
760 Also included in @file{language.c} is the code that updates the variable
761 @code{current_language}, and the routines that translate the
762 @code{language_@var{lang}} enumerated identifier into a printable
765 Update the function @code{_initialize_language} to include your language. This
766 function picks the default language upon startup, so is dependent upon
767 which languages that GDB is built for.
769 Update @code{allocate_symtab} in @file{symfile.c} and/or symbol-reading
770 code so that the language of each symtab (source file) is set properly.
771 This is used to determine the language to use at each stack frame level.
772 Currently, the language is set based upon the extension of the source
773 file. If the language can be better inferred from the symbol
774 information, please set the language of the symtab in the symbol-reading
777 Add helper code to @code{expprint.c:print_subexp()} to handle any new
778 expression opcodes you have added to @file{expression.h}. Also, add the
779 printed representations of your operators to @code{op_print_tab}.
781 @item Add a place of call
783 Add a call to @code{@var{lang}_parse()} and @code{@var{lang}_error} in
784 @code{parse.c:parse_exp_1()}.
786 @item Use macros to trim code
788 The user has the option of building GDB for some or all of the
789 languages. If the user decides to build GDB for the language
790 @var{lang}, then every file dependent on @file{language.h} will have the
791 macro @code{_LANG_@var{lang}} defined in it. Use @code{#ifdef}s to
792 leave out large routines that the user won't need if he or she is not
795 Note that you do not need to do this in your YACC parser, since if GDB
796 is not build for @var{lang}, then @file{@var{lang}-exp.tab.o} (the
797 compiled form of your parser) is not linked into GDB at all.
799 See the file @file{configure.in} for how GDB is configured for different
802 @item Edit @file{Makefile.in}
804 Add dependencies in @file{Makefile.in}. Make sure you update the macro
805 variables such as @code{HFILES} and @code{OBJS}, otherwise your code may
806 not get linked in, or, worse yet, it may not get @code{tar}red into the
812 @chapter Configuring GDB for Release
814 From the top level directory (containing @file{gdb}, @file{bfd},
815 @file{libiberty}, and so on):
817 make -f Makefile.in gdb.tar.Z
820 This will properly configure, clean, rebuild any files that are
821 distributed pre-built (e.g. @file{c-exp.tab.c} or @file{refcard.ps}),
822 and will then make a tarfile. (If the top level directory has already
823 beenn configured, you can just do @code{make gdb.tar.Z} instead.)
825 This procedure requires:
828 @item @code{makeinfo} (texinfo2 level)
831 @item @code{yacc} or @code{bison}
834 @dots{} and the usual slew of utilities (@code{sed}, @code{tar}, etc.).
836 @subheading TEMPORARY RELEASE PROCEDURE FOR DOCUMENTATION
838 @file{gdb.texinfo} is currently marked up using the texinfo-2 macros,
839 which are not yet a default for anything (but we have to start using
842 For making paper, the only thing this implies is the right generation of
843 @file{texinfo.tex} needs to be included in the distribution.
845 For making info files, however, rather than duplicating the texinfo2
846 distribution, generate @file{gdb-all.texinfo} locally, and include the files
847 @file{gdb.info*} in the distribution. Note the plural; @code{makeinfo} will
848 split the document into one overall file and five or so included files.
851 @node Partial Symbol Tables
852 @chapter Partial Symbol Tables
854 GDB has three types of symbol tables.
857 @item full symbol tables (symtabs). These contain the main
858 information about symbols and addresses.
859 @item partial symbol tables (psymtabs). These contain enough
860 information to know when to read the corresponding
861 part of the full symbol table.
862 @item minimal symbol tables (msymtabs). These contain information
863 gleaned from non-debugging symbols.
866 This section describes partial symbol tables.
868 A psymtab is constructed by doing a very quick pass over an executable
869 file's debugging information. Small amounts of information are
870 extracted -- enough to identify which parts of the symbol table will
871 need to be re-read and fully digested later, when the user needs the
872 information. The speed of this pass causes GDB to start up very
873 quickly. Later, as the detailed rereading occurs, it occurs in small
874 pieces, at various times, and the delay therefrom is mostly invisible to
875 the user. (@xref{Symbol Reading}.)
877 The symbols that show up in a file's psymtab should be, roughly, those
878 visible to the debugger's user when the program is not running code from
879 that file. These include external symbols and types, static
880 symbols and types, and enum values declared at file scope.
882 The psymtab also contains the range of instruction addresses that the
883 full symbol table would represent.
885 The idea is that there are only two ways for the user (or much of
886 the code in the debugger) to reference a symbol:
891 (e.g. execution stops at some address which is inside a function
892 in this file). The address will be noticed to be in the
893 range of this psymtab, and the full symtab will be read in.
894 @code{find_pc_function}, @code{find_pc_line}, and other @code{find_pc_@dots{}}
895 functions handle this.
898 (e.g. the user asks to print a variable, or set a breakpoint on a
899 function). Global names and file-scope names will be found in the
900 psymtab, which will cause the symtab to be pulled in. Local names will
901 have to be qualified by a global name, or a file-scope name, in which
902 case we will have already read in the symtab as we evaluated the
903 qualifier. Or, a local symbol can be referenced when
904 we are "in" a local scope, in which case the first case applies.
905 @code{lookup_symbol} does most of the work here.
909 The only reason that psymtabs exist is to cause a symtab to be read in
910 at the right moment. Any symbol that can be elided from a psymtab,
911 while still causing that to happen, should not appear in it. Since
912 psymtabs don't have the idea of scope, you can't put local symbols in
913 them anyway. Psymtabs don't have the idea of the type of a symbol,
914 either, so types need not appear, unless they will be referenced by
917 It is a bug for GDB to behave one way when only a psymtab has been read,
918 and another way if the corresponding symtab has been read in. Such
919 bugs are typically caused by a psymtab that does not contain all the
920 visible symbols, or which has the wrong instruction address ranges.
922 The psymtab for a particular section of a symbol-file (objfile)
923 could be thrown away after the symtab has been read in. The symtab
924 should always be searched before the psymtab, so the psymtab will
925 never be used (in a bug-free environment). Currently,
926 psymtabs are allocated on an obstack, and all the psymbols themselves
927 are allocated in a pair of large arrays on an obstack, so there is
928 little to be gained by trying to free them unless you want to do a lot
934 Fundamental Types (e.g., FT_VOID, FT_BOOLEAN).
936 These are the fundamental types that gdb uses internally. Fundamental
937 types from the various debugging formats (stabs, ELF, etc) are mapped into
938 one of these. They are basically a union of all fundamental types that
939 gdb knows about for all the languages that gdb knows about.
941 Type Codes (e.g., TYPE_CODE_PTR, TYPE_CODE_ARRAY).
943 Each time gdb builds an internal type, it marks it with one of these
944 types. The type may be a fundamental type, such as TYPE_CODE_INT, or
945 a derived type, such as TYPE_CODE_PTR which is a pointer to another
946 type. Typically, several FT_* types map to one TYPE_CODE_* type, and
947 are distinguished by other members of the type struct, such as whether
948 the type is signed or unsigned, and how many bits it uses.
950 Builtin Types (e.g., builtin_type_void, builtin_type_char).
952 These are instances of type structs that roughly correspond to fundamental
953 types and are created as global types for gdb to use for various ugly
954 historical reasons. We eventually want to eliminate these. Note for
955 example that builtin_type_int initialized in gdbtypes.c is basically the
956 same as a TYPE_CODE_INT type that is initialized in c-lang.c for an
957 FT_INTEGER fundamental type. The difference is that the builtin_type is
958 not associated with any particular objfile, and only one instance exists,
959 while c-lang.c builds as many TYPE_CODE_INT types as needed, with each
960 one associated with some particular objfile.
962 @node BFD support for GDB
963 @chapter Binary File Descriptor Library Support for GDB
965 BFD provides support for GDB in several ways:
968 @item identifying executable and core files
969 BFD will identify a variety of file types, including a.out, coff, and
970 several variants thereof, as well as several kinds of core files.
972 @item access to sections of files
973 BFD parses the file headers to determine the names, virtual addresses,
974 sizes, and file locations of all the various named sections in files
975 (such as the text section or the data section). GDB simply calls
976 BFD to read or write section X at byte offset Y for length Z.
978 @item specialized core file support
979 BFD provides routines to determine the failing command name stored
980 in a core file, the signal with which the program failed, and whether
981 a core file matches (i.e. could be a core dump of) a particular executable
984 @item locating the symbol information
985 GDB uses an internal interface of BFD to determine where to find the
986 symbol information in an executable file or symbol-file. GDB itself
987 handles the reading of symbols, since BFD does not ``understand'' debug
988 symbols, but GDB uses BFD's cached information to find the symbols,
992 @c The interface for symbol reading is described in @ref{Symbol
993 @c Reading,,Symbol Reading}.
997 @chapter Symbol Reading
999 GDB reads symbols from "symbol files". The usual symbol file is the
1000 file containing the program which gdb is debugging. GDB can be directed
1001 to use a different file for symbols (with the ``symbol-file''
1002 command), and it can also read more symbols via the ``add-file'' and ``load''
1003 commands, or while reading symbols from shared libraries.
1005 Symbol files are initially opened by @file{symfile.c} using the BFD
1006 library. BFD identifies the type of the file by examining its header.
1007 @code{symfile_init} then uses this identification to locate a
1008 set of symbol-reading functions.
1010 Symbol reading modules identify themselves to GDB by calling
1011 @code{add_symtab_fns} during their module initialization. The argument
1012 to @code{add_symtab_fns} is a @code{struct sym_fns} which contains
1013 the name (or name prefix) of the symbol format, the length of the prefix,
1014 and pointers to four functions. These functions are called at various
1015 times to process symbol-files whose identification matches the specified
1018 The functions supplied by each module are:
1021 @item @var{xxx}_symfile_init(struct sym_fns *sf)
1023 Called from @code{symbol_file_add} when we are about to read a new
1024 symbol file. This function should clean up any internal state
1025 (possibly resulting from half-read previous files, for example)
1026 and prepare to read a new symbol file. Note that the symbol file
1027 which we are reading might be a new "main" symbol file, or might
1028 be a secondary symbol file whose symbols are being added to the
1029 existing symbol table.
1031 The argument to @code{@var{xxx}_symfile_init} is a newly allocated
1032 @code{struct sym_fns} whose @code{bfd} field contains the BFD
1033 for the new symbol file being read. Its @code{private} field
1034 has been zeroed, and can be modified as desired. Typically,
1035 a struct of private information will be @code{malloc}'d, and
1036 a pointer to it will be placed in the @code{private} field.
1038 There is no result from @code{@var{xxx}_symfile_init}, but it can call
1039 @code{error} if it detects an unavoidable problem.
1041 @item @var{xxx}_new_init()
1043 Called from @code{symbol_file_add} when discarding existing symbols.
1044 This function need only handle
1045 the symbol-reading module's internal state; the symbol table data
1046 structures visible to the rest of GDB will be discarded by
1047 @code{symbol_file_add}. It has no arguments and no result.
1048 It may be called after @code{@var{xxx}_symfile_init}, if a new symbol
1049 table is being read, or may be called alone if all symbols are
1050 simply being discarded.
1052 @item @var{xxx}_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline)
1054 Called from @code{symbol_file_add} to actually read the symbols from a
1055 symbol-file into a set of psymtabs or symtabs.
1057 @code{sf} points to the struct sym_fns originally passed to
1058 @code{@var{xxx}_sym_init} for possible initialization. @code{addr} is the
1059 offset between the file's specified start address and its true address
1060 in memory. @code{mainline} is 1 if this is the main symbol table being
1061 read, and 0 if a secondary symbol file (e.g. shared library or
1062 dynamically loaded file) is being read.@refill
1065 In addition, if a symbol-reading module creates psymtabs when
1066 @var{xxx}_symfile_read is called, these psymtabs will contain a pointer to
1067 a function @code{@var{xxx}_psymtab_to_symtab}, which can be called from
1068 any point in the GDB symbol-handling code.
1071 @item @var{xxx}_psymtab_to_symtab (struct partial_symtab *pst)
1073 Called from @code{psymtab_to_symtab} (or the PSYMTAB_TO_SYMTAB
1074 macro) if the psymtab has not already been read in and had its
1075 @code{pst->symtab} pointer set. The argument is the psymtab
1076 to be fleshed-out into a symtab. Upon return, pst->readin
1077 should have been set to 1, and pst->symtab should contain a
1078 pointer to the new corresponding symtab, or zero if there
1079 were no symbols in that part of the symbol file.
1086 Cleanups are a structured way to deal with things that need to be done
1087 later. When your code does something (like @code{malloc} some memory, or open
1088 a file) that needs to be undone later (e.g. free the memory or close
1089 the file), it can make a cleanup. The cleanup will be done at some
1090 future point: when the command is finished, when an error occurs, or
1091 when your code decides it's time to do cleanups.
1093 You can also discard cleanups, that is, throw them away without doing
1094 what they say. This is only done if you ask that it be done.
1099 @item struct cleanup *@var{old_chain};
1100 Declare a variable which will hold a cleanup chain handle.
1102 @item @var{old_chain} = make_cleanup (@var{function}, @var{arg});
1103 Make a cleanup which will cause @var{function} to be called with @var{arg}
1104 (a @code{char *}) later. The result, @var{old_chain}, is a handle that can be
1105 passed to @code{do_cleanups} or @code{discard_cleanups} later. Unless you are
1106 going to call @code{do_cleanups} or @code{discard_cleanups} yourself,
1107 you can ignore the result from @code{make_cleanup}.
1110 @item do_cleanups (@var{old_chain});
1111 Perform all cleanups done since @code{make_cleanup} returned @var{old_chain}.
1114 make_cleanup (a, 0);
1115 old = make_cleanup (b, 0);
1119 will call @code{b()} but will not call @code{a()}. The cleanup that calls @code{a()} will remain
1120 in the cleanup chain, and will be done later unless otherwise discarded.@refill
1122 @item discard_cleanups (@var{old_chain});
1123 Same as @code{do_cleanups} except that it just removes the cleanups from the
1124 chain and does not call the specified functions.
1128 Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they
1129 ``should not be called when cleanups are not in place''. This means
1130 that any actions you need to reverse in the case of an error or
1131 interruption must be on the cleanup chain before you call these functions,
1132 since they might never return to your code (they @samp{longjmp} instead).
1136 @chapter Wrapping Output Lines
1138 Output that goes through @code{printf_filtered} or @code{fputs_filtered} or
1139 @code{fputs_demangled} needs only to have calls to @code{wrap_here} added
1140 in places that would be good breaking points. The utility routines
1141 will take care of actually wrapping if the line width is exceeded.
1143 The argument to @code{wrap_here} is an indentation string which is printed
1144 @emph{only} if the line breaks there. This argument is saved away and used
1145 later. It must remain valid until the next call to @code{wrap_here} or
1146 until a newline has been printed through the @code{*_filtered} functions.
1147 Don't pass in a local variable and then return!
1149 It is usually best to call @code{wrap_here()} after printing a comma or space.
1150 If you call it before printing a space, make sure that your indentation
1151 properly accounts for the leading space that will print if the line wraps
1154 Any function or set of functions that produce filtered output must finish
1155 by printing a newline, to flush the wrap buffer, before switching to
1156 unfiltered (``@code{printf}'') output. Symbol reading routines that print
1157 warnings are a good example.
1163 A frame is a construct that GDB uses to keep track of calling and called
1168 in the machine description has no meaning to the machine-independent
1169 part of GDB, except that it is used when setting up a new frame from
1170 scratch, as follows:
1173 create_new_frame (read_register (FP_REGNUM), read_pc ()));
1176 Other than that, all the meaning imparted to @code{FP_REGNUM} is imparted by
1177 the machine-dependent code. So, @code{FP_REGNUM} can have any value that
1178 is convenient for the code that creates new frames. (@code{create_new_frame}
1179 calls @code{INIT_EXTRA_FRAME_INFO} if it is defined; that is where you should
1180 use the @code{FP_REGNUM} value, if your frames are nonstandard.)
1183 Given a GDB frame, determine the address of the calling function's
1184 frame. This will be used to create a new GDB frame struct, and then
1185 @code{INIT_EXTRA_FRAME_INFO} and @code{INIT_FRAME_PC} will be called for
1190 @chapter Remote Stubs
1192 GDB's file @file{remote.c} talks a serial protocol to code that runs
1193 in the target system. GDB provides several sample ``stubs'' that can
1194 be integrated into target programs or operating systems for this purpose;
1195 they are named @file{*-stub.c}.
1197 The GDB user's manual describes how to put such a stub into your target
1198 code. What follows is a discussion of integrating the SPARC stub
1199 into a complicated operating system (rather than a simple program),
1200 by Stu Grossman, the author of this stub.
1202 The trap handling code in the stub assumes the following upon entry to
1206 @item %l1 and %l2 contain pc and npc respectively at the time of the trap
1207 @item traps are disabled
1208 @item you are in the correct trap window
1211 As long as your trap handler can guarantee those conditions, then there is no
1212 reason why you shouldn't be able to `share' traps with the stub. The stub has
1213 no requirement that it be jumped to directly from the hardware trap vector.
1214 That is why it calls @code{exceptionHandler()}, which is provided by the external
1215 environment. For instance, this could setup the hardware traps to actually
1216 execute code which calls the stub first, and then transfers to its own trap
1219 For the most point, there probably won't be much of an issue with `sharing'
1220 traps, as the traps we use are usually not used by the kernel, and often
1221 indicate unrecoverable error conditions. Anyway, this is all controlled by a
1222 table, and is trivial to modify.
1223 The most important trap for us is for @code{ta 1}. Without that, we
1224 can't single step or do breakpoints. Everything else is unnecessary
1225 for the proper operation of the debugger/stub.
1227 From reading the stub, it's probably not obvious how breakpoints work. They
1228 are simply done by deposit/examine operations from GDB.
1230 @node Longjmp Support
1231 @chapter Longjmp Support
1233 GDB has support for figuring out that the target is doing a
1234 @code{longjmp} and for stopping at the target of the jump, if we are
1235 stepping. This is done with a few specialized internal breakpoints,
1236 which are visible in the @code{maint info breakpoint} command.
1238 To make this work, you need to define a macro called
1239 @code{GET_LONGJMP_TARGET}, which will examine the @code{jmp_buf}
1240 structure and extract the longjmp target address. Since @code{jmp_buf}
1241 is target specific, you will need to define it in the appropriate
1242 @file{tm-xxx.h} file. Look in @file{tm-sun4os4.h} and
1243 @file{sparc-tdep.c} for examples of how to do this.
1246 @chapter Coding Style
1248 GDB is generally written using the GNU coding standards, as described in
1249 @file{standards.texi}, which is available for anonymous FTP from GNU
1250 archive sites. There are some additional considerations for GDB
1251 maintainers that reflect the unique environment and style of GDB
1252 maintenance. If you follow these guidelines, GDB will be more
1253 consistent and easier to maintain.
1255 GDB's policy on the use of prototypes is that prototypes are used
1256 to @emph{declare} functions but never to @emph{define} them. Simple
1257 macros are used in the declarations, so that a non-ANSI compiler can
1258 compile GDB without trouble. The simple macro calls are used like
1263 memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
1266 Note the double parentheses around the parameter types. This allows
1267 an arbitrary number of parameters to be described, without freaking
1268 out the C preprocessor. When the function has no parameters, it
1269 should be described like:
1273 noprocess PARAMS ((void));
1276 The @code{PARAMS} macro expands to its argument in ANSI C, or to a simple
1277 @code{()} in traditional C.
1279 All external functions should have a @code{PARAMS} declaration in a
1280 header file that callers include. All static functions should have such
1281 a declaration near the top of their source file.
1283 We don't have a gcc option that will properly check that these rules
1284 have been followed, but it's GDB policy, and we periodically check it
1285 using the tools available (plus manual labor), and clean up any remnants.
1288 @chapter Clean Design
1290 In addition to getting the syntax right, there's the little question of
1291 semantics. Some things are done in certain ways in GDB because long
1292 experience has shown that the more obvious ways caused various kinds of
1293 trouble. In particular:
1297 You can't assume the byte order of anything that comes from a
1298 target (including @var{value}s, object files, and instructions). Such
1299 things must be byte-swapped using @code{SWAP_TARGET_AND_HOST} in GDB,
1300 or one of the swap routines defined in @file{bfd.h}, such as @code{bfd_get_32}.
1303 You can't assume that you know what interface is being used to talk to
1304 the target system. All references to the target must go through the
1305 current @code{target_ops} vector.
1308 You can't assume that the host and target machines are the same machine
1309 (except in the ``native'' support modules).
1310 In particular, you can't assume that the target machine's header files
1311 will be available on the host machine. Target code must bring along its
1312 own header files -- written from scratch or explicitly donated by their
1313 owner, to avoid copyright problems.
1316 Insertion of new @code{#ifdef}'s will be frowned upon. It's much better
1317 to write the code portably than to conditionalize it for various systems.
1320 New @code{#ifdef}'s which test for specific compilers or manufacturers
1321 or operating systems are unacceptable. All @code{#ifdef}'s should test
1322 for features. The information about which configurations contain which
1323 features should be segregated into the configuration files. Experience
1324 has proven far too often that a feature unique to one particular system
1325 often creeps into other systems; and that a conditional based on
1326 some predefined macro for your current system will become worthless
1327 over time, as new versions of your system come out that behave differently
1328 with regard to this feature.
1331 Adding code that handles specific architectures, operating systems, target
1332 interfaces, or hosts, is not acceptable in generic code. If a hook
1333 is needed at that point, invent a generic hook and define it for your
1334 configuration, with something like:
1337 #ifdef WRANGLE_SIGNALS
1338 WRANGLE_SIGNALS (signo);
1342 In your host, target, or native configuration file, as appropriate,
1343 define @code{WRANGLE_SIGNALS} to do the machine-dependent thing. Take
1344 a bit of care in defining the hook, so that it can be used by other
1345 ports in the future, if they need a hook in the same place.
1347 If the hook is not defined, the code should do whatever "most" machines
1348 want. Using @code{#ifdef}, as above, is the preferred way to do this,
1349 but sometimes that gets convoluted, in which case use
1352 #ifndef SPECIAL_FOO_HANDLING
1353 #define SPECIAL_FOO_HANDLING(pc, sp) (0)
1357 where the macro is used or in an appropriate header file.
1359 Whether to include a @dfn{small} hook, a hook around the exact pieces of
1360 code which are system-dependent, or whether to replace a whole function
1361 with a hook depends on the case. A good example of this dilemma can be
1362 found in @code{get_saved_register}. All machines that GDB 2.8 ran on
1363 just needed the @code{FRAME_FIND_SAVED_REGS} hook to find the saved
1364 registers. Then the SPARC and Pyramid came along, and
1365 @code{HAVE_REGISTER_WINDOWS} and @code{REGISTER_IN_WINDOW_P} were
1366 introduced. Then the 29k and 88k required the @code{GET_SAVED_REGISTER}
1367 hook. The first three are examples of small hooks; the latter replaces
1368 a whole function. In this specific case, it is useful to have both
1369 kinds; it would be a bad idea to replace all the uses of the small hooks
1370 with @code{GET_SAVED_REGISTER}, since that would result in much
1371 duplicated code. Other times, duplicating a few lines of code here or
1372 there is much cleaner than introducing a large number of small hooks.
1374 Another way to generalize GDB along a particular interface is with an
1375 attribute struct. For example, GDB has been generalized to handle
1376 multiple kinds of remote interfaces -- not by #ifdef's everywhere, but
1377 by defining the "target_ops" structure and having a current target (as
1378 well as a stack of targets below it, for memory references). Whenever
1379 something needs to be done that depends on which remote interface we are
1380 using, a flag in the current target_ops structure is tested (e.g.
1381 `target_has_stack'), or a function is called through a pointer in the
1382 current target_ops structure. In this way, when a new remote interface
1383 is added, only one module needs to be touched -- the one that actually
1384 implements the new remote interface. Other examples of
1385 attribute-structs are BFD access to multiple kinds of object file
1386 formats, or GDB's access to multiple source languages.
1388 Please avoid duplicating code. For example, in GDB 3.x all the code
1389 interfacing between @code{ptrace} and the rest of GDB was duplicated in
1390 @file{*-dep.c}, and so changing something was very painful. In GDB 4.x,
1391 these have all been consolidated into @file{infptrace.c}.
1392 @file{infptrace.c} can deal with variations between systems the same way
1393 any system-independent file would (hooks, #if defined, etc.), and
1394 machines which are radically different don't need to use infptrace.c at
1398 @emph{Do} write code that doesn't depend on the sizes of C data types,
1399 the format of the host's floating point numbers, the alignment of anything,
1400 or the order of evaluation of expressions. In short, follow good
1401 programming practices for writing portable C code.
1405 @node Submitting Patches
1406 @chapter Submitting Patches
1408 Thanks for thinking of offering your changes back to the community of
1409 GDB users. In general we like to get well designed enhancements.
1410 Thanks also for checking in advance about the best way to transfer the
1413 The two main problems with getting your patches in are,
1417 The GDB maintainers will only install ``cleanly designed'' patches.
1418 You may not always agree on what is clean design.
1419 @pxref{Coding Style}, @pxref{Clean Design}.
1422 If the maintainers don't have time to put the patch in when it
1423 arrives, or if there is any question about a patch, it
1424 goes into a large queue with everyone else's patches and
1428 I don't know how to get past these problems except by continuing to try.
1430 There are two issues here -- technical and legal.
1432 The legal issue is that to incorporate substantial changes requires a
1433 copyright assignment from you and/or your employer, granting ownership
1434 of the changes to the Free Software Foundation. You can get the
1435 standard document for doing this by sending mail to
1436 @code{gnu@@prep.ai.mit.edu} and asking for it. I recommend that people
1437 write in "All programs owned by the Free Software Foundation" as "NAME
1438 OF PROGRAM", so that changes in many programs (not just GDB, but GAS,
1439 Emacs, GCC, etc) can be contributed with only one piece of legalese
1440 pushed through the bureacracy and filed with the FSF. I can't start
1441 merging changes until this paperwork is received by the FSF (their
1442 rules, which I follow since I maintain it for them).
1444 Technically, the easiest way to receive changes is to receive each
1445 feature as a small context diff or unidiff, suitable for "patch".
1446 Each message sent to me should include the changes to C code and
1447 header files for a single feature, plus ChangeLog entries for each
1448 directory where files were modified, and diffs for any changes needed
1449 to the manuals (gdb/doc/gdb.texi or gdb/doc/gdbint.texi). If there
1450 are a lot of changes for a single feature, they can be split down
1451 into multiple messages.
1453 In this way, if I read and like the feature, I can add it to the
1454 sources with a single patch command, do some testing, and check it in.
1455 If you leave out the ChangeLog, I have to write one. If you leave
1456 out the doc, I have to puzzle out what needs documenting. Etc.
1458 The reason to send each change in a separate message is that I will
1459 not install some of the changes. They'll be returned to you with
1460 questions or comments. If I'm doing my job, my message back to you
1461 will say what you have to fix in order to make the change acceptable.
1462 The reason to have separate messages for separate features is so
1463 that other changes (which I @emph{am} willing to accept) can be installed
1464 while one or more changes are being reworked. If multiple features
1465 are sent in a single message, I tend to not put in the effort to sort
1466 out the acceptable changes from the unacceptable, so none of the
1467 features get installed until all are acceptable.
1469 If this sounds painful or authoritarian, well, it is. But I get a lot
1470 of bug reports and a lot of patches, and most of them don't get
1471 installed because I don't have the time to finish the job that the bug
1472 reporter or the contributor could have done. Patches that arrive
1473 complete, working, and well designed, tend to get installed on the day
1474 they arrive. The others go into a queue and get installed if and when
1475 I scan back over the queue -- which can literally take months
1476 sometimes. It's in both our interests to make patch installation easy
1477 -- you get your changes installed, and I make some forward progress on
1478 GDB in a normal 12-hour day (instead of them having to wait until I
1479 have a 14-hour or 16-hour day to spend cleaning up patches before I
1482 Please send patches to @code{bug-gdb@@prep.ai.mit.edu}, if they are less
1483 than about 25,000 characters. If longer than that, either make them
1484 available somehow (e.g. anonymous FTP), and announce it on
1485 @code{bug-gdb}, or send them directly to the GDB maintainers at
1486 @code{gdb-patches@@cygnus.com}.
1488 @node Host Conditionals
1489 @chapter Host Conditionals
1491 When GDB is configured and compiled, various macros are defined or left
1492 undefined, to control compilation based on the attributes of the host
1493 system. These macros and their meanings are:
1495 @emph{NOTE: For now, both host and target conditionals are here.
1496 Eliminate target conditionals from this list as they are identified.}
1501 @item BLOCK_ADDRESS_FUNCTION_RELATIVE
1503 @item GDBINIT_FILENAME
1507 @item MEM_FNS_DECLARED
1508 Your host config file defines this if it includes
1509 declarations of @code{memcpy} and @code{memset}. Define this
1510 to avoid conflicts between the native include
1511 files and the declarations in @file{defs.h}.
1514 @item PYRAMID_CONTROL_FRAME_DEBUGGING
1516 @item SIGWINCH_HANDLER_BODY
1534 @item ADDITIONAL_OPTIONS
1536 @item ADDITIONAL_OPTION_CASES
1538 @item ADDITIONAL_OPTION_HANDLER
1540 @item ADDITIONAL_OPTION_HELP
1542 @item ADDR_BITS_REMOVE
1544 @item AIX_BUGGY_PTRACE_CONTINUE
1546 @item ALIGN_STACK_ON_STARTUP
1558 @item BEFORE_MAIN_LOOP_HOOK
1560 @item BELIEVE_PCC_PROMOTION
1562 @item BELIEVE_PCC_PROMOTION_TYPE
1566 @item BITS_BIG_ENDIAN
1570 @item BLOCK_ADDRESS_ABSOLUTE
1576 @item BREAKPOINT_DEBUG
1578 @item BROKEN_LARGE_ALLOCA
1579 Avoid large @code{alloca}'s. For example, on sun's, Large alloca's fail
1580 because the attempt to increase the stack limit in main() fails because
1581 shared libraries are allocated just below the initial stack limit. The
1582 SunOS kernel will not allow the stack to grow into the area occupied by
1583 the shared libraries.
1588 @item CALL_DUMMY_LOCATION
1590 @item CALL_DUMMY_STACK_ADJUST
1592 @item CANNOT_FETCH_REGISTER
1594 @item CANNOT_STORE_REGISTER
1596 @item CFRONT_PRODUCER
1598 @item CHILD_PREPARE_TO_STORE
1600 @item CLEAR_DEFERRED_STORES
1604 @item COFF_ENCAPSULATE
1608 @item CORE_NEEDS_RELOCATION
1612 @item CREATE_INFERIOR_HOOK
1620 @item DBX_PARM_SYMBOL_CLASS
1628 @item DECR_PC_AFTER_BREAK
1630 @item DEFAULT_PROMPT
1638 @item DISABLE_UNSETTABLE_BREAK
1640 @item DONT_USE_REMOTE
1642 @item DO_DEFERRED_STORES
1644 @item DO_REGISTERS_INFO
1646 @item END_OF_TEXT_DEFAULT
1650 @item EXTRACT_RETURN_VALUE
1652 @item EXTRACT_STRUCT_VALUE_ADDRESS
1654 @item EXTRA_FRAME_INFO
1656 @item EXTRA_SYMTAB_INFO
1658 @item FILES_INFO_HOOK
1672 @item FRAMELESS_FUNCTION_INVOCATION
1674 @item FRAME_ARGS_ADDRESS_CORRECT
1676 @item FRAME_CHAIN_COMBINE
1678 @item FRAME_CHAIN_VALID
1680 @item FRAME_CHAIN_VALID_ALTERNATE
1682 @item FRAME_FIND_SAVED_REGS
1684 @item FRAME_GET_BASEREG_VALUE
1686 @item FRAME_NUM_ARGS
1688 @item FRAME_SPECIFICATION_DYADIC
1690 @item FUNCTION_EPILOGUE_SIZE
1694 @item GCC2_COMPILED_FLAG_SYMBOL
1696 @item GCC_COMPILED_FLAG_SYMBOL
1698 @item GCC_MANGLE_BUG
1702 @item GET_SAVED_REGISTER
1704 @item GPLUS_PRODUCER
1715 In some cases, use the system call @code{mmap} for reading symbol
1716 tables. For some machines this allows for sharing and quick updates.
1717 @item HAVE_REGISTER_WINDOWS
1719 @item HAVE_SIGSETMASK
1723 @item HEADER_SEEK_FD
1727 @item HOST_BYTE_ORDER
1731 @item HPUX_VERSION_5
1743 @item INIT_EXTRA_FRAME_INFO
1745 @item INIT_EXTRA_SYMTAB_INFO
1759 @item IN_SOLIB_TRAMPOLINE
1763 @item IS_TRAPPED_INTERNALVAR
1767 @item KERNEL_DEBUGGING
1770 Define this to the address of the @code{u} structure (the ``user struct'',
1771 also known as the ``u-page'') in kernel virtual memory. GDB needs to know
1772 this so that it can subtract this address from absolute addresses in
1773 the upage, that are obtained via ptrace or from core files. On systems
1774 that don't need this value, set it to zero.
1775 @item KERNEL_U_ADDR_BSD
1776 Define this to cause GDB to determine the address of @code{u} at runtime,
1777 by using Berkeley-style @code{nlist} on the kernel's image in the root
1779 @item KERNEL_U_ADDR_HPUX
1780 Define this to cause GDB to determine the address of @code{u} at runtime,
1781 by using HP-style @code{nlist} on the kernel's image in the root
1793 @item CC_HAS_LONG_LONG
1795 @item PRINTF_HAS_LONG_LONG
1799 @item LSEEK_NOT_LINEAR
1804 This macro is used as the argument to lseek (or, most commonly, bfd_seek).
1805 FIXME, it should be replaced by SEEK_SET instead, which is the POSIX equivalent.
1806 @item MACHKERNELDEBUG
1812 @item MAINTENANCE_CMDS
1814 @item MAINTENANCE_CMDS
1816 @item MALLOC_INCOMPATIBLE
1817 Define this if the system's prototype for @code{malloc} differs from the
1818 @sc{ANSI} definition.
1821 @item MMAP_BASE_ADDRESS
1822 When using HAVE_MMAP, the first mapping should go at this address.
1823 @item MMAP_INCREMENT
1824 when using HAVE_MMAP, this is the increment between mappings.
1831 @item NEED_POSIX_SETPGID
1833 @item NEED_TEXT_START_END
1847 @item NOTICE_SIGNAL_HANDLING_CHANGE
1849 @item NO_HIF_SUPPORT
1851 @item NO_JOB_CONTROL
1854 GDB will use the @code{mmalloc} library for memory allocation for symbol
1855 reading, unless this symbol is defined. Define it on systems
1856 on which @code{mmalloc} does not
1857 work for some reason. One example is the DECstation, where its RPC
1858 library can't cope with our redefinition of @code{malloc} to call
1859 @code{mmalloc}. When defining @code{NO_MMALLOC}, you will also have
1860 to override the setting of @code{MMALLOC_LIB} to empty, in the Makefile.
1861 Therefore, this define is usually set on the command line by overriding
1862 @code{MMALLOC_DISABLE} in @file{config/*/*.mh}, rather than by defining
1863 it in @file{xm-*.h}.
1864 @item NO_MMALLOC_CHECK
1865 Define this if you are using @code{mmalloc}, but don't want the overhead
1866 of checking the heap with @code{mmcheck}.
1867 @item NO_SIGINTERRUPT
1869 @item NO_SINGLE_STEP
1873 @item NS32K_SVC_IMMED_OPERANDS
1875 @item NUMERIC_REG_NAMES
1883 @item ONE_PROCESS_WRITETEXT
1891 @item PCC_SOL_BROKEN
1893 @item PC_IN_CALL_DUMMY
1895 @item PC_LOAD_SEGMENT
1899 @item PRINT_RANDOM_SIGNAL
1901 @item PRINT_REGISTER_HOOK
1903 @item PRINT_TYPELESS_INTEGER
1905 @item PROCESS_LINENUMBER_HOOK
1907 @item PROLOGUE_FIRSTLINE_OVERLAP
1909 @item PSIGNAL_IN_SIGNAL_H
1913 @item PUSH_ARGUMENTS
1915 @item PYRAMID_CONTROL_FRAME_DEBUGGING
1919 @item PYRAMID_PTRACE
1921 @item REGISTER_BYTES
1923 @item REGISTER_NAMES
1925 @item REG_STACK_SEGMENT
1927 @item REG_STRUCT_HAS_ADDR
1935 @item SDB_REG_TO_REGNUM
1943 @item SET_STACK_LIMIT_HUGE
1944 When defined, stack limits will be raised to their maximum. Use this
1945 if your host supports @code{setrlimit} and you have trouble with
1946 @code{stringtab} in @file{dbxread.c}.
1948 Also used in @file{fork-child.c} to return stack limits before child
1949 processes are forked.
1950 @item SHELL_COMMAND_CONCAT
1954 @item SHIFT_INST_REGS
1956 @item SIGN_EXTEND_CHAR
1958 @item SIGTRAP_STOP_AFTER_LOAD
1962 @item SKIP_PROLOGUE_FRAMELESS_P
1964 @item SKIP_TRAMPOLINE_CODE
1968 @item SOLIB_CREATE_INFERIOR_HOOK
1972 @item STAB_REG_TO_REGNUM
1976 @item STACK_DIRECTION
1978 @item START_INFERIOR_TRAPS_EXPECTED
1982 @item STORE_RETURN_VALUE
1984 @item SUN4_COMPILER_FEATURE
1986 @item SUN_FIXED_LBRAC_BUG
1988 @item SVR4_SHARED_LIBS
1990 @item SWITCH_ENUM_BUG
1994 @item SYMBOL_RELOADING_DEFAULT
2028 @item USE_STRUCT_CONVENTION
2031 Means that System V (prior to SVR4) include files are in use.
2032 (FIXME: This symbol is abused in @file{infrun.c}, @file{regex.c},
2033 @file{remote-nindy.c}, and @file{utils.c} for other things, at the moment.)
2038 @item VARIABLES_INSIDE_BLOCK
2050 @item __HAVE_68881__
2054 @item __INT_VARARGS_H
2056 @item __not_on_pyr_yet
2072 @item longest_to_int
2102 @node Target Conditionals
2103 @chapter Target Conditionals
2105 When GDB is configured and compiled, various macros are defined or left
2106 undefined, to control compilation based on the attributes of the target
2107 system. These macros and their meanings are:
2109 @emph{NOTE: For now, both host and target conditionals are here.
2110 Eliminate host conditionals from this list as they are identified.}
2113 @item PUSH_DUMMY_FRAME
2114 Used in @samp{call_function_by_hand} to create an artificial stack frame.
2116 Used in @samp{call_function_by_hand} to remove an artificial stack frame.
2119 @item BLOCK_ADDRESS_FUNCTION_RELATIVE
2121 @item GDBINIT_FILENAME
2127 @item PYRAMID_CONTROL_FRAME_DEBUGGING
2129 @item SIGWINCH_HANDLER_BODY
2131 @item ADDITIONAL_OPTIONS
2133 @item ADDITIONAL_OPTION_CASES
2135 @item ADDITIONAL_OPTION_HANDLER
2137 @item ADDITIONAL_OPTION_HELP
2139 @item ADDR_BITS_REMOVE
2141 @item ALIGN_STACK_ON_STARTUP
2153 @item BEFORE_MAIN_LOOP_HOOK
2155 @item BELIEVE_PCC_PROMOTION
2157 @item BELIEVE_PCC_PROMOTION_TYPE
2161 @item BITS_BIG_ENDIAN
2165 @item BLOCK_ADDRESS_ABSOLUTE
2171 @item BREAKPOINT_DEBUG
2177 @item CALL_DUMMY_LOCATION
2179 @item CALL_DUMMY_STACK_ADJUST
2181 @item CANNOT_FETCH_REGISTER
2183 @item CANNOT_STORE_REGISTER
2185 @item CFRONT_PRODUCER
2187 @item CHILD_PREPARE_TO_STORE
2189 @item CLEAR_DEFERRED_STORES
2193 @item COFF_ENCAPSULATE
2197 @item CORE_NEEDS_RELOCATION
2201 @item CREATE_INFERIOR_HOOK
2209 @item DBX_PARM_SYMBOL_CLASS
2217 @item DECR_PC_AFTER_BREAK
2219 @item DEFAULT_PROMPT
2227 @item DISABLE_UNSETTABLE_BREAK
2229 @item DONT_USE_REMOTE
2231 @item DO_DEFERRED_STORES
2233 @item DO_REGISTERS_INFO
2235 @item END_OF_TEXT_DEFAULT
2239 @item EXTRACT_RETURN_VALUE
2241 @item EXTRACT_STRUCT_VALUE_ADDRESS
2243 @item EXTRA_FRAME_INFO
2245 @item EXTRA_SYMTAB_INFO
2247 @item FILES_INFO_HOOK
2262 Unused? 6-oct-92 rich@@cygnus.com. FIXME.
2263 @item FRAMELESS_FUNCTION_INVOCATION
2265 @item FRAME_ARGS_ADDRESS_CORRECT
2268 Given FRAME, return a pointer to the calling frame.
2269 @item FRAME_CHAIN_COMBINE
2271 @item FRAME_CHAIN_VALID
2273 @item FRAME_CHAIN_VALID_ALTERNATE
2275 @item FRAME_FIND_SAVED_REGS
2277 @item FRAME_GET_BASEREG_VALUE
2279 @item FRAME_NUM_ARGS
2281 @item FRAME_SPECIFICATION_DYADIC
2283 @item FRAME_SAVED_PC
2284 Given FRAME, return the pc saved there. That is, the return address.
2285 @item FUNCTION_EPILOGUE_SIZE
2289 @item GCC2_COMPILED_FLAG_SYMBOL
2291 @item GCC_COMPILED_FLAG_SYMBOL
2293 @item GCC_MANGLE_BUG
2297 @item GDB_TARGET_IS_HPPA
2298 This determines whether horrible kludge code in dbxread.c and partial-stab.h
2299 is used to mangle multiple-symbol-table files from HPPA's. This should all
2300 be ripped out, and a scheme like elfread.c used.
2301 @item GDB_TARGET_IS_MACH386
2303 @item GDB_TARGET_IS_SUN3
2305 @item GDB_TARGET_IS_SUN386
2307 @item GET_LONGJMP_TARGET
2308 For most machines, this is a target-dependent parameter. On the DECstation
2309 and the Iris, this is a native-dependent parameter, since <setjmp.h> is
2310 needed to define it.
2312 This macro determines the target PC address that longjmp() will jump
2313 to, assuming that we have just stopped at a longjmp breakpoint. It
2314 takes a CORE_ADDR * as argument, and stores the target PC value through
2315 this pointer. It examines the current state of the machine as needed.
2316 @item GET_SAVED_REGISTER
2318 @item GPLUS_PRODUCER
2328 @item HAVE_REGISTER_WINDOWS
2330 @item HAVE_SIGSETMASK
2334 @item HEADER_SEEK_FD
2338 @item HOST_BYTE_ORDER
2342 @item HPUX_VERSION_5
2348 @item IBM6000_TARGET
2349 Shows that we are configured for an IBM RS/6000 target. This conditional
2350 should be eliminated (FIXME) and replaced by feature-specific macros.
2351 It was introduced in haste and we are repenting at leisure.
2358 @item INIT_EXTRA_FRAME_INFO
2360 @item INIT_EXTRA_SYMTAB_INFO
2374 @item IN_SOLIB_TRAMPOLINE
2378 @item IS_TRAPPED_INTERNALVAR
2382 @item KERNEL_DEBUGGING
2394 @item CC_HAS_LONG_LONG
2396 @item PRINTF_HAS_LONG_LONG
2402 @item MACHKERNELDEBUG
2408 @item MAINTENANCE_CMDS
2410 @item MAINTENANCE_CMDS
2418 @item NEED_POSIX_SETPGID
2420 @item NEED_TEXT_START_END
2434 @item NOTICE_SIGNAL_HANDLING_CHANGE
2436 @item NO_HIF_SUPPORT
2438 @item NO_SIGINTERRUPT
2440 @item NO_SINGLE_STEP
2444 @item NS32K_SVC_IMMED_OPERANDS
2446 @item NUMERIC_REG_NAMES
2454 @item ONE_PROCESS_WRITETEXT
2458 @item PCC_SOL_BROKEN
2460 @item PC_IN_CALL_DUMMY
2462 @item PC_LOAD_SEGMENT
2466 @item PRINT_RANDOM_SIGNAL
2468 @item PRINT_REGISTER_HOOK
2470 @item PRINT_TYPELESS_INTEGER
2472 @item PROCESS_LINENUMBER_HOOK
2474 @item PROLOGUE_FIRSTLINE_OVERLAP
2476 @item PSIGNAL_IN_SIGNAL_H
2480 @item PUSH_ARGUMENTS
2482 @item REGISTER_BYTES
2484 @item REGISTER_NAMES
2486 @item REG_STACK_SEGMENT
2488 @item REG_STRUCT_HAS_ADDR
2496 @item SDB_REG_TO_REGNUM
2504 @item SHELL_COMMAND_CONCAT
2508 @item SHIFT_INST_REGS
2510 @item SIGN_EXTEND_CHAR
2512 @item SIGTRAP_STOP_AFTER_LOAD
2516 @item SKIP_PROLOGUE_FRAMELESS_P
2518 @item SKIP_TRAMPOLINE_CODE
2522 @item SOLIB_CREATE_INFERIOR_HOOK
2526 @item STAB_REG_TO_REGNUM
2530 @item STACK_DIRECTION
2532 @item START_INFERIOR_TRAPS_EXPECTED
2536 @item STORE_RETURN_VALUE
2538 @item SUN4_COMPILER_FEATURE
2540 @item SUN_FIXED_LBRAC_BUG
2542 @item SVR4_SHARED_LIBS
2544 @item SWITCH_ENUM_BUG
2548 @item SYMBOL_RELOADING_DEFAULT
2554 @item TARGET_BYTE_ORDER
2556 @item TARGET_CHAR_BIT
2558 @item TARGET_COMPLEX_BIT
2560 @item TARGET_DOUBLE_BIT
2562 @item TARGET_DOUBLE_COMPLEX_BIT
2564 @item TARGET_FLOAT_BIT
2566 @item TARGET_INT_BIT
2568 @item TARGET_LONG_BIT
2570 @item TARGET_LONG_DOUBLE_BIT
2572 @item TARGET_LONG_LONG_BIT
2574 @item TARGET_PTR_BIT
2576 @item TARGET_READ_PC
2577 @item TARGET_WRITE_PC
2578 @item TARGET_READ_SP
2579 @item TARGET_WRITE_SP
2580 @item TARGET_READ_FP
2581 @item TARGET_WRITE_FP
2582 These change the behavior of @code{read_pc}, @code{write_pc},
2583 @code{read_sp}, @code{write_sp}, @code{read_fp} and @code{write_fp}.
2584 For most targets, these may be left undefined. GDB will call the
2585 read and write register functions with the relevant @code{_REGNUM} argument.
2587 These macros are useful when a target keeps one of these registers in a
2588 hard to get at place; for example, part in a segment register and part
2589 in an ordinary register.
2591 @item TARGET_SHORT_BIT
2605 @item USE_STRUCT_CONVENTION
2611 @item VARIABLES_INSIDE_BLOCK
2621 @item __HAVE_68881__
2625 @item __INT_VARARGS_H
2627 @item __not_on_pyr_yet
2637 @item longest_to_int
2661 @node Native Conditionals
2662 @chapter Native Conditionals
2664 When GDB is configured and compiled, various macros are defined or left
2665 undefined, to control compilation when the host and target systems
2666 are the same. These macros should be defined (or left undefined)
2667 in @file{nm-@var{system}.h}.
2671 If defined, then gdb will include support for the @code{attach} and
2672 @code{detach} commands.
2673 @item FETCH_INFERIOR_REGISTERS
2674 Define this if the native-dependent code will provide its
2676 @code{fetch_inferior_registers} and @code{store_inferior_registers} in
2677 @file{@var{HOST}-nat.c}.
2678 If this symbol is @emph{not} defined, and @file{infptrace.c}
2679 is included in this configuration, the default routines in
2680 @file{infptrace.c} are used for these functions.
2681 @item GET_LONGJMP_TARGET
2682 For most machines, this is a target-dependent parameter. On the DECstation
2683 and the Iris, this is a native-dependent parameter, since <setjmp.h> is
2684 needed to define it.
2686 This macro determines the target PC address that longjmp() will jump
2687 to, assuming that we have just stopped at a longjmp breakpoint. It
2688 takes a CORE_ADDR * as argument, and stores the target PC value through
2689 this pointer. It examines the current state of the machine as needed.
2691 Defines the format for the name of a @file{/proc} device. Should be
2692 defined in @file{nm.h} @emph{only} in order to override the default
2693 definition in @file{procfs.c}.
2696 @item PTRACE_ARG3_TYPE
2697 The type of the third argument to the @code{ptrace} system call, if it exists
2698 and is different from @code{int}.
2699 @item REGISTER_U_ADDR
2700 Defines the offset of the registers in the ``u area''; @pxref{Host}.
2702 This determines whether small routines in @file{*-tdep.c}, which
2703 translate register values
2704 between GDB's internal representation and the /proc representation,
2707 This is the offset of the registers in the upage. It need only be
2708 defined if the generic ptrace register access routines in
2709 @file{infptrace.c} are being used (that is,
2710 @file{infptrace.c} is configured in, and
2711 @code{FETCH_INFERIOR_REGISTERS} is not defined). If the default value
2712 from @file{infptrace.c} is good enough, leave it undefined.
2714 The default value means that u.u_ar0 @emph{points to} the location of the
2715 registers. I'm guessing that @code{#define U_REGS_OFFSET 0} means that
2716 u.u_ar0 @emph{is} the location of the registers.
2719 @node Obsolete Conditionals
2720 @chapter Obsolete Conditionals
2722 Fragments of old code in GDB sometimes reference or set the following
2723 configuration macros. They should not be used by new code, and
2724 old uses should be removed as those parts of the debugger are
2728 @item STACK_END_ADDR
2729 This macro used to define where the end of the stack appeared, for use
2730 in interpreting core file formats that don't record this address in the
2731 core file itself. This information is now configured in BFD, and GDB
2732 gets the info portably from there. The values in GDB's configuration
2733 files should be moved into BFD configuration files (if needed there),
2734 and deleted from all of GDB's config files.
2736 Any @file{@var{foo}-xdep.c} file that references STACK_END_ADDR
2737 is so old that it has never been converted to use BFD. Now that's old!
2741 @chapter The XCOFF Object File Format
2743 The IBM RS/6000 running AIX uses an object file format called xcoff.
2744 The COFF sections, symbols, and line numbers are used, but debugging
2745 symbols are dbx-style stabs whose strings are located in the
2746 @samp{.debug} section (rather than the string table). For more
2747 information, @xref{Top,,,stabs,The Stabs Debugging Format}, and search
2750 The shared library scheme has a nice clean interface for figuring out
2751 what shared libraries are in use, but the catch is that everything which
2752 refers to addresses (symbol tables and breakpoints at least) needs to be
2753 relocated for both shared libraries and the main executable. At least
2754 using the standard mechanism this can only be done once the program has
2755 been run (or the core file has been read).