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