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