* hppa-tdep.c (hppa_push_arguments): Allocate enough space for
[deliverable/binutils-gdb.git] / gdb / doc / gdbint.texinfo
CommitLineData
ca714d03 1\input texinfo
7f09f15f 2@setfilename gdbint.info
d98259f8 3@c $Id$
b7becc8f
RP
4
5@ifinfo
6@format
7START-INFO-DIR-ENTRY
b517f124 8* Gdb-Internals: (gdbint). The GNU debugger's internals.
b7becc8f
RP
9END-INFO-DIR-ENTRY
10@end format
11@end ifinfo
12
ca714d03
RP
13@ifinfo
14This file documents the internals of the GNU debugger GDB.
f222d23d 15
224226b8 16Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
ca714d03 17Contributed by Cygnus Support. Written by John Gilmore.
cfddbd02 18
ca714d03
RP
19Permission is granted to make and distribute verbatim copies of
20this manual provided the copyright notice and this permission notice
21are preserved on all copies.
22
23@ignore
24Permission is granted to process this file through Tex and print the
25results, provided the printed document carries copying permission
26notice identical to this one except for the removal of this paragraph
27(this paragraph not being relevant to the printed manual).
28
29@end ignore
30Permission is granted to copy or distribute modified versions of this
31manual under the terms of the GPL (for which purpose this text may be
32regarded as a program in the language TeX).
33@end ifinfo
34
7f09f15f 35@setchapternewpage off
ca714d03
RP
36@settitle GDB Internals
37@titlepage
38@title{Working in GDB}
39@subtitle{A guide to the internals of the GNU debugger}
40@author John Gilmore
41@author Cygnus Support
42@page
43@tex
44\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
45\xdef\manvers{\$Revision$} % For use in headers, footers too
46{\parskip=0pt
47\hfill Cygnus Support\par
48\hfill \manvers\par
49\hfill \TeX{}info \texinfoversion\par
50}
51@end tex
52
53@vskip 0pt plus 1filll
224226b8 54Copyright @copyright{} 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
ca714d03
RP
55
56Permission is granted to make and distribute verbatim copies of
57this manual provided the copyright notice and this permission notice
58are preserved on all copies.
59
60@end titlepage
61
b517f124
JG
62@node Top
63@top
a5e7f259
JK
64@c IMHO much information should go into *comments* as you discover it
65@c or design changes to GDB. It's more likely to get noticed and
66@c easier to maintain there. -kingdon
b517f124 67This documents the internals of the GNU debugger, GDB. It is a
493cf018
JG
68collection of miscellaneous information with little form at this point.
69Mostly, it is a repository into which you can put information about
70GDB as you discover it (or as you design changes to GDB).
71
ca714d03 72@menu
97f3cb72 73* README:: The README File
a5e7f259
JK
74* Getting Started:: Getting started working on GDB
75* Debugging GDB:: Debugging GDB with itself
97f3cb72
RP
76* New Architectures:: Defining a New Host or Target Architecture
77* Config:: Adding a New Configuration
7f09f15f 78* Host:: Adding a New Host
fd3d2e1d 79* Native:: Adding a New Native Configuration
7f09f15f 80* Target:: Adding a New Target
97f3cb72
RP
81* Languages:: Defining New Source Languages
82* Releases:: Configuring GDB for Release
493cf018 83* Partial Symbol Tables:: How GDB reads symbols quickly at startup
3a8bc841 84* Types:: How GDB keeps track of types
d98259f8 85* BFD support for GDB:: How BFD and GDB interface
97f3cb72
RP
86* Symbol Reading:: Defining New Symbol Readers
87* Cleanups:: Cleanups
88* Wrapping:: Wrapping Output Lines
968720bf 89* Frames:: Keeping track of function calls
00db1549 90* Remote Stubs:: Code that runs in targets and talks to GDB
d3d6d0ff 91* Longjmp Support:: Stepping through longjmp's in the target
968720bf 92* Coding Style:: Strunk and White for GDB maintainers
2a20c602
JG
93* Clean Design:: Frank Lloyd Wright for GDB maintainers
94* Submitting Patches:: How to get your changes into GDB releases
b517f124
JG
95* Host Conditionals:: What features exist in the host
96* Target Conditionals:: What features exist in the target
97* Native Conditionals:: Conditionals for when host and target are same
98* Obsolete Conditionals:: Conditionals that don't exist any more
9729ef22 99* XCOFF:: The Object file format used on IBM's RS/6000
ca714d03
RP
100@end menu
101
b517f124 102@node README
97f3cb72 103@chapter The @file{README} File
cfddbd02 104
97f3cb72
RP
105Check the @file{README} file, it often has useful information that does not
106appear anywhere else in the directory.
cfddbd02 107
a5e7f259
JK
108@node Getting Started
109@chapter Getting Started Working on GDB
110
111GDB is a large and complicated program, and if you first starting to
112work on it, it can be hard to know where to start. Fortunately, if you
113know how to go about it, there are ways to figure out what is going on:
114
115@table @bullet
116@item
117This manual, the GDB Internals manual, has information which applies
118generally to many parts of GDB.
119
120@item
121Information about particular functions or data structures are located in
122comments with those functions or data structures. If you run across a
123function or a global variable which does not have a comment correctly
124explaining what is does, this can be thought of as a bug in GDB; feel
125free to submit a bug report, with a suggested comment if you can figure
126out what the comment should say (@pxref{Submitting Patches}). If you
127find a comment which is actually wrong, be especially sure to report that.
128
129Comments explaining the function of macros defined in host, target, or
130native dependent files can be in several places. Sometimes they are
131repeated every place the macro is defined. Sometimes they are where the
132macro is used. Sometimes there is a header file which supplies a
133default definition of the macro, and the comment is there. This manual
134also has a list of macros (@pxref{Host Conditionals}, @pxref{Target
135Conditionals}, @pxref{Native Conditionals}, and @pxref{Obsolete
136Conditionals}) with some documentation.
137
138@item
139Start with the header files. Once you some idea of how GDB's internal
140symbol tables are stored (see @file{symtab.h}, @file{gdbtypes.h}), you
141will find it much easier to understand the code which uses and creates
142those symbol tables.
143
144@item
145You may wish to process the information you are getting somehow, to
146enhance your understanding of it. Summarize it, translate it to another
147language, add some (perhaps trivial or non-useful) feature to GDB, use
148the code to predict what a test case would do and write the test case
149and verify your prediction, etc. If you are reading code and your eyes
150are starting to glaze over, this is a sign you need to use a more active
151approach.
152
153@item
154Once you have a part of GDB to start with, you can find more
155specifically the part you are looking for by stepping through each
156function with the @code{next} command. Do not use @code{step} or you
157will quickly get distracted; when the function you are stepping through
158calls another function try only to get a big-picture understanding
159(perhaps using the comment at the beginning of the function being
160called) of what it does. This way you can identify which of the
161functions being called by the function you are stepping through is the
162one which you are interested in. You may need to examine the data
163structures generated at each stage, with reference to the comments in
164the header files explaining what the data structures are supposed to
165look like.
166
167Of course, this same technique can be used if you are just reading the
168code, rather than actually stepping through it. The same general
169principle applies---when the code you are looking at calls something
170else, just try to understand generally what the code being called does,
171rather than worrying about all its details.
172
173@item
174A good place to start when tracking down some particular area is with a
175command which invokes that feature. Suppose you want to know how
176single-stepping works. As a GDB user, you know that the @code{step}
177command invokes single-stepping. The command is invoked via command
178tables (see @file{command.h}); by convention the function which actually
179performs the command is formed by taking the name of the command and
180adding @samp{_command}, or in the case of an @code{info} subcommand,
181@samp{_info}. For example, the @code{step} command invokes the
182@code{step_command} function and the @code{info display} command invokes
183@code{display_info}. When this convention is not followed, you might
184have to use @code{grep} or @kbd{M-x tags-search} in emacs, or run GDB on
185itself and set a breakpoint in @code{execute_command}.
186
187@item
188If all of the above fail, it may be appropriate to ask for information
189on @code{bug-gdb}. But @emph{never} post a generic question like ``I was
190wondering if anyone could give me some tips about understanding
191GDB''---if we had some magic secret we would put it in this manual.
192Suggestions for improving the manual are always welcome, of course.
193@end table
194
195Good luck!
196
197@node Debugging GDB
198@chapter Debugging GDB with itself
199If gdb is limping on your machine, this is the preferred way to get it
200fully functional. Be warned that in some ancient Unix systems, like
201Ultrix 4.0, a program can't be running in one process while it is being
202debugged in another. Rather than typing the command @code{@w{./gdb
203./gdb}}, which works on Suns and such, you can copy @file{gdb} to
204@file{gdb2} and then type @code{@w{./gdb ./gdb2}}.
205
206When you run gdb in the gdb source directory, it will read a
207@file{.gdbinit} file that sets up some simple things to make debugging
208gdb easier. The @code{info} command, when executed without a subcommand
209in a gdb being debugged by gdb, will pop you back up to the top level
210gdb. See @file{.gdbinit} for details.
211
212If you use emacs, you will probably want to do a @code{make TAGS} after
213you configure your distribution; this will put the machine dependent
214routines for your local machine where they will be accessed first by
215@kbd{M-.}
216
217Also, make sure that you've either compiled gdb with your local cc, or
218have run @code{fixincludes} if you are compiling with gcc.
cfddbd02 219
b517f124 220@node New Architectures
97f3cb72 221@chapter Defining a New Host or Target Architecture
cfddbd02 222
97f3cb72
RP
223When building support for a new host and/or target, much of the work you
224need to do is handled by specifying configuration files;
225@pxref{Config,,Adding a New Configuration}. Further work can be
226divided into ``host-dependent'' (@pxref{Host,,Adding a New Host}) and
aeb62c7b 227``target-dependent'' (@pxref{Target,,Adding a New Target}). The
97f3cb72
RP
228following discussion is meant to explain the difference between hosts
229and targets.
d98259f8 230
97f3cb72 231@heading What is considered ``host-dependent'' versus ``target-dependent''?
d98259f8 232
b7becc8f
RP
233@dfn{Host} refers to attributes of the system where GDB runs.
234@dfn{Target} refers to the system where the program being debugged
fd3d2e1d
JG
235executes. In most cases they are the same machine, in which case
236a third type of @dfn{Native} attributes come into play.
cfddbd02 237
97f3cb72
RP
238Defines and include files needed to build on the host are host support.
239Examples are tty support, system defined types, host byte order, host
240float format.
cfddbd02 241
fd3d2e1d
JG
242Defines and information needed to handle the target format are target
243dependent. Examples are the stack frame format, instruction set,
244breakpoint instruction, registers, and how to set up and tear down the stack
245to call a function.
246
247Information that is only needed when the host and target are the same,
248is native dependent. One example is Unix child process support; if the
249host and target are not the same, doing a fork to start the target
250process is a bad idea. The various macros needed for finding the
251registers in the @code{upage}, running @code{ptrace}, and such are all in the
252native-dependent files.
253
254Another example of native-dependent code is support for features
255that are really part of the target environment, but which require
256@code{#include} files that are only available on the host system.
257Core file handling and @code{setjmp} handling are two common cases.
258
259When you want to make GDB work ``native'' on a particular
260machine, you have to include all three kinds of information.
261
262The dependent information in GDB is organized into files by naming
263conventions.
7f27984e 264
fd3d2e1d
JG
265Host-Dependent Files
266@table @file
3a8bc841 267@item config/*/*.mh
fd3d2e1d 268Sets Makefile parameters
3a8bc841 269@item config/*/xm-*.h
fd3d2e1d
JG
270Global #include's and #define's and definitions
271@item *-xdep.c
272Global variables and functions
273@end table
274
275Native-Dependent Files
276@table @file
3a8bc841 277@item config/*/*.mh
fd3d2e1d 278Sets Makefile parameters (for @emph{both} host and native)
3a8bc841 279@item config/*/nm-*.h
fd3d2e1d
JG
280#include's and #define's and definitions. This file
281is only included by the small number of modules that need it,
282so beware of doing feature-test #define's from its macros.
283@item *-nat.c
284global variables and functions
285@end table
7f27984e 286
fd3d2e1d
JG
287Target-Dependent Files
288@table @file
3a8bc841 289@item config/*/*.mt
fd3d2e1d 290Sets Makefile parameters
3a8bc841 291@item config/*/tm-*.h
fd3d2e1d
JG
292Global #include's and #define's and definitions
293@item *-tdep.c
294Global variables and functions
295@end table
bbb5013f 296
fd3d2e1d
JG
297At this writing, most supported hosts have had their host and native
298dependencies sorted out properly. There are a few stragglers, which
299can be recognized by the absence of NATDEPFILES lines in their
3a8bc841 300@file{config/*/*.mh}.
bbb5013f 301
b517f124 302@node Config
97f3cb72 303@chapter Adding a New Configuration
bbb5013f 304
97f3cb72
RP
305Most of the work in making GDB compile on a new machine is in specifying
306the configuration of the machine. This is done in a dizzying variety of
307header files and configuration scripts, which we hope to make more
308sensible soon. Let's say your new host is called an @var{xxx} (e.g.
309@samp{sun4}), and its full three-part configuration name is
310@code{@var{xarch}-@var{xvend}-@var{xos}} (e.g. @samp{sparc-sun-sunos4}). In
311particular:
312
b7becc8f 313In the top level directory, edit @file{config.sub} and add @var{xarch},
97f3cb72
RP
314@var{xvend}, and @var{xos} to the lists of supported architectures,
315vendors, and operating systems near the bottom of the file. Also, add
316@var{xxx} as an alias that maps to
317@code{@var{xarch}-@var{xvend}-@var{xos}}. You can test your changes by
318running
bbb5013f 319
97f3cb72
RP
320@example
321./config.sub @var{xxx}
322@end example
323@noindent
324and
325@example
326./config.sub @code{@var{xarch}-@var{xvend}-@var{xos}}
327@end example
328@noindent
329which should both respond with @code{@var{xarch}-@var{xvend}-@var{xos}}
330and no error messages.
bbb5013f 331
b7becc8f
RP
332Now, go to the @file{bfd} directory and
333create a new file @file{bfd/hosts/h-@var{xxx}.h}. Examine the
97f3cb72
RP
334other @file{h-*.h} files as templates, and create one that brings in the
335right include files for your system, and defines any host-specific
fd3d2e1d
JG
336macros needed by BFD, the Binutils, GNU LD, or the Opcodes directories.
337(They all share the bfd @file{hosts} directory and the @file{configure.host}
338file.)
7f27984e 339
fd3d2e1d 340Then edit @file{bfd/configure.host}. Add a line to recognize your
97f3cb72 341@code{@var{xarch}-@var{xvend}-@var{xos}} configuration, and set
b7becc8f
RP
342@code{my_host} to @var{xxx} when you recognize it. This will cause your
343file @file{h-@var{xxx}.h} to be linked to @file{sysdep.h} at configuration
fd3d2e1d
JG
344time. When creating the line that recognizes your configuration,
345only match the fields that you really need to match; e.g. don't match
346match the architecture or manufacturer if the OS is sufficient
347to distinguish the configuration that your @file{h-@var{xxx}.h} file supports.
348Don't match the manufacturer name unless you really need to.
349This should make future ports easier.
7f27984e 350
b7becc8f 351Also, if this host requires any changes to the Makefile, create a file
fd3d2e1d 352@file{bfd/config/@var{xxx}.mh}, which includes the required lines.
97f3cb72 353
8cc1c08f 354It's possible that the @file{libiberty} and @file{readline} directories
97f3cb72
RP
355won't need any changes for your configuration, but if they do, you can
356change the @file{configure.in} file there to recognize your system and
8cc1c08f 357map to an @file{mh-@var{xxx}} file. Then add @file{mh-@var{xxx}}
97f3cb72
RP
358to the @file{config/} subdirectory, to set any makefile variables you
359need. The only current options in there are things like @samp{-DSYSV}.
fd3d2e1d
JG
360(This @file{mh-@var{xxx}} naming convention differs from elsewhere
361in GDB, by historical accident. It should be cleaned up so that all
362such files are called @file{@var{xxx}.mh}.)
97f3cb72 363
b7becc8f 364Aha! Now to configure GDB itself! Edit
97f3cb72
RP
365@file{gdb/configure.in} to recognize your system and set @code{gdb_host}
366to @var{xxx}, and (unless your desired target is already available) also
367set @code{gdb_target} to something appropriate (for instance,
368@var{xxx}). To handle new hosts, modify the segment after the comment
369@samp{# per-host}; to handle new targets, modify after @samp{#
370per-target}.
371@c Would it be simpler to just use different per-host and per-target
372@c *scripts*, and call them from {configure} ?
7f27984e 373
fd3d2e1d 374Finally, you'll need to specify and define GDB's host-, native-, and
8cc1c08f
JG
375target-dependent @file{.h} and @file{.c} files used for your
376configuration; the next two chapters discuss those.
7f27984e 377
7f27984e 378
b517f124 379@node Host
97f3cb72 380@chapter Adding a New Host
7f27984e 381
97f3cb72 382Once you have specified a new configuration for your host
fd3d2e1d 383(@pxref{Config,,Adding a New Configuration}), there are three remaining
97f3cb72
RP
384pieces to making GDB work on a new machine. First, you have to make it
385host on the new machine (compile there, handle that machine's terminals
386properly, etc). If you will be cross-debugging to some other kind of
387system that's already supported, you are done.
46bc46eb 388
97f3cb72
RP
389If you want to use GDB to debug programs that run on the new machine,
390you have to get it to understand the machine's object files, symbol
fd3d2e1d
JG
391files, and interfaces to processes; @pxref{Target,,Adding a New Target}
392and @pxref{Native,,Adding a New Native Configuration}
46bc46eb 393
aeb62c7b
JG
394Several files control GDB's configuration for host systems:
395
396@table @file
3a8bc841 397@item gdb/config/@var{arch}/@var{xxx}.mh
8cc1c08f
JG
398Specifies Makefile fragments needed when hosting on machine @var{xxx}.
399In particular, this lists the required machine-dependent object files,
400by defining @samp{XDEPFILES=@dots{}}. Also
401specifies the header file which describes host @var{xxx}, by defining
97f3cb72
RP
402@samp{XM_FILE= xm-@var{xxx}.h}. You can also define @samp{CC},
403@samp{REGEX} and @samp{REGEX1}, @samp{SYSV_DEFINE}, @samp{XM_CFLAGS},
aeb62c7b
JG
404@samp{XM_ADD_FILES}, @samp{XM_CLIBS}, @samp{XM_CDEPS},
405etc.; see @file{Makefile.in}.
406
3a8bc841 407@item gdb/config/@var{arch}/xm-@var{xxx}.h
aeb62c7b
JG
408(@file{xm.h} is a link to this file, created by configure).
409Contains C macro definitions describing the host system environment,
410such as byte order, host C compiler and library, ptrace support,
411and core file structure. Crib from existing @file{xm-*.h} files
412to create a new one.
413
414@item gdb/@var{xxx}-xdep.c
415Contains any miscellaneous C code required for this machine
fd3d2e1d
JG
416as a host. On many machines it doesn't exist at all. If it does
417exist, put @file{@var{xxx}-xdep.o} into the @code{XDEPFILES} line
418in @file{gdb/config/mh-@var{xxx}}.
aeb62c7b 419@end table
46bc46eb 420
fd3d2e1d
JG
421@subheading Generic Host Support Files
422
97f3cb72 423There are some ``generic'' versions of routines that can be used by
fd3d2e1d 424various systems. These can be customized in various ways by macros
97f3cb72
RP
425defined in your @file{xm-@var{xxx}.h} file. If these routines work for
426the @var{xxx} host, you can just include the generic file's name (with
427@samp{.o}, not @samp{.c}) in @code{XDEPFILES}.
46bc46eb 428
97f3cb72
RP
429Otherwise, if your machine needs custom support routines, you will need
430to write routines that perform the same functions as the generic file.
431Put them into @code{@var{xxx}-xdep.c}, and put @code{@var{xxx}-xdep.o}
fd3d2e1d 432into @code{XDEPFILES}.
46bc46eb 433
fd3d2e1d
JG
434@table @file
435@item ser-bsd.c
436This contains serial line support for Berkeley-derived Unix systems.
437
438@item ser-go32.c
439This contains serial line support for 32-bit programs running under DOS
440using the GO32 execution environment.
441
442@item ser-termios.c
443This contains serial line support for System V-derived Unix systems.
444@end table
445
446Now, you are now ready to try configuring GDB to compile using your system
447as its host. From the top level (above @file{bfd}, @file{gdb}, etc), do:
448
449@example
450./configure @var{xxx} +target=vxworks960
451@end example
452
453This will configure your system to cross-compile for VxWorks on
454the Intel 960, which is probably not what you really want, but it's
455a test case that works at this stage. (You haven't set up to be
456able to debug programs that run @emph{on} @var{xxx} yet.)
457
458If this succeeds, you can try building it all with:
459
460@example
461make
462@end example
463
464Repeat until the program configures, compiles, links, and runs.
465When run, it won't be able to do much (unless you have a VxWorks/960
466board on your network) but you will know that the host support is
467pretty well done.
468
469Good luck! Comments and suggestions about this section are particularly
470welcome; send them to @samp{bug-gdb@@prep.ai.mit.edu}.
471
472@node Native
473@chapter Adding a New Native Configuration
474
475If you are making GDB run native on the @var{xxx} machine, you have
476plenty more work to do. Several files control GDB's configuration for
477native support:
46bc46eb 478
aeb62c7b 479@table @file
3a8bc841 480@item gdb/config/@var{xarch}/@var{xxx}.mh
fd3d2e1d
JG
481Specifies Makefile fragments needed when hosting @emph{or native}
482on machine @var{xxx}.
483In particular, this lists the required native-dependent object files,
484by defining @samp{NATDEPFILES=@dots{}}. Also
485specifies the header file which describes native support on @var{xxx},
224226b8 486by defining @samp{NAT_FILE= nm-@var{xxx}.h}.
fd3d2e1d
JG
487You can also define @samp{NAT_CFLAGS},
488@samp{NAT_ADD_FILES}, @samp{NAT_CLIBS}, @samp{NAT_CDEPS},
489etc.; see @file{Makefile.in}.
490
3a8bc841 491@item gdb/config/@var{arch}/nm-@var{xxx}.h
fd3d2e1d
JG
492(@file{nm.h} is a link to this file, created by configure).
493Contains C macro definitions describing the native system environment,
494such as child process control and core file support.
495Crib from existing @file{nm-*.h} files to create a new one.
fd3d2e1d
JG
496
497@item gdb/@var{xxx}-nat.c
498Contains any miscellaneous C code required for this native support
499of this machine. On some machines it doesn't exist at all.
500@end table
501
502@subheading Generic Native Support Files
503
504There are some ``generic'' versions of routines that can be used by
505various systems. These can be customized in various ways by macros
506defined in your @file{nm-@var{xxx}.h} file. If these routines work for
507the @var{xxx} host, you can just include the generic file's name (with
508@samp{.o}, not @samp{.c}) in @code{NATDEPFILES}.
509
510Otherwise, if your machine needs custom support routines, you will need
511to write routines that perform the same functions as the generic file.
512Put them into @code{@var{xxx}-nat.c}, and put @code{@var{xxx}-nat.o}
513into @code{NATDEPFILES}.
514
515@table @file
516
517@item inftarg.c
518This contains the @emph{target_ops vector} that supports Unix child
519processes on systems which use ptrace and wait to control the child.
520
521@item procfs.c
522This contains the @emph{target_ops vector} that supports Unix child
523processes on systems which use /proc to control the child.
524
525@item fork-child.c
526This does the low-level grunge that uses Unix system calls
527to do a "fork and exec" to start up a child process.
46bc46eb 528
97f3cb72 529@item infptrace.c
aeb62c7b
JG
530This is the low level interface to inferior processes for systems
531using the Unix @code{ptrace} call in a vanilla way.
46bc46eb 532
aeb62c7b 533@item coredep.c::fetch_core_registers()
46bc46eb 534Support for reading registers out of a core file. This routine calls
aeb62c7b
JG
535@code{register_addr()}, see below.
536Now that BFD is used to read core files, virtually all machines should
537use @code{coredep.c}, and should just provide @code{fetch_core_registers} in
fd3d2e1d 538@code{@var{xxx}-nat.c} (or @code{REGISTER_U_ADDR} in @code{nm-@var{xxx}.h}).
ca714d03 539
aeb62c7b 540@item coredep.c::register_addr()
fd3d2e1d 541If your @code{nm-@var{xxx}.h} file defines the macro
493cf018
JG
542@code{REGISTER_U_ADDR(addr, blockend, regno)}, it should be defined to
543set @code{addr} to the offset within the @samp{user}
544struct of GDB register number @code{regno}. @code{blockend} is the
545offset within the ``upage'' of @code{u.u_ar0}.
546If @code{REGISTER_U_ADDR} is defined,
d98259f8
RP
547@file{coredep.c} will define the @code{register_addr()} function and use
548the macro in it. If you do not define @code{REGISTER_U_ADDR}, but you
97f3cb72
RP
549are using the standard @code{fetch_core_registers()}, you will need to
550define your own version of @code{register_addr()}, put it into your
fd3d2e1d
JG
551@code{@var{xxx}-nat.c} file, and be sure @code{@var{xxx}-nat.o} is in
552the @code{NATDEPFILES} list. If you have your own
97f3cb72
RP
553@code{fetch_core_registers()}, you may not need a separate
554@code{register_addr()}. Many custom @code{fetch_core_registers()}
555implementations simply locate the registers themselves.@refill
ca714d03 556@end table
46bc46eb 557
fd3d2e1d
JG
558When making GDB run native on a new operating system,
559to make it possible to debug
97f3cb72
RP
560core files, you will need to either write specific code for parsing your
561OS's core files, or customize @file{bfd/trad-core.c}. First, use
562whatever @code{#include} files your machine uses to define the struct of
563registers that is accessible (possibly in the u-area) in a core file
564(rather than @file{machine/reg.h}), and an include file that defines whatever
565header exists on a core file (e.g. the u-area or a @samp{struct core}). Then
566modify @code{trad_unix_core_file_p()} to use these values to set up the
567section information for the data segment, stack segment, any other
568segments in the core file (perhaps shared library contents or control
569information), ``registers'' segment, and if there are two discontiguous
570sets of registers (e.g. integer and float), the ``reg2'' segment. This
571section information basically delimits areas in the core file in a
572standard way, which the section-reading routines in BFD know how to seek
573around in.
574
b7becc8f
RP
575Then back in GDB, you need a matching routine called
576@code{fetch_core_registers()}. If you can use the generic one, it's in
fd3d2e1d 577@file{coredep.c}; if not, it's in your @file{@var{xxx}-nat.c} file.
b7becc8f
RP
578It will be passed a char pointer to the entire ``registers'' segment,
579its length, and a zero; or a char pointer to the entire ``regs2''
580segment, its length, and a 2. The routine should suck out the supplied
581register values and install them into GDB's ``registers'' array.
582(@xref{New Architectures,,Defining a New Host or Target Architecture},
1dbe1ef7
JG
583for more info about this.)
584
fd3d2e1d
JG
585If your system uses @file{/proc} to control processes, and uses ELF
586format core files, then you may be able to use the same routines
587for reading the registers out of processes and out of core files.
97f3cb72 588
b517f124 589@node Target
7f09f15f 590@chapter Adding a New Target
d98259f8 591
97f3cb72
RP
592For a new target called @var{ttt}, first specify the configuration as
593described in @ref{Config,,Adding a New Configuration}. If your new
594target is the same as your new host, you've probably already done that.
595
8cc1c08f 596A variety of files specify attributes of the GDB target environment:
1dbe1ef7 597
aeb62c7b 598@table @file
3a8bc841 599@item gdb/config/@var{arch}/@var{ttt}.mt
8cc1c08f 600Contains a Makefile fragment specific to this target.
aeb62c7b 601Specifies what object files are needed for target @var{ttt}, by
8cc1c08f 602defining @samp{TDEPFILES=@dots{}}.
aeb62c7b 603Also specifies the header file which describes @var{ttt}, by defining
8cc1c08f 604@samp{TM_FILE= tm-@var{ttt}.h}. You can also define @samp{TM_CFLAGS},
fd3d2e1d 605@samp{TM_CLIBS}, @samp{TM_CDEPS},
aeb62c7b
JG
606and other Makefile variables here; see @file{Makefile.in}.
607
3a8bc841 608@item gdb/config/@var{arch}/tm-@var{ttt}.h
aeb62c7b
JG
609(@file{tm.h} is a link to this file, created by configure).
610Contains macro definitions about the target machine's
611registers, stack frame format and instructions.
612Crib from existing @file{tm-*.h} files when building a new one.
613
614@item gdb/@var{ttt}-tdep.c
615Contains any miscellaneous code required for this target machine.
616On some machines it doesn't exist at all. Sometimes the macros
617in @file{tm-@var{ttt}.h} become very complicated, so they are
618implemented as functions here instead, and the macro is simply
619defined to call the function.
620
621@item gdb/exec.c
622Defines functions for accessing files that are
97f3cb72
RP
623executable on the target system. These functions open and examine an
624exec file, extract data from one, write data to one, print information
625about one, etc. Now that executable files are handled with BFD, every
626target should be able to use the generic exec.c rather than its
627own custom code.
628
aeb62c7b
JG
629@item gdb/@var{arch}-pinsn.c
630Prints (disassembles) the target machine's instructions.
631This file is usually shared with other target machines which use the
632same processor, which is why it is @file{@var{arch}-pinsn.c} rather
633than @file{@var{ttt}-pinsn.c}.
634
635@item gdb/@var{arch}-opcode.h
636Contains some large initialized
637data structures describing the target machine's instructions.
638This is a bit strange for a @file{.h} file, but it's OK since
639it is only included in one place. @file{@var{arch}-opcode.h} is shared
640between the debugger and the assembler, if the GNU assembler has been
641ported to the target machine.
642
3a8bc841 643@item gdb/config/@var{arch}/tm-@var{arch}.h
aeb62c7b
JG
644This often exists to describe the basic layout of the target machine's
645processor chip (registers, stack, etc).
646If used, it is included by @file{tm-@var{xxx}.h}. It can
647be shared among many targets that use the same processor.
648
649@item gdb/@var{arch}-tdep.c
650Similarly, there are often common subroutines that are shared by all
651target machines that use this particular architecture.
652@end table
653
654When adding support for a new target machine, there are various areas
655of support that might need change, or might be OK.
656
1dbe1ef7
JG
657If you are using an existing object file format (a.out or COFF),
658there is probably little to be done. See @file{bfd/doc/bfd.texinfo}
659for more information on writing new a.out or COFF versions.
660
6e1c67d2
JG
661If you need to add a new object file format, you must first add it to
662BFD. This is beyond the scope of this document right now. Basically
663you must build a transfer vector (of type @code{bfd_target}), which will
664mean writing all the required routines, and add it to the list in
1dbe1ef7
JG
665@file{bfd/targets.c}.
666
6e1c67d2
JG
667You must then arrange for the BFD code to provide access to the
668debugging symbols. Generally GDB will have to call swapping routines
669from BFD and a few other BFD internal routines to locate the debugging
670information. As much as possible, GDB should not depend on the BFD
671internal data structures.
672
673For some targets (e.g., COFF), there is a special transfer vector used
674to call swapping routines, since the external data structures on various
675platforms have different sizes and layouts. Specialized routines that
676will only ever be implemented by one object file format may be called
677directly. This interface should be described in a file
678@file{bfd/libxxx.h}, which is included by GDB.
679
97f3cb72
RP
680If you are adding a new operating system for an existing CPU chip, add a
681@file{tm-@var{xos}.h} file that describes the operating system
682facilities that are unusual (extra symbol table info; the breakpoint
683instruction needed; etc). Then write a
684@file{tm-@var{xarch}-@var{xos}.h} that just @code{#include}s
685@file{tm-@var{xarch}.h} and @file{tm-@var{xos}.h}. (Now that we have
1dbe1ef7 686three-part configuration names, this will probably get revised to
97f3cb72
RP
687separate the @var{xos} configuration from the @var{xarch}
688configuration.)
689
690
b517f124 691@node Languages
97f3cb72
RP
692@chapter Adding a Source Language to GDB
693
694To add other languages to GDB's expression parser, follow the following steps:
695
696@table @emph
697@item Create the expression parser.
698
699This should reside in a file @file{@var{lang}-exp.y}. Routines for building
700parsed expressions into a @samp{union exp_element} list are in @file{parse.c}.
701
aeb62c7b
JG
702Since we can't depend upon everyone having Bison, and YACC produces
703parsers that define a bunch of global names, the following lines
704@emph{must} be included at the top of the YACC parser, to prevent
705the various parsers from defining the same global names:
d98259f8 706
d98259f8 707@example
97f3cb72 708#define yyparse @var{lang}_parse
aeb62c7b 709#define yylex @var{lang}_lex
97f3cb72
RP
710#define yyerror @var{lang}_error
711#define yylval @var{lang}_lval
712#define yychar @var{lang}_char
713#define yydebug @var{lang}_debug
714#define yypact @var{lang}_pact
715#define yyr1 @var{lang}_r1
716#define yyr2 @var{lang}_r2
717#define yydef @var{lang}_def
718#define yychk @var{lang}_chk
719#define yypgo @var{lang}_pgo
720#define yyact @var{lang}_act
721#define yyexca @var{lang}_exca
aeb62c7b
JG
722#define yyerrflag @var{lang}_errflag
723#define yynerrs @var{lang}_nerrs
d98259f8 724@end example
d98259f8 725
b7becc8f
RP
726At the bottom of your parser, define a @code{struct language_defn} and
727initialize it with the right values for your language. Define an
728@code{initialize_@var{lang}} routine and have it call
729@samp{add_language(@var{lang}_language_defn)} to tell the rest of GDB
730that your language exists. You'll need some other supporting variables
731and functions, which will be used via pointers from your
732@code{@var{lang}_language_defn}. See the declaration of @code{struct
733language_defn} in @file{language.h}, and the other @file{*-exp.y} files,
734for more information.
735
97f3cb72
RP
736@item Add any evaluation routines, if necessary
737
738If you need new opcodes (that represent the operations of the language),
739add them to the enumerated type in @file{expression.h}. Add support
740code for these operations in @code{eval.c:evaluate_subexp()}. Add cases
741for new opcodes in two functions from @file{parse.c}:
742@code{prefixify_subexp()} and @code{length_of_subexp()}. These compute
743the number of @code{exp_element}s that a given operation takes up.
744
745@item Update some existing code
746
747Add an enumerated identifier for your language to the enumerated type
748@code{enum language} in @file{defs.h}.
749
750Update the routines in @file{language.c} so your language is included. These
751routines include type predicates and such, which (in some cases) are
752language dependent. If your language does not appear in the switch
753statement, an error is reported.
754
755Also included in @file{language.c} is the code that updates the variable
756@code{current_language}, and the routines that translate the
757@code{language_@var{lang}} enumerated identifier into a printable
758string.
759
760Update the function @code{_initialize_language} to include your language. This
761function picks the default language upon startup, so is dependent upon
762which languages that GDB is built for.
763
b7becc8f
RP
764Update @code{allocate_symtab} in @file{symfile.c} and/or symbol-reading
765code so that the language of each symtab (source file) is set properly.
766This is used to determine the language to use at each stack frame level.
767Currently, the language is set based upon the extension of the source
768file. If the language can be better inferred from the symbol
769information, please set the language of the symtab in the symbol-reading
770code.
97f3cb72
RP
771
772Add helper code to @code{expprint.c:print_subexp()} to handle any new
773expression opcodes you have added to @file{expression.h}. Also, add the
774printed representations of your operators to @code{op_print_tab}.
775
776@item Add a place of call
777
778Add a call to @code{@var{lang}_parse()} and @code{@var{lang}_error} in
779@code{parse.c:parse_exp_1()}.
780
781@item Use macros to trim code
782
783The user has the option of building GDB for some or all of the
784languages. If the user decides to build GDB for the language
785@var{lang}, then every file dependent on @file{language.h} will have the
786macro @code{_LANG_@var{lang}} defined in it. Use @code{#ifdef}s to
787leave out large routines that the user won't need if he or she is not
788using your language.
789
790Note that you do not need to do this in your YACC parser, since if GDB
791is not build for @var{lang}, then @file{@var{lang}-exp.tab.o} (the
792compiled form of your parser) is not linked into GDB at all.
793
794See the file @file{configure.in} for how GDB is configured for different
795languages.
796
797@item Edit @file{Makefile.in}
798
799Add dependencies in @file{Makefile.in}. Make sure you update the macro
800variables such as @code{HFILES} and @code{OBJS}, otherwise your code may
801not get linked in, or, worse yet, it may not get @code{tar}red into the
802distribution!
803@end table
804
805
b517f124 806@node Releases
97f3cb72
RP
807@chapter Configuring GDB for Release
808
b7becc8f
RP
809From the top level directory (containing @file{gdb}, @file{bfd},
810@file{libiberty}, and so on):
811@example
ca25cb3b 812make -f Makefile.in gdb.tar.Z
b7becc8f 813@end example
97f3cb72 814
b7becc8f
RP
815This will properly configure, clean, rebuild any files that are
816distributed pre-built (e.g. @file{c-exp.tab.c} or @file{refcard.ps}),
ca25cb3b
JG
817and will then make a tarfile. (If the top level directory has already
818beenn configured, you can just do @code{make gdb.tar.Z} instead.)
b7becc8f
RP
819
820This procedure requires:
821@itemize @bullet
822@item symbolic links
823@item @code{makeinfo} (texinfo2 level)
824@item @TeX{}
825@item @code{dvips}
826@item @code{yacc} or @code{bison}
827@end itemize
828@noindent
829@dots{} and the usual slew of utilities (@code{sed}, @code{tar}, etc.).
97f3cb72
RP
830
831@subheading TEMPORARY RELEASE PROCEDURE FOR DOCUMENTATION
832
833@file{gdb.texinfo} is currently marked up using the texinfo-2 macros,
834which are not yet a default for anything (but we have to start using
835them sometime).
836
837For making paper, the only thing this implies is the right generation of
838@file{texinfo.tex} needs to be included in the distribution.
839
840For making info files, however, rather than duplicating the texinfo2
841distribution, generate @file{gdb-all.texinfo} locally, and include the files
842@file{gdb.info*} in the distribution. Note the plural; @code{makeinfo} will
843split the document into one overall file and five or so included files.
844
845
b517f124 846@node Partial Symbol Tables
493cf018
JG
847@chapter Partial Symbol Tables
848
849GDB has three types of symbol tables.
850
851@itemize @bullet
852@item full symbol tables (symtabs). These contain the main
853information about symbols and addresses.
854@item partial symbol tables (psymtabs). These contain enough
855information to know when to read the corresponding
856part of the full symbol table.
857@item minimal symbol tables (msymtabs). These contain information
858gleaned from non-debugging symbols.
859@end itemize
860
861This section describes partial symbol tables.
862
863A psymtab is constructed by doing a very quick pass over an executable
864file's debugging information. Small amounts of information are
865extracted -- enough to identify which parts of the symbol table will
866need to be re-read and fully digested later, when the user needs the
867information. The speed of this pass causes GDB to start up very
868quickly. Later, as the detailed rereading occurs, it occurs in small
869pieces, at various times, and the delay therefrom is mostly invisible to
870the user. (@xref{Symbol Reading}.)
871
872The symbols that show up in a file's psymtab should be, roughly, those
873visible to the debugger's user when the program is not running code from
874that file. These include external symbols and types, static
875symbols and types, and enum values declared at file scope.
876
877The psymtab also contains the range of instruction addresses that the
878full symbol table would represent.
879
880The idea is that there are only two ways for the user (or much of
881the code in the debugger) to reference a symbol:
882
883@itemize @bullet
884
885@item by its address
886(e.g. execution stops at some address which is inside a function
887in this file). The address will be noticed to be in the
888range of this psymtab, and the full symtab will be read in.
889@code{find_pc_function}, @code{find_pc_line}, and other @code{find_pc_@dots{}}
890functions handle this.
891
892@item by its name
893(e.g. the user asks to print a variable, or set a breakpoint on a
894function). Global names and file-scope names will be found in the
895psymtab, which will cause the symtab to be pulled in. Local names will
896have to be qualified by a global name, or a file-scope name, in which
897case we will have already read in the symtab as we evaluated the
898qualifier. Or, a local symbol can be referenced when
899we are "in" a local scope, in which case the first case applies.
900@code{lookup_symbol} does most of the work here.
901
902@end itemize
903
904The only reason that psymtabs exist is to cause a symtab to be read in
905at the right moment. Any symbol that can be elided from a psymtab,
906while still causing that to happen, should not appear in it. Since
907psymtabs don't have the idea of scope, you can't put local symbols in
908them anyway. Psymtabs don't have the idea of the type of a symbol,
909either, so types need not appear, unless they will be referenced by
910name.
911
912It is a bug for GDB to behave one way when only a psymtab has been read,
913and another way if the corresponding symtab has been read in. Such
914bugs are typically caused by a psymtab that does not contain all the
915visible symbols, or which has the wrong instruction address ranges.
916
917The psymtab for a particular section of a symbol-file (objfile)
918could be thrown away after the symtab has been read in. The symtab
919should always be searched before the psymtab, so the psymtab will
920never be used (in a bug-free environment). Currently,
921psymtabs are allocated on an obstack, and all the psymbols themselves
922are allocated in a pair of large arrays on an obstack, so there is
923little to be gained by trying to free them unless you want to do a lot
924more work.
925
3a8bc841
JK
926@node Types
927@chapter Types
928
929Fundamental Types (e.g., FT_VOID, FT_BOOLEAN).
930
931These are the fundamental types that gdb uses internally. Fundamental
932types from the various debugging formats (stabs, ELF, etc) are mapped into
933one of these. They are basically a union of all fundamental types that
934gdb knows about for all the languages that gdb knows about.
935
936Type Codes (e.g., TYPE_CODE_PTR, TYPE_CODE_ARRAY).
937
938Each time gdb builds an internal type, it marks it with one of these
939types. The type may be a fundamental type, such as TYPE_CODE_INT, or
940a derived type, such as TYPE_CODE_PTR which is a pointer to another
941type. Typically, several FT_* types map to one TYPE_CODE_* type, and
942are distinguished by other members of the type struct, such as whether
943the type is signed or unsigned, and how many bits it uses.
944
945Builtin Types (e.g., builtin_type_void, builtin_type_char).
946
947These are instances of type structs that roughly correspond to fundamental
948types and are created as global types for gdb to use for various ugly
949historical reasons. We eventually want to eliminate these. Note for
950example that builtin_type_int initialized in gdbtypes.c is basically the
951same as a TYPE_CODE_INT type that is initialized in c-lang.c for an
952FT_INTEGER fundamental type. The difference is that the builtin_type is
953not associated with any particular objfile, and only one instance exists,
954while c-lang.c builds as many TYPE_CODE_INT types as needed, with each
955one associated with some particular objfile.
956
b517f124 957@node BFD support for GDB
97f3cb72 958@chapter Binary File Descriptor Library Support for GDB
7f09f15f
JG
959
960BFD provides support for GDB in several ways:
961
962@table @emph
963@item identifying executable and core files
964BFD will identify a variety of file types, including a.out, coff, and
965several variants thereof, as well as several kinds of core files.
966
967@item access to sections of files
968BFD parses the file headers to determine the names, virtual addresses,
969sizes, and file locations of all the various named sections in files
970(such as the text section or the data section). GDB simply calls
971BFD to read or write section X at byte offset Y for length Z.
972
973@item specialized core file support
974BFD provides routines to determine the failing command name stored
975in a core file, the signal with which the program failed, and whether
976a core file matches (i.e. could be a core dump of) a particular executable
977file.
978
979@item locating the symbol information
980GDB uses an internal interface of BFD to determine where to find the
981symbol information in an executable file or symbol-file. GDB itself
982handles the reading of symbols, since BFD does not ``understand'' debug
983symbols, but GDB uses BFD's cached information to find the symbols,
984string table, etc.
985@end table
986
b7becc8f
RP
987@c The interface for symbol reading is described in @ref{Symbol
988@c Reading,,Symbol Reading}.
7f09f15f 989
7f09f15f 990
b517f124 991@node Symbol Reading
eb752e4e
JG
992@chapter Symbol Reading
993
994GDB reads symbols from "symbol files". The usual symbol file is the
995file containing the program which gdb is debugging. GDB can be directed
996to use a different file for symbols (with the ``symbol-file''
997command), and it can also read more symbols via the ``add-file'' and ``load''
998commands, or while reading symbols from shared libraries.
999
1000Symbol files are initially opened by @file{symfile.c} using the BFD
1001library. BFD identifies the type of the file by examining its header.
1002@code{symfile_init} then uses this identification to locate a
1003set of symbol-reading functions.
1004
1005Symbol reading modules identify themselves to GDB by calling
1006@code{add_symtab_fns} during their module initialization. The argument
1007to @code{add_symtab_fns} is a @code{struct sym_fns} which contains
1008the name (or name prefix) of the symbol format, the length of the prefix,
1009and pointers to four functions. These functions are called at various
1010times to process symbol-files whose identification matches the specified
1011prefix.
1012
1013The functions supplied by each module are:
1014
1015@table @code
97f3cb72 1016@item @var{xxx}_symfile_init(struct sym_fns *sf)
eb752e4e
JG
1017
1018Called from @code{symbol_file_add} when we are about to read a new
1019symbol file. This function should clean up any internal state
1020(possibly resulting from half-read previous files, for example)
1021and prepare to read a new symbol file. Note that the symbol file
1022which we are reading might be a new "main" symbol file, or might
1023be a secondary symbol file whose symbols are being added to the
1024existing symbol table.
1025
97f3cb72 1026The argument to @code{@var{xxx}_symfile_init} is a newly allocated
eb752e4e
JG
1027@code{struct sym_fns} whose @code{bfd} field contains the BFD
1028for the new symbol file being read. Its @code{private} field
1029has been zeroed, and can be modified as desired. Typically,
1030a struct of private information will be @code{malloc}'d, and
1031a pointer to it will be placed in the @code{private} field.
1032
97f3cb72 1033There is no result from @code{@var{xxx}_symfile_init}, but it can call
eb752e4e
JG
1034@code{error} if it detects an unavoidable problem.
1035
97f3cb72 1036@item @var{xxx}_new_init()
eb752e4e
JG
1037
1038Called from @code{symbol_file_add} when discarding existing symbols.
1039This function need only handle
1040the symbol-reading module's internal state; the symbol table data
1041structures visible to the rest of GDB will be discarded by
1042@code{symbol_file_add}. It has no arguments and no result.
97f3cb72 1043It may be called after @code{@var{xxx}_symfile_init}, if a new symbol
eb752e4e
JG
1044table is being read, or may be called alone if all symbols are
1045simply being discarded.
1046
97f3cb72 1047@item @var{xxx}_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline)
eb752e4e
JG
1048
1049Called from @code{symbol_file_add} to actually read the symbols from a
1050symbol-file into a set of psymtabs or symtabs.
1051
d98259f8 1052@code{sf} points to the struct sym_fns originally passed to
97f3cb72 1053@code{@var{xxx}_sym_init} for possible initialization. @code{addr} is the
d98259f8
RP
1054offset between the file's specified start address and its true address
1055in memory. @code{mainline} is 1 if this is the main symbol table being
1056read, and 0 if a secondary symbol file (e.g. shared library or
1057dynamically loaded file) is being read.@refill
eb752e4e
JG
1058@end table
1059
1060In addition, if a symbol-reading module creates psymtabs when
97f3cb72
RP
1061@var{xxx}_symfile_read is called, these psymtabs will contain a pointer to
1062a function @code{@var{xxx}_psymtab_to_symtab}, which can be called from
eb752e4e
JG
1063any point in the GDB symbol-handling code.
1064
1065@table @code
97f3cb72 1066@item @var{xxx}_psymtab_to_symtab (struct partial_symtab *pst)
eb752e4e
JG
1067
1068Called from @code{psymtab_to_symtab} (or the PSYMTAB_TO_SYMTAB
1069macro) if the psymtab has not already been read in and had its
1070@code{pst->symtab} pointer set. The argument is the psymtab
1071to be fleshed-out into a symtab. Upon return, pst->readin
1072should have been set to 1, and pst->symtab should contain a
1073pointer to the new corresponding symtab, or zero if there
1074were no symbols in that part of the symbol file.
1075@end table
1076
7f09f15f 1077
b517f124 1078@node Cleanups
97f3cb72 1079@chapter Cleanups
7f09f15f 1080
97f3cb72
RP
1081Cleanups are a structured way to deal with things that need to be done
1082later. When your code does something (like @code{malloc} some memory, or open
1083a file) that needs to be undone later (e.g. free the memory or close
1084the file), it can make a cleanup. The cleanup will be done at some
1085future point: when the command is finished, when an error occurs, or
1086when your code decides it's time to do cleanups.
7f09f15f 1087
97f3cb72
RP
1088You can also discard cleanups, that is, throw them away without doing
1089what they say. This is only done if you ask that it be done.
7f09f15f 1090
97f3cb72 1091Syntax:
7f09f15f 1092
97f3cb72 1093@table @code
f8f37439
DZ
1094@item struct cleanup *@var{old_chain};
1095Declare a variable which will hold a cleanup chain handle.
1096
97f3cb72
RP
1097@item @var{old_chain} = make_cleanup (@var{function}, @var{arg});
1098Make a cleanup which will cause @var{function} to be called with @var{arg}
1099(a @code{char *}) later. The result, @var{old_chain}, is a handle that can be
1100passed to @code{do_cleanups} or @code{discard_cleanups} later. Unless you are
1101going to call @code{do_cleanups} or @code{discard_cleanups} yourself,
1102you can ignore the result from @code{make_cleanup}.
7f09f15f 1103
7f09f15f 1104
97f3cb72
RP
1105@item do_cleanups (@var{old_chain});
1106Perform all cleanups done since @code{make_cleanup} returned @var{old_chain}.
1107E.g.:
1108@example
1109make_cleanup (a, 0);
1110old = make_cleanup (b, 0);
1111do_cleanups (old);
1112@end example
1113@noindent
1114will call @code{b()} but will not call @code{a()}. The cleanup that calls @code{a()} will remain
1115in the cleanup chain, and will be done later unless otherwise discarded.@refill
7f09f15f 1116
97f3cb72
RP
1117@item discard_cleanups (@var{old_chain});
1118Same as @code{do_cleanups} except that it just removes the cleanups from the
1119chain and does not call the specified functions.
7f09f15f 1120
97f3cb72 1121@end table
7f09f15f 1122
97f3cb72
RP
1123Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they
1124``should not be called when cleanups are not in place''. This means
1125that any actions you need to reverse in the case of an error or
1126interruption must be on the cleanup chain before you call these functions,
1127since they might never return to your code (they @samp{longjmp} instead).
7f09f15f 1128
7f09f15f 1129
b517f124 1130@node Wrapping
97f3cb72 1131@chapter Wrapping Output Lines
7f09f15f 1132
97f3cb72
RP
1133Output that goes through @code{printf_filtered} or @code{fputs_filtered} or
1134@code{fputs_demangled} needs only to have calls to @code{wrap_here} added
1135in places that would be good breaking points. The utility routines
1136will take care of actually wrapping if the line width is exceeded.
7f09f15f 1137
97f3cb72
RP
1138The argument to @code{wrap_here} is an indentation string which is printed
1139@emph{only} if the line breaks there. This argument is saved away and used
1140later. It must remain valid until the next call to @code{wrap_here} or
1141until a newline has been printed through the @code{*_filtered} functions.
1142Don't pass in a local variable and then return!
7f09f15f 1143
97f3cb72
RP
1144It is usually best to call @code{wrap_here()} after printing a comma or space.
1145If you call it before printing a space, make sure that your indentation
1146properly accounts for the leading space that will print if the line wraps
1147there.
7f09f15f 1148
97f3cb72
RP
1149Any function or set of functions that produce filtered output must finish
1150by printing a newline, to flush the wrap buffer, before switching to
1151unfiltered (``@code{printf}'') output. Symbol reading routines that print
1152warnings are a good example.
7f09f15f 1153
7f09f15f 1154
b517f124 1155@node Frames
edbf28ce
JG
1156@chapter Frames
1157
1158A frame is a construct that GDB uses to keep track of calling and called
1159functions.
1160
8cc1c08f
JG
1161@table @code
1162@item FRAME_FP
1163in the machine description has no meaning to the machine-independent
edbf28ce
JG
1164part of GDB, except that it is used when setting up a new frame from
1165scratch, as follows:
1166
1167@example
1168 create_new_frame (read_register (FP_REGNUM), read_pc ()));
1169@end example
1170
8cc1c08f
JG
1171Other than that, all the meaning imparted to @code{FP_REGNUM} is imparted by
1172the machine-dependent code. So, @code{FP_REGNUM} can have any value that
1173is convenient for the code that creates new frames. (@code{create_new_frame}
1174calls @code{INIT_EXTRA_FRAME_INFO} if it is defined; that is where you should
1175use the @code{FP_REGNUM} value, if your frames are nonstandard.)
1176
1177@item FRAME_CHAIN
1178Given a GDB frame, determine the address of the calling function's
1179frame. This will be used to create a new GDB frame struct, and then
1180@code{INIT_EXTRA_FRAME_INFO} and @code{INIT_FRAME_PC} will be called for
1181the new frame.
1182@end table
edbf28ce 1183
00db1549
JG
1184@node Remote Stubs
1185@chapter Remote Stubs
1186
1187GDB's file @file{remote.c} talks a serial protocol to code that runs
1188in the target system. GDB provides several sample ``stubs'' that can
1189be integrated into target programs or operating systems for this purpose;
1190they are named @file{*-stub.c}.
1191
1192The GDB user's manual describes how to put such a stub into your target
1193code. What follows is a discussion of integrating the SPARC stub
1194into a complicated operating system (rather than a simple program),
1195by Stu Grossman, the author of this stub.
1196
1197The trap handling code in the stub assumes the following upon entry to
1198trap_low:
1199
1200@enumerate
1201@item %l1 and %l2 contain pc and npc respectively at the time of the trap
1202@item traps are disabled
1203@item you are in the correct trap window
1204@end enumerate
1205
1206As long as your trap handler can guarantee those conditions, then there is no
1207reason why you shouldn't be able to `share' traps with the stub. The stub has
1208no requirement that it be jumped to directly from the hardware trap vector.
1209That is why it calls @code{exceptionHandler()}, which is provided by the external
1210environment. For instance, this could setup the hardware traps to actually
1211execute code which calls the stub first, and then transfers to its own trap
1212handler.
1213
1214For the most point, there probably won't be much of an issue with `sharing'
1215traps, as the traps we use are usually not used by the kernel, and often
1216indicate unrecoverable error conditions. Anyway, this is all controlled by a
1217table, and is trivial to modify.
1218The most important trap for us is for @code{ta 1}. Without that, we
1219can't single step or do breakpoints. Everything else is unnecessary
1220for the proper operation of the debugger/stub.
1221
1222From reading the stub, it's probably not obvious how breakpoints work. They
1223are simply done by deposit/examine operations from GDB.
1224
d3d6d0ff
JG
1225@node Longjmp Support
1226@chapter Longjmp Support
1227
1228GDB has support for figuring out that the target is doing a
1229@code{longjmp} and for stopping at the target of the jump, if we are
1230stepping. This is done with a few specialized internal breakpoints,
1231which are visible in the @code{maint info breakpoint} command.
1232
1233To make this work, you need to define a macro called
1234@code{GET_LONGJMP_TARGET}, which will examine the @code{jmp_buf}
1235structure and extract the longjmp target address. Since @code{jmp_buf}
1236is target specific, you will need to define it in the appropriate
1237@file{tm-xxx.h} file. Look in @file{tm-sun4os4.h} and
1238@file{sparc-tdep.c} for examples of how to do this.
1239
b517f124 1240@node Coding Style
968720bf
RP
1241@chapter Coding Style
1242
1243GDB is generally written using the GNU coding standards, as described in
a5e7f259
JK
1244@file{standards.texi}, which is available for anonymous FTP from GNU
1245archive sites. There are some additional considerations for GDB
1246maintainers that reflect the unique environment and style of GDB
1247maintenance. If you follow these guidelines, GDB will be more
1248consistent and easier to maintain.
968720bf
RP
1249
1250GDB's policy on the use of prototypes is that prototypes are used
1251to @emph{declare} functions but never to @emph{define} them. Simple
1252macros are used in the declarations, so that a non-ANSI compiler can
1253compile GDB without trouble. The simple macro calls are used like
1254this:
1255
1256@example @code
1257extern int
1258memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
1259@end example
1260
1261Note the double parentheses around the parameter types. This allows
1262an arbitrary number of parameters to be described, without freaking
1263out the C preprocessor. When the function has no parameters, it
1264should be described like:
1265
1266@example @code
1267void
1268noprocess PARAMS ((void));
1269@end example
1270
1271The @code{PARAMS} macro expands to its argument in ANSI C, or to a simple
1272@code{()} in traditional C.
1273
1274All external functions should have a @code{PARAMS} declaration in a
1275header file that callers include. All static functions should have such
1276a declaration near the top of their source file.
1277
1278We don't have a gcc option that will properly check that these rules
1279have been followed, but it's GDB policy, and we periodically check it
1280using the tools available (plus manual labor), and clean up any remnants.
1281
2a20c602
JG
1282@node Clean Design
1283@chapter Clean Design
1284
1285In addition to getting the syntax right, there's the little question of
1286semantics. Some things are done in certain ways in GDB because long
1287experience has shown that the more obvious ways caused various kinds of
1288trouble. In particular:
1289
1290@table @bullet
1291@item
1292You can't assume the byte order of anything that comes from a
1293target (including @var{value}s, object files, and instructions). Such
00db1549 1294things must be byte-swapped using @code{SWAP_TARGET_AND_HOST} in GDB,
2a20c602
JG
1295or one of the swap routines defined in @file{bfd.h}, such as @code{bfd_get_32}.
1296
1297@item
1298You can't assume that you know what interface is being used to talk to
1299the target system. All references to the target must go through the
1300current @code{target_ops} vector.
1301
1302@item
1303You can't assume that the host and target machines are the same machine
1304(except in the ``native'' support modules).
1305In particular, you can't assume that the target machine's header files
1306will be available on the host machine. Target code must bring along its
1307own header files -- written from scratch or explicitly donated by their
1308owner, to avoid copyright problems.
1309
1310@item
00db1549
JG
1311Insertion of new @code{#ifdef}'s will be frowned upon. It's much better
1312to write the code portably than to conditionalize it for various systems.
2a20c602
JG
1313
1314@item
1315New @code{#ifdef}'s which test for specific compilers or manufacturers
1316or operating systems are unacceptable. All @code{#ifdef}'s should test
1317for features. The information about which configurations contain which
1318features should be segregated into the configuration files. Experience
1319has proven far too often that a feature unique to one particular system
1320often creeps into other systems; and that a conditional based on
1321some predefined macro for your current system will become worthless
1322over time, as new versions of your system come out that behave differently
1323with regard to this feature.
1324
1325@item
1326Adding code that handles specific architectures, operating systems, target
1327interfaces, or hosts, is not acceptable in generic code. If a hook
1328is needed at that point, invent a generic hook and define it for your
1329configuration, with something like:
1330
1331@example
1332#ifdef WRANGLE_SIGNALS
1333 WRANGLE_SIGNALS (signo);
1334#endif
1335@end example
1336
1337In your host, target, or native configuration file, as appropriate,
1338define @code{WRANGLE_SIGNALS} to do the machine-dependent thing. Take
1339a bit of care in defining the hook, so that it can be used by other
1340ports in the future, if they need a hook in the same place.
1341
a5e7f259
JK
1342If the hook is not defined, the code should do whatever "most" machines
1343want. Using @code{#ifdef}, as above, is the preferred way to do this,
1344but sometimes that gets convoluted, in which case use
1345
1346@example
1347#ifndef SPECIAL_FOO_HANDLING
1348#define SPECIAL_FOO_HANDLING(pc, sp) (0)
1349#endif
1350@end example
1351
1352where the macro is used or in an appropriate header file.
1353
1354Whether to include a @dfn{small} hook, a hook around the exact pieces of
1355code which are system-dependent, or whether to replace a whole function
1356with a hook depends on the case. A good example of this dilemma can be
1357found in @code{get_saved_register}. All machines that GDB 2.8 ran on
1358just needed the @code{FRAME_FIND_SAVED_REGS} hook to find the saved
1359registers. Then the SPARC and Pyramid came along, and
1360@code{HAVE_REGISTER_WINDOWS} and @code{REGISTER_IN_WINDOW_P} were
1361introduced. Then the 29k and 88k required the @code{GET_SAVED_REGISTER}
1362hook. The first three are examples of small hooks; the latter replaces
1363a whole function. In this specific case, it is useful to have both
1364kinds; it would be a bad idea to replace all the uses of the small hooks
1365with @code{GET_SAVED_REGISTER}, since that would result in much
1366duplicated code. Other times, duplicating a few lines of code here or
1367there is much cleaner than introducing a large number of small hooks.
1368
1369Another way to generalize GDB along a particular interface is with an
1370attribute struct. For example, GDB has been generalized to handle
1371multiple kinds of remote interfaces -- not by #ifdef's everywhere, but
1372by defining the "target_ops" structure and having a current target (as
1373well as a stack of targets below it, for memory references). Whenever
1374something needs to be done that depends on which remote interface we are
1375using, a flag in the current target_ops structure is tested (e.g.
1376`target_has_stack'), or a function is called through a pointer in the
1377current target_ops structure. In this way, when a new remote interface
1378is added, only one module needs to be touched -- the one that actually
1379implements the new remote interface. Other examples of
1380attribute-structs are BFD access to multiple kinds of object file
1381formats, or GDB's access to multiple source languages.
1382
1383Please avoid duplicating code. For example, in GDB 3.x all the code
1384interfacing between @code{ptrace} and the rest of GDB was duplicated in
1385@file{*-dep.c}, and so changing something was very painful. In GDB 4.x,
1386these have all been consolidated into @file{infptrace.c}.
1387@file{infptrace.c} can deal with variations between systems the same way
1388any system-independent file would (hooks, #if defined, etc.), and
1389machines which are radically different don't need to use infptrace.c at
1390all.
1391
2a20c602
JG
1392@item
1393@emph{Do} write code that doesn't depend on the sizes of C data types,
1394the format of the host's floating point numbers, the alignment of anything,
1395or the order of evaluation of expressions. In short, follow good
1396programming practices for writing portable C code.
1397
1398@end table
1399
1400@node Submitting Patches
1401@chapter Submitting Patches
1402
1403Thanks for thinking of offering your changes back to the community of
1404GDB users. In general we like to get well designed enhancements.
1405Thanks also for checking in advance about the best way to transfer the
1406changes.
1407
1408The two main problems with getting your patches in are,
1409
1410@table @bullet
1411@item
a5e7f259 1412The GDB maintainers will only install ``cleanly designed'' patches.
2a20c602
JG
1413You may not always agree on what is clean design.
1414@pxref{Coding Style}, @pxref{Clean Design}.
1415
1416@item
1417If the maintainers don't have time to put the patch in when it
1418arrives, or if there is any question about a patch, it
1419goes into a large queue with everyone else's patches and
00db1549 1420bug reports.
2a20c602
JG
1421@end table
1422
1423I don't know how to get past these problems except by continuing to try.
1424
1425There are two issues here -- technical and legal.
1426
1427The legal issue is that to incorporate substantial changes requires a
a5e7f259
JK
1428copyright assignment from you and/or your employer, granting ownership
1429of the changes to the Free Software Foundation. You can get the
1430standard document for doing this by sending mail to
1431@code{gnu@@prep.ai.mit.edu} and asking for it. I recommend that people
1432write in "All programs owned by the Free Software Foundation" as "NAME
1433OF PROGRAM", so that changes in many programs (not just GDB, but GAS,
1434Emacs, GCC, etc) can be contributed with only one piece of legalese
1435pushed through the bureacracy and filed with the FSF. I can't start
1436merging changes until this paperwork is received by the FSF (their
1437rules, which I follow since I maintain it for them).
2a20c602
JG
1438
1439Technically, the easiest way to receive changes is to receive each
1440feature as a small context diff or unidiff, suitable for "patch".
1441Each message sent to me should include the changes to C code and
1442header files for a single feature, plus ChangeLog entries for each
1443directory where files were modified, and diffs for any changes needed
1444to the manuals (gdb/doc/gdb.texi or gdb/doc/gdbint.texi). If there
1445are a lot of changes for a single feature, they can be split down
1446into multiple messages.
1447
1448In this way, if I read and like the feature, I can add it to the
1449sources with a single patch command, do some testing, and check it in.
1450If you leave out the ChangeLog, I have to write one. If you leave
1451out the doc, I have to puzzle out what needs documenting. Etc.
1452
1453The reason to send each change in a separate message is that I will
1454not install some of the changes. They'll be returned to you with
1455questions or comments. If I'm doing my job, my message back to you
1456will say what you have to fix in order to make the change acceptable.
1457The reason to have separate messages for separate features is so
1458that other changes (which I @emph{am} willing to accept) can be installed
1459while one or more changes are being reworked. If multiple features
1460are sent in a single message, I tend to not put in the effort to sort
1461out the acceptable changes from the unacceptable, so none of the
1462features get installed until all are acceptable.
1463
1464If this sounds painful or authoritarian, well, it is. But I get a lot
1465of bug reports and a lot of patches, and most of them don't get
1466installed because I don't have the time to finish the job that the bug
1467reporter or the contributor could have done. Patches that arrive
1468complete, working, and well designed, tend to get installed on the day
1469they arrive. The others go into a queue and get installed if and when
1470I scan back over the queue -- which can literally take months
1471sometimes. It's in both our interests to make patch installation easy
1472-- you get your changes installed, and I make some forward progress on
1473GDB in a normal 12-hour day (instead of them having to wait until I
1474have a 14-hour or 16-hour day to spend cleaning up patches before I
1475can install them).
1476
a5e7f259
JK
1477Please send patches to @code{bug-gdb@@prep.ai.mit.edu}, if they are less
1478than about 25,000 characters. If longer than that, either make them
1479available somehow (e.g. anonymous FTP), and announce it on
1480@code{bug-gdb}, or send them directly to the GDB maintainers at
1481@code{gdb-patches@@cygnus.com}.
1482
b517f124 1483@node Host Conditionals
493cf018
JG
1484@chapter Host Conditionals
1485
1486When GDB is configured and compiled, various macros are defined or left
1487undefined, to control compilation based on the attributes of the host
1488system. These macros and their meanings are:
1489
1490@emph{NOTE: For now, both host and target conditionals are here.
1491Eliminate target conditionals from this list as they are identified.}
1492
1493@table @code
1494@item ALIGN_SIZE
1495alloca.c
1496@item BLOCK_ADDRESS_FUNCTION_RELATIVE
1497dbxread.c
1498@item GDBINIT_FILENAME
1499main.c
1500@item KERNELDEBUG
1501tm-hppa.h
1502@item MEM_FNS_DECLARED
00db1549
JG
1503Your host config file defines this if it includes
1504declarations of @code{memcpy} and @code{memset}. Define this
1505to avoid conflicts between the native include
1506files and the declarations in @file{defs.h}.
493cf018
JG
1507@item NO_SYS_FILE
1508dbxread.c
493cf018
JG
1509@item PYRAMID_CONTROL_FRAME_DEBUGGING
1510pyr-xdep.c
1511@item SIGWINCH_HANDLER_BODY
1512utils.c
1513@item 1
1514buildsym.c
1515@item 1
1516dbxread.c
1517@item 1
1518dbxread.c
1519@item 1
1520buildsym.c
1521@item 1
1522dwarfread.c
1523@item 1
1524valops.c
1525@item 1
1526valops.c
1527@item 1
1528pyr-xdep.c
1529@item ADDITIONAL_OPTIONS
1530main.c
1531@item ADDITIONAL_OPTION_CASES
1532main.c
1533@item ADDITIONAL_OPTION_HANDLER
1534main.c
1535@item ADDITIONAL_OPTION_HELP
1536main.c
1537@item ADDR_BITS_REMOVE
1538defs.h
1539@item AIX_BUGGY_PTRACE_CONTINUE
1540infptrace.c
1541@item ALIGN_STACK_ON_STARTUP
1542main.c
1543@item ALTOS
1544altos-xdep.c
1545@item ALTOS_AS
1546xm-altos.h
1547@item ASCII_COFF
1548remote-adapt.c
493cf018
JG
1549@item BADMAG
1550coffread.c
1551@item BCS
1552tm-delta88.h
1553@item BEFORE_MAIN_LOOP_HOOK
1554main.c
1555@item BELIEVE_PCC_PROMOTION
1556coffread.c
1557@item BELIEVE_PCC_PROMOTION_TYPE
1558stabsread.c
1559@item BIG_ENDIAN
1560defs.h
1561@item BITS_BIG_ENDIAN
1562defs.h
1563@item BKPT_AT_MAIN
1564solib.c
1565@item BLOCK_ADDRESS_ABSOLUTE
1566dbxread.c
1567@item BPT_VECTOR
3a8bc841 1568tm-m68k.h
493cf018 1569@item BREAKPOINT
3a8bc841 1570tm-m68k.h
493cf018
JG
1571@item BREAKPOINT_DEBUG
1572breakpoint.c
1573@item BROKEN_LARGE_ALLOCA
968720bf
RP
1574Avoid large @code{alloca}'s. For example, on sun's, Large alloca's fail
1575because the attempt to increase the stack limit in main() fails because
1576shared libraries are allocated just below the initial stack limit. The
1577SunOS kernel will not allow the stack to grow into the area occupied by
1578the shared libraries.
493cf018
JG
1579@item BSTRING
1580regex.c
1581@item CALL_DUMMY
1582valops.c
1583@item CALL_DUMMY_LOCATION
1584inferior.h
1585@item CALL_DUMMY_STACK_ADJUST
1586valops.c
1587@item CANNOT_FETCH_REGISTER
1588hppabsd-xdep.c
1589@item CANNOT_STORE_REGISTER
1590findvar.c
1591@item CFRONT_PRODUCER
1592dwarfread.c
1593@item CHILD_PREPARE_TO_STORE
1594inftarg.c
1595@item CLEAR_DEFERRED_STORES
1596inflow.c
1597@item CLEAR_SOLIB
1598objfiles.c
1599@item COFF_ENCAPSULATE
1600hppabsd-tdep.c
1601@item COFF_FORMAT
1602symm-tdep.c
493cf018
JG
1603@item CORE_NEEDS_RELOCATION
1604stack.c
1605@item CPLUS_MARKER
1606cplus-dem.c
1607@item CREATE_INFERIOR_HOOK
1608infrun.c
1609@item C_ALLOCA
1610regex.c
1611@item C_GLBLREG
1612coffread.c
493cf018
JG
1613@item DBXREAD_ONLY
1614partial-stab.h
1615@item DBX_PARM_SYMBOL_CLASS
1616stabsread.c
1617@item DEBUG
1618remote-adapt.c
1619@item DEBUG_INFO
1620partial-stab.h
1621@item DEBUG_PTRACE
1622hppabsd-xdep.c
1623@item DECR_PC_AFTER_BREAK
1624breakpoint.c
1625@item DEFAULT_PROMPT
1626main.c
1627@item DELTA88
1628m88k-xdep.c
1629@item DEV_TTY
1630symmisc.c
1631@item DGUX
1632m88k-xdep.c
1633@item DISABLE_UNSETTABLE_BREAK
1634breakpoint.c
1635@item DONT_USE_REMOTE
1636remote.c
1637@item DO_DEFERRED_STORES
1638infrun.c
1639@item DO_REGISTERS_INFO
1640infcmd.c
1641@item END_OF_TEXT_DEFAULT
1642dbxread.c
1643@item EXTERN
1644buildsym.h
1645@item EXTRACT_RETURN_VALUE
3a8bc841 1646tm-m68k.h
493cf018
JG
1647@item EXTRACT_STRUCT_VALUE_ADDRESS
1648values.c
1649@item EXTRA_FRAME_INFO
1650frame.h
1651@item EXTRA_SYMTAB_INFO
1652symtab.h
493cf018
JG
1653@item FILES_INFO_HOOK
1654target.c
1655@item FIXME
1656coffread.c
1657@item FLOAT_INFO
1658infcmd.c
1659@item FOPEN_RB
1660defs.h
1661@item FP0_REGNUM
1662a68v-xdep.c
1663@item FPC_REGNUM
1664mach386-xdep.c
1665@item FP_REGNUM
1666parse.c
1667@item FRAMELESS_FUNCTION_INVOCATION
1668blockframe.c
1669@item FRAME_ARGS_ADDRESS_CORRECT
1670stack.c
1671@item FRAME_CHAIN_COMBINE
1672blockframe.c
1673@item FRAME_CHAIN_VALID
1674frame.h
1675@item FRAME_CHAIN_VALID_ALTERNATE
1676frame.h
1677@item FRAME_FIND_SAVED_REGS
1678stack.c
1679@item FRAME_GET_BASEREG_VALUE
1680frame.h
1681@item FRAME_NUM_ARGS
3a8bc841 1682tm-m68k.h
493cf018
JG
1683@item FRAME_SPECIFICATION_DYADIC
1684stack.c
1685@item FUNCTION_EPILOGUE_SIZE
1686coffread.c
1687@item F_OK
1688xm-ultra3.h
1689@item GCC2_COMPILED_FLAG_SYMBOL
1690dbxread.c
1691@item GCC_COMPILED_FLAG_SYMBOL
1692dbxread.c
1693@item GCC_MANGLE_BUG
1694symtab.c
1695@item GCC_PRODUCER
1696dwarfread.c
493cf018
JG
1697@item GET_SAVED_REGISTER
1698findvar.c
1699@item GPLUS_PRODUCER
1700dwarfread.c
1701@item GR64_REGNUM
1702remote-adapt.c
1703@item GR64_REGNUM
1704remote-mm.c
1705@item HANDLE_RBRAC
1706partial-stab.h
1707@item HAVE_68881
1708m68k-tdep.c
1709@item HAVE_MMAP
968720bf
RP
1710In some cases, use the system call @code{mmap} for reading symbol
1711tables. For some machines this allows for sharing and quick updates.
493cf018
JG
1712@item HAVE_REGISTER_WINDOWS
1713findvar.c
1714@item HAVE_SIGSETMASK
1715main.c
1716@item HAVE_TERMIO
1717inflow.c
1718@item HEADER_SEEK_FD
1719arm-tdep.c
1720@item HOSTING_ONLY
1721xm-rtbsd.h
1722@item HOST_BYTE_ORDER
1723ieee-float.c
1724@item HPUX_ASM
1725xm-hp300hpux.h
1726@item HPUX_VERSION_5
1727hp300ux-xdep.c
1728@item HP_OS_BUG
1729infrun.c
1730@item I80960
1731remote-vx.c
493cf018
JG
1732@item IEEE_DEBUG
1733ieee-float.c
1734@item IEEE_FLOAT
1735valprint.c
1736@item IGNORE_SYMBOL
1737dbxread.c
1738@item INIT_EXTRA_FRAME_INFO
1739blockframe.c
1740@item INIT_EXTRA_SYMTAB_INFO
1741symfile.c
1742@item INIT_FRAME_PC
1743blockframe.c
1744@item INNER_THAN
1745valops.c
1746@item INT_MAX
1747defs.h
1748@item INT_MIN
1749defs.h
1750@item IN_GDB
1751i960-pinsn.c
1752@item IN_SIGTRAMP
1753infrun.c
1754@item IN_SOLIB_TRAMPOLINE
1755infrun.c
1756@item ISATTY
1757main.c
1758@item IS_TRAPPED_INTERNALVAR
1759values.c
1760@item KERNELDEBUG
1761dbxread.c
1762@item KERNEL_DEBUGGING
1763tm-ultra3.h
1764@item KERNEL_U_ADDR
1765Define this to the address of the @code{u} structure (the ``user struct'',
1766also known as the ``u-page'') in kernel virtual memory. GDB needs to know
1767this so that it can subtract this address from absolute addresses in
1768the upage, that are obtained via ptrace or from core files. On systems
1769that don't need this value, set it to zero.
1770@item KERNEL_U_ADDR_BSD
1771Define this to cause GDB to determine the address of @code{u} at runtime,
1772by using Berkeley-style @code{nlist} on the kernel's image in the root
1773directory.
1774@item KERNEL_U_ADDR_HPUX
1775Define this to cause GDB to determine the address of @code{u} at runtime,
1776by using HP-style @code{nlist} on the kernel's image in the root
1777directory.
1778@item LCC_PRODUCER
1779dwarfread.c
1780@item LITTLE_ENDIAN
1781defs.h
1782@item LOG_FILE
1783remote-adapt.c
1784@item LONGERNAMES
1785cplus-dem.c
1786@item LONGEST
1787defs.h
238ffce0
JG
1788@item CC_HAS_LONG_LONG
1789defs.h
1790@item PRINTF_HAS_LONG_LONG
493cf018
JG
1791defs.h
1792@item LONG_MAX
1793defs.h
1794@item LSEEK_NOT_LINEAR
1795source.c
1796@item L_LNNO32
1797coffread.c
1798@item L_SET
c3bbca3a
JG
1799This macro is used as the argument to lseek (or, most commonly, bfd_seek).
1800FIXME, it should be replaced by SEEK_SET instead, which is the POSIX equivalent.
493cf018
JG
1801@item MACHKERNELDEBUG
1802hppabsd-tdep.c
1803@item MAIN
1804cplus-dem.c
1805@item MAINTENANCE
1806dwarfread.c
1807@item MAINTENANCE_CMDS
1808breakpoint.c
1809@item MAINTENANCE_CMDS
1810maint.c
1811@item MALLOC_INCOMPATIBLE
968720bf
RP
1812Define this if the system's prototype for @code{malloc} differs from the
1813@sc{ANSI} definition.
493cf018
JG
1814@item MIPSEL
1815mips-tdep.c
1816@item MMAP_BASE_ADDRESS
968720bf
RP
1817When using HAVE_MMAP, the first mapping should go at this address.
1818@item MMAP_INCREMENT
1819when using HAVE_MMAP, this is the increment between mappings.
493cf018
JG
1820@item MONO
1821ser-go32.c
1822@item MOTOROLA
1823xm-altos.h
493cf018
JG
1824@item NBPG
1825altos-xdep.c
1826@item NEED_POSIX_SETPGID
1827infrun.c
1828@item NEED_TEXT_START_END
1829exec.c
1830@item NFAILURES
1831regex.c
1832@item NNPC_REGNUM
1833infrun.c
1834@item NORETURN
1835defs.h
1836@item NOTDEF
1837regex.c
1838@item NOTDEF
1839remote-adapt.c
1840@item NOTDEF
1841remote-mm.c
1842@item NOTICE_SIGNAL_HANDLING_CHANGE
1843infrun.c
493cf018
JG
1844@item NO_HIF_SUPPORT
1845remote-mm.c
1846@item NO_JOB_CONTROL
1847signals.h
493cf018 1848@item NO_MMALLOC
d7d35f00
FF
1849GDB will use the @code{mmalloc} library for memory allocation for symbol
1850reading, unless this symbol is defined. Define it on systems
1851on which @code{mmalloc} does not
1852work for some reason. One example is the DECstation, where its RPC
1853library can't cope with our redefinition of @code{malloc} to call
1854@code{mmalloc}. When defining @code{NO_MMALLOC}, you will also have
1855to override the setting of @code{MMALLOC_LIB} to empty, in the Makefile.
1856Therefore, this define is usually set on the command line by overriding
3a8bc841 1857@code{MMALLOC_DISABLE} in @file{config/*/*.mh}, rather than by defining
d7d35f00
FF
1858it in @file{xm-*.h}.
1859@item NO_MMALLOC_CHECK
1860Define this if you are using @code{mmalloc}, but don't want the overhead
1861of checking the heap with @code{mmcheck}.
493cf018
JG
1862@item NO_SIGINTERRUPT
1863remote-adapt.c
1864@item NO_SINGLE_STEP
1865infptrace.c
493cf018
JG
1866@item NPC_REGNUM
1867infcmd.c
1868@item NS32K_SVC_IMMED_OPERANDS
1869ns32k-opcode.h
1870@item NUMERIC_REG_NAMES
1871mips-tdep.c
1872@item N_SETV
1873dbxread.c
1874@item N_SET_MAGIC
1875hppabsd-tdep.c
1876@item NaN
1877tm-umax.h
1878@item ONE_PROCESS_WRITETEXT
1879breakpoint.c
1880@item O_BINARY
1881exec.c
1882@item O_RDONLY
1883xm-ultra3.h
1884@item PC
1885convx-opcode.h
1886@item PCC_SOL_BROKEN
1887dbxread.c
1888@item PC_IN_CALL_DUMMY
1889inferior.h
1890@item PC_LOAD_SEGMENT
1891stack.c
1892@item PC_REGNUM
1893parse.c
1894@item PRINT_RANDOM_SIGNAL
1895infcmd.c
1896@item PRINT_REGISTER_HOOK
1897infcmd.c
1898@item PRINT_TYPELESS_INTEGER
1899valprint.c
1900@item PROCESS_LINENUMBER_HOOK
1901buildsym.c
1902@item PROLOGUE_FIRSTLINE_OVERLAP
1903infrun.c
1904@item PSIGNAL_IN_SIGNAL_H
1905defs.h
1906@item PS_REGNUM
1907parse.c
493cf018
JG
1908@item PUSH_ARGUMENTS
1909valops.c
1910@item PYRAMID_CONTROL_FRAME_DEBUGGING
1911pyr-xdep.c
1912@item PYRAMID_CORE
1913pyr-xdep.c
1914@item PYRAMID_PTRACE
1915pyr-xdep.c
1916@item REGISTER_BYTES
1917remote.c
1918@item REGISTER_NAMES
d7d35f00 1919tm-a29k.h
493cf018
JG
1920@item REG_STACK_SEGMENT
1921exec.c
1922@item REG_STRUCT_HAS_ADDR
1923findvar.c
1924@item RE_NREGS
1925regex.h
1926@item R_FP
1927dwarfread.c
1928@item R_OK
1929xm-altos.h
1930@item SDB_REG_TO_REGNUM
1931coffread.c
1932@item SEEK_END
1933state.c
1934@item SEEK_SET
1935state.c
1936@item SEM
1937coffread.c
1938@item SET_STACK_LIMIT_HUGE
968720bf
RP
1939When defined, stack limits will be raised to their maximum. Use this
1940if your host supports @code{setrlimit} and you have trouble with
1941@code{stringtab} in @file{dbxread.c}.
1942
1943Also used in @file{fork-child.c} to return stack limits before child
1944processes are forked.
493cf018
JG
1945@item SHELL_COMMAND_CONCAT
1946infrun.c
1947@item SHELL_FILE
1948infrun.c
1949@item SHIFT_INST_REGS
1950breakpoint.c
1951@item SIGN_EXTEND_CHAR
1952regex.c
1953@item SIGTRAP_STOP_AFTER_LOAD
1954infrun.c
1955@item SKIP_PROLOGUE
3a8bc841 1956tm-m68k.h
493cf018
JG
1957@item SKIP_PROLOGUE_FRAMELESS_P
1958blockframe.c
1959@item SKIP_TRAMPOLINE_CODE
1960infrun.c
1961@item SOLIB_ADD
1962core.c
1963@item SOLIB_CREATE_INFERIOR_HOOK
1964infrun.c
493cf018
JG
1965@item SP_REGNUM
1966parse.c
1967@item STAB_REG_TO_REGNUM
1968stabsread.h
1969@item STACK_ALIGN
1970valops.c
1971@item STACK_DIRECTION
1972alloca.c
1973@item START_INFERIOR_TRAPS_EXPECTED
1974infrun.c
1975@item STOP_SIGNAL
1976main.c
1977@item STORE_RETURN_VALUE
3a8bc841 1978tm-m68k.h
493cf018
JG
1979@item SUN4_COMPILER_FEATURE
1980infrun.c
1981@item SUN_FIXED_LBRAC_BUG
1982dbxread.c
1983@item SVR4_SHARED_LIBS
1984solib.c
1985@item SWITCH_ENUM_BUG
1986regex.c
1987@item SYM1
1988tm-ultra3.h
1989@item SYMBOL_RELOADING_DEFAULT
1990symfile.c
1991@item SYNTAX_TABLE
1992regex.c
1993@item Sword
1994regex.c
1995@item TDESC
1996infrun.c
1997@item TIOCGETC
1998inflow.c
1999@item TIOCGLTC
2000inflow.c
2001@item TIOCGPGRP
2002inflow.c
2003@item TIOCLGET
2004inflow.c
2005@item TIOCLSET
2006inflow.c
2007@item TIOCNOTTY
2008inflow.c
2009@item TM_FILE_OVERRIDE
2010defs.h
2011@item T_ARG
2012coffread.c
2013@item T_VOID
2014coffread.c
2015@item UINT_MAX
2016defs.h
2017@item UPAGES
2018altos-xdep.c
2019@item USER
2020m88k-tdep.c
2021@item USE_GAS
2022xm-news.h
2023@item USE_O_NOCTTY
2024inflow.c
493cf018
JG
2025@item USE_STRUCT_CONVENTION
2026values.c
2027@item USG
2028Means that System V (prior to SVR4) include files are in use.
2029(FIXME: This symbol is abused in @file{infrun.c}, @file{regex.c},
2030@file{remote-nindy.c}, and @file{utils.c} for other things, at the moment.)
2031@item USIZE
2032xm-m88k.h
2033@item U_FPSTATE
2034i386-xdep.c
493cf018
JG
2035@item VARIABLES_INSIDE_BLOCK
2036dbxread.c
2037@item WRS_ORIG
2038remote-vx.c
2039@item _LANG_c
2040language.c
2041@item _LANG_m2
2042language.c
2043@item __GNUC__
2044news-xdep.c
2045@item __GO32__
2046inflow.c
2047@item __HAVE_68881__
2048m68k-stub.c
2049@item __HPUX_ASM__
2050xm-hp300hpux.h
2051@item __INT_VARARGS_H
2052printcmd.c
2053@item __not_on_pyr_yet
2054pyr-xdep.c
2055@item alloca
2056defs.h
2057@item const
2058defs.h
2059@item GOULD_PN
2060gould-pinsn.c
2061@item emacs
2062alloca.c
2063@item hp800
2064xm-hppabsd.h
493cf018
JG
2065@item hpux
2066hppabsd-core.c
2067@item lint
2068valarith.c
2069@item longest_to_int
2070defs.h
2071@item mc68020
2072m68k-stub.c
2073@item notdef
2074gould-pinsn.c
2075@item ns32k_opcodeT
2076ns32k-opcode.h
2077@item sgi
2078mips-tdep.c
2079@item sparc
2080regex.c
2081@item static
2082alloca.c
2083@item sun
2084m68k-tdep.c
2085@item sun386
2086tm-sun386.h
2087@item test
2088regex.c
2089@item ultrix
2090xm-mips.h
2091@item volatile
2092defs.h
2093@item x_name
2094coffread.c
2095@item x_zeroes
2096coffread.c
2097@end table
2098
b517f124 2099@node Target Conditionals
493cf018
JG
2100@chapter Target Conditionals
2101
2102When GDB is configured and compiled, various macros are defined or left
2103undefined, to control compilation based on the attributes of the target
2104system. These macros and their meanings are:
2105
2106@emph{NOTE: For now, both host and target conditionals are here.
2107Eliminate host conditionals from this list as they are identified.}
2108
2109@table @code
ca048722
RP
2110@item PUSH_DUMMY_FRAME
2111Used in @samp{call_function_by_hand} to create an artificial stack frame.
2112@item POP_FRAME
2113Used in @samp{call_function_by_hand} to remove an artificial stack frame.
493cf018
JG
2114@item ALIGN_SIZE
2115alloca.c
2116@item BLOCK_ADDRESS_FUNCTION_RELATIVE
2117dbxread.c
2118@item GDBINIT_FILENAME
2119main.c
2120@item KERNELDEBUG
2121tm-hppa.h
493cf018
JG
2122@item NO_SYS_FILE
2123dbxread.c
493cf018
JG
2124@item PYRAMID_CONTROL_FRAME_DEBUGGING
2125pyr-xdep.c
2126@item SIGWINCH_HANDLER_BODY
2127utils.c
2128@item ADDITIONAL_OPTIONS
2129main.c
2130@item ADDITIONAL_OPTION_CASES
2131main.c
2132@item ADDITIONAL_OPTION_HANDLER
2133main.c
2134@item ADDITIONAL_OPTION_HELP
2135main.c
2136@item ADDR_BITS_REMOVE
2137defs.h
2138@item ALIGN_STACK_ON_STARTUP
2139main.c
2140@item ALTOS
2141altos-xdep.c
2142@item ALTOS_AS
2143xm-altos.h
2144@item ASCII_COFF
2145remote-adapt.c
493cf018
JG
2146@item BADMAG
2147coffread.c
2148@item BCS
2149tm-delta88.h
2150@item BEFORE_MAIN_LOOP_HOOK
2151main.c
2152@item BELIEVE_PCC_PROMOTION
2153coffread.c
2154@item BELIEVE_PCC_PROMOTION_TYPE
2155stabsread.c
2156@item BIG_ENDIAN
2157defs.h
2158@item BITS_BIG_ENDIAN
2159defs.h
2160@item BKPT_AT_MAIN
2161solib.c
2162@item BLOCK_ADDRESS_ABSOLUTE
2163dbxread.c
2164@item BPT_VECTOR
3a8bc841 2165tm-m68k.h
493cf018 2166@item BREAKPOINT
3a8bc841 2167tm-m68k.h
493cf018
JG
2168@item BREAKPOINT_DEBUG
2169breakpoint.c
493cf018
JG
2170@item BSTRING
2171regex.c
2172@item CALL_DUMMY
2173valops.c
2174@item CALL_DUMMY_LOCATION
2175inferior.h
2176@item CALL_DUMMY_STACK_ADJUST
2177valops.c
2178@item CANNOT_FETCH_REGISTER
2179hppabsd-xdep.c
2180@item CANNOT_STORE_REGISTER
2181findvar.c
2182@item CFRONT_PRODUCER
2183dwarfread.c
2184@item CHILD_PREPARE_TO_STORE
2185inftarg.c
2186@item CLEAR_DEFERRED_STORES
2187inflow.c
2188@item CLEAR_SOLIB
2189objfiles.c
2190@item COFF_ENCAPSULATE
2191hppabsd-tdep.c
2192@item COFF_FORMAT
2193symm-tdep.c
493cf018
JG
2194@item CORE_NEEDS_RELOCATION
2195stack.c
2196@item CPLUS_MARKER
2197cplus-dem.c
2198@item CREATE_INFERIOR_HOOK
2199infrun.c
2200@item C_ALLOCA
2201regex.c
2202@item C_GLBLREG
2203coffread.c
493cf018
JG
2204@item DBXREAD_ONLY
2205partial-stab.h
2206@item DBX_PARM_SYMBOL_CLASS
2207stabsread.c
2208@item DEBUG
2209remote-adapt.c
2210@item DEBUG_INFO
2211partial-stab.h
2212@item DEBUG_PTRACE
2213hppabsd-xdep.c
2214@item DECR_PC_AFTER_BREAK
2215breakpoint.c
2216@item DEFAULT_PROMPT
2217main.c
2218@item DELTA88
2219m88k-xdep.c
2220@item DEV_TTY
2221symmisc.c
2222@item DGUX
2223m88k-xdep.c
2224@item DISABLE_UNSETTABLE_BREAK
2225breakpoint.c
2226@item DONT_USE_REMOTE
2227remote.c
2228@item DO_DEFERRED_STORES
2229infrun.c
2230@item DO_REGISTERS_INFO
2231infcmd.c
2232@item END_OF_TEXT_DEFAULT
2233dbxread.c
2234@item EXTERN
2235buildsym.h
2236@item EXTRACT_RETURN_VALUE
3a8bc841 2237tm-m68k.h
493cf018
JG
2238@item EXTRACT_STRUCT_VALUE_ADDRESS
2239values.c
2240@item EXTRA_FRAME_INFO
2241frame.h
2242@item EXTRA_SYMTAB_INFO
2243symtab.h
2244@item FILES_INFO_HOOK
2245target.c
2246@item FIXME
2247coffread.c
2248@item FLOAT_INFO
2249infcmd.c
2250@item FOPEN_RB
2251defs.h
2252@item FP0_REGNUM
2253a68v-xdep.c
2254@item FPC_REGNUM
2255mach386-xdep.c
2256@item FP_REGNUM
2257parse.c
968720bf 2258@item FPU
1b87a1b2 2259Unused? 6-oct-92 rich@@cygnus.com. FIXME.
493cf018
JG
2260@item FRAMELESS_FUNCTION_INVOCATION
2261blockframe.c
2262@item FRAME_ARGS_ADDRESS_CORRECT
2263stack.c
a5e7f259
JK
2264@item FRAME_CHAIN
2265Given FRAME, return a pointer to the calling frame.
493cf018
JG
2266@item FRAME_CHAIN_COMBINE
2267blockframe.c
2268@item FRAME_CHAIN_VALID
2269frame.h
2270@item FRAME_CHAIN_VALID_ALTERNATE
2271frame.h
2272@item FRAME_FIND_SAVED_REGS
2273stack.c
2274@item FRAME_GET_BASEREG_VALUE
2275frame.h
2276@item FRAME_NUM_ARGS
3a8bc841 2277tm-m68k.h
493cf018
JG
2278@item FRAME_SPECIFICATION_DYADIC
2279stack.c
a5e7f259
JK
2280@item FRAME_SAVED_PC
2281Given FRAME, return the pc saved there. That is, the return address.
493cf018
JG
2282@item FUNCTION_EPILOGUE_SIZE
2283coffread.c
2284@item F_OK
2285xm-ultra3.h
2286@item GCC2_COMPILED_FLAG_SYMBOL
2287dbxread.c
2288@item GCC_COMPILED_FLAG_SYMBOL
2289dbxread.c
2290@item GCC_MANGLE_BUG
2291symtab.c
2292@item GCC_PRODUCER
2293dwarfread.c
968720bf
RP
2294@item GDB_TARGET_IS_HPPA
2295This determines whether horrible kludge code in dbxread.c and partial-stab.h
2296is used to mangle multiple-symbol-table files from HPPA's. This should all
2297be ripped out, and a scheme like elfread.c used.
493cf018
JG
2298@item GDB_TARGET_IS_MACH386
2299mach386-xdep.c
2300@item GDB_TARGET_IS_SUN3
2301a68v-xdep.c
2302@item GDB_TARGET_IS_SUN386
2303sun386-xdep.c
2304@item GET_LONGJMP_TARGET
c3bbca3a
JG
2305For most machines, this is a target-dependent parameter. On the DECstation
2306and the Iris, this is a native-dependent parameter, since <setjmp.h> is
2307needed to define it.
2308
2309This macro determines the target PC address that longjmp() will jump
2310to, assuming that we have just stopped at a longjmp breakpoint. It
2311takes a CORE_ADDR * as argument, and stores the target PC value through
2312this pointer. It examines the current state of the machine as needed.
493cf018
JG
2313@item GET_SAVED_REGISTER
2314findvar.c
2315@item GPLUS_PRODUCER
2316dwarfread.c
2317@item GR64_REGNUM
2318remote-adapt.c
2319@item GR64_REGNUM
2320remote-mm.c
2321@item HANDLE_RBRAC
2322partial-stab.h
2323@item HAVE_68881
2324m68k-tdep.c
493cf018
JG
2325@item HAVE_REGISTER_WINDOWS
2326findvar.c
2327@item HAVE_SIGSETMASK
2328main.c
2329@item HAVE_TERMIO
2330inflow.c
2331@item HEADER_SEEK_FD
2332arm-tdep.c
2333@item HOSTING_ONLY
2334xm-rtbsd.h
2335@item HOST_BYTE_ORDER
2336ieee-float.c
2337@item HPUX_ASM
2338xm-hp300hpux.h
2339@item HPUX_VERSION_5
2340hp300ux-xdep.c
2341@item HP_OS_BUG
2342infrun.c
2343@item I80960
2344remote-vx.c
493cf018 2345@item IBM6000_TARGET
d3d6d0ff
JG
2346Shows that we are configured for an IBM RS/6000 target. This conditional
2347should be eliminated (FIXME) and replaced by feature-specific macros.
2348It was introduced in haste and we are repenting at leisure.
493cf018
JG
2349@item IEEE_DEBUG
2350ieee-float.c
2351@item IEEE_FLOAT
2352valprint.c
2353@item IGNORE_SYMBOL
2354dbxread.c
2355@item INIT_EXTRA_FRAME_INFO
2356blockframe.c
2357@item INIT_EXTRA_SYMTAB_INFO
2358symfile.c
2359@item INIT_FRAME_PC
2360blockframe.c
2361@item INNER_THAN
2362valops.c
2363@item INT_MAX
2364defs.h
2365@item INT_MIN
2366defs.h
2367@item IN_GDB
2368i960-pinsn.c
2369@item IN_SIGTRAMP
2370infrun.c
2371@item IN_SOLIB_TRAMPOLINE
2372infrun.c
2373@item ISATTY
2374main.c
2375@item IS_TRAPPED_INTERNALVAR
2376values.c
2377@item KERNELDEBUG
2378dbxread.c
2379@item KERNEL_DEBUGGING
2380tm-ultra3.h
2381@item LCC_PRODUCER
2382dwarfread.c
2383@item LITTLE_ENDIAN
2384defs.h
2385@item LOG_FILE
2386remote-adapt.c
2387@item LONGERNAMES
2388cplus-dem.c
2389@item LONGEST
2390defs.h
238ffce0
JG
2391@item CC_HAS_LONG_LONG
2392defs.h
2393@item PRINTF_HAS_LONG_LONG
493cf018
JG
2394defs.h
2395@item LONG_MAX
2396defs.h
493cf018
JG
2397@item L_LNNO32
2398coffread.c
493cf018
JG
2399@item MACHKERNELDEBUG
2400hppabsd-tdep.c
2401@item MAIN
2402cplus-dem.c
2403@item MAINTENANCE
2404dwarfread.c
2405@item MAINTENANCE_CMDS
2406breakpoint.c
2407@item MAINTENANCE_CMDS
2408maint.c
2409@item MIPSEL
2410mips-tdep.c
493cf018
JG
2411@item MOTOROLA
2412xm-altos.h
493cf018
JG
2413@item NBPG
2414altos-xdep.c
2415@item NEED_POSIX_SETPGID
2416infrun.c
2417@item NEED_TEXT_START_END
2418exec.c
2419@item NFAILURES
2420regex.c
2421@item NNPC_REGNUM
2422infrun.c
2423@item NORETURN
2424defs.h
2425@item NOTDEF
2426regex.c
2427@item NOTDEF
2428remote-adapt.c
2429@item NOTDEF
2430remote-mm.c
2431@item NOTICE_SIGNAL_HANDLING_CHANGE
2432infrun.c
493cf018
JG
2433@item NO_HIF_SUPPORT
2434remote-mm.c
493cf018
JG
2435@item NO_SIGINTERRUPT
2436remote-adapt.c
2437@item NO_SINGLE_STEP
2438infptrace.c
493cf018
JG
2439@item NPC_REGNUM
2440infcmd.c
2441@item NS32K_SVC_IMMED_OPERANDS
2442ns32k-opcode.h
2443@item NUMERIC_REG_NAMES
2444mips-tdep.c
2445@item N_SETV
2446dbxread.c
2447@item N_SET_MAGIC
2448hppabsd-tdep.c
2449@item NaN
2450tm-umax.h
2451@item ONE_PROCESS_WRITETEXT
2452breakpoint.c
2453@item PC
2454convx-opcode.h
2455@item PCC_SOL_BROKEN
2456dbxread.c
2457@item PC_IN_CALL_DUMMY
2458inferior.h
2459@item PC_LOAD_SEGMENT
2460stack.c
2461@item PC_REGNUM
2462parse.c
2463@item PRINT_RANDOM_SIGNAL
2464infcmd.c
2465@item PRINT_REGISTER_HOOK
2466infcmd.c
2467@item PRINT_TYPELESS_INTEGER
2468valprint.c
2469@item PROCESS_LINENUMBER_HOOK
2470buildsym.c
2471@item PROLOGUE_FIRSTLINE_OVERLAP
2472infrun.c
2473@item PSIGNAL_IN_SIGNAL_H
2474defs.h
2475@item PS_REGNUM
2476parse.c
493cf018
JG
2477@item PUSH_ARGUMENTS
2478valops.c
2479@item REGISTER_BYTES
2480remote.c
2481@item REGISTER_NAMES
d7d35f00 2482tm-a29k.h
493cf018
JG
2483@item REG_STACK_SEGMENT
2484exec.c
2485@item REG_STRUCT_HAS_ADDR
2486findvar.c
2487@item RE_NREGS
2488regex.h
2489@item R_FP
2490dwarfread.c
2491@item R_OK
2492xm-altos.h
2493@item SDB_REG_TO_REGNUM
2494coffread.c
2495@item SEEK_END
2496state.c
2497@item SEEK_SET
2498state.c
2499@item SEM
2500coffread.c
493cf018
JG
2501@item SHELL_COMMAND_CONCAT
2502infrun.c
2503@item SHELL_FILE
2504infrun.c
2505@item SHIFT_INST_REGS
2506breakpoint.c
2507@item SIGN_EXTEND_CHAR
2508regex.c
2509@item SIGTRAP_STOP_AFTER_LOAD
2510infrun.c
2511@item SKIP_PROLOGUE
3a8bc841 2512tm-m68k.h
493cf018
JG
2513@item SKIP_PROLOGUE_FRAMELESS_P
2514blockframe.c
2515@item SKIP_TRAMPOLINE_CODE
2516infrun.c
2517@item SOLIB_ADD
2518core.c
2519@item SOLIB_CREATE_INFERIOR_HOOK
2520infrun.c
493cf018
JG
2521@item SP_REGNUM
2522parse.c
2523@item STAB_REG_TO_REGNUM
2524stabsread.h
2525@item STACK_ALIGN
2526valops.c
2527@item STACK_DIRECTION
2528alloca.c
2529@item START_INFERIOR_TRAPS_EXPECTED
2530infrun.c
2531@item STOP_SIGNAL
2532main.c
2533@item STORE_RETURN_VALUE
3a8bc841 2534tm-m68k.h
493cf018
JG
2535@item SUN4_COMPILER_FEATURE
2536infrun.c
2537@item SUN_FIXED_LBRAC_BUG
2538dbxread.c
2539@item SVR4_SHARED_LIBS
2540solib.c
2541@item SWITCH_ENUM_BUG
2542regex.c
2543@item SYM1
2544tm-ultra3.h
2545@item SYMBOL_RELOADING_DEFAULT
2546symfile.c
2547@item SYNTAX_TABLE
2548regex.c
2549@item Sword
2550regex.c
2551@item TARGET_BYTE_ORDER
2552defs.h
2553@item TARGET_CHAR_BIT
2554defs.h
2555@item TARGET_COMPLEX_BIT
2556defs.h
2557@item TARGET_DOUBLE_BIT
2558defs.h
2559@item TARGET_DOUBLE_COMPLEX_BIT
2560defs.h
2561@item TARGET_FLOAT_BIT
2562defs.h
2563@item TARGET_INT_BIT
2564defs.h
2565@item TARGET_LONG_BIT
2566defs.h
2567@item TARGET_LONG_DOUBLE_BIT
2568defs.h
2569@item TARGET_LONG_LONG_BIT
2570defs.h
2571@item TARGET_PTR_BIT
2572defs.h
238ffce0
JG
2573@item TARGET_READ_PC
2574@item TARGET_WRITE_PC
2575@item TARGET_READ_SP
2576@item TARGET_WRITE_SP
2577@item TARGET_READ_FP
2578@item TARGET_WRITE_FP
2579These change the behavior of @code{read_pc}, @code{write_pc},
2580@code{read_sp}, @code{write_sp}, @code{read_fp} and @code{write_fp}.
2581For most targets, these may be left undefined. GDB will call the
2582read and write register functions with the relevant @code{_REGNUM} argument.
2583
2584These macros are useful when a target keeps one of these registers in a
2585hard to get at place; for example, part in a segment register and part
2586in an ordinary register.
2587
493cf018
JG
2588@item TARGET_SHORT_BIT
2589defs.h
2590@item TDESC
2591infrun.c
2592@item TM_FILE_OVERRIDE
2593defs.h
2594@item T_ARG
2595coffread.c
2596@item T_VOID
2597coffread.c
2598@item UINT_MAX
2599defs.h
2600@item USER
2601m88k-tdep.c
2602@item USE_GAS
2603xm-news.h
2604@item USE_STRUCT_CONVENTION
2605values.c
2606@item USIZE
2607xm-m88k.h
2608@item U_FPSTATE
2609i386-xdep.c
2610@item VARIABLES_INSIDE_BLOCK
2611dbxread.c
2612@item WRS_ORIG
2613remote-vx.c
2614@item _LANG_c
2615language.c
2616@item _LANG_m2
2617language.c
2618@item __GO32__
2619inflow.c
2620@item __HAVE_68881__
2621m68k-stub.c
2622@item __HPUX_ASM__
2623xm-hp300hpux.h
2624@item __INT_VARARGS_H
2625printcmd.c
2626@item __not_on_pyr_yet
2627pyr-xdep.c
2628@item GOULD_PN
2629gould-pinsn.c
2630@item emacs
2631alloca.c
2632@item hp800
2633xm-hppabsd.h
493cf018
JG
2634@item hpux
2635hppabsd-core.c
2636@item longest_to_int
2637defs.h
2638@item mc68020
2639m68k-stub.c
2640@item ns32k_opcodeT
2641ns32k-opcode.h
2642@item sgi
2643mips-tdep.c
2644@item sparc
2645regex.c
2646@item static
2647alloca.c
2648@item sun
2649m68k-tdep.c
2650@item sun386
2651tm-sun386.h
2652@item test
2653regex.c
2654@item x_name
2655coffread.c
2656@item x_zeroes
2657coffread.c
2658@end table
2659
b517f124 2660@node Native Conditionals
968720bf
RP
2661@chapter Native Conditionals
2662
b517f124
JG
2663When GDB is configured and compiled, various macros are defined or left
2664undefined, to control compilation when the host and target systems
2665are the same. These macros should be defined (or left undefined)
2666in @file{nm-@var{system}.h}.
968720bf 2667
1b87a1b2 2668@table @code
968720bf
RP
2669@item ATTACH_DETACH
2670If defined, then gdb will include support for the @code{attach} and
2671@code{detach} commands.
968720bf
RP
2672@item FETCH_INFERIOR_REGISTERS
2673Define this if the native-dependent code will provide its
2674own routines
2675@code{fetch_inferior_registers} and @code{store_inferior_registers} in
2676@file{@var{HOST}-nat.c}.
f8f37439
DZ
2677If this symbol is @emph{not} defined, and @file{infptrace.c}
2678is included in this configuration, the default routines in
968720bf 2679@file{infptrace.c} are used for these functions.
c3bbca3a
JG
2680@item GET_LONGJMP_TARGET
2681For most machines, this is a target-dependent parameter. On the DECstation
2682and the Iris, this is a native-dependent parameter, since <setjmp.h> is
2683needed to define it.
2684
2685This macro determines the target PC address that longjmp() will jump
2686to, assuming that we have just stopped at a longjmp breakpoint. It
2687takes a CORE_ADDR * as argument, and stores the target PC value through
2688this pointer. It examines the current state of the machine as needed.
968720bf
RP
2689@item PROC_NAME_FMT
2690Defines the format for the name of a @file{/proc} device. Should be
2691defined in @file{nm.h} @emph{only} in order to override the default
2692definition in @file{procfs.c}.
9729ef22
JK
2693@item PTRACE_FP_BUG
2694mach386-xdep.c
2695@item PTRACE_ARG3_TYPE
2696The type of the third argument to the @code{ptrace} system call, if it exists
2697and is different from @code{int}.
968720bf
RP
2698@item REGISTER_U_ADDR
2699Defines the offset of the registers in the ``u area''; @pxref{Host}.
2700@item USE_PROC_FS
f8f37439
DZ
2701This determines whether small routines in @file{*-tdep.c}, which
2702translate register values
2703between GDB's internal representation and the /proc representation,
2704are compiled.
968720bf
RP
2705@item U_REGS_OFFSET
2706This is the offset of the registers in the upage. It need only be
2707defined if the generic ptrace register access routines in
2708@file{infptrace.c} are being used (that is,
f8f37439 2709@file{infptrace.c} is configured in, and
968720bf
RP
2710@code{FETCH_INFERIOR_REGISTERS} is not defined). If the default value
2711from @file{infptrace.c} is good enough, leave it undefined.
2712
2713The default value means that u.u_ar0 @emph{points to} the location of the
2714registers. I'm guessing that @code{#define U_REGS_OFFSET 0} means that
2715u.u_ar0 @emph{is} the location of the registers.
2716@end table
2717
b517f124
JG
2718@node Obsolete Conditionals
2719@chapter Obsolete Conditionals
2720
2721Fragments of old code in GDB sometimes reference or set the following
2722configuration macros. They should not be used by new code, and
2723old uses should be removed as those parts of the debugger are
2724otherwise touched.
2725
2726@table @code
2727@item STACK_END_ADDR
2728This macro used to define where the end of the stack appeared, for use
2729in interpreting core file formats that don't record this address in the
2730core file itself. This information is now configured in BFD, and GDB
2731gets the info portably from there. The values in GDB's configuration
2732files should be moved into BFD configuration files (if needed there),
2733and deleted from all of GDB's config files.
2734
2735Any @file{@var{foo}-xdep.c} file that references STACK_END_ADDR
2736is so old that it has never been converted to use BFD. Now that's old!
2737@end table
9729ef22
JK
2738
2739@node XCOFF
2740@chapter The XCOFF Object File Format
2741
2742The IBM RS/6000 running AIX uses an object file format called xcoff.
2743The COFF sections, symbols, and line numbers are used, but debugging
2744symbols are dbx-style stabs whose strings are located in the
238ffce0
JG
2745@samp{.debug} section (rather than the string table). For more
2746information, @xref{Top,,,stabs,The Stabs Debugging Format}, and search
2747for XCOFF.
9729ef22
JK
2748
2749The shared library scheme has a nice clean interface for figuring out
2750what shared libraries are in use, but the catch is that everything which
2751refers to addresses (symbol tables and breakpoints at least) needs to be
2752relocated for both shared libraries and the main executable. At least
2753using the standard mechanism this can only be done once the program has
2754been run (or the core file has been read).
2755
ca714d03
RP
2756@contents
2757@bye
This page took 0.213705 seconds and 4 git commands to generate.