]> Git Repo - binutils.git/blame - gdb/doc/gdbint.texinfo
Replace abort() with internal_error().
[binutils.git] / gdb / doc / gdbint.texinfo
CommitLineData
c906108c
SS
1\input texinfo
2@setfilename gdbint.info
25822942 3@include gdb-cfg.texi
c906108c
SS
4@ifinfo
5@format
6START-INFO-DIR-ENTRY
7* Gdb-Internals: (gdbint). The GNU debugger's internals.
8END-INFO-DIR-ENTRY
9@end format
10@end ifinfo
11
12@ifinfo
25822942 13This file documents the internals of the GNU debugger @value{GDBN}.
c906108c 14
b6ba6518
KB
15Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
162001 Free Software Foundation, Inc.
c906108c
SS
17Contributed by Cygnus Solutions. Written by John Gilmore.
18Second Edition by Stan Shebs.
19
20Permission is granted to make and distribute verbatim copies of this
21manual provided the copyright notice and this permission notice are
22preserved on all copies.
23
24@ignore
25Permission is granted to process this file through Tex and print the
26results, provided the printed document carries copying permission notice
27identical to this one except for the removal of this paragraph (this
28paragraph not being relevant to the printed manual).
29
30@end ignore
31Permission is granted to copy or distribute modified versions of this
32manual under the terms of the GPL (for which purpose this text may be
33regarded as a program in the language TeX).
34@end ifinfo
35
36@setchapternewpage off
25822942 37@settitle @value{GDBN} Internals
c906108c 38
56caf160
EZ
39@syncodeindex fn cp
40@syncodeindex vr cp
41
c906108c 42@titlepage
25822942 43@title @value{GDBN} Internals
c906108c
SS
44@subtitle{A guide to the internals of the GNU debugger}
45@author John Gilmore
46@author Cygnus Solutions
47@author Second Edition:
48@author Stan Shebs
49@author Cygnus Solutions
50@page
51@tex
52\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
53\xdef\manvers{\$Revision$} % For use in headers, footers too
54{\parskip=0pt
55\hfill Cygnus Solutions\par
56\hfill \manvers\par
57\hfill \TeX{}info \texinfoversion\par
58}
59@end tex
60
61@vskip 0pt plus 1filll
62Copyright @copyright{} 1990-1999 Free Software Foundation, Inc.
63
64Permission is granted to make and distribute verbatim copies of
65this manual provided the copyright notice and this permission notice
66are preserved on all copies.
67
68@end titlepage
69
449f3b6c
AC
70@c TeX can handle the contents at the start but makeinfo 3.12 can not
71@iftex
72@contents
73@end iftex
74
c906108c
SS
75@node Top
76@c Perhaps this should be the title of the document (but only for info,
77@c not for TeX). Existing GNU manuals seem inconsistent on this point.
78@top Scope of this Document
79
25822942
DB
80This document documents the internals of the GNU debugger, @value{GDBN}. It
81includes description of @value{GDBN}'s key algorithms and operations, as well
82as the mechanisms that adapt @value{GDBN} to specific hosts and targets.
c906108c
SS
83
84@menu
85* Requirements::
86* Overall Structure::
87* Algorithms::
88* User Interface::
89* Symbol Handling::
90* Language Support::
91* Host Definition::
92* Target Architecture Definition::
93* Target Vector Definition::
94* Native Debugging::
95* Support Libraries::
96* Coding::
97* Porting GDB::
085dd6e6 98* Testsuite::
c906108c 99* Hints::
56caf160 100* Index::
c906108c
SS
101@end menu
102
103@node Requirements
104
105@chapter Requirements
56caf160 106@cindex requirements for @value{GDBN}
c906108c
SS
107
108Before diving into the internals, you should understand the formal
56caf160
EZ
109requirements and other expectations for @value{GDBN}. Although some
110of these may seem obvious, there have been proposals for @value{GDBN}
111that have run counter to these requirements.
c906108c 112
56caf160
EZ
113First of all, @value{GDBN} is a debugger. It's not designed to be a
114front panel for embedded systems. It's not a text editor. It's not a
115shell. It's not a programming environment.
c906108c 116
56caf160
EZ
117@value{GDBN} is an interactive tool. Although a batch mode is
118available, @value{GDBN}'s primary role is to interact with a human
119programmer.
c906108c 120
56caf160
EZ
121@value{GDBN} should be responsive to the user. A programmer hot on
122the trail of a nasty bug, and operating under a looming deadline, is
123going to be very impatient of everything, including the response time
124to debugger commands.
c906108c 125
56caf160
EZ
126@value{GDBN} should be relatively permissive, such as for expressions.
127While the compiler should be picky (or have the option to be made
128picky), since source code lives for a long time usuazlly, the
129programmer doing debugging shouldn't be spending time figuring out to
130mollify the debugger.
c906108c 131
56caf160
EZ
132@value{GDBN} will be called upon to deal with really large programs.
133Executable sizes of 50 to 100 megabytes occur regularly, and we've
134heard reports of programs approaching 1 gigabyte in size.
c906108c 135
56caf160
EZ
136@value{GDBN} should be able to run everywhere. No other debugger is
137available for even half as many configurations as @value{GDBN}
138supports.
c906108c
SS
139
140
141@node Overall Structure
142
143@chapter Overall Structure
144
56caf160
EZ
145@value{GDBN} consists of three major subsystems: user interface,
146symbol handling (the @dfn{symbol side}), and target system handling (the
147@dfn{target side}).
c906108c 148
2e685b93 149The user interface consists of several actual interfaces, plus
c906108c
SS
150supporting code.
151
152The symbol side consists of object file readers, debugging info
153interpreters, symbol table management, source language expression
154parsing, type and value printing.
155
156The target side consists of execution control, stack frame analysis, and
157physical target manipulation.
158
159The target side/symbol side division is not formal, and there are a
160number of exceptions. For instance, core file support involves symbolic
161elements (the basic core file reader is in BFD) and target elements (it
162supplies the contents of memory and the values of registers). Instead,
163this division is useful for understanding how the minor subsystems
164should fit together.
165
166@section The Symbol Side
167
56caf160
EZ
168The symbolic side of @value{GDBN} can be thought of as ``everything
169you can do in @value{GDBN} without having a live program running''.
170For instance, you can look at the types of variables, and evaluate
171many kinds of expressions.
c906108c
SS
172
173@section The Target Side
174
56caf160
EZ
175The target side of @value{GDBN} is the ``bits and bytes manipulator''.
176Although it may make reference to symbolic info here and there, most
177of the target side will run with only a stripped executable
178available---or even no executable at all, in remote debugging cases.
c906108c
SS
179
180Operations such as disassembly, stack frame crawls, and register
181display, are able to work with no symbolic info at all. In some cases,
25822942 182such as disassembly, @value{GDBN} will use symbolic info to present addresses
c906108c
SS
183relative to symbols rather than as raw numbers, but it will work either
184way.
185
186@section Configurations
187
56caf160
EZ
188@cindex host
189@cindex target
25822942 190@dfn{Host} refers to attributes of the system where @value{GDBN} runs.
c906108c
SS
191@dfn{Target} refers to the system where the program being debugged
192executes. In most cases they are the same machine, in which case a
193third type of @dfn{Native} attributes come into play.
194
195Defines and include files needed to build on the host are host support.
196Examples are tty support, system defined types, host byte order, host
197float format.
198
199Defines and information needed to handle the target format are target
200dependent. Examples are the stack frame format, instruction set,
201breakpoint instruction, registers, and how to set up and tear down the stack
202to call a function.
203
204Information that is only needed when the host and target are the same,
205is native dependent. One example is Unix child process support; if the
206host and target are not the same, doing a fork to start the target
207process is a bad idea. The various macros needed for finding the
208registers in the @code{upage}, running @code{ptrace}, and such are all
209in the native-dependent files.
210
211Another example of native-dependent code is support for features that
212are really part of the target environment, but which require
213@code{#include} files that are only available on the host system. Core
214file handling and @code{setjmp} handling are two common cases.
215
25822942 216When you want to make @value{GDBN} work ``native'' on a particular machine, you
c906108c
SS
217have to include all three kinds of information.
218
219
220@node Algorithms
221
222@chapter Algorithms
56caf160 223@cindex algorithms
c906108c 224
56caf160
EZ
225@value{GDBN} uses a number of debugging-specific algorithms. They are
226often not very complicated, but get lost in the thicket of special
227cases and real-world issues. This chapter describes the basic
228algorithms and mentions some of the specific target definitions that
229they use.
c906108c
SS
230
231@section Frames
232
56caf160
EZ
233@cindex frame
234@cindex call stack frame
235A frame is a construct that @value{GDBN} uses to keep track of calling
236and called functions.
c906108c 237
56caf160
EZ
238@findex create_new_frame
239@vindex FRAME_FP
c906108c 240@code{FRAME_FP} in the machine description has no meaning to the
56caf160
EZ
241machine-independent part of @value{GDBN}, except that it is used when
242setting up a new frame from scratch, as follows:
c906108c
SS
243
244@example
245 create_new_frame (read_register (FP_REGNUM), read_pc ()));
246@end example
247
56caf160 248@cindex frame pointer register
c906108c
SS
249Other than that, all the meaning imparted to @code{FP_REGNUM} is
250imparted by the machine-dependent code. So, @code{FP_REGNUM} can have
251any value that is convenient for the code that creates new frames.
252(@code{create_new_frame} calls @code{INIT_EXTRA_FRAME_INFO} if it is
253defined; that is where you should use the @code{FP_REGNUM} value, if
254your frames are nonstandard.)
255
56caf160
EZ
256@cindex frame chain
257Given a @value{GDBN} frame, define @code{FRAME_CHAIN} to determine the
258address of the calling function's frame. This will be used to create
259a new @value{GDBN} frame struct, and then @code{INIT_EXTRA_FRAME_INFO}
260and @code{INIT_FRAME_PC} will be called for the new frame.
c906108c
SS
261
262@section Breakpoint Handling
263
56caf160 264@cindex breakpoints
c906108c
SS
265In general, a breakpoint is a user-designated location in the program
266where the user wants to regain control if program execution ever reaches
267that location.
268
269There are two main ways to implement breakpoints; either as ``hardware''
270breakpoints or as ``software'' breakpoints.
271
56caf160
EZ
272@cindex hardware breakpoints
273@cindex program counter
c906108c
SS
274Hardware breakpoints are sometimes available as a builtin debugging
275features with some chips. Typically these work by having dedicated
276register into which the breakpoint address may be stored. If the PC
56caf160 277(shorthand for @dfn{program counter})
c906108c 278ever matches a value in a breakpoint registers, the CPU raises an
56caf160
EZ
279exception and reports it to @value{GDBN}.
280
281Another possibility is when an emulator is in use; many emulators
282include circuitry that watches the address lines coming out from the
283processor, and force it to stop if the address matches a breakpoint's
284address.
285
286A third possibility is that the target already has the ability to do
287breakpoints somehow; for instance, a ROM monitor may do its own
288software breakpoints. So although these are not literally ``hardware
289breakpoints'', from @value{GDBN}'s point of view they work the same;
290@value{GDBN} need not do nothing more than set the breakpoint and wait
291for something to happen.
c906108c
SS
292
293Since they depend on hardware resources, hardware breakpoints may be
56caf160
EZ
294limited in number; when the user asks for more, @value{GDBN} will
295start trying to set software breakpoints.
296
297@cindex software breakpoints
298Software breakpoints require @value{GDBN} to do somewhat more work.
299The basic theory is that @value{GDBN} will replace a program
300instruction with a trap, illegal divide, or some other instruction
301that will cause an exception, and then when it's encountered,
302@value{GDBN} will take the exception and stop the program. When the
303user says to continue, @value{GDBN} will restore the original
c906108c
SS
304instruction, single-step, re-insert the trap, and continue on.
305
306Since it literally overwrites the program being tested, the program area
307must be writeable, so this technique won't work on programs in ROM. It
308can also distort the behavior of programs that examine themselves,
56caf160 309although such a situation would be highly unusual.
c906108c
SS
310
311Also, the software breakpoint instruction should be the smallest size of
312instruction, so it doesn't overwrite an instruction that might be a jump
313target, and cause disaster when the program jumps into the middle of the
314breakpoint instruction. (Strictly speaking, the breakpoint must be no
315larger than the smallest interval between instructions that may be jump
316targets; perhaps there is an architecture where only even-numbered
317instructions may jumped to.) Note that it's possible for an instruction
318set not to have any instructions usable for a software breakpoint,
319although in practice only the ARC has failed to define such an
320instruction.
321
56caf160 322@findex BREAKPOINT
c906108c
SS
323The basic definition of the software breakpoint is the macro
324@code{BREAKPOINT}.
325
326Basic breakpoint object handling is in @file{breakpoint.c}. However,
327much of the interesting breakpoint action is in @file{infrun.c}.
328
329@section Single Stepping
330
331@section Signal Handling
332
333@section Thread Handling
334
335@section Inferior Function Calls
336
337@section Longjmp Support
338
56caf160 339@cindex @code{longjmp} debugging
25822942 340@value{GDBN} has support for figuring out that the target is doing a
c906108c
SS
341@code{longjmp} and for stopping at the target of the jump, if we are
342stepping. This is done with a few specialized internal breakpoints,
56caf160
EZ
343which are visible in the output of the @samp{maint info breakpoint}
344command.
c906108c 345
56caf160 346@findex GET_LONGJMP_TARGET
c906108c
SS
347To make this work, you need to define a macro called
348@code{GET_LONGJMP_TARGET}, which will examine the @code{jmp_buf}
349structure and extract the longjmp target address. Since @code{jmp_buf}
350is target specific, you will need to define it in the appropriate
56caf160 351@file{tm-@var{target}.h} file. Look in @file{tm-sun4os4.h} and
c906108c
SS
352@file{sparc-tdep.c} for examples of how to do this.
353
354@node User Interface
355
356@chapter User Interface
357
25822942 358@value{GDBN} has several user interfaces. Although the command-line interface
c906108c
SS
359is the most common and most familiar, there are others.
360
361@section Command Interpreter
362
56caf160 363@cindex command interpreter
25822942 364The command interpreter in @value{GDBN} is fairly simple. It is designed to
c906108c
SS
365allow for the set of commands to be augmented dynamically, and also
366has a recursive subcommand capability, where the first argument to
367a command may itself direct a lookup on a different command list.
368
56caf160
EZ
369For instance, the @samp{set} command just starts a lookup on the
370@code{setlist} command list, while @samp{set thread} recurses
c906108c
SS
371to the @code{set_thread_cmd_list}.
372
56caf160
EZ
373@findex add_cmd
374@findex add_com
c906108c
SS
375To add commands in general, use @code{add_cmd}. @code{add_com} adds to
376the main command list, and should be used for those commands. The usual
cfeada60
FN
377place to add commands is in the @code{_initialize_@var{xyz}} routines at
378the ends of most source files.
379
56caf160
EZ
380@cindex deprecating commands
381@findex deprecate_cmd
cfeada60
FN
382Before removing commands from the command set it is a good idea to
383deprecate them for some time. Use @code{deprecate_cmd} on commands or
384aliases to set the deprecated flag. @code{deprecate_cmd} takes a
385@code{struct cmd_list_element} as it's first argument. You can use the
386return value from @code{add_com} or @code{add_cmd} to deprecate the
387command immediately after it is created.
388
389The first time a comamnd is used the user will be warned and offered a
390replacement (if one exists). Note that the replacement string passed to
391@code{deprecate_cmd} should be the full name of the command, i.e. the
392entire string the user should type at the command line.
c906108c
SS
393
394@section Console Printing
395
396@section TUI
397
398@section libgdb
399
56caf160 400@cindex @code{libgdb}
c906108c 401@code{libgdb} was an abortive project of years ago. The theory was to
25822942 402provide an API to @value{GDBN}'s functionality.
c906108c
SS
403
404@node Symbol Handling
405
406@chapter Symbol Handling
407
25822942 408Symbols are a key part of @value{GDBN}'s operation. Symbols include variables,
c906108c
SS
409functions, and types.
410
411@section Symbol Reading
412
56caf160
EZ
413@cindex symbol reading
414@cindex reading of symbols
415@cindex symbol files
416@value{GDBN} reads symbols from @dfn{symbol files}. The usual symbol
417file is the file containing the program which @value{GDBN} is
418debugging. @value{GDBN} can be directed to use a different file for
419symbols (with the @samp{symbol-file} command), and it can also read
420more symbols via the @samp{add-file} and @samp{load} commands, or while
421reading symbols from shared libraries.
422
423@findex find_sym_fns
424Symbol files are initially opened by code in @file{symfile.c} using
425the BFD library (@pxref{Support Libraries}). BFD identifies the type
426of the file by examining its header. @code{find_sym_fns} then uses
427this identification to locate a set of symbol-reading functions.
428
429@findex add_symtab_fns
430@cindex @code{sym_fns} structure
431@cindex adding a symbol-reading module
432Symbol-reading modules identify themselves to @value{GDBN} by calling
c906108c
SS
433@code{add_symtab_fns} during their module initialization. The argument
434to @code{add_symtab_fns} is a @code{struct sym_fns} which contains the
435name (or name prefix) of the symbol format, the length of the prefix,
436and pointers to four functions. These functions are called at various
56caf160 437times to process symbol files whose identification matches the specified
c906108c
SS
438prefix.
439
440The functions supplied by each module are:
441
442@table @code
443@item @var{xyz}_symfile_init(struct sym_fns *sf)
444
56caf160 445@cindex secondary symbol file
c906108c
SS
446Called from @code{symbol_file_add} when we are about to read a new
447symbol file. This function should clean up any internal state (possibly
448resulting from half-read previous files, for example) and prepare to
56caf160
EZ
449read a new symbol file. Note that the symbol file which we are reading
450might be a new ``main'' symbol file, or might be a secondary symbol file
c906108c
SS
451whose symbols are being added to the existing symbol table.
452
453The argument to @code{@var{xyz}_symfile_init} is a newly allocated
454@code{struct sym_fns} whose @code{bfd} field contains the BFD for the
455new symbol file being read. Its @code{private} field has been zeroed,
456and can be modified as desired. Typically, a struct of private
457information will be @code{malloc}'d, and a pointer to it will be placed
458in the @code{private} field.
459
460There is no result from @code{@var{xyz}_symfile_init}, but it can call
461@code{error} if it detects an unavoidable problem.
462
463@item @var{xyz}_new_init()
464
465Called from @code{symbol_file_add} when discarding existing symbols.
56caf160
EZ
466This function needs only handle the symbol-reading module's internal
467state; the symbol table data structures visible to the rest of
468@value{GDBN} will be discarded by @code{symbol_file_add}. It has no
469arguments and no result. It may be called after
470@code{@var{xyz}_symfile_init}, if a new symbol table is being read, or
471may be called alone if all symbols are simply being discarded.
c906108c
SS
472
473@item @var{xyz}_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline)
474
475Called from @code{symbol_file_add} to actually read the symbols from a
476symbol-file into a set of psymtabs or symtabs.
477
56caf160 478@code{sf} points to the @code{struct sym_fns} originally passed to
c906108c
SS
479@code{@var{xyz}_sym_init} for possible initialization. @code{addr} is
480the offset between the file's specified start address and its true
481address in memory. @code{mainline} is 1 if this is the main symbol
482table being read, and 0 if a secondary symbol file (e.g. shared library
483or dynamically loaded file) is being read.@refill
484@end table
485
486In addition, if a symbol-reading module creates psymtabs when
487@var{xyz}_symfile_read is called, these psymtabs will contain a pointer
488to a function @code{@var{xyz}_psymtab_to_symtab}, which can be called
25822942 489from any point in the @value{GDBN} symbol-handling code.
c906108c
SS
490
491@table @code
492@item @var{xyz}_psymtab_to_symtab (struct partial_symtab *pst)
493
56caf160 494Called from @code{psymtab_to_symtab} (or the @code{PSYMTAB_TO_SYMTAB} macro) if
c906108c
SS
495the psymtab has not already been read in and had its @code{pst->symtab}
496pointer set. The argument is the psymtab to be fleshed-out into a
56caf160
EZ
497symtab. Upon return, @code{pst->readin} should have been set to 1, and
498@code{pst->symtab} should contain a pointer to the new corresponding symtab, or
c906108c
SS
499zero if there were no symbols in that part of the symbol file.
500@end table
501
502@section Partial Symbol Tables
503
56caf160 504@value{GDBN} has three types of symbol tables:
c906108c
SS
505
506@itemize @bullet
56caf160
EZ
507@cindex full symbol table
508@cindex symtabs
509@item
510Full symbol tables (@dfn{symtabs}). These contain the main
511information about symbols and addresses.
c906108c 512
56caf160
EZ
513@cindex psymtabs
514@item
515Partial symbol tables (@dfn{psymtabs}). These contain enough
c906108c
SS
516information to know when to read the corresponding part of the full
517symbol table.
518
56caf160
EZ
519@cindex minimal symbol table
520@cindex minsymtabs
521@item
522Minimal symbol tables (@dfn{msymtabs}). These contain information
c906108c 523gleaned from non-debugging symbols.
c906108c
SS
524@end itemize
525
56caf160 526@cindex partial symbol table
c906108c
SS
527This section describes partial symbol tables.
528
529A psymtab is constructed by doing a very quick pass over an executable
530file's debugging information. Small amounts of information are
56caf160 531extracted---enough to identify which parts of the symbol table will
c906108c 532need to be re-read and fully digested later, when the user needs the
25822942 533information. The speed of this pass causes @value{GDBN} to start up very
c906108c
SS
534quickly. Later, as the detailed rereading occurs, it occurs in small
535pieces, at various times, and the delay therefrom is mostly invisible to
536the user.
537@c (@xref{Symbol Reading}.)
538
539The symbols that show up in a file's psymtab should be, roughly, those
540visible to the debugger's user when the program is not running code from
541that file. These include external symbols and types, static symbols and
56caf160 542types, and @code{enum} values declared at file scope.
c906108c
SS
543
544The psymtab also contains the range of instruction addresses that the
545full symbol table would represent.
546
56caf160
EZ
547@cindex finding a symbol
548@cindex symbol lookup
c906108c
SS
549The idea is that there are only two ways for the user (or much of the
550code in the debugger) to reference a symbol:
551
552@itemize @bullet
56caf160
EZ
553@findex find_pc_function
554@findex find_pc_line
555@item
556By its address (e.g. execution stops at some address which is inside a
557function in this file). The address will be noticed to be in the
558range of this psymtab, and the full symtab will be read in.
559@code{find_pc_function}, @code{find_pc_line}, and other
560@code{find_pc_@dots{}} functions handle this.
c906108c 561
56caf160
EZ
562@cindex lookup_symbol
563@item
564By its name
c906108c
SS
565(e.g. the user asks to print a variable, or set a breakpoint on a
566function). Global names and file-scope names will be found in the
567psymtab, which will cause the symtab to be pulled in. Local names will
568have to be qualified by a global name, or a file-scope name, in which
569case we will have already read in the symtab as we evaluated the
56caf160 570qualifier. Or, a local symbol can be referenced when we are ``in'' a
c906108c
SS
571local scope, in which case the first case applies. @code{lookup_symbol}
572does most of the work here.
c906108c
SS
573@end itemize
574
575The only reason that psymtabs exist is to cause a symtab to be read in
576at the right moment. Any symbol that can be elided from a psymtab,
577while still causing that to happen, should not appear in it. Since
578psymtabs don't have the idea of scope, you can't put local symbols in
579them anyway. Psymtabs don't have the idea of the type of a symbol,
580either, so types need not appear, unless they will be referenced by
581name.
582
56caf160
EZ
583It is a bug for @value{GDBN} to behave one way when only a psymtab has
584been read, and another way if the corresponding symtab has been read
585in. Such bugs are typically caused by a psymtab that does not contain
586all the visible symbols, or which has the wrong instruction address
587ranges.
c906108c 588
56caf160 589The psymtab for a particular section of a symbol file (objfile) could be
c906108c
SS
590thrown away after the symtab has been read in. The symtab should always
591be searched before the psymtab, so the psymtab will never be used (in a
592bug-free environment). Currently, psymtabs are allocated on an obstack,
593and all the psymbols themselves are allocated in a pair of large arrays
594on an obstack, so there is little to be gained by trying to free them
595unless you want to do a lot more work.
596
597@section Types
598
56caf160 599@unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}).
c906108c 600
56caf160 601@cindex fundamental types
25822942 602These are the fundamental types that @value{GDBN} uses internally. Fundamental
c906108c
SS
603types from the various debugging formats (stabs, ELF, etc) are mapped
604into one of these. They are basically a union of all fundamental types
56caf160
EZ
605that @value{GDBN} knows about for all the languages that @value{GDBN}
606knows about.
c906108c 607
56caf160 608@unnumberedsubsec Type Codes (e.g., @code{TYPE_CODE_PTR}, @code{TYPE_CODE_ARRAY}).
c906108c 609
56caf160
EZ
610@cindex type codes
611Each time @value{GDBN} builds an internal type, it marks it with one
612of these types. The type may be a fundamental type, such as
613@code{TYPE_CODE_INT}, or a derived type, such as @code{TYPE_CODE_PTR}
614which is a pointer to another type. Typically, several @code{FT_*}
615types map to one @code{TYPE_CODE_*} type, and are distinguished by
616other members of the type struct, such as whether the type is signed
617or unsigned, and how many bits it uses.
c906108c 618
56caf160 619@unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}).
c906108c
SS
620
621These are instances of type structs that roughly correspond to
56caf160
EZ
622fundamental types and are created as global types for @value{GDBN} to
623use for various ugly historical reasons. We eventually want to
624eliminate these. Note for example that @code{builtin_type_int}
625initialized in @file{gdbtypes.c} is basically the same as a
626@code{TYPE_CODE_INT} type that is initialized in @file{c-lang.c} for
627an @code{FT_INTEGER} fundamental type. The difference is that the
628@code{builtin_type} is not associated with any particular objfile, and
629only one instance exists, while @file{c-lang.c} builds as many
630@code{TYPE_CODE_INT} types as needed, with each one associated with
631some particular objfile.
c906108c
SS
632
633@section Object File Formats
56caf160 634@cindex object file formats
c906108c
SS
635
636@subsection a.out
637
56caf160
EZ
638@cindex @code{a.out} format
639The @code{a.out} format is the original file format for Unix. It
640consists of three sections: @code{text}, @code{data}, and @code{bss},
641which are for program code, initialized data, and uninitialized data,
642respectively.
c906108c 643
56caf160 644The @code{a.out} format is so simple that it doesn't have any reserved
c906108c 645place for debugging information. (Hey, the original Unix hackers used
56caf160
EZ
646@samp{adb}, which is a machine-language debugger!) The only debugging
647format for @code{a.out} is stabs, which is encoded as a set of normal
c906108c
SS
648symbols with distinctive attributes.
649
56caf160 650The basic @code{a.out} reader is in @file{dbxread.c}.
c906108c
SS
651
652@subsection COFF
653
56caf160 654@cindex COFF format
c906108c
SS
655The COFF format was introduced with System V Release 3 (SVR3) Unix.
656COFF files may have multiple sections, each prefixed by a header. The
657number of sections is limited.
658
659The COFF specification includes support for debugging. Although this
660was a step forward, the debugging information was woefully limited. For
661instance, it was not possible to represent code that came from an
662included file.
663
664The COFF reader is in @file{coffread.c}.
665
666@subsection ECOFF
667
56caf160 668@cindex ECOFF format
c906108c
SS
669ECOFF is an extended COFF originally introduced for Mips and Alpha
670workstations.
671
672The basic ECOFF reader is in @file{mipsread.c}.
673
674@subsection XCOFF
675
56caf160 676@cindex XCOFF format
c906108c
SS
677The IBM RS/6000 running AIX uses an object file format called XCOFF.
678The COFF sections, symbols, and line numbers are used, but debugging
56caf160
EZ
679symbols are @code{dbx}-style stabs whose strings are located in the
680@code{.debug} section (rather than the string table). For more
681information, see @ref{Top,,,stabs,The Stabs Debugging Format}.
c906108c
SS
682
683The shared library scheme has a clean interface for figuring out what
684shared libraries are in use, but the catch is that everything which
685refers to addresses (symbol tables and breakpoints at least) needs to be
686relocated for both shared libraries and the main executable. At least
687using the standard mechanism this can only be done once the program has
688been run (or the core file has been read).
689
690@subsection PE
691
56caf160
EZ
692@cindex PE-COFF format
693Windows 95 and NT use the PE (@dfn{Portable Executable}) format for their
c906108c
SS
694executables. PE is basically COFF with additional headers.
695
25822942 696While BFD includes special PE support, @value{GDBN} needs only the basic
c906108c
SS
697COFF reader.
698
699@subsection ELF
700
56caf160 701@cindex ELF format
c906108c
SS
702The ELF format came with System V Release 4 (SVR4) Unix. ELF is similar
703to COFF in being organized into a number of sections, but it removes
704many of COFF's limitations.
705
706The basic ELF reader is in @file{elfread.c}.
707
708@subsection SOM
709
56caf160 710@cindex SOM format
c906108c
SS
711SOM is HP's object file and debug format (not to be confused with IBM's
712SOM, which is a cross-language ABI).
713
714The SOM reader is in @file{hpread.c}.
715
716@subsection Other File Formats
717
56caf160 718@cindex Netware Loadable Module format
25822942 719Other file formats that have been supported by @value{GDBN} include Netware
c906108c
SS
720Loadable Modules (@file{nlmread.c}.
721
722@section Debugging File Formats
723
724This section describes characteristics of debugging information that
725are independent of the object file format.
726
727@subsection stabs
728
56caf160 729@cindex stabs debugging info
c906108c
SS
730@code{stabs} started out as special symbols within the @code{a.out}
731format. Since then, it has been encapsulated into other file
732formats, such as COFF and ELF.
733
734While @file{dbxread.c} does some of the basic stab processing,
735including for encapsulated versions, @file{stabsread.c} does
736the real work.
737
738@subsection COFF
739
56caf160 740@cindex COFF debugging info
c906108c
SS
741The basic COFF definition includes debugging information. The level
742of support is minimal and non-extensible, and is not often used.
743
744@subsection Mips debug (Third Eye)
745
56caf160 746@cindex ECOFF debugging info
c906108c
SS
747ECOFF includes a definition of a special debug format.
748
749The file @file{mdebugread.c} implements reading for this format.
750
751@subsection DWARF 1
752
56caf160 753@cindex DWARF 1 debugging info
c906108c
SS
754DWARF 1 is a debugging format that was originally designed to be
755used with ELF in SVR4 systems.
756
757@c CHILL_PRODUCER
758@c GCC_PRODUCER
759@c GPLUS_PRODUCER
760@c LCC_PRODUCER
761@c If defined, these are the producer strings in a DWARF 1 file. All of
762@c these have reasonable defaults already.
763
764The DWARF 1 reader is in @file{dwarfread.c}.
765
766@subsection DWARF 2
767
56caf160 768@cindex DWARF 2 debugging info
c906108c
SS
769DWARF 2 is an improved but incompatible version of DWARF 1.
770
771The DWARF 2 reader is in @file{dwarf2read.c}.
772
773@subsection SOM
774
56caf160 775@cindex SOM debugging info
c906108c
SS
776Like COFF, the SOM definition includes debugging information.
777
25822942 778@section Adding a New Symbol Reader to @value{GDBN}
c906108c 779
56caf160
EZ
780@cindex adding debugging info reader
781If you are using an existing object file format (@code{a.out}, COFF, ELF, etc),
c906108c
SS
782there is probably little to be done.
783
784If you need to add a new object file format, you must first add it to
785BFD. This is beyond the scope of this document.
786
787You must then arrange for the BFD code to provide access to the
25822942 788debugging symbols. Generally @value{GDBN} will have to call swapping routines
c906108c 789from BFD and a few other BFD internal routines to locate the debugging
25822942 790information. As much as possible, @value{GDBN} should not depend on the BFD
c906108c
SS
791internal data structures.
792
793For some targets (e.g., COFF), there is a special transfer vector used
794to call swapping routines, since the external data structures on various
795platforms have different sizes and layouts. Specialized routines that
796will only ever be implemented by one object file format may be called
797directly. This interface should be described in a file
56caf160 798@file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}.
c906108c
SS
799
800
801@node Language Support
802
803@chapter Language Support
804
56caf160
EZ
805@cindex language support
806@value{GDBN}'s language support is mainly driven by the symbol reader,
807although it is possible for the user to set the source language
808manually.
c906108c 809
56caf160
EZ
810@value{GDBN} chooses the source language by looking at the extension
811of the file recorded in the debug info; @file{.c} means C, @file{.f}
812means Fortran, etc. It may also use a special-purpose language
813identifier if the debug format supports it, like with DWARF.
c906108c 814
25822942 815@section Adding a Source Language to @value{GDBN}
c906108c 816
56caf160
EZ
817@cindex adding source language
818To add other languages to @value{GDBN}'s expression parser, follow the
819following steps:
c906108c
SS
820
821@table @emph
822@item Create the expression parser.
823
56caf160 824@cindex expression parser
c906108c 825This should reside in a file @file{@var{lang}-exp.y}. Routines for
56caf160 826building parsed expressions into a @code{union exp_element} list are in
c906108c
SS
827@file{parse.c}.
828
56caf160 829@cindex language parser
c906108c
SS
830Since we can't depend upon everyone having Bison, and YACC produces
831parsers that define a bunch of global names, the following lines
56caf160 832@strong{must} be included at the top of the YACC parser, to prevent the
c906108c
SS
833various parsers from defining the same global names:
834
835@example
56caf160
EZ
836#define yyparse @var{lang}_parse
837#define yylex @var{lang}_lex
838#define yyerror @var{lang}_error
839#define yylval @var{lang}_lval
840#define yychar @var{lang}_char
841#define yydebug @var{lang}_debug
842#define yypact @var{lang}_pact
843#define yyr1 @var{lang}_r1
844#define yyr2 @var{lang}_r2
845#define yydef @var{lang}_def
846#define yychk @var{lang}_chk
847#define yypgo @var{lang}_pgo
848#define yyact @var{lang}_act
849#define yyexca @var{lang}_exca
850#define yyerrflag @var{lang}_errflag
851#define yynerrs @var{lang}_nerrs
c906108c
SS
852@end example
853
854At the bottom of your parser, define a @code{struct language_defn} and
855initialize it with the right values for your language. Define an
856@code{initialize_@var{lang}} routine and have it call
25822942 857@samp{add_language(@var{lang}_language_defn)} to tell the rest of @value{GDBN}
c906108c
SS
858that your language exists. You'll need some other supporting variables
859and functions, which will be used via pointers from your
860@code{@var{lang}_language_defn}. See the declaration of @code{struct
861language_defn} in @file{language.h}, and the other @file{*-exp.y} files,
862for more information.
863
864@item Add any evaluation routines, if necessary
865
56caf160
EZ
866@cindex expression evaluation routines
867@findex evaluate_subexp
868@findex prefixify_subexp
869@findex length_of_subexp
c906108c
SS
870If you need new opcodes (that represent the operations of the language),
871add them to the enumerated type in @file{expression.h}. Add support
56caf160
EZ
872code for these operations in the @code{evaluate_subexp} function
873defined in the file @file{eval.c}. Add cases
c906108c 874for new opcodes in two functions from @file{parse.c}:
56caf160 875@code{prefixify_subexp} and @code{length_of_subexp}. These compute
c906108c
SS
876the number of @code{exp_element}s that a given operation takes up.
877
878@item Update some existing code
879
880Add an enumerated identifier for your language to the enumerated type
881@code{enum language} in @file{defs.h}.
882
883Update the routines in @file{language.c} so your language is included.
884These routines include type predicates and such, which (in some cases)
885are language dependent. If your language does not appear in the switch
886statement, an error is reported.
887
56caf160 888@vindex current_language
c906108c
SS
889Also included in @file{language.c} is the code that updates the variable
890@code{current_language}, and the routines that translate the
891@code{language_@var{lang}} enumerated identifier into a printable
892string.
893
56caf160 894@findex _initialize_language
c906108c
SS
895Update the function @code{_initialize_language} to include your
896language. This function picks the default language upon startup, so is
25822942 897dependent upon which languages that @value{GDBN} is built for.
c906108c 898
56caf160 899@findex allocate_symtab
c906108c
SS
900Update @code{allocate_symtab} in @file{symfile.c} and/or symbol-reading
901code so that the language of each symtab (source file) is set properly.
902This is used to determine the language to use at each stack frame level.
903Currently, the language is set based upon the extension of the source
904file. If the language can be better inferred from the symbol
905information, please set the language of the symtab in the symbol-reading
906code.
907
56caf160
EZ
908@findex print_subexp
909@findex op_print_tab
910Add helper code to @code{print_subexp} (in @file{expprint.c}) to handle any new
c906108c
SS
911expression opcodes you have added to @file{expression.h}. Also, add the
912printed representations of your operators to @code{op_print_tab}.
913
914@item Add a place of call
915
56caf160 916@findex parse_exp_1
c906108c 917Add a call to @code{@var{lang}_parse()} and @code{@var{lang}_error} in
56caf160 918@code{parse_exp_1} (defined in @file{parse.c}).
c906108c
SS
919
920@item Use macros to trim code
921
56caf160 922@cindex trimming language-dependent code
25822942
DB
923The user has the option of building @value{GDBN} for some or all of the
924languages. If the user decides to build @value{GDBN} for the language
c906108c
SS
925@var{lang}, then every file dependent on @file{language.h} will have the
926macro @code{_LANG_@var{lang}} defined in it. Use @code{#ifdef}s to
927leave out large routines that the user won't need if he or she is not
928using your language.
929
25822942 930Note that you do not need to do this in your YACC parser, since if @value{GDBN}
c906108c 931is not build for @var{lang}, then @file{@var{lang}-exp.tab.o} (the
25822942 932compiled form of your parser) is not linked into @value{GDBN} at all.
c906108c 933
56caf160
EZ
934See the file @file{configure.in} for how @value{GDBN} is configured
935for different languages.
c906108c
SS
936
937@item Edit @file{Makefile.in}
938
939Add dependencies in @file{Makefile.in}. Make sure you update the macro
940variables such as @code{HFILES} and @code{OBJS}, otherwise your code may
941not get linked in, or, worse yet, it may not get @code{tar}red into the
942distribution!
c906108c
SS
943@end table
944
945
946@node Host Definition
947
948@chapter Host Definition
949
56caf160 950With the advent of Autoconf, it's rarely necessary to have host
c906108c
SS
951definition machinery anymore.
952
953@section Adding a New Host
954
56caf160
EZ
955@cindex adding a new host
956@cindex host, adding
957Most of @value{GDBN}'s host configuration support happens via
958Autoconf. New host-specific definitions should be rarely needed.
959@value{GDBN} still uses the host-specific definitions and files listed
960below, but these mostly exist for historical reasons, and should
961eventually disappear.
c906108c 962
25822942 963Several files control @value{GDBN}'s configuration for host systems:
c906108c
SS
964
965@table @file
56caf160 966@vindex XDEPFILES
c906108c
SS
967@item gdb/config/@var{arch}/@var{xyz}.mh
968Specifies Makefile fragments needed when hosting on machine @var{xyz}.
969In particular, this lists the required machine-dependent object files,
970by defining @samp{XDEPFILES=@dots{}}. Also specifies the header file
971which describes host @var{xyz}, by defining @code{XM_FILE=
972xm-@var{xyz}.h}. You can also define @code{CC}, @code{SYSV_DEFINE},
973@code{XM_CFLAGS}, @code{XM_ADD_FILES}, @code{XM_CLIBS}, @code{XM_CDEPS},
974etc.; see @file{Makefile.in}.
975
976@item gdb/config/@var{arch}/xm-@var{xyz}.h
56caf160 977(@file{xm.h} is a link to this file, created by @code{configure}). Contains C
c906108c
SS
978macro definitions describing the host system environment, such as byte
979order, host C compiler and library.
980
981@item gdb/@var{xyz}-xdep.c
982Contains any miscellaneous C code required for this machine as a host.
983On most machines it doesn't exist at all. If it does exist, put
984@file{@var{xyz}-xdep.o} into the @code{XDEPFILES} line in
985@file{gdb/config/@var{arch}/@var{xyz}.mh}.
c906108c
SS
986@end table
987
988@subheading Generic Host Support Files
989
56caf160 990@cindex generic host support
c906108c
SS
991There are some ``generic'' versions of routines that can be used by
992various systems. These can be customized in various ways by macros
993defined in your @file{xm-@var{xyz}.h} file. If these routines work for
994the @var{xyz} host, you can just include the generic file's name (with
995@samp{.o}, not @samp{.c}) in @code{XDEPFILES}.
996
997Otherwise, if your machine needs custom support routines, you will need
998to write routines that perform the same functions as the generic file.
999Put them into @code{@var{xyz}-xdep.c}, and put @code{@var{xyz}-xdep.o}
1000into @code{XDEPFILES}.
1001
1002@table @file
56caf160
EZ
1003@cindex remote debugging support
1004@cindex serial line support
c906108c
SS
1005@item ser-unix.c
1006This contains serial line support for Unix systems. This is always
1007included, via the makefile variable @code{SER_HARDWIRE}; override this
1008variable in the @file{.mh} file to avoid it.
1009
1010@item ser-go32.c
1011This contains serial line support for 32-bit programs running under DOS,
56caf160 1012using the DJGPP (a.k.a.@: GO32) execution environment.
c906108c 1013
56caf160 1014@cindex TCP remote support
c906108c
SS
1015@item ser-tcp.c
1016This contains generic TCP support using sockets.
c906108c
SS
1017@end table
1018
1019@section Host Conditionals
1020
56caf160
EZ
1021When @value{GDBN} is configured and compiled, various macros are
1022defined or left undefined, to control compilation based on the
1023attributes of the host system. These macros and their meanings (or if
1024the meaning is not documented here, then one of the source files where
1025they are used is indicated) are:
c906108c 1026
56caf160 1027@ftable @code
25822942 1028@item @value{GDBN}INIT_FILENAME
56caf160
EZ
1029The default name of @value{GDBN}'s initialization file (normally
1030@file{.gdbinit}).
c906108c
SS
1031
1032@item MEM_FNS_DECLARED
1033Your host config file defines this if it includes declarations of
1034@code{memcpy} and @code{memset}. Define this to avoid conflicts between
1035the native include files and the declarations in @file{defs.h}.
1036
cce74817
JM
1037@item NO_STD_REGS
1038This macro is deprecated.
1039
c906108c
SS
1040@item NO_SYS_FILE
1041Define this if your system does not have a @code{<sys/file.h>}.
1042
1043@item SIGWINCH_HANDLER
1044If your host defines @code{SIGWINCH}, you can define this to be the name
1045of a function to be called if @code{SIGWINCH} is received.
1046
1047@item SIGWINCH_HANDLER_BODY
1048Define this to expand into code that will define the function named by
1049the expansion of @code{SIGWINCH_HANDLER}.
1050
1051@item ALIGN_STACK_ON_STARTUP
56caf160 1052@cindex stack alignment
c906108c
SS
1053Define this if your system is of a sort that will crash in
1054@code{tgetent} if the stack happens not to be longword-aligned when
1055@code{main} is called. This is a rare situation, but is known to occur
1056on several different types of systems.
1057
1058@item CRLF_SOURCE_FILES
56caf160 1059@cindex DOS text files
c906108c
SS
1060Define this if host files use @code{\r\n} rather than @code{\n} as a
1061line terminator. This will cause source file listings to omit @code{\r}
56caf160
EZ
1062characters when printing and it will allow @code{\r\n} line endings of files
1063which are ``sourced'' by gdb. It must be possible to open files in binary
c906108c
SS
1064mode using @code{O_BINARY} or, for fopen, @code{"rb"}.
1065
1066@item DEFAULT_PROMPT
56caf160 1067@cindex prompt
c906108c
SS
1068The default value of the prompt string (normally @code{"(gdb) "}).
1069
1070@item DEV_TTY
56caf160 1071@cindex terminal device
c906108c
SS
1072The name of the generic TTY device, defaults to @code{"/dev/tty"}.
1073
1074@item FCLOSE_PROVIDED
1075Define this if the system declares @code{fclose} in the headers included
1076in @code{defs.h}. This isn't needed unless your compiler is unusually
1077anal.
1078
1079@item FOPEN_RB
1080Define this if binary files are opened the same way as text files.
1081
1082@item GETENV_PROVIDED
1083Define this if the system declares @code{getenv} in its headers included
56caf160 1084in @code{defs.h}. This isn't needed unless your compiler is unusually
c906108c
SS
1085anal.
1086
1087@item HAVE_MMAP
56caf160 1088@findex mmap
c906108c
SS
1089In some cases, use the system call @code{mmap} for reading symbol
1090tables. For some machines this allows for sharing and quick updates.
1091
1092@item HAVE_SIGSETMASK
56caf160 1093@findex sigsetmask
c906108c 1094Define this if the host system has job control, but does not define
56caf160 1095@code{sigsetmask}. Currently, this is only true of the RS/6000.
c906108c
SS
1096
1097@item HAVE_TERMIO
1098Define this if the host system has @code{termio.h}.
1099
1100@item HOST_BYTE_ORDER
56caf160 1101@cindex byte order
c906108c
SS
1102The ordering of bytes in the host. This must be defined to be either
1103@code{BIG_ENDIAN} or @code{LITTLE_ENDIAN}.
1104
1105@item INT_MAX
1106@item INT_MIN
1107@item LONG_MAX
1108@item UINT_MAX
1109@item ULONG_MAX
1110Values for host-side constants.
1111
1112@item ISATTY
1113Substitute for isatty, if not available.
1114
1115@item LONGEST
1116This is the longest integer type available on the host. If not defined,
1117it will default to @code{long long} or @code{long}, depending on
1118@code{CC_HAS_LONG_LONG}.
1119
1120@item CC_HAS_LONG_LONG
56caf160
EZ
1121@cindex @code{long long} data type
1122Define this if the host C compiler supports @code{long long}. This is set
1123by the @code{configure} script.
c906108c
SS
1124
1125@item PRINTF_HAS_LONG_LONG
1126Define this if the host can handle printing of long long integers via
56caf160
EZ
1127the printf format conversion specifier @code{ll}. This is set by the
1128@code{configure} script.
c906108c
SS
1129
1130@item HAVE_LONG_DOUBLE
56caf160
EZ
1131Define this if the host C compiler supports @code{long double}. This is
1132set by the @code{configure} script.
c906108c
SS
1133
1134@item PRINTF_HAS_LONG_DOUBLE
1135Define this if the host can handle printing of long double float-point
56caf160
EZ
1136numbers via the printf format conversion specifier @code{Lg}. This is
1137set by the @code{configure} script.
c906108c
SS
1138
1139@item SCANF_HAS_LONG_DOUBLE
1140Define this if the host can handle the parsing of long double
56caf160
EZ
1141float-point numbers via the scanf format conversion specifier
1142@code{Lg}. This is set by the @code{configure} script.
c906108c
SS
1143
1144@item LSEEK_NOT_LINEAR
1145Define this if @code{lseek (n)} does not necessarily move to byte number
1146@code{n} in the file. This is only used when reading source files. It
1147is normally faster to define @code{CRLF_SOURCE_FILES} when possible.
1148
1149@item L_SET
56caf160
EZ
1150This macro is used as the argument to @code{lseek} (or, most commonly,
1151@code{bfd_seek}). FIXME, should be replaced by SEEK_SET instead,
1152which is the POSIX equivalent.
c906108c 1153
c906108c
SS
1154@item MALLOC_INCOMPATIBLE
1155Define this if the system's prototype for @code{malloc} differs from the
56caf160 1156@sc{ansi} definition.
c906108c
SS
1157
1158@item MMAP_BASE_ADDRESS
1159When using HAVE_MMAP, the first mapping should go at this address.
1160
1161@item MMAP_INCREMENT
1162when using HAVE_MMAP, this is the increment between mappings.
1163
1164@item NEED_POSIX_SETPGID
56caf160 1165@findex setpgid
c906108c
SS
1166Define this to use the POSIX version of @code{setpgid} to determine
1167whether job control is available.
1168
1169@item NORETURN
1170If defined, this should be one or more tokens, such as @code{volatile},
1171that can be used in both the declaration and definition of functions to
1172indicate that they never return. The default is already set correctly
1173if compiling with GCC. This will almost never need to be defined.
1174
1175@item ATTR_NORETURN
1176If defined, this should be one or more tokens, such as
1177@code{__attribute__ ((noreturn))}, that can be used in the declarations
1178of functions to indicate that they never return. The default is already
1179set correctly if compiling with GCC. This will almost never need to be
1180defined.
1181
7a292a7a 1182@item USE_GENERIC_DUMMY_FRAMES
56caf160 1183@cindex generic dummy frames
7a292a7a
SS
1184Define this to 1 if the target is using the generic inferior function
1185call code. See @code{blockframe.c} for more information.
1186
c906108c 1187@item USE_MMALLOC
56caf160
EZ
1188@findex mmalloc
1189@value{GDBN} will use the @code{mmalloc} library for memory allocation
1190for symbol reading if this symbol is defined. Be careful defining it
1191since there are systems on which @code{mmalloc} does not work for some
1192reason. One example is the DECstation, where its RPC library can't
1193cope with our redefinition of @code{malloc} to call @code{mmalloc}.
1194When defining @code{USE_MMALLOC}, you will also have to set
1195@code{MMALLOC} in the Makefile, to point to the @code{mmalloc} library. This
1196define is set when you configure with @samp{--with-mmalloc}.
c906108c
SS
1197
1198@item NO_MMCHECK
56caf160 1199@findex mmcheck
c906108c
SS
1200Define this if you are using @code{mmalloc}, but don't want the overhead
1201of checking the heap with @code{mmcheck}. Note that on some systems,
56caf160 1202the C runtime makes calls to @code{malloc} prior to calling @code{main}, and if
c906108c
SS
1203@code{free} is ever called with these pointers after calling
1204@code{mmcheck} to enable checking, a memory corruption abort is certain
56caf160
EZ
1205to occur. These systems can still use @code{mmalloc}, but must define
1206@code{NO_MMCHECK}.
c906108c
SS
1207
1208@item MMCHECK_FORCE
1209Define this to 1 if the C runtime allocates memory prior to
1210@code{mmcheck} being called, but that memory is never freed so we don't
1211have to worry about it triggering a memory corruption abort. The
1212default is 0, which means that @code{mmcheck} will only install the heap
1213checking functions if there has not yet been any memory allocation
56caf160 1214calls, and if it fails to install the functions, @value{GDBN} will issue a
c906108c 1215warning. This is currently defined if you configure using
56caf160 1216@samp{--with-mmalloc}.
c906108c
SS
1217
1218@item NO_SIGINTERRUPT
56caf160
EZ
1219@findex siginterrupt
1220Define this to indicate that @code{siginterrupt} is not available.
c906108c
SS
1221
1222@item R_OK
56caf160 1223Define if this is not in a system header file (typically, @file{unistd.h}).
c906108c
SS
1224
1225@item SEEK_CUR
1226@item SEEK_SET
56caf160 1227Define these to appropriate value for the system @code{lseek}, if not already
c906108c
SS
1228defined.
1229
1230@item STOP_SIGNAL
56caf160
EZ
1231This is the signal for stopping @value{GDBN}. Defaults to
1232@code{SIGTSTP}. (Only redefined for the Convex.)
c906108c
SS
1233
1234@item USE_O_NOCTTY
56caf160 1235Define this if the interior's tty should be opened with the @code{O_NOCTTY}
c906108c
SS
1236flag. (FIXME: This should be a native-only flag, but @file{inflow.c} is
1237always linked in.)
1238
1239@item USG
1240Means that System V (prior to SVR4) include files are in use. (FIXME:
1241This symbol is abused in @file{infrun.c}, @file{regex.c},
1242@file{remote-nindy.c}, and @file{utils.c} for other things, at the
1243moment.)
1244
1245@item lint
56caf160 1246Define this to help placate @code{lint} in some situations.
c906108c
SS
1247
1248@item volatile
1249Define this to override the defaults of @code{__volatile__} or
1250@code{/**/}.
56caf160 1251@end ftable
c906108c
SS
1252
1253
1254@node Target Architecture Definition
1255
1256@chapter Target Architecture Definition
1257
56caf160
EZ
1258@cindex target architecture definition
1259@value{GDBN}'s target architecture defines what sort of
1260machine-language programs @value{GDBN} can work with, and how it works
1261with them.
c906108c
SS
1262
1263At present, the target architecture definition consists of a number of C
1264macros.
1265
1266@section Registers and Memory
1267
56caf160
EZ
1268@value{GDBN}'s model of the target machine is rather simple.
1269@value{GDBN} assumes the machine includes a bank of registers and a
1270block of memory. Each register may have a different size.
c906108c 1271
56caf160
EZ
1272@value{GDBN} does not have a magical way to match up with the
1273compiler's idea of which registers are which; however, it is critical
1274that they do match up accurately. The only way to make this work is
1275to get accurate information about the order that the compiler uses,
1276and to reflect that in the @code{REGISTER_NAME} and related macros.
c906108c 1277
25822942 1278@value{GDBN} can handle big-endian, little-endian, and bi-endian architectures.
c906108c 1279
93e79dbd
JB
1280@section Pointers Are Not Always Addresses
1281@cindex pointer representation
1282@cindex address representation
1283@cindex word-addressed machines
1284@cindex separate data and code address spaces
1285@cindex spaces, separate data and code address
1286@cindex address spaces, separate data and code
1287@cindex code pointers, word-addressed
1288@cindex converting between pointers and addresses
1289@cindex D10V addresses
1290
1291On almost all 32-bit architectures, the representation of a pointer is
1292indistinguishable from the representation of some fixed-length number
1293whose value is the byte address of the object pointed to. On such
56caf160 1294machines, the words ``pointer'' and ``address'' can be used interchangeably.
93e79dbd
JB
1295However, architectures with smaller word sizes are often cramped for
1296address space, so they may choose a pointer representation that breaks this
1297identity, and allows a larger code address space.
1298
1299For example, the Mitsubishi D10V is a 16-bit VLIW processor whose
1300instructions are 32 bits long@footnote{Some D10V instructions are
1301actually pairs of 16-bit sub-instructions. However, since you can't
1302jump into the middle of such a pair, code addresses can only refer to
1303full 32 bit instructions, which is what matters in this explanation.}.
1304If the D10V used ordinary byte addresses to refer to code locations,
1305then the processor would only be able to address 64kb of instructions.
1306However, since instructions must be aligned on four-byte boundaries, the
56caf160
EZ
1307low two bits of any valid instruction's byte address are always
1308zero---byte addresses waste two bits. So instead of byte addresses,
1309the D10V uses word addresses---byte addresses shifted right two bits---to
93e79dbd
JB
1310refer to code. Thus, the D10V can use 16-bit words to address 256kb of
1311code space.
1312
1313However, this means that code pointers and data pointers have different
1314forms on the D10V. The 16-bit word @code{0xC020} refers to byte address
1315@code{0xC020} when used as a data address, but refers to byte address
1316@code{0x30080} when used as a code address.
1317
1318(The D10V also uses separate code and data address spaces, which also
1319affects the correspondence between pointers and addresses, but we're
1320going to ignore that here; this example is already too long.)
1321
56caf160
EZ
1322To cope with architectures like this---the D10V is not the only
1323one!---@value{GDBN} tries to distinguish between @dfn{addresses}, which are
93e79dbd
JB
1324byte numbers, and @dfn{pointers}, which are the target's representation
1325of an address of a particular type of data. In the example above,
1326@code{0xC020} is the pointer, which refers to one of the addresses
1327@code{0xC020} or @code{0x30080}, depending on the type imposed upon it.
1328@value{GDBN} provides functions for turning a pointer into an address
1329and vice versa, in the appropriate way for the current architecture.
1330
1331Unfortunately, since addresses and pointers are identical on almost all
1332processors, this distinction tends to bit-rot pretty quickly. Thus,
1333each time you port @value{GDBN} to an architecture which does
1334distinguish between pointers and addresses, you'll probably need to
1335clean up some architecture-independent code.
1336
1337Here are functions which convert between pointers and addresses:
1338
1339@deftypefun CORE_ADDR extract_typed_address (void *@var{buf}, struct type *@var{type})
1340Treat the bytes at @var{buf} as a pointer or reference of type
1341@var{type}, and return the address it represents, in a manner
1342appropriate for the current architecture. This yields an address
1343@value{GDBN} can use to read target memory, disassemble, etc. Note that
1344@var{buf} refers to a buffer in @value{GDBN}'s memory, not the
1345inferior's.
1346
1347For example, if the current architecture is the Intel x86, this function
1348extracts a little-endian integer of the appropriate length from
1349@var{buf} and returns it. However, if the current architecture is the
1350D10V, this function will return a 16-bit integer extracted from
1351@var{buf}, multiplied by four if @var{type} is a pointer to a function.
1352
1353If @var{type} is not a pointer or reference type, then this function
1354will signal an internal error.
1355@end deftypefun
1356
1357@deftypefun CORE_ADDR store_typed_address (void *@var{buf}, struct type *@var{type}, CORE_ADDR @var{addr})
1358Store the address @var{addr} in @var{buf}, in the proper format for a
1359pointer of type @var{type} in the current architecture. Note that
1360@var{buf} refers to a buffer in @value{GDBN}'s memory, not the
1361inferior's.
1362
1363For example, if the current architecture is the Intel x86, this function
1364stores @var{addr} unmodified as a little-endian integer of the
1365appropriate length in @var{buf}. However, if the current architecture
1366is the D10V, this function divides @var{addr} by four if @var{type} is
1367a pointer to a function, and then stores it in @var{buf}.
1368
1369If @var{type} is not a pointer or reference type, then this function
1370will signal an internal error.
1371@end deftypefun
1372
1373@deftypefun CORE_ADDR value_as_pointer (value_ptr @var{val})
1374Assuming that @var{val} is a pointer, return the address it represents,
1375as appropriate for the current architecture.
1376
1377This function actually works on integral values, as well as pointers.
1378For pointers, it performs architecture-specific conversions as
1379described above for @code{extract_typed_address}.
1380@end deftypefun
1381
1382@deftypefun CORE_ADDR value_from_pointer (struct type *@var{type}, CORE_ADDR @var{addr})
1383Create and return a value representing a pointer of type @var{type} to
1384the address @var{addr}, as appropriate for the current architecture.
1385This function performs architecture-specific conversions as described
1386above for @code{store_typed_address}.
1387@end deftypefun
1388
1389
1390@value{GDBN} also provides functions that do the same tasks, but assume
1391that pointers are simply byte addresses; they aren't sensitive to the
1392current architecture, beyond knowing the appropriate endianness.
1393
1394@deftypefun CORE_ADDR extract_address (void *@var{addr}, int len)
1395Extract a @var{len}-byte number from @var{addr} in the appropriate
1396endianness for the current architecture, and return it. Note that
1397@var{addr} refers to @value{GDBN}'s memory, not the inferior's.
1398
1399This function should only be used in architecture-specific code; it
1400doesn't have enough information to turn bits into a true address in the
1401appropriate way for the current architecture. If you can, use
1402@code{extract_typed_address} instead.
1403@end deftypefun
1404
1405@deftypefun void store_address (void *@var{addr}, int @var{len}, LONGEST @var{val})
1406Store @var{val} at @var{addr} as a @var{len}-byte integer, in the
1407appropriate endianness for the current architecture. Note that
1408@var{addr} refers to a buffer in @value{GDBN}'s memory, not the
1409inferior's.
1410
1411This function should only be used in architecture-specific code; it
1412doesn't have enough information to turn a true address into bits in the
1413appropriate way for the current architecture. If you can, use
1414@code{store_typed_address} instead.
1415@end deftypefun
1416
1417
1418Here are some macros which architectures can define to indicate the
1419relationship between pointers and addresses. These have default
1420definitions, appropriate for architectures on which all pointers are
1421simple byte addresses.
1422
1423@deftypefn {Target Macro} CORE_ADDR POINTER_TO_ADDRESS (struct type *@var{type}, char *@var{buf})
1424Assume that @var{buf} holds a pointer of type @var{type}, in the
1425appropriate format for the current architecture. Return the byte
1426address the pointer refers to.
1427
1428This function may safely assume that @var{type} is either a pointer or a
56caf160 1429C@t{++} reference type.
93e79dbd
JB
1430@end deftypefn
1431
1432@deftypefn {Target Macro} void ADDRESS_TO_POINTER (struct type *@var{type}, char *@var{buf}, CORE_ADDR @var{addr})
1433Store in @var{buf} a pointer of type @var{type} representing the address
1434@var{addr}, in the appropriate format for the current architecture.
1435
1436This function may safely assume that @var{type} is either a pointer or a
56caf160 1437C@t{++} reference type.
93e79dbd
JB
1438@end deftypefn
1439
1440
9fb4dd36
JB
1441@section Using Different Register and Memory Data Representations
1442@cindex raw representation
1443@cindex virtual representation
1444@cindex representations, raw and virtual
1445@cindex register data formats, converting
1446@cindex @code{struct value}, converting register contents to
1447
1448Some architectures use one representation for a value when it lives in a
1449register, but use a different representation when it lives in memory.
25822942 1450In @value{GDBN}'s terminology, the @dfn{raw} representation is the one used in
9fb4dd36 1451the target registers, and the @dfn{virtual} representation is the one
25822942 1452used in memory, and within @value{GDBN} @code{struct value} objects.
9fb4dd36
JB
1453
1454For almost all data types on almost all architectures, the virtual and
1455raw representations are identical, and no special handling is needed.
1456However, they do occasionally differ. For example:
1457
1458@itemize @bullet
9fb4dd36 1459@item
56caf160 1460The x86 architecture supports an 80-bit @code{long double} type. However, when
9fb4dd36
JB
1461we store those values in memory, they occupy twelve bytes: the
1462floating-point number occupies the first ten, and the final two bytes
1463are unused. This keeps the values aligned on four-byte boundaries,
1464allowing more efficient access. Thus, the x86 80-bit floating-point
1465type is the raw representation, and the twelve-byte loosely-packed
1466arrangement is the virtual representation.
1467
1468@item
25822942
DB
1469Some 64-bit MIPS targets present 32-bit registers to @value{GDBN} as 64-bit
1470registers, with garbage in their upper bits. @value{GDBN} ignores the top 32
9fb4dd36
JB
1471bits. Thus, the 64-bit form, with garbage in the upper 32 bits, is the
1472raw representation, and the trimmed 32-bit representation is the
1473virtual representation.
9fb4dd36
JB
1474@end itemize
1475
1476In general, the raw representation is determined by the architecture, or
25822942
DB
1477@value{GDBN}'s interface to the architecture, while the virtual representation
1478can be chosen for @value{GDBN}'s convenience. @value{GDBN}'s register file,
56caf160
EZ
1479@code{registers}, holds the register contents in raw format, and the
1480@value{GDBN} remote protocol transmits register values in raw format.
9fb4dd36 1481
56caf160
EZ
1482Your architecture may define the following macros to request
1483conversions between the raw and virtual format:
9fb4dd36
JB
1484
1485@deftypefn {Target Macro} int REGISTER_CONVERTIBLE (int @var{reg})
1486Return non-zero if register number @var{reg}'s value needs different raw
1487and virtual formats.
6f6ef15a
EZ
1488
1489You should not use @code{REGISTER_CONVERT_TO_VIRTUAL} for a register
1490unless this macro returns a non-zero value for that register.
9fb4dd36
JB
1491@end deftypefn
1492
1493@deftypefn {Target Macro} int REGISTER_RAW_SIZE (int @var{reg})
1494The size of register number @var{reg}'s raw value. This is the number
25822942 1495of bytes the register will occupy in @code{registers}, or in a @value{GDBN}
9fb4dd36
JB
1496remote protocol packet.
1497@end deftypefn
1498
1499@deftypefn {Target Macro} int REGISTER_VIRTUAL_SIZE (int @var{reg})
1500The size of register number @var{reg}'s value, in its virtual format.
1501This is the size a @code{struct value}'s buffer will have, holding that
1502register's value.
1503@end deftypefn
1504
1505@deftypefn {Target Macro} struct type *REGISTER_VIRTUAL_TYPE (int @var{reg})
1506This is the type of the virtual representation of register number
1507@var{reg}. Note that there is no need for a macro giving a type for the
25822942 1508register's raw form; once the register's value has been obtained, @value{GDBN}
9fb4dd36
JB
1509always uses the virtual form.
1510@end deftypefn
1511
1512@deftypefn {Target Macro} void REGISTER_CONVERT_TO_VIRTUAL (int @var{reg}, struct type *@var{type}, char *@var{from}, char *@var{to})
1513Convert the value of register number @var{reg} to @var{type}, which
1514should always be @code{REGISTER_VIRTUAL_TYPE (@var{reg})}. The buffer
1515at @var{from} holds the register's value in raw format; the macro should
1516convert the value to virtual format, and place it at @var{to}.
1517
6f6ef15a
EZ
1518Note that @code{REGISTER_CONVERT_TO_VIRTUAL} and
1519@code{REGISTER_CONVERT_TO_RAW} take their @var{reg} and @var{type}
1520arguments in different orders.
1521
1522You should only use @code{REGISTER_CONVERT_TO_VIRTUAL} with registers
1523for which the @code{REGISTER_CONVERTIBLE} macro returns a non-zero
1524value.
9fb4dd36
JB
1525@end deftypefn
1526
1527@deftypefn {Target Macro} void REGISTER_CONVERT_TO_RAW (struct type *@var{type}, int @var{reg}, char *@var{from}, char *@var{to})
1528Convert the value of register number @var{reg} to @var{type}, which
1529should always be @code{REGISTER_VIRTUAL_TYPE (@var{reg})}. The buffer
1530at @var{from} holds the register's value in raw format; the macro should
1531convert the value to virtual format, and place it at @var{to}.
1532
1533Note that REGISTER_CONVERT_TO_VIRTUAL and REGISTER_CONVERT_TO_RAW take
1534their @var{reg} and @var{type} arguments in different orders.
1535@end deftypefn
1536
1537
c906108c
SS
1538@section Frame Interpretation
1539
1540@section Inferior Call Setup
1541
1542@section Compiler Characteristics
1543
1544@section Target Conditionals
1545
1546This section describes the macros that you can use to define the target
1547machine.
1548
1549@table @code
1550
1551@item ADDITIONAL_OPTIONS
56caf160
EZ
1552@itemx ADDITIONAL_OPTION_CASES
1553@itemx ADDITIONAL_OPTION_HANDLER
1554@itemx ADDITIONAL_OPTION_HELP
1555@findex ADDITIONAL_OPTION_HELP
1556@findex ADDITIONAL_OPTION_HANDLER
1557@findex ADDITIONAL_OPTION_CASES
1558@findex ADDITIONAL_OPTIONS
c906108c 1559These are a set of macros that allow the addition of additional command
25822942 1560line options to @value{GDBN}. They are currently used only for the unsupported
c906108c
SS
1561i960 Nindy target, and should not be used in any other configuration.
1562
1563@item ADDR_BITS_REMOVE (addr)
56caf160 1564@findex ADDR_BITS_REMOVE
adf40b2e
JM
1565If a raw machine instruction address includes any bits that are not
1566really part of the address, then define this macro to expand into an
56caf160 1567expression that zeroes those bits in @var{addr}. This is only used for
adf40b2e
JM
1568addresses of instructions, and even then not in all contexts.
1569
1570For example, the two low-order bits of the PC on the Hewlett-Packard PA
15712.0 architecture contain the privilege level of the corresponding
1572instruction. Since instructions must always be aligned on four-byte
1573boundaries, the processor masks out these bits to generate the actual
1574address of the instruction. ADDR_BITS_REMOVE should filter out these
1575bits with an expression such as @code{((addr) & ~3)}.
c906108c 1576
93e79dbd 1577@item ADDRESS_TO_POINTER (@var{type}, @var{buf}, @var{addr})
56caf160 1578@findex ADDRESS_TO_POINTER
93e79dbd
JB
1579Store in @var{buf} a pointer of type @var{type} representing the address
1580@var{addr}, in the appropriate format for the current architecture.
1581This macro may safely assume that @var{type} is either a pointer or a
56caf160 1582C@t{++} reference type.
93e79dbd
JB
1583@xref{Target Architecture Definition, , Pointers Are Not Always Addresses}.
1584
c906108c 1585@item BEFORE_MAIN_LOOP_HOOK
56caf160 1586@findex BEFORE_MAIN_LOOP_HOOK
c906108c
SS
1587Define this to expand into any code that you want to execute before the
1588main loop starts. Although this is not, strictly speaking, a target
1589conditional, that is how it is currently being used. Note that if a
1590configuration were to define it one way for a host and a different way
56caf160
EZ
1591for the target, @value{GDBN} will probably not compile, let alone run
1592correctly. This macro is currently used only for the unsupported i960 Nindy
1593target, and should not be used in any other configuration.
c906108c
SS
1594
1595@item BELIEVE_PCC_PROMOTION
56caf160
EZ
1596@findex BELIEVE_PCC_PROMOTION
1597Define if the compiler promotes a @code{short} or @code{char}
1598parameter to an @code{int}, but still reports the parameter as its
1599original type, rather than the promoted type.
c906108c
SS
1600
1601@item BELIEVE_PCC_PROMOTION_TYPE
56caf160
EZ
1602@findex BELIEVE_PCC_PROMOTION_TYPE
1603Define this if @value{GDBN} should believe the type of a @code{short}
1604argument when compiled by @code{pcc}, but look within a full int space to get
1605its value. Only defined for Sun-3 at present.
c906108c
SS
1606
1607@item BITS_BIG_ENDIAN
56caf160
EZ
1608@findex BITS_BIG_ENDIAN
1609Define this if the numbering of bits in the targets does @strong{not} match the
c906108c 1610endianness of the target byte order. A value of 1 means that the bits
56caf160 1611are numbered in a big-endian bit order, 0 means little-endian.
c906108c
SS
1612
1613@item BREAKPOINT
56caf160 1614@findex BREAKPOINT
c906108c
SS
1615This is the character array initializer for the bit pattern to put into
1616memory where a breakpoint is set. Although it's common to use a trap
1617instruction for a breakpoint, it's not required; for instance, the bit
1618pattern could be an invalid instruction. The breakpoint must be no
1619longer than the shortest instruction of the architecture.
1620
56caf160
EZ
1621@code{BREAKPOINT} has been deprecated in favor of
1622@code{BREAKPOINT_FROM_PC}.
7a292a7a 1623
c906108c 1624@item BIG_BREAKPOINT
56caf160
EZ
1625@itemx LITTLE_BREAKPOINT
1626@findex LITTLE_BREAKPOINT
1627@findex BIG_BREAKPOINT
c906108c
SS
1628Similar to BREAKPOINT, but used for bi-endian targets.
1629
56caf160
EZ
1630@code{BIG_BREAKPOINT} and @code{LITTLE_BREAKPOINT} have been deprecated in
1631favor of @code{BREAKPOINT_FROM_PC}.
7a292a7a 1632
c906108c 1633@item REMOTE_BREAKPOINT
56caf160
EZ
1634@itemx LITTLE_REMOTE_BREAKPOINT
1635@itemx BIG_REMOTE_BREAKPOINT
1636@findex BIG_REMOTE_BREAKPOINT
1637@findex LITTLE_REMOTE_BREAKPOINT
1638@findex REMOTE_BREAKPOINT
c906108c
SS
1639Similar to BREAKPOINT, but used for remote targets.
1640
56caf160
EZ
1641@code{BIG_REMOTE_BREAKPOINT} and @code{LITTLE_REMOTE_BREAKPOINT} have been
1642deprecated in favor of @code{BREAKPOINT_FROM_PC}.
c906108c 1643
56caf160
EZ
1644@item BREAKPOINT_FROM_PC (@var{pcptr}, @var{lenptr})
1645@findex BREAKPOINT_FROM_PC
c906108c 1646Use the program counter to determine the contents and size of a
56caf160
EZ
1647breakpoint instruction. It returns a pointer to a string of bytes
1648that encode a breakpoint instruction, stores the length of the string
1649to *@var{lenptr}, and adjusts pc (if necessary) to point to the actual
1650memory location where the breakpoint should be inserted.
c906108c
SS
1651
1652Although it is common to use a trap instruction for a breakpoint, it's
1653not required; for instance, the bit pattern could be an invalid
1654instruction. The breakpoint must be no longer than the shortest
1655instruction of the architecture.
1656
7a292a7a
SS
1657Replaces all the other @var{BREAKPOINT} macros.
1658
56caf160
EZ
1659@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
1660@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
1661@findex MEMORY_REMOVE_BREAKPOINT
1662@findex MEMORY_INSERT_BREAKPOINT
917317f4
JM
1663Insert or remove memory based breakpoints. Reasonable defaults
1664(@code{default_memory_insert_breakpoint} and
1665@code{default_memory_remove_breakpoint} respectively) have been
1666provided so that it is not necessary to define these for most
1667architectures. Architectures which may want to define
56caf160 1668@code{MEMORY_INSERT_BREAKPOINT} and @code{MEMORY_REMOVE_BREAKPOINT} will
917317f4
JM
1669likely have instructions that are oddly sized or are not stored in a
1670conventional manner.
1671
1672It may also be desirable (from an efficiency standpoint) to define
1673custom breakpoint insertion and removal routines if
56caf160 1674@code{BREAKPOINT_FROM_PC} needs to read the target's memory for some
917317f4
JM
1675reason.
1676
7a292a7a 1677@item CALL_DUMMY_P
56caf160 1678@findex CALL_DUMMY_P
7a292a7a
SS
1679A C expresson that is non-zero when the target suports inferior function
1680calls.
1681
1682@item CALL_DUMMY_WORDS
56caf160
EZ
1683@findex CALL_DUMMY_WORDS
1684Pointer to an array of @code{LONGEST} words of data containing
1685host-byte-ordered @code{REGISTER_BYTES} sized values that partially
7a292a7a
SS
1686specify the sequence of instructions needed for an inferior function
1687call.
1688
56caf160 1689Should be deprecated in favor of a macro that uses target-byte-ordered
7a292a7a
SS
1690data.
1691
1692@item SIZEOF_CALL_DUMMY_WORDS
56caf160
EZ
1693@findex SIZEOF_CALL_DUMMY_WORDS
1694The size of @code{CALL_DUMMY_WORDS}. When @code{CALL_DUMMY_P} this must
1695return a positive value. See also @code{CALL_DUMMY_LENGTH}.
c906108c
SS
1696
1697@item CALL_DUMMY
56caf160
EZ
1698@findex CALL_DUMMY
1699A static initializer for @code{CALL_DUMMY_WORDS}. Deprecated.
7a292a7a 1700
c906108c 1701@item CALL_DUMMY_LOCATION
56caf160
EZ
1702@findex CALL_DUMMY_LOCATION
1703See the file @file{inferior.h}.
7a292a7a 1704
c906108c 1705@item CALL_DUMMY_STACK_ADJUST
56caf160 1706@findex CALL_DUMMY_STACK_ADJUST
7a292a7a
SS
1707Stack adjustment needed when performing an inferior function call.
1708
56caf160 1709Should be deprecated in favor of something like @code{STACK_ALIGN}.
7a292a7a
SS
1710
1711@item CALL_DUMMY_STACK_ADJUST_P
56caf160
EZ
1712@findex CALL_DUMMY_STACK_ADJUST_P
1713Predicate for use of @code{CALL_DUMMY_STACK_ADJUST}.
7a292a7a 1714
56caf160 1715Should be deprecated in favor of something like @code{STACK_ALIGN}.
c906108c 1716
56caf160
EZ
1717@item CANNOT_FETCH_REGISTER (@var{regno})
1718@findex CANNOT_FETCH_REGISTER
c906108c
SS
1719A C expression that should be nonzero if @var{regno} cannot be fetched
1720from an inferior process. This is only relevant if
1721@code{FETCH_INFERIOR_REGISTERS} is not defined.
1722
56caf160
EZ
1723@item CANNOT_STORE_REGISTER (@var{regno})
1724@findex CANNOT_STORE_REGISTER
c906108c
SS
1725A C expression that should be nonzero if @var{regno} should not be
1726written to the target. This is often the case for program counters,
56caf160
EZ
1727status words, and other special registers. If this is not defined,
1728@value{GDBN} will assume that all registers may be written.
c906108c
SS
1729
1730@item DO_DEFERRED_STORES
56caf160
EZ
1731@itemx CLEAR_DEFERRED_STORES@item
1732@findex CLEAR_DEFERRED_STORES
1733@findex DO_DEFERRED_STORES
c906108c
SS
1734Define this to execute any deferred stores of registers into the inferior,
1735and to cancel any deferred stores.
1736
1737Currently only implemented correctly for native Sparc configurations?
1738
ef36d45e 1739@item COERCE_FLOAT_TO_DOUBLE (@var{formal}, @var{actual})
56caf160
EZ
1740@findex COERCE_FLOAT_TO_DOUBLE
1741@cindex promotion to @code{double}
ef36d45e
JB
1742If we are calling a function by hand, and the function was declared
1743(according to the debug info) without a prototype, should we
56caf160
EZ
1744automatically promote @code{float}s to @code{double}s? This macro
1745must evaluate to non-zero if we should, or zero if we should leave the
1746value alone.
ef36d45e
JB
1747
1748The argument @var{actual} is the type of the value we want to pass to
1749the function. The argument @var{formal} is the type of this argument,
1750as it appears in the function's definition. Note that @var{formal} may
1751be zero if we have no debugging information for the function, or if
1752we're passing more arguments than are officially declared (for example,
1753varargs). This macro is never invoked if the function definitely has a
1754prototype.
1755
56caf160
EZ
1756@findex set_gdbarch_coerce_float_to_double
1757@findex standard_coerce_float_to_double
ef36d45e
JB
1758The default behavior is to promote only when we have no type information
1759for the formal parameter. This is different from the obvious behavior,
1760which would be to promote whenever we have no prototype, just as the
1761compiler does. It's annoying, but some older targets rely on this. If
56caf160
EZ
1762you want @value{GDBN} to follow the typical compiler behavior---to always
1763promote when there is no prototype in scope---your gdbarch @code{init}
ef36d45e
JB
1764function can call @code{set_gdbarch_coerce_float_to_double} and select
1765the @code{standard_coerce_float_to_double} function.
1766
c906108c 1767@item CPLUS_MARKER
56caf160
EZ
1768@findex CPLUS_MARKERz
1769Define this to expand into the character that G@t{++} uses to distinguish
c906108c
SS
1770compiler-generated identifiers from programmer-specified identifiers.
1771By default, this expands into @code{'$'}. Most System V targets should
1772define this to @code{'.'}.
1773
1774@item DBX_PARM_SYMBOL_CLASS
56caf160 1775@findex DBX_PARM_SYMBOL_CLASS
c906108c
SS
1776Hook for the @code{SYMBOL_CLASS} of a parameter when decoding DBX symbol
1777information. In the i960, parameters can be stored as locals or as
1778args, depending on the type of the debug record.
1779
1780@item DECR_PC_AFTER_BREAK
56caf160 1781@findex DECR_PC_AFTER_BREAK
c906108c
SS
1782Define this to be the amount by which to decrement the PC after the
1783program encounters a breakpoint. This is often the number of bytes in
56caf160 1784@code{BREAKPOINT}, though not always. For most targets this value will be 0.
c906108c
SS
1785
1786@item DECR_PC_AFTER_HW_BREAK
56caf160 1787@findex DECR_PC_AFTER_HW_BREAK
c906108c
SS
1788Similarly, for hardware breakpoints.
1789
56caf160
EZ
1790@item DISABLE_UNSETTABLE_BREAK (@var{addr})
1791@findex DISABLE_UNSETTABLE_BREAK
c906108c
SS
1792If defined, this should evaluate to 1 if @var{addr} is in a shared
1793library in which breakpoints cannot be set and so should be disabled.
1794
1795@item DO_REGISTERS_INFO
56caf160 1796@findex DO_REGISTERS_INFO
c906108c
SS
1797If defined, use this to print the value of a register or all registers.
1798
0dcedd82 1799@item DWARF_REG_TO_REGNUM
56caf160 1800@findex DWARF_REG_TO_REGNUM
0dcedd82
AC
1801Convert DWARF register number into @value{GDBN} regnum. If not defined,
1802no conversion will be performed.
1803
1804@item DWARF2_REG_TO_REGNUM
56caf160 1805@findex DWARF2_REG_TO_REGNUM
0dcedd82
AC
1806Convert DWARF2 register number into @value{GDBN} regnum. If not
1807defined, no conversion will be performed.
1808
1809@item ECOFF_REG_TO_REGNUM
56caf160 1810@findex ECOFF_REG_TO_REGNUM
0dcedd82
AC
1811Convert ECOFF register number into @value{GDBN} regnum. If not defined,
1812no conversion will be performed.
1813
c906108c 1814@item END_OF_TEXT_DEFAULT
56caf160
EZ
1815@findex END_OF_TEXT_DEFAULT
1816This is an expression that should designate the end of the text section.
1817@c (? FIXME ?)
c906108c 1818
56caf160
EZ
1819@item EXTRACT_RETURN_VALUE(@var{type}, @var{regbuf}, @var{valbuf})
1820@findex EXTRACT_RETURN_VALUE
c906108c
SS
1821Define this to extract a function's return value of type @var{type} from
1822the raw register state @var{regbuf} and copy that, in virtual format,
1823into @var{valbuf}.
1824
56caf160
EZ
1825@item EXTRACT_STRUCT_VALUE_ADDRESS(@var{regbuf})
1826@findex EXTRACT_STRUCT_VALUE_ADDRESS
1827When @code{EXTRACT_STRUCT_VALUE_ADDRESS_P} is non-zero, this is used to extract
ac9a91a7
JM
1828from an array @var{regbuf} (containing the raw register state) the
1829address in which a function should return its structure value, as a
56caf160 1830@code{CORE_ADDR} (or an expression that can be used as one).
ac9a91a7
JM
1831
1832@item EXTRACT_STRUCT_VALUE_ADDRESS_P
56caf160
EZ
1833@findex EXTRACT_STRUCT_VALUE_ADDRESS_P
1834Predicate for @code{EXTRACT_STRUCT_VALUE_ADDRESS}.
c906108c
SS
1835
1836@item FLOAT_INFO
56caf160
EZ
1837@findex FLOAT_INFO
1838If defined, then the @samp{info float} command will print information about
c906108c
SS
1839the processor's floating point unit.
1840
1841@item FP_REGNUM
56caf160 1842@findex FP_REGNUM
cce74817
JM
1843If the virtual frame pointer is kept in a register, then define this
1844macro to be the number (greater than or equal to zero) of that register.
1845
1846This should only need to be defined if @code{TARGET_READ_FP} and
1847@code{TARGET_WRITE_FP} are not defined.
c906108c 1848
56caf160
EZ
1849@item FRAMELESS_FUNCTION_INVOCATION(@var{fi})
1850@findex FRAMELESS_FUNCTION_INVOCATION
392a587b
JM
1851Define this to an expression that returns 1 if the function invocation
1852represented by @var{fi} does not have a stack frame associated with it.
1853Otherwise return 0.
c906108c 1854
56caf160
EZ
1855@item FRAME_ARGS_ADDRESS_CORRECT@item
1856@findex FRAME_ARGS_ADDRESS_CORRECT
1857See @file{stack.c}.
c906108c 1858
56caf160
EZ
1859@item FRAME_CHAIN(@var{frame})
1860@findex FRAME_CHAIN
c906108c
SS
1861Given @var{frame}, return a pointer to the calling frame.
1862
56caf160
EZ
1863@item FRAME_CHAIN_COMBINE(@var{chain}, @var{frame})
1864@findex FRAME_CHAIN_COMBINE
c906108c
SS
1865Define this to take the frame chain pointer and the frame's nominal
1866address and produce the nominal address of the caller's frame.
1867Presently only defined for HP PA.
1868
56caf160
EZ
1869@item FRAME_CHAIN_VALID(@var{chain}, @var{thisframe})
1870@findex FRAME_CHAIN_VALID
c906108c 1871Define this to be an expression that returns zero if the given frame is
c4093a6a 1872an outermost frame, with no caller, and nonzero otherwise. Several
56caf160 1873common definitions are available:
c4093a6a 1874
56caf160
EZ
1875@itemize @bullet
1876@item
c4093a6a
JM
1877@code{file_frame_chain_valid} is nonzero if the chain pointer is nonzero
1878and given frame's PC is not inside the startup file (such as
56caf160
EZ
1879@file{crt0.o}).
1880
1881@item
1882@code{func_frame_chain_valid} is nonzero if the chain
1883pointer is nonzero and the given frame's PC is not in @code{main} or a
1884known entry point function (such as @code{_start}).
1885
1886@item
c4093a6a
JM
1887@code{generic_file_frame_chain_valid} and
1888@code{generic_func_frame_chain_valid} are equivalent implementations for
1889targets using generic dummy frames.
56caf160 1890@end itemize
c906108c 1891
56caf160
EZ
1892@item FRAME_INIT_SAVED_REGS(@var{frame})
1893@findex FRAME_INIT_SAVED_REGS
c906108c
SS
1894See @file{frame.h}. Determines the address of all registers in the
1895current stack frame storing each in @code{frame->saved_regs}. Space for
1896@code{frame->saved_regs} shall be allocated by
1897@code{FRAME_INIT_SAVED_REGS} using either
1898@code{frame_saved_regs_zalloc} or @code{frame_obstack_alloc}.
1899
56caf160 1900@code{FRAME_FIND_SAVED_REGS} and @code{EXTRA_FRAME_INFO} are deprecated.
c906108c 1901
56caf160
EZ
1902@item FRAME_NUM_ARGS (@var{fi})
1903@findex FRAME_NUM_ARGS
392a587b
JM
1904For the frame described by @var{fi} return the number of arguments that
1905are being passed. If the number of arguments is not known, return
1906@code{-1}.
c906108c 1907
56caf160
EZ
1908@item FRAME_SAVED_PC(@var{frame})
1909@findex FRAME_SAVED_PC
1910Given @var{frame}, return the pc saved there. This is the return
c906108c
SS
1911address.
1912
1913@item FUNCTION_EPILOGUE_SIZE
56caf160 1914@findex FUNCTION_EPILOGUE_SIZE
c906108c
SS
1915For some COFF targets, the @code{x_sym.x_misc.x_fsize} field of the
1916function end symbol is 0. For such targets, you must define
1917@code{FUNCTION_EPILOGUE_SIZE} to expand into the standard size of a
1918function's epilogue.
1919
f7cb2b90 1920@item FUNCTION_START_OFFSET
56caf160 1921@findex FUNCTION_START_OFFSET
f7cb2b90
JB
1922An integer, giving the offset in bytes from a function's address (as
1923used in the values of symbols, function pointers, etc.), and the
1924function's first genuine instruction.
1925
1926This is zero on almost all machines: the function's address is usually
1927the address of its first instruction. However, on the VAX, for example,
1928each function starts with two bytes containing a bitmask indicating
1929which registers to save upon entry to the function. The VAX @code{call}
1930instructions check this value, and save the appropriate registers
1931automatically. Thus, since the offset from the function's address to
1932its first instruction is two bytes, @code{FUNCTION_START_OFFSET} would
1933be 2 on the VAX.
1934
c906108c 1935@item GCC_COMPILED_FLAG_SYMBOL
56caf160
EZ
1936@itemx GCC2_COMPILED_FLAG_SYMBOL
1937@findex GCC2_COMPILED_FLAG_SYMBOL
1938@findex GCC_COMPILED_FLAG_SYMBOL
1939If defined, these are the names of the symbols that @value{GDBN} will
1940look for to detect that GCC compiled the file. The default symbols
1941are @code{gcc_compiled.} and @code{gcc2_compiled.},
1942respectively. (Currently only defined for the Delta 68.)
c906108c 1943
25822942 1944@item @value{GDBN}_MULTI_ARCH
56caf160 1945@findex @value{GDBN}_MULTI_ARCH
0f71a2f6 1946If defined and non-zero, enables suport for multiple architectures
25822942 1947within @value{GDBN}.
0f71a2f6 1948
56caf160 1949This support can be enabled at two levels. At level one, only
0f71a2f6
JM
1950definitions for previously undefined macros are provided; at level two,
1951a multi-arch definition of all architecture dependant macros will be
1952defined.
1953
25822942 1954@item @value{GDBN}_TARGET_IS_HPPA
56caf160
EZ
1955@findex @value{GDBN}_TARGET_IS_HPPA
1956This determines whether horrible kludge code in @file{dbxread.c} and
1957@file{partial-stab.h} is used to mangle multiple-symbol-table files from
1958HPPA's. This should all be ripped out, and a scheme like @file{elfread.c}
1959used instead.
c906108c 1960
c906108c 1961@item GET_LONGJMP_TARGET
56caf160 1962@findex GET_LONGJMP_TARGET
c906108c
SS
1963For most machines, this is a target-dependent parameter. On the
1964DECstation and the Iris, this is a native-dependent parameter, since
56caf160 1965trhe header file @file{setjmp.h} is needed to define it.
c906108c 1966
56caf160
EZ
1967This macro determines the target PC address that @code{longjmp} will jump to,
1968assuming that we have just stopped at a @code{longjmp} breakpoint. It takes a
1969@code{CORE_ADDR *} as argument, and stores the target PC value through this
c906108c
SS
1970pointer. It examines the current state of the machine as needed.
1971
1972@item GET_SAVED_REGISTER
56caf160
EZ
1973@findex GET_SAVED_REGISTER
1974@findex get_saved_register
c906108c 1975Define this if you need to supply your own definition for the function
7a292a7a 1976@code{get_saved_register}.
c906108c
SS
1977
1978@item HAVE_REGISTER_WINDOWS
56caf160 1979@findex HAVE_REGISTER_WINDOWS
c906108c 1980Define this if the target has register windows.
56caf160
EZ
1981
1982@item REGISTER_IN_WINDOW_P (@var{regnum})
1983@findex REGISTER_IN_WINDOW_P
c906108c
SS
1984Define this to be an expression that is 1 if the given register is in
1985the window.
1986
1987@item IBM6000_TARGET
56caf160 1988@findex IBM6000_TARGET
c906108c
SS
1989Shows that we are configured for an IBM RS/6000 target. This
1990conditional should be eliminated (FIXME) and replaced by
56caf160 1991feature-specific macros. It was introduced in a haste and we are
c906108c
SS
1992repenting at leisure.
1993
2df3850c 1994@item SYMBOLS_CAN_START_WITH_DOLLAR
56caf160 1995@findex SYMBOLS_CAN_START_WITH_DOLLAR
2df3850c 1996Some systems have routines whose names start with @samp{$}. Giving this
25822942 1997macro a non-zero value tells @value{GDBN}'s expression parser to check for such
2df3850c
JM
1998routines when parsing tokens that begin with @samp{$}.
1999
2000On HP-UX, certain system routines (millicode) have names beginning with
2001@samp{$} or @samp{$$}. For example, @code{$$dyncall} is a millicode
2002routine that handles inter-space procedure calls on PA-RISC.
2003
c906108c 2004@item IEEE_FLOAT
56caf160 2005@findex IEEE_FLOAT
c906108c
SS
2006Define this if the target system uses IEEE-format floating point numbers.
2007
56caf160
EZ
2008@item INIT_EXTRA_FRAME_INFO (@var{fromleaf}, @var{frame})
2009@findex INIT_EXTRA_FRAME_INFO
c906108c
SS
2010If additional information about the frame is required this should be
2011stored in @code{frame->extra_info}. Space for @code{frame->extra_info}
2012is allocated using @code{frame_obstack_alloc}.
2013
56caf160
EZ
2014@item INIT_FRAME_PC (@var{fromleaf}, @var{prev})
2015@findex INIT_FRAME_PC
c906108c
SS
2016This is a C statement that sets the pc of the frame pointed to by
2017@var{prev}. [By default...]
2018
56caf160
EZ
2019@item INNER_THAN (@var{lhs}, @var{rhs})
2020@findex INNER_THAN
c906108c
SS
2021Returns non-zero if stack address @var{lhs} is inner than (nearer to the
2022stack top) stack address @var{rhs}. Define this as @code{lhs < rhs} if
2023the target's stack grows downward in memory, or @code{lhs > rsh} if the
2024stack grows upward.
2025
56caf160
EZ
2026@item IN_SIGTRAMP (@var{pc}, @var{name})
2027@findex IN_SIGTRAMP
2028Define this to return non-zero if the given @var{pc} and/or @var{name}
2029indicates that the current function is a @code{sigtramp}.
c906108c 2030
56caf160
EZ
2031@item SIGTRAMP_START (@var{pc})
2032@findex SIGTRAMP_START
2033@itemx SIGTRAMP_END (@var{pc})
2034@findex SIGTRAMP_END
2035Define these to be the start and end address of the @code{sigtramp} for the
c906108c
SS
2036given @var{pc}. On machines where the address is just a compile time
2037constant, the macro expansion will typically just ignore the supplied
2038@var{pc}.
2039
56caf160
EZ
2040@item IN_SOLIB_CALL_TRAMPOLINE (@var{pc}, @var{name})
2041@findex IN_SOLIB_CALL_TRAMPOLINE
c906108c
SS
2042Define this to evaluate to nonzero if the program is stopped in the
2043trampoline that connects to a shared library.
2044
56caf160
EZ
2045@item IN_SOLIB_RETURN_TRAMPOLINE (@var{pc}, @var{name})
2046@findex IN_SOLIB_RETURN_TRAMPOLINE
c906108c
SS
2047Define this to evaluate to nonzero if the program is stopped in the
2048trampoline that returns from a shared library.
2049
56caf160
EZ
2050@item IN_SOLIB_DYNSYM_RESOLVE_CODE (@var{pc})
2051@findex IN_SOLIB_DYNSYM_RESOLVE_CODE
d4f3574e
SS
2052Define this to evaluate to nonzero if the program is stopped in the
2053dynamic linker.
2054
56caf160
EZ
2055@item SKIP_SOLIB_RESOLVER (@var{pc})
2056@findex SKIP_SOLIB_RESOLVER
d4f3574e
SS
2057Define this to evaluate to the (nonzero) address at which execution
2058should continue to get past the dynamic linker's symbol resolution
2059function. A zero value indicates that it is not important or necessary
2060to set a breakpoint to get through the dynamic linker and that single
2061stepping will suffice.
2062
56caf160
EZ
2063@item IS_TRAPPED_INTERNALVAR (@var{name})
2064@findex IS_TRAPPED_INTERNALVAR
c906108c
SS
2065This is an ugly hook to allow the specification of special actions that
2066should occur as a side-effect of setting the value of a variable
25822942 2067internal to @value{GDBN}. Currently only used by the h8500. Note that this
c906108c
SS
2068could be either a host or target conditional.
2069
2070@item NEED_TEXT_START_END
56caf160 2071@findex NEED_TEXT_START_END
25822942 2072Define this if @value{GDBN} should determine the start and end addresses of the
c906108c
SS
2073text section. (Seems dubious.)
2074
2075@item NO_HIF_SUPPORT
56caf160 2076@findex NO_HIF_SUPPORT
c906108c
SS
2077(Specific to the a29k.)
2078
93e79dbd 2079@item POINTER_TO_ADDRESS (@var{type}, @var{buf})
56caf160 2080@findex POINTER_TO_ADDRESS
93e79dbd
JB
2081Assume that @var{buf} holds a pointer of type @var{type}, in the
2082appropriate format for the current architecture. Return the byte
2083address the pointer refers to.
2084@xref{Target Architecture Definition, , Pointers Are Not Always Addresses}.
2085
9fb4dd36 2086@item REGISTER_CONVERTIBLE (@var{reg})
56caf160 2087@findex REGISTER_CONVERTIBLE
9fb4dd36 2088Return non-zero if @var{reg} uses different raw and virtual formats.
4281a42e 2089@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36
JB
2090
2091@item REGISTER_RAW_SIZE (@var{reg})
56caf160 2092@findex REGISTER_RAW_SIZE
9fb4dd36 2093Return the raw size of @var{reg}.
4281a42e 2094@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36
JB
2095
2096@item REGISTER_VIRTUAL_SIZE (@var{reg})
56caf160 2097@findex REGISTER_VIRTUAL_SIZE
9fb4dd36 2098Return the virtual size of @var{reg}.
4281a42e 2099@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36
JB
2100
2101@item REGISTER_VIRTUAL_TYPE (@var{reg})
56caf160 2102@findex REGISTER_VIRTUAL_TYPE
9fb4dd36 2103Return the virtual type of @var{reg}.
4281a42e 2104@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36
JB
2105
2106@item REGISTER_CONVERT_TO_VIRTUAL(@var{reg}, @var{type}, @var{from}, @var{to})
56caf160 2107@findex REGISTER_CONVERT_TO_VIRTUAL
9fb4dd36 2108Convert the value of register @var{reg} from its raw form to its virtual
4281a42e
JB
2109form.
2110@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36
JB
2111
2112@item REGISTER_CONVERT_TO_RAW(@var{type}, @var{reg}, @var{from}, @var{to})
56caf160 2113@findex REGISTER_CONVERT_TO_RAW
9fb4dd36 2114Convert the value of register @var{reg} from its virtual form to its raw
4281a42e
JB
2115form.
2116@xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}.
9fb4dd36 2117
e5419804
JB
2118@item RETURN_VALUE_ON_STACK(@var{type})
2119@findex RETURN_VALUE_ON_STACK
2120@cindex returning structures by value
2121@cindex structures, returning by value
2122
2123Return non-zero if values of type TYPE are returned on the stack, using
2124the ``struct convention'' (i.e., the caller provides a pointer to a
2125buffer in which the callee should store the return value). This
2126controls how the @samp{finish} command finds a function's return value,
2127and whether an inferior function call reserves space on the stack for
2128the return value.
2129
2130The full logic @value{GDBN} uses here is kind of odd.
e5419804 2131
56caf160 2132@itemize @bullet
e5419804
JB
2133@item
2134If the type being returned by value is not a structure, union, or array,
2135and @code{RETURN_VALUE_ON_STACK} returns zero, then @value{GDBN}
2136concludes the value is not returned using the struct convention.
2137
2138@item
2139Otherwise, @value{GDBN} calls @code{USE_STRUCT_CONVENTION} (see below).
2140If that returns non-zero, @value{GDBN} assumes the struct convention is
2141in use.
e5419804
JB
2142@end itemize
2143
2144In other words, to indicate that a given type is returned by value using
2145the struct convention, that type must be either a struct, union, array,
2146or something @code{RETURN_VALUE_ON_STACK} likes, @emph{and} something
2147that @code{USE_STRUCT_CONVENTION} likes.
2148
56caf160 2149Note that, in C and C@t{++}, arrays are never returned by value. In those
e5419804
JB
2150languages, these predicates will always see a pointer type, never an
2151array type. All the references above to arrays being returned by value
2152apply only to other languages.
2153
c906108c 2154@item SOFTWARE_SINGLE_STEP_P
56caf160 2155@findex SOFTWARE_SINGLE_STEP_P
c906108c 2156Define this as 1 if the target does not have a hardware single-step
56caf160 2157mechanism. The macro @code{SOFTWARE_SINGLE_STEP} must also be defined.
c906108c 2158
56caf160
EZ
2159@item SOFTWARE_SINGLE_STEP(@var{signal}, @var{insert_breapoints_p})
2160@findex SOFTWARE_SINGLE_STEP
2161A function that inserts or removes (depending on
c906108c 2162@var{insert_breapoints_p}) breakpoints at each possible destinations of
56caf160 2163the next instruction. See @file{sparc-tdep.c} and @file{rs6000-tdep.c}
c906108c
SS
2164for examples.
2165
da59e081 2166@item SOFUN_ADDRESS_MAYBE_MISSING
56caf160 2167@findex SOFUN_ADDRESS_MAYBE_MISSING
da59e081
JM
2168Somebody clever observed that, the more actual addresses you have in the
2169debug information, the more time the linker has to spend relocating
2170them. So whenever there's some other way the debugger could find the
2171address it needs, you should omit it from the debug info, to make
2172linking faster.
2173
2174@code{SOFUN_ADDRESS_MAYBE_MISSING} indicates that a particular set of
2175hacks of this sort are in use, affecting @code{N_SO} and @code{N_FUN}
2176entries in stabs-format debugging information. @code{N_SO} stabs mark
2177the beginning and ending addresses of compilation units in the text
2178segment. @code{N_FUN} stabs mark the starts and ends of functions.
2179
2180@code{SOFUN_ADDRESS_MAYBE_MISSING} means two things:
da59e081 2181
56caf160 2182@itemize @bullet
da59e081
JM
2183@item
2184@code{N_FUN} stabs have an address of zero. Instead, you should find the
2185addresses where the function starts by taking the function name from
56caf160
EZ
2186the stab, and then looking that up in the minsyms (the
2187linker/assembler symbol table). In other words, the stab has the
2188name, and the linker/assembler symbol table is the only place that carries
da59e081
JM
2189the address.
2190
2191@item
2192@code{N_SO} stabs have an address of zero, too. You just look at the
2193@code{N_FUN} stabs that appear before and after the @code{N_SO} stab,
2194and guess the starting and ending addresses of the compilation unit from
2195them.
da59e081
JM
2196@end itemize
2197
c906108c 2198@item PCC_SOL_BROKEN
56caf160 2199@findex PCC_SOL_BROKEN
c906108c
SS
2200(Used only in the Convex target.)
2201
2202@item PC_IN_CALL_DUMMY
56caf160
EZ
2203@findex PC_IN_CALL_DUMMY
2204See @file{inferior.h}.
c906108c
SS
2205
2206@item PC_LOAD_SEGMENT
56caf160 2207@findex PC_LOAD_SEGMENT
c906108c
SS
2208If defined, print information about the load segment for the program
2209counter. (Defined only for the RS/6000.)
2210
2211@item PC_REGNUM
56caf160 2212@findex PC_REGNUM
c906108c 2213If the program counter is kept in a register, then define this macro to
cce74817
JM
2214be the number (greater than or equal to zero) of that register.
2215
2216This should only need to be defined if @code{TARGET_READ_PC} and
2217@code{TARGET_WRITE_PC} are not defined.
c906108c
SS
2218
2219@item NPC_REGNUM
56caf160 2220@findex NPC_REGNUM
c906108c
SS
2221The number of the ``next program counter'' register, if defined.
2222
2223@item NNPC_REGNUM
56caf160 2224@findex NNPC_REGNUM
c906108c
SS
2225The number of the ``next next program counter'' register, if defined.
2226Currently, this is only defined for the Motorola 88K.
2227
2df3850c 2228@item PARM_BOUNDARY
56caf160 2229@findex PARM_BOUNDARY
2df3850c
JM
2230If non-zero, round arguments to a boundary of this many bits before
2231pushing them on the stack.
2232
56caf160
EZ
2233@item PRINT_REGISTER_HOOK (@var{regno})
2234@findex PRINT_REGISTER_HOOK
c906108c
SS
2235If defined, this must be a function that prints the contents of the
2236given register to standard output.
2237
2238@item PRINT_TYPELESS_INTEGER
56caf160 2239@findex PRINT_TYPELESS_INTEGER
c906108c
SS
2240This is an obscure substitute for @code{print_longest} that seems to
2241have been defined for the Convex target.
2242
2243@item PROCESS_LINENUMBER_HOOK
56caf160 2244@findex PROCESS_LINENUMBER_HOOK
c906108c
SS
2245A hook defined for XCOFF reading.
2246
2247@item PROLOGUE_FIRSTLINE_OVERLAP
56caf160 2248@findex PROLOGUE_FIRSTLINE_OVERLAP
c906108c
SS
2249(Only used in unsupported Convex configuration.)
2250
2251@item PS_REGNUM
56caf160 2252@findex PS_REGNUM
c906108c
SS
2253If defined, this is the number of the processor status register. (This
2254definition is only used in generic code when parsing "$ps".)
2255
2256@item POP_FRAME
56caf160
EZ
2257@findex POP_FRAME
2258@findex call_function_by_hand
2259@findex return_command
c906108c 2260Used in @samp{call_function_by_hand} to remove an artificial stack
1c6147de 2261frame and in @samp{return_command} to remove a real stack frame.
c906108c 2262
56caf160
EZ
2263@item PUSH_ARGUMENTS (@var{nargs}, @var{args}, @var{sp}, @var{struct_return}, @var{struct_addr})
2264@findex PUSH_ARGUMENTS
392a587b 2265Define this to push arguments onto the stack for inferior function
56caf160 2266call. Returns the updated stack pointer value.
c906108c
SS
2267
2268@item PUSH_DUMMY_FRAME
56caf160 2269@findex PUSH_DUMMY_FRAME
c906108c
SS
2270Used in @samp{call_function_by_hand} to create an artificial stack frame.
2271
2272@item REGISTER_BYTES
56caf160 2273@findex REGISTER_BYTES
25822942 2274The total amount of space needed to store @value{GDBN}'s copy of the machine's
c906108c
SS
2275register state.
2276
56caf160
EZ
2277@item REGISTER_NAME(@var{i})
2278@findex REGISTER_NAME
2279Return the name of register @var{i} as a string. May return @code{NULL}
2280or @code{NUL} to indicate that register @var{i} is not valid.
c906108c 2281
7a292a7a 2282@item REGISTER_NAMES
56caf160
EZ
2283@findex REGISTER_NAMES
2284Deprecated in favor of @code{REGISTER_NAME}.
7a292a7a 2285
56caf160
EZ
2286@item REG_STRUCT_HAS_ADDR (@var{gcc_p}, @var{type})
2287@findex REG_STRUCT_HAS_ADDR
c906108c
SS
2288Define this to return 1 if the given type will be passed by pointer
2289rather than directly.
2290
56caf160
EZ
2291@item SAVE_DUMMY_FRAME_TOS (@var{sp})
2292@findex SAVE_DUMMY_FRAME_TOS
43ff13b4
JM
2293Used in @samp{call_function_by_hand} to notify the target dependent code
2294of the top-of-stack value that will be passed to the the inferior code.
56caf160 2295This is the value of the @code{SP} after both the dummy frame and space
43ff13b4
JM
2296for parameters/results have been allocated on the stack.
2297
c906108c 2298@item SDB_REG_TO_REGNUM
56caf160 2299@findex SDB_REG_TO_REGNUM
25822942 2300Define this to convert sdb register numbers into @value{GDBN} regnums. If not
c906108c
SS
2301defined, no conversion will be done.
2302
2303@item SHIFT_INST_REGS
56caf160 2304@findex SHIFT_INST_REGS
c906108c
SS
2305(Only used for m88k targets.)
2306
c2c6d25f 2307@item SKIP_PERMANENT_BREAKPOINT
56caf160 2308@findex SKIP_PERMANENT_BREAKPOINT
25822942 2309Advance the inferior's PC past a permanent breakpoint. @value{GDBN} normally
c2c6d25f
JM
2310steps over a breakpoint by removing it, stepping one instruction, and
2311re-inserting the breakpoint. However, permanent breakpoints are
2312hardwired into the inferior, and can't be removed, so this strategy
56caf160 2313doesn't work. Calling @code{SKIP_PERMANENT_BREAKPOINT} adjusts the processor's
c2c6d25f
JM
2314state so that execution will resume just after the breakpoint. This
2315macro does the right thing even when the breakpoint is in the delay slot
2316of a branch or jump.
2317
56caf160
EZ
2318@item SKIP_PROLOGUE (@var{pc})
2319@findex SKIP_PROLOGUE
b83266a0
SS
2320A C expression that returns the address of the ``real'' code beyond the
2321function entry prologue found at @var{pc}.
c906108c
SS
2322
2323@item SKIP_PROLOGUE_FRAMELESS_P
56caf160 2324@findex SKIP_PROLOGUE_FRAMELESS_P
b83266a0
SS
2325A C expression that should behave similarly, but that can stop as soon
2326as the function is known to have a frame. If not defined,
c906108c
SS
2327@code{SKIP_PROLOGUE} will be used instead.
2328
56caf160
EZ
2329@item SKIP_TRAMPOLINE_CODE (@var{pc})
2330@findex SKIP_TRAMPOLINE_CODE
c906108c
SS
2331If the target machine has trampoline code that sits between callers and
2332the functions being called, then define this macro to return a new PC
2333that is at the start of the real function.
2334
2335@item SP_REGNUM
56caf160 2336@findex SP_REGNUM
cce74817
JM
2337If the stack-pointer is kept in a register, then define this macro to be
2338the number (greater than or equal to zero) of that register.
2339
2340This should only need to be defined if @code{TARGET_WRITE_SP} and
2341@code{TARGET_WRITE_SP} are not defined.
c906108c
SS
2342
2343@item STAB_REG_TO_REGNUM
56caf160 2344@findex STAB_REG_TO_REGNUM
c906108c 2345Define this to convert stab register numbers (as gotten from `r'
25822942 2346declarations) into @value{GDBN} regnums. If not defined, no conversion will be
c906108c
SS
2347done.
2348
56caf160
EZ
2349@item STACK_ALIGN (@var{addr})
2350@findex STACK_ALIGN
c906108c
SS
2351Define this to adjust the address to the alignment required for the
2352processor's stack.
2353
56caf160
EZ
2354@item STEP_SKIPS_DELAY (@var{addr})
2355@findex STEP_SKIPS_DELAY
c906108c
SS
2356Define this to return true if the address is of an instruction with a
2357delay slot. If a breakpoint has been placed in the instruction's delay
25822942 2358slot, @value{GDBN} will single-step over that instruction before resuming
c906108c
SS
2359normally. Currently only defined for the Mips.
2360
56caf160
EZ
2361@item STORE_RETURN_VALUE (@var{type}, @var{valbuf})
2362@findex STORE_RETURN_VALUE
c906108c
SS
2363A C expression that stores a function return value of type @var{type},
2364where @var{valbuf} is the address of the value to be stored.
2365
2366@item SUN_FIXED_LBRAC_BUG
56caf160 2367@findex SUN_FIXED_LBRAC_BUG
c906108c
SS
2368(Used only for Sun-3 and Sun-4 targets.)
2369
2370@item SYMBOL_RELOADING_DEFAULT
56caf160
EZ
2371@findex SYMBOL_RELOADING_DEFAULT
2372The default value of the ``symbol-reloading'' variable. (Never defined in
c906108c
SS
2373current sources.)
2374
2375@item TARGET_BYTE_ORDER_DEFAULT
56caf160 2376@findex TARGET_BYTE_ORDER_DEFAULT
c906108c
SS
2377The ordering of bytes in the target. This must be either
2378@code{BIG_ENDIAN} or @code{LITTLE_ENDIAN}. This macro replaces
56caf160 2379@code{TARGET_BYTE_ORDER} which is deprecated.
c906108c
SS
2380
2381@item TARGET_BYTE_ORDER_SELECTABLE_P
56caf160 2382@findex TARGET_BYTE_ORDER_SELECTABLE_P
c906108c
SS
2383Non-zero if the target has both @code{BIG_ENDIAN} and
2384@code{LITTLE_ENDIAN} variants. This macro replaces
56caf160 2385@code{TARGET_BYTE_ORDER_SELECTABLE} which is deprecated.
c906108c
SS
2386
2387@item TARGET_CHAR_BIT
56caf160 2388@findex TARGET_CHAR_BIT
c906108c
SS
2389Number of bits in a char; defaults to 8.
2390
2391@item TARGET_COMPLEX_BIT
56caf160 2392@findex TARGET_COMPLEX_BIT
c906108c
SS
2393Number of bits in a complex number; defaults to @code{2 * TARGET_FLOAT_BIT}.
2394
ac9a91a7
JM
2395At present this macro is not used.
2396
c906108c 2397@item TARGET_DOUBLE_BIT
56caf160 2398@findex TARGET_DOUBLE_BIT
c906108c
SS
2399Number of bits in a double float; defaults to @code{8 * TARGET_CHAR_BIT}.
2400
2401@item TARGET_DOUBLE_COMPLEX_BIT
56caf160 2402@findex TARGET_DOUBLE_COMPLEX_BIT
c906108c
SS
2403Number of bits in a double complex; defaults to @code{2 * TARGET_DOUBLE_BIT}.
2404
ac9a91a7
JM
2405At present this macro is not used.
2406
c906108c 2407@item TARGET_FLOAT_BIT
56caf160 2408@findex TARGET_FLOAT_BIT
c906108c
SS
2409Number of bits in a float; defaults to @code{4 * TARGET_CHAR_BIT}.
2410
2411@item TARGET_INT_BIT
56caf160 2412@findex TARGET_INT_BIT
c906108c
SS
2413Number of bits in an integer; defaults to @code{4 * TARGET_CHAR_BIT}.
2414
2415@item TARGET_LONG_BIT
56caf160 2416@findex TARGET_LONG_BIT
c906108c
SS
2417Number of bits in a long integer; defaults to @code{4 * TARGET_CHAR_BIT}.
2418
2419@item TARGET_LONG_DOUBLE_BIT
56caf160 2420@findex TARGET_LONG_DOUBLE_BIT
c906108c
SS
2421Number of bits in a long double float;
2422defaults to @code{2 * TARGET_DOUBLE_BIT}.
2423
2424@item TARGET_LONG_LONG_BIT
56caf160 2425@findex TARGET_LONG_LONG_BIT
c906108c
SS
2426Number of bits in a long long integer; defaults to @code{2 * TARGET_LONG_BIT}.
2427
2428@item TARGET_PTR_BIT
56caf160 2429@findex TARGET_PTR_BIT
c906108c
SS
2430Number of bits in a pointer; defaults to @code{TARGET_INT_BIT}.
2431
2432@item TARGET_SHORT_BIT
56caf160 2433@findex TARGET_SHORT_BIT
c906108c
SS
2434Number of bits in a short integer; defaults to @code{2 * TARGET_CHAR_BIT}.
2435
2436@item TARGET_READ_PC
56caf160
EZ
2437@findex TARGET_READ_PC
2438@itemx TARGET_WRITE_PC (@var{val}, @var{pid})
2439@findex TARGET_WRITE_PC
2440@itemx TARGET_READ_SP
2441@findex TARGET_READ_SP
2442@itemx TARGET_WRITE_SP
2443@findex TARGET_WRITE_SP
2444@itemx TARGET_READ_FP
2445@findex TARGET_READ_FP
2446@itemx TARGET_WRITE_FP
2447@findex TARGET_WRITE_FP
2448@findex read_pc
2449@findex write_pc
2450@findex read_sp
2451@findex write_sp
2452@findex read_fp
2453@findex write_fp
c906108c
SS
2454These change the behavior of @code{read_pc}, @code{write_pc},
2455@code{read_sp}, @code{write_sp}, @code{read_fp} and @code{write_fp}.
25822942 2456For most targets, these may be left undefined. @value{GDBN} will call the read
c906108c
SS
2457and write register functions with the relevant @code{_REGNUM} argument.
2458
2459These macros are useful when a target keeps one of these registers in a
2460hard to get at place; for example, part in a segment register and part
2461in an ordinary register.
2462
56caf160
EZ
2463@item TARGET_VIRTUAL_FRAME_POINTER(@var{pc}, @var{regp}, @var{offsetp})
2464@findex TARGET_VIRTUAL_FRAME_POINTER
c906108c 2465Returns a @code{(register, offset)} pair representing the virtual
56caf160 2466frame pointer in use at the code address @var{pc}. If virtual
c906108c
SS
2467frame pointers are not used, a default definition simply returns
2468@code{FP_REGNUM}, with an offset of zero.
2469
56caf160
EZ
2470@item USE_STRUCT_CONVENTION (@var{gcc_p}, @var{type})
2471@findex USE_STRUCT_CONVENTION
c906108c
SS
2472If defined, this must be an expression that is nonzero if a value of the
2473given @var{type} being returned from a function must have space
2474allocated for it on the stack. @var{gcc_p} is true if the function
2475being considered is known to have been compiled by GCC; this is helpful
2476for systems where GCC is known to use different calling convention than
2477other compilers.
2478
56caf160
EZ
2479@item VARIABLES_INSIDE_BLOCK (@var{desc}, @var{gcc_p})
2480@findex VARIABLES_INSIDE_BLOCK
c906108c
SS
2481For dbx-style debugging information, if the compiler puts variable
2482declarations inside LBRAC/RBRAC blocks, this should be defined to be
2483nonzero. @var{desc} is the value of @code{n_desc} from the
25822942 2484@code{N_RBRAC} symbol, and @var{gcc_p} is true if @value{GDBN} has noticed the
c906108c
SS
2485presence of either the @code{GCC_COMPILED_SYMBOL} or the
2486@code{GCC2_COMPILED_SYMBOL}. By default, this is 0.
2487
56caf160
EZ
2488@item OS9K_VARIABLES_INSIDE_BLOCK (@var{desc}, @var{gcc_p})
2489@findex OS9K_VARIABLES_INSIDE_BLOCK
c906108c 2490Similarly, for OS/9000. Defaults to 1.
c906108c
SS
2491@end table
2492
2493Motorola M68K target conditionals.
2494
56caf160 2495@ftable @code
c906108c
SS
2496@item BPT_VECTOR
2497Define this to be the 4-bit location of the breakpoint trap vector. If
2498not defined, it will default to @code{0xf}.
2499
2500@item REMOTE_BPT_VECTOR
2501Defaults to @code{1}.
56caf160 2502@end ftable
c906108c
SS
2503
2504@section Adding a New Target
2505
56caf160 2506@cindex adding a target
25822942 2507The following files define a target to @value{GDBN}:
c906108c
SS
2508
2509@table @file
56caf160 2510@vindex TDEPFILES
c906108c
SS
2511@item gdb/config/@var{arch}/@var{ttt}.mt
2512Contains a Makefile fragment specific to this target. Specifies what
2513object files are needed for target @var{ttt}, by defining
104c1213
JM
2514@samp{TDEPFILES=@dots{}} and @samp{TDEPLIBS=@dots{}}. Also specifies
2515the header file which describes @var{ttt}, by defining @samp{TM_FILE=
2516tm-@var{ttt}.h}.
2517
2518You can also define @samp{TM_CFLAGS}, @samp{TM_CLIBS}, @samp{TM_CDEPS},
2519but these are now deprecated, replaced by autoconf, and may go away in
25822942 2520future versions of @value{GDBN}.
c906108c
SS
2521
2522@item gdb/config/@var{arch}/tm-@var{ttt}.h
56caf160 2523(@file{tm.h} is a link to this file, created by @code{configure}). Contains
c906108c
SS
2524macro definitions about the target machine's registers, stack frame
2525format and instructions.
2526
2527@item gdb/@var{ttt}-tdep.c
2528Contains any miscellaneous code required for this target machine. On
2529some machines it doesn't exist at all. Sometimes the macros in
2530@file{tm-@var{ttt}.h} become very complicated, so they are implemented
2531as functions here instead, and the macro is simply defined to call the
2532function. This is vastly preferable, since it is easier to understand
2533and debug.
2534
2535@item gdb/config/@var{arch}/tm-@var{arch}.h
2536This often exists to describe the basic layout of the target machine's
56caf160 2537processor chip (registers, stack, etc.). If used, it is included by
c906108c
SS
2538@file{tm-@var{ttt}.h}. It can be shared among many targets that use the
2539same processor.
2540
2541@item gdb/@var{arch}-tdep.c
2542Similarly, there are often common subroutines that are shared by all
2543target machines that use this particular architecture.
c906108c
SS
2544@end table
2545
2546If you are adding a new operating system for an existing CPU chip, add a
2547@file{config/tm-@var{os}.h} file that describes the operating system
2548facilities that are unusual (extra symbol table info; the breakpoint
56caf160 2549instruction needed; etc.). Then write a @file{@var{arch}/tm-@var{os}.h}
c906108c
SS
2550that just @code{#include}s @file{tm-@var{arch}.h} and
2551@file{config/tm-@var{os}.h}.
2552
2553
2554@node Target Vector Definition
2555
2556@chapter Target Vector Definition
56caf160 2557@cindex target vector
c906108c 2558
56caf160
EZ
2559The target vector defines the interface between @value{GDBN}'s
2560abstract handling of target systems, and the nitty-gritty code that
2561actually exercises control over a process or a serial port.
2562@value{GDBN} includes some 30-40 different target vectors; however,
2563each configuration of @value{GDBN} includes only a few of them.
c906108c
SS
2564
2565@section File Targets
2566
2567Both executables and core files have target vectors.
2568
2569@section Standard Protocol and Remote Stubs
2570
56caf160
EZ
2571@value{GDBN}'s file @file{remote.c} talks a serial protocol to code
2572that runs in the target system. @value{GDBN} provides several sample
2573@dfn{stubs} that can be integrated into target programs or operating
2574systems for this purpose; they are named @file{*-stub.c}.
c906108c 2575
56caf160
EZ
2576The @value{GDBN} user's manual describes how to put such a stub into
2577your target code. What follows is a discussion of integrating the
2578SPARC stub into a complicated operating system (rather than a simple
2579program), by Stu Grossman, the author of this stub.
c906108c
SS
2580
2581The trap handling code in the stub assumes the following upon entry to
56caf160 2582@code{trap_low}:
c906108c
SS
2583
2584@enumerate
56caf160
EZ
2585@item
2586%l1 and %l2 contain pc and npc respectively at the time of the trap;
c906108c 2587
56caf160
EZ
2588@item
2589traps are disabled;
c906108c 2590
56caf160
EZ
2591@item
2592you are in the correct trap window.
c906108c
SS
2593@end enumerate
2594
2595As long as your trap handler can guarantee those conditions, then there
56caf160 2596is no reason why you shouldn't be able to ``share'' traps with the stub.
c906108c
SS
2597The stub has no requirement that it be jumped to directly from the
2598hardware trap vector. That is why it calls @code{exceptionHandler()},
2599which is provided by the external environment. For instance, this could
56caf160 2600set up the hardware traps to actually execute code which calls the stub
c906108c
SS
2601first, and then transfers to its own trap handler.
2602
2603For the most point, there probably won't be much of an issue with
56caf160 2604``sharing'' traps, as the traps we use are usually not used by the kernel,
c906108c
SS
2605and often indicate unrecoverable error conditions. Anyway, this is all
2606controlled by a table, and is trivial to modify. The most important
2607trap for us is for @code{ta 1}. Without that, we can't single step or
2608do breakpoints. Everything else is unnecessary for the proper operation
2609of the debugger/stub.
2610
2611From reading the stub, it's probably not obvious how breakpoints work.
25822942 2612They are simply done by deposit/examine operations from @value{GDBN}.
c906108c
SS
2613
2614@section ROM Monitor Interface
2615
2616@section Custom Protocols
2617
2618@section Transport Layer
2619
2620@section Builtin Simulator
2621
2622
2623@node Native Debugging
2624
2625@chapter Native Debugging
56caf160 2626@cindex native debugging
c906108c 2627
25822942 2628Several files control @value{GDBN}'s configuration for native support:
c906108c
SS
2629
2630@table @file
56caf160 2631@vindex NATDEPFILES
c906108c
SS
2632@item gdb/config/@var{arch}/@var{xyz}.mh
2633Specifies Makefile fragments needed when hosting @emph{or native} on
2634machine @var{xyz}. In particular, this lists the required
2635native-dependent object files, by defining @samp{NATDEPFILES=@dots{}}.
2636Also specifies the header file which describes native support on
2637@var{xyz}, by defining @samp{NAT_FILE= nm-@var{xyz}.h}. You can also
2638define @samp{NAT_CFLAGS}, @samp{NAT_ADD_FILES}, @samp{NAT_CLIBS},
2639@samp{NAT_CDEPS}, etc.; see @file{Makefile.in}.
2640
2641@item gdb/config/@var{arch}/nm-@var{xyz}.h
56caf160 2642(@file{nm.h} is a link to this file, created by @code{configure}). Contains C
c906108c
SS
2643macro definitions describing the native system environment, such as
2644child process control and core file support.
2645
2646@item gdb/@var{xyz}-nat.c
2647Contains any miscellaneous C code required for this native support of
2648this machine. On some machines it doesn't exist at all.
c906108c
SS
2649@end table
2650
2651There are some ``generic'' versions of routines that can be used by
2652various systems. These can be customized in various ways by macros
2653defined in your @file{nm-@var{xyz}.h} file. If these routines work for
2654the @var{xyz} host, you can just include the generic file's name (with
2655@samp{.o}, not @samp{.c}) in @code{NATDEPFILES}.
2656
2657Otherwise, if your machine needs custom support routines, you will need
2658to write routines that perform the same functions as the generic file.
56caf160 2659Put them into @file{@var{xyz}-nat.c}, and put @file{@var{xyz}-nat.o}
c906108c
SS
2660into @code{NATDEPFILES}.
2661
2662@table @file
c906108c
SS
2663@item inftarg.c
2664This contains the @emph{target_ops vector} that supports Unix child
2665processes on systems which use ptrace and wait to control the child.
2666
2667@item procfs.c
2668This contains the @emph{target_ops vector} that supports Unix child
2669processes on systems which use /proc to control the child.
2670
2671@item fork-child.c
56caf160
EZ
2672This does the low-level grunge that uses Unix system calls to do a ``fork
2673and exec'' to start up a child process.
c906108c
SS
2674
2675@item infptrace.c
2676This is the low level interface to inferior processes for systems using
2677the Unix @code{ptrace} call in a vanilla way.
c906108c
SS
2678@end table
2679
2680@section Native core file Support
56caf160 2681@cindex native core files
c906108c
SS
2682
2683@table @file
56caf160 2684@findex fetch_core_registers
c906108c
SS
2685@item core-aout.c::fetch_core_registers()
2686Support for reading registers out of a core file. This routine calls
2687@code{register_addr()}, see below. Now that BFD is used to read core
2688files, virtually all machines should use @code{core-aout.c}, and should
2689just provide @code{fetch_core_registers} in @code{@var{xyz}-nat.c} (or
2690@code{REGISTER_U_ADDR} in @code{nm-@var{xyz}.h}).
2691
2692@item core-aout.c::register_addr()
2693If your @code{nm-@var{xyz}.h} file defines the macro
2694@code{REGISTER_U_ADDR(addr, blockend, regno)}, it should be defined to
25822942 2695set @code{addr} to the offset within the @samp{user} struct of @value{GDBN}
c906108c
SS
2696register number @code{regno}. @code{blockend} is the offset within the
2697``upage'' of @code{u.u_ar0}. If @code{REGISTER_U_ADDR} is defined,
2698@file{core-aout.c} will define the @code{register_addr()} function and
2699use the macro in it. If you do not define @code{REGISTER_U_ADDR}, but
2700you are using the standard @code{fetch_core_registers()}, you will need
2701to define your own version of @code{register_addr()}, put it into your
2702@code{@var{xyz}-nat.c} file, and be sure @code{@var{xyz}-nat.o} is in
2703the @code{NATDEPFILES} list. If you have your own
2704@code{fetch_core_registers()}, you may not need a separate
2705@code{register_addr()}. Many custom @code{fetch_core_registers()}
2706implementations simply locate the registers themselves.@refill
c906108c
SS
2707@end table
2708
25822942 2709When making @value{GDBN} run native on a new operating system, to make it
c906108c
SS
2710possible to debug core files, you will need to either write specific
2711code for parsing your OS's core files, or customize
2712@file{bfd/trad-core.c}. First, use whatever @code{#include} files your
2713machine uses to define the struct of registers that is accessible
2714(possibly in the u-area) in a core file (rather than
2715@file{machine/reg.h}), and an include file that defines whatever header
56caf160
EZ
2716exists on a core file (e.g. the u-area or a @code{struct core}). Then
2717modify @code{trad_unix_core_file_p} to use these values to set up the
c906108c
SS
2718section information for the data segment, stack segment, any other
2719segments in the core file (perhaps shared library contents or control
2720information), ``registers'' segment, and if there are two discontiguous
2721sets of registers (e.g. integer and float), the ``reg2'' segment. This
2722section information basically delimits areas in the core file in a
2723standard way, which the section-reading routines in BFD know how to seek
2724around in.
2725
25822942 2726Then back in @value{GDBN}, you need a matching routine called
56caf160 2727@code{fetch_core_registers}. If you can use the generic one, it's in
c906108c
SS
2728@file{core-aout.c}; if not, it's in your @file{@var{xyz}-nat.c} file.
2729It will be passed a char pointer to the entire ``registers'' segment,
2730its length, and a zero; or a char pointer to the entire ``regs2''
2731segment, its length, and a 2. The routine should suck out the supplied
25822942 2732register values and install them into @value{GDBN}'s ``registers'' array.
c906108c
SS
2733
2734If your system uses @file{/proc} to control processes, and uses ELF
2735format core files, then you may be able to use the same routines for
2736reading the registers out of processes and out of core files.
2737
2738@section ptrace
2739
2740@section /proc
2741
2742@section win32
2743
2744@section shared libraries
2745
2746@section Native Conditionals
56caf160 2747@cindex native conditionals
c906108c 2748
56caf160
EZ
2749When @value{GDBN} is configured and compiled, various macros are
2750defined or left undefined, to control compilation when the host and
2751target systems are the same. These macros should be defined (or left
2752undefined) in @file{nm-@var{system}.h}.
c906108c
SS
2753
2754@table @code
c906108c 2755@item ATTACH_DETACH
56caf160 2756@findex ATTACH_DETACH
25822942 2757If defined, then @value{GDBN} will include support for the @code{attach} and
c906108c
SS
2758@code{detach} commands.
2759
2760@item CHILD_PREPARE_TO_STORE
56caf160 2761@findex CHILD_PREPARE_TO_STORE
c906108c
SS
2762If the machine stores all registers at once in the child process, then
2763define this to ensure that all values are correct. This usually entails
2764a read from the child.
2765
2766[Note that this is incorrectly defined in @file{xm-@var{system}.h} files
2767currently.]
2768
2769@item FETCH_INFERIOR_REGISTERS
56caf160 2770@findex FETCH_INFERIOR_REGISTERS
c906108c
SS
2771Define this if the native-dependent code will provide its own routines
2772@code{fetch_inferior_registers} and @code{store_inferior_registers} in
56caf160 2773@file{@var{host}-nat.c}. If this symbol is @emph{not} defined, and
c906108c
SS
2774@file{infptrace.c} is included in this configuration, the default
2775routines in @file{infptrace.c} are used for these functions.
2776
2777@item FILES_INFO_HOOK
56caf160 2778@findex FILES_INFO_HOOK
c906108c
SS
2779(Only defined for Convex.)
2780
2781@item FP0_REGNUM
56caf160 2782@findex FP0_REGNUM
c906108c
SS
2783This macro is normally defined to be the number of the first floating
2784point register, if the machine has such registers. As such, it would
56caf160 2785appear only in target-specific code. However, @file{/proc} support uses this
c906108c
SS
2786to decide whether floats are in use on this target.
2787
2788@item GET_LONGJMP_TARGET
56caf160 2789@findex GET_LONGJMP_TARGET
c906108c
SS
2790For most machines, this is a target-dependent parameter. On the
2791DECstation and the Iris, this is a native-dependent parameter, since
56caf160 2792@file{setjmp.h} is needed to define it.
c906108c 2793
56caf160 2794This macro determines the target PC address that @code{longjmp} will jump to,
c906108c 2795assuming that we have just stopped at a longjmp breakpoint. It takes a
56caf160 2796@code{CORE_ADDR *} as argument, and stores the target PC value through this
c906108c
SS
2797pointer. It examines the current state of the machine as needed.
2798
2799@item KERNEL_U_ADDR
56caf160 2800@findex KERNEL_U_ADDR
c906108c 2801Define this to the address of the @code{u} structure (the ``user
25822942 2802struct'', also known as the ``u-page'') in kernel virtual memory. @value{GDBN}
c906108c
SS
2803needs to know this so that it can subtract this address from absolute
2804addresses in the upage, that are obtained via ptrace or from core files.
2805On systems that don't need this value, set it to zero.
2806
2807@item KERNEL_U_ADDR_BSD
56caf160 2808@findex KERNEL_U_ADDR_BSD
25822942 2809Define this to cause @value{GDBN} to determine the address of @code{u} at
c906108c
SS
2810runtime, by using Berkeley-style @code{nlist} on the kernel's image in
2811the root directory.
2812
2813@item KERNEL_U_ADDR_HPUX
56caf160 2814@findex KERNEL_U_ADDR_HPUX
25822942 2815Define this to cause @value{GDBN} to determine the address of @code{u} at
c906108c
SS
2816runtime, by using HP-style @code{nlist} on the kernel's image in the
2817root directory.
2818
2819@item ONE_PROCESS_WRITETEXT
56caf160 2820@findex ONE_PROCESS_WRITETEXT
c906108c
SS
2821Define this to be able to, when a breakpoint insertion fails, warn the
2822user that another process may be running with the same executable.
2823
56caf160
EZ
2824@item PREPARE_TO_PROCEED (@var{select_it})
2825@findex PREPARE_TO_PROCEED
adf40b2e
JM
2826This (ugly) macro allows a native configuration to customize the way the
2827@code{proceed} function in @file{infrun.c} deals with switching between
2828threads.
2829
2830In a multi-threaded task we may select another thread and then continue
2831or step. But if the old thread was stopped at a breakpoint, it will
2832immediately cause another breakpoint stop without any execution (i.e. it
25822942 2833will report a breakpoint hit incorrectly). So @value{GDBN} must step over it
adf40b2e
JM
2834first.
2835
2836If defined, @code{PREPARE_TO_PROCEED} should check the current thread
2837against the thread that reported the most recent event. If a step-over
2838is required, it returns TRUE. If @var{select_it} is non-zero, it should
2839reselect the old thread.
2840
c906108c 2841@item PROC_NAME_FMT
56caf160 2842@findex PROC_NAME_FMT
c906108c
SS
2843Defines the format for the name of a @file{/proc} device. Should be
2844defined in @file{nm.h} @emph{only} in order to override the default
2845definition in @file{procfs.c}.
2846
2847@item PTRACE_FP_BUG
56caf160
EZ
2848@findex PTRACE_FP_BUG
2849See @file{mach386-xdep.c}.
c906108c
SS
2850
2851@item PTRACE_ARG3_TYPE
56caf160 2852@findex PTRACE_ARG3_TYPE
c906108c
SS
2853The type of the third argument to the @code{ptrace} system call, if it
2854exists and is different from @code{int}.
2855
2856@item REGISTER_U_ADDR
56caf160 2857@findex REGISTER_U_ADDR
c906108c
SS
2858Defines the offset of the registers in the ``u area''.
2859
2860@item SHELL_COMMAND_CONCAT
56caf160 2861@findex SHELL_COMMAND_CONCAT
c906108c
SS
2862If defined, is a string to prefix on the shell command used to start the
2863inferior.
2864
2865@item SHELL_FILE
56caf160 2866@findex SHELL_FILE
c906108c
SS
2867If defined, this is the name of the shell to use to run the inferior.
2868Defaults to @code{"/bin/sh"}.
2869
56caf160
EZ
2870@item SOLIB_ADD (@var{filename}, @var{from_tty}, @var{targ})
2871@findex SOLIB_ADD
c906108c 2872Define this to expand into an expression that will cause the symbols in
25822942 2873@var{filename} to be added to @value{GDBN}'s symbol table.
c906108c
SS
2874
2875@item SOLIB_CREATE_INFERIOR_HOOK
56caf160 2876@findex SOLIB_CREATE_INFERIOR_HOOK
c906108c
SS
2877Define this to expand into any shared-library-relocation code that you
2878want to be run just after the child process has been forked.
2879
2880@item START_INFERIOR_TRAPS_EXPECTED
56caf160
EZ
2881@findex START_INFERIOR_TRAPS_EXPECTED
2882When starting an inferior, @value{GDBN} normally expects to trap
2883twice; once when
c906108c
SS
2884the shell execs, and once when the program itself execs. If the actual
2885number of traps is something other than 2, then define this macro to
2886expand into the number expected.
2887
2888@item SVR4_SHARED_LIBS
56caf160 2889@findex SVR4_SHARED_LIBS
c906108c
SS
2890Define this to indicate that SVR4-style shared libraries are in use.
2891
2892@item USE_PROC_FS
56caf160 2893@findex USE_PROC_FS
c906108c 2894This determines whether small routines in @file{*-tdep.c}, which
56caf160
EZ
2895translate register values between @value{GDBN}'s internal
2896representation and the @file{/proc} representation, are compiled.
c906108c
SS
2897
2898@item U_REGS_OFFSET
56caf160 2899@findex U_REGS_OFFSET
c906108c
SS
2900This is the offset of the registers in the upage. It need only be
2901defined if the generic ptrace register access routines in
2902@file{infptrace.c} are being used (that is, @file{infptrace.c} is
2903configured in, and @code{FETCH_INFERIOR_REGISTERS} is not defined). If
2904the default value from @file{infptrace.c} is good enough, leave it
2905undefined.
2906
2907The default value means that u.u_ar0 @emph{points to} the location of
2908the registers. I'm guessing that @code{#define U_REGS_OFFSET 0} means
56caf160 2909that @code{u.u_ar0} @emph{is} the location of the registers.
c906108c
SS
2910
2911@item CLEAR_SOLIB
56caf160
EZ
2912@findex CLEAR_SOLIB
2913See @file{objfiles.c}.
c906108c
SS
2914
2915@item DEBUG_PTRACE
56caf160
EZ
2916@findex DEBUG_PTRACE
2917Define this to debug @code{ptrace} calls.
c906108c
SS
2918@end table
2919
2920
2921@node Support Libraries
2922
2923@chapter Support Libraries
2924
2925@section BFD
56caf160 2926@cindex BFD library
c906108c 2927
25822942 2928BFD provides support for @value{GDBN} in several ways:
c906108c
SS
2929
2930@table @emph
c906108c
SS
2931@item identifying executable and core files
2932BFD will identify a variety of file types, including a.out, coff, and
2933several variants thereof, as well as several kinds of core files.
2934
2935@item access to sections of files
2936BFD parses the file headers to determine the names, virtual addresses,
2937sizes, and file locations of all the various named sections in files
56caf160
EZ
2938(such as the text section or the data section). @value{GDBN} simply
2939calls BFD to read or write section @var{x} at byte offset @var{y} for
2940length @var{z}.
c906108c
SS
2941
2942@item specialized core file support
2943BFD provides routines to determine the failing command name stored in a
2944core file, the signal with which the program failed, and whether a core
56caf160 2945file matches (i.e.@: could be a core dump of) a particular executable
c906108c
SS
2946file.
2947
2948@item locating the symbol information
25822942
DB
2949@value{GDBN} uses an internal interface of BFD to determine where to find the
2950symbol information in an executable file or symbol-file. @value{GDBN} itself
c906108c 2951handles the reading of symbols, since BFD does not ``understand'' debug
25822942 2952symbols, but @value{GDBN} uses BFD's cached information to find the symbols,
c906108c 2953string table, etc.
c906108c
SS
2954@end table
2955
2956@section opcodes
56caf160 2957@cindex opcodes library
c906108c 2958
25822942 2959The opcodes library provides @value{GDBN}'s disassembler. (It's a separate
c906108c
SS
2960library because it's also used in binutils, for @file{objdump}).
2961
2962@section readline
2963
2964@section mmalloc
2965
2966@section libiberty
2967
2968@section gnu-regex
56caf160 2969@cindex regular expressions library
c906108c
SS
2970
2971Regex conditionals.
2972
2973@table @code
c906108c
SS
2974@item C_ALLOCA
2975
2976@item NFAILURES
2977
2978@item RE_NREGS
2979
2980@item SIGN_EXTEND_CHAR
2981
2982@item SWITCH_ENUM_BUG
2983
2984@item SYNTAX_TABLE
2985
2986@item Sword
2987
2988@item sparc
c906108c
SS
2989@end table
2990
2991@section include
2992
2993@node Coding
2994
2995@chapter Coding
2996
2997This chapter covers topics that are lower-level than the major
25822942 2998algorithms of @value{GDBN}.
c906108c
SS
2999
3000@section Cleanups
56caf160 3001@cindex cleanups
c906108c
SS
3002
3003Cleanups are a structured way to deal with things that need to be done
3004later. When your code does something (like @code{malloc} some memory,
56caf160 3005or open a file) that needs to be undone later (e.g., free the memory or
c906108c
SS
3006close the file), it can make a cleanup. The cleanup will be done at
3007some future point: when the command is finished, when an error occurs,
3008or when your code decides it's time to do cleanups.
3009
3010You can also discard cleanups, that is, throw them away without doing
3011what they say. This is only done if you ask that it be done.
3012
3013Syntax:
3014
3015@table @code
c906108c
SS
3016@item struct cleanup *@var{old_chain};
3017Declare a variable which will hold a cleanup chain handle.
3018
56caf160 3019@findex make_cleanup
c906108c
SS
3020@item @var{old_chain} = make_cleanup (@var{function}, @var{arg});
3021Make a cleanup which will cause @var{function} to be called with
3022@var{arg} (a @code{char *}) later. The result, @var{old_chain}, is a
3023handle that can be passed to @code{do_cleanups} or
3024@code{discard_cleanups} later. Unless you are going to call
3025@code{do_cleanups} or @code{discard_cleanups} yourself, you can ignore
3026the result from @code{make_cleanup}.
3027
56caf160 3028@findex do_cleanups
c906108c
SS
3029@item do_cleanups (@var{old_chain});
3030Perform all cleanups done since @code{make_cleanup} returned
3031@var{old_chain}. E.g.:
56caf160 3032
c906108c
SS
3033@example
3034make_cleanup (a, 0);
3035old = make_cleanup (b, 0);
3036do_cleanups (old);
3037@end example
56caf160 3038
c906108c
SS
3039@noindent
3040will call @code{b()} but will not call @code{a()}. The cleanup that
3041calls @code{a()} will remain in the cleanup chain, and will be done
3042later unless otherwise discarded.@refill
3043
56caf160 3044@findex discard_cleanups
c906108c
SS
3045@item discard_cleanups (@var{old_chain});
3046Same as @code{do_cleanups} except that it just removes the cleanups from
3047the chain and does not call the specified functions.
c906108c
SS
3048@end table
3049
3050Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify
3051that they ``should not be called when cleanups are not in place''. This
3052means that any actions you need to reverse in the case of an error or
3053interruption must be on the cleanup chain before you call these
3054functions, since they might never return to your code (they
3055@samp{longjmp} instead).
3056
3057@section Wrapping Output Lines
56caf160 3058@cindex line wrap in output
c906108c 3059
56caf160 3060@findex wrap_here
c906108c
SS
3061Output that goes through @code{printf_filtered} or @code{fputs_filtered}
3062or @code{fputs_demangled} needs only to have calls to @code{wrap_here}
3063added in places that would be good breaking points. The utility
3064routines will take care of actually wrapping if the line width is
3065exceeded.
3066
3067The argument to @code{wrap_here} is an indentation string which is
3068printed @emph{only} if the line breaks there. This argument is saved
3069away and used later. It must remain valid until the next call to
3070@code{wrap_here} or until a newline has been printed through the
3071@code{*_filtered} functions. Don't pass in a local variable and then
3072return!
3073
56caf160 3074It is usually best to call @code{wrap_here} after printing a comma or
c906108c
SS
3075space. If you call it before printing a space, make sure that your
3076indentation properly accounts for the leading space that will print if
3077the line wraps there.
3078
3079Any function or set of functions that produce filtered output must
3080finish by printing a newline, to flush the wrap buffer, before switching
56caf160 3081to unfiltered (@code{printf}) output. Symbol reading routines that
c906108c
SS
3082print warnings are a good example.
3083
25822942 3084@section @value{GDBN} Coding Standards
56caf160 3085@cindex coding standards
c906108c 3086
25822942 3087@value{GDBN} follows the GNU coding standards, as described in
c906108c 3088@file{etc/standards.texi}. This file is also available for anonymous
25822942 3089FTP from GNU archive sites. @value{GDBN} takes a strict interpretation of the
c906108c 3090standard; in general, when the GNU standard recommends a practice but
25822942 3091does not require it, @value{GDBN} requires it.
c906108c 3092
56caf160
EZ
3093@value{GDBN} follows an additional set of coding standards specific to
3094@value{GDBN}, as described in the following sections.
c906108c 3095
56caf160 3096@cindex compiler warnings
3b851bce
AC
3097You can configure with @samp{--enable-build-warnings} or
3098@samp{--enable-gdb-build-warnings} to get GCC to check on a number of
3099these rules. @value{GDBN} sources ought not to engender any complaints,
3100unless they are caused by bogus host systems. (The exact set of enabled
3101warnings is currently @samp{-Wimplicit -Wreturn-type -Wcomment
3102-Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized}.
c906108c
SS
3103
3104@subsection Formatting
3105
56caf160 3106@cindex source code formatting
c906108c
SS
3107The standard GNU recommendations for formatting must be followed
3108strictly.
3109
3110Note that while in a definition, the function's name must be in column
3111zero; in a function declaration, the name must be on the same line as
3112the return type.
3113
3114In addition, there must be a space between a function or macro name and
3115the opening parenthesis of its argument list (except for macro
3116definitions, as required by C). There must not be a space after an open
3117paren/bracket or before a close paren/bracket.
3118
3119While additional whitespace is generally helpful for reading, do not use
3120more than one blank line to separate blocks, and avoid adding whitespace
3121after the end of a program line (as of 1/99, some 600 lines had whitespace
56caf160
EZ
3122after the semicolon). Excess whitespace causes difficulties for
3123@code{diff} and @code{patch} utilities.
c906108c
SS
3124
3125@subsection Comments
3126
56caf160 3127@cindex comment formatting
c906108c
SS
3128The standard GNU requirements on comments must be followed strictly.
3129
56caf160
EZ
3130Block comments must appear in the following form, with no @samp{/*}- or
3131@samp{*/}-only lines, and no leading @samp{*}:
c906108c 3132
56caf160 3133@example
c906108c
SS
3134/* Wait for control to return from inferior to debugger. If inferior
3135 gets a signal, we may decide to start it up again instead of
3136 returning. That is why there is a loop in this function. When
3137 this function actually returns it means the inferior should be left
25822942 3138 stopped and @value{GDBN} should read more commands. */
c906108c
SS
3139@end example
3140
3141(Note that this format is encouraged by Emacs; tabbing for a multi-line
56caf160 3142comment works correctly, and @kbd{M-q} fills the block consistently.)
c906108c
SS
3143
3144Put a blank line between the block comments preceding function or
3145variable definitions, and the definition itself.
3146
3147In general, put function-body comments on lines by themselves, rather
3148than trying to fit them into the 20 characters left at the end of a
3149line, since either the comment or the code will inevitably get longer
3150than will fit, and then somebody will have to move it anyhow.
3151
3152@subsection C Usage
3153
56caf160 3154@cindex C data types
c906108c
SS
3155Code must not depend on the sizes of C data types, the format of the
3156host's floating point numbers, the alignment of anything, or the order
3157of evaluation of expressions.
3158
56caf160 3159@cindex function usage
c906108c 3160Use functions freely. There are only a handful of compute-bound areas
56caf160
EZ
3161in @value{GDBN} that might be affected by the overhead of a function
3162call, mainly in symbol reading. Most of @value{GDBN}'s performance is
3163limited by the target interface (whether serial line or system call).
c906108c
SS
3164
3165However, use functions with moderation. A thousand one-line functions
3166are just as hard to understand as a single thousand-line function.
3167
3168@subsection Function Prototypes
3169
56caf160
EZ
3170@cindex function prototypes
3171Prototypes must be used to @emph{declare} functions, and may be used
3172to @emph{define} them. Prototypes for @value{GDBN} functions must
3173include both the argument type and name, with the name matching that
3174used in the actual function definition.
c906108c 3175
53a5351d
JM
3176All external functions should have a declaration in a header file that
3177callers include, except for @code{_initialize_*} functions, which must
3178be external so that @file{init.c} construction works, but shouldn't be
3179visible to random source files.
c906108c
SS
3180
3181All static functions must be declared in a block near the top of the
3182source file.
3183
3184@subsection Clean Design
3185
56caf160 3186@cindex design
c906108c 3187In addition to getting the syntax right, there's the little question of
25822942 3188semantics. Some things are done in certain ways in @value{GDBN} because long
c906108c
SS
3189experience has shown that the more obvious ways caused various kinds of
3190trouble.
3191
56caf160 3192@cindex assumptions about targets
c906108c
SS
3193You can't assume the byte order of anything that comes from a target
3194(including @var{value}s, object files, and instructions). Such things
56caf160
EZ
3195must be byte-swapped using @code{SWAP_TARGET_AND_HOST} in
3196@value{GDBN}, or one of the swap routines defined in @file{bfd.h},
3197such as @code{bfd_get_32}.
c906108c
SS
3198
3199You can't assume that you know what interface is being used to talk to
3200the target system. All references to the target must go through the
3201current @code{target_ops} vector.
3202
3203You can't assume that the host and target machines are the same machine
3204(except in the ``native'' support modules). In particular, you can't
3205assume that the target machine's header files will be available on the
3206host machine. Target code must bring along its own header files --
3207written from scratch or explicitly donated by their owner, to avoid
3208copyright problems.
3209
56caf160 3210@cindex portability
c906108c
SS
3211Insertion of new @code{#ifdef}'s will be frowned upon. It's much better
3212to write the code portably than to conditionalize it for various
3213systems.
3214
56caf160 3215@cindex system dependencies
c906108c
SS
3216New @code{#ifdef}'s which test for specific compilers or manufacturers
3217or operating systems are unacceptable. All @code{#ifdef}'s should test
3218for features. The information about which configurations contain which
3219features should be segregated into the configuration files. Experience
3220has proven far too often that a feature unique to one particular system
3221often creeps into other systems; and that a conditional based on some
3222predefined macro for your current system will become worthless over
3223time, as new versions of your system come out that behave differently
3224with regard to this feature.
3225
3226Adding code that handles specific architectures, operating systems,
3227target interfaces, or hosts, is not acceptable in generic code. If a
3228hook is needed at that point, invent a generic hook and define it for
3229your configuration, with something like:
3230
3231@example
3232#ifdef WRANGLE_SIGNALS
3233 WRANGLE_SIGNALS (signo);
3234#endif
3235@end example
3236
3237In your host, target, or native configuration file, as appropriate,
3238define @code{WRANGLE_SIGNALS} to do the machine-dependent thing. Take a
3239bit of care in defining the hook, so that it can be used by other ports
3240in the future, if they need a hook in the same place.
3241
56caf160 3242If the hook is not defined, the code should do whatever ``most'' machines
c906108c
SS
3243want. Using @code{#ifdef}, as above, is the preferred way to do this,
3244but sometimes that gets convoluted, in which case use
3245
3246@example
3247#ifndef SPECIAL_FOO_HANDLING
3248#define SPECIAL_FOO_HANDLING(pc, sp) (0)
3249#endif
3250@end example
3251
56caf160 3252@noindent
c906108c
SS
3253where the macro is used or in an appropriate header file.
3254
3255Whether to include a @dfn{small} hook, a hook around the exact pieces of
3256code which are system-dependent, or whether to replace a whole function
56caf160 3257with a hook, depends on the case. A good example of this dilemma can be
25822942 3258found in @code{get_saved_register}. All machines that @value{GDBN} 2.8 ran on
c906108c
SS
3259just needed the @code{FRAME_FIND_SAVED_REGS} hook to find the saved
3260registers. Then the SPARC and Pyramid came along, and
3261@code{HAVE_REGISTER_WINDOWS} and @code{REGISTER_IN_WINDOW_P} were
3262introduced. Then the 29k and 88k required the @code{GET_SAVED_REGISTER}
3263hook. The first three are examples of small hooks; the latter replaces
3264a whole function. In this specific case, it is useful to have both
3265kinds; it would be a bad idea to replace all the uses of the small hooks
3266with @code{GET_SAVED_REGISTER}, since that would result in much
3267duplicated code. Other times, duplicating a few lines of code here or
3268there is much cleaner than introducing a large number of small hooks.
3269
25822942
DB
3270Another way to generalize @value{GDBN} along a particular interface is with an
3271attribute struct. For example, @value{GDBN} has been generalized to handle
56caf160
EZ
3272multiple kinds of remote interfaces---not by @code{#ifdef}s everywhere, but
3273by defining the @code{target_ops} structure and having a current target (as
c906108c
SS
3274well as a stack of targets below it, for memory references). Whenever
3275something needs to be done that depends on which remote interface we are
56caf160
EZ
3276using, a flag in the current target_ops structure is tested (e.g.,
3277@code{target_has_stack}), or a function is called through a pointer in the
c906108c 3278current target_ops structure. In this way, when a new remote interface
56caf160 3279is added, only one module needs to be touched---the one that actually
c906108c
SS
3280implements the new remote interface. Other examples of
3281attribute-structs are BFD access to multiple kinds of object file
25822942 3282formats, or @value{GDBN}'s access to multiple source languages.
c906108c 3283
56caf160
EZ
3284Please avoid duplicating code. For example, in @value{GDBN} 3.x all
3285the code interfacing between @code{ptrace} and the rest of
3286@value{GDBN} was duplicated in @file{*-dep.c}, and so changing
3287something was very painful. In @value{GDBN} 4.x, these have all been
3288consolidated into @file{infptrace.c}. @file{infptrace.c} can deal
3289with variations between systems the same way any system-independent
3290file would (hooks, @code{#if defined}, etc.), and machines which are
3291radically different don't need to use @file{infptrace.c} at all.
c906108c 3292
56caf160 3293Don't put debugging @code{printf}s in the code.
c906108c 3294
8487521e 3295@node Porting GDB
c906108c 3296
25822942 3297@chapter Porting @value{GDBN}
56caf160 3298@cindex porting to new machines
c906108c 3299
56caf160
EZ
3300Most of the work in making @value{GDBN} compile on a new machine is in
3301specifying the configuration of the machine. This is done in a
3302dizzying variety of header files and configuration scripts, which we
3303hope to make more sensible soon. Let's say your new host is called an
3304@var{xyz} (e.g., @samp{sun4}), and its full three-part configuration
3305name is @code{@var{arch}-@var{xvend}-@var{xos}} (e.g.,
3306@samp{sparc-sun-sunos4}). In particular:
c906108c 3307
56caf160
EZ
3308@itemize @bullet
3309@item
c906108c
SS
3310In the top level directory, edit @file{config.sub} and add @var{arch},
3311@var{xvend}, and @var{xos} to the lists of supported architectures,
3312vendors, and operating systems near the bottom of the file. Also, add
3313@var{xyz} as an alias that maps to
3314@code{@var{arch}-@var{xvend}-@var{xos}}. You can test your changes by
3315running
3316
3317@example
3318./config.sub @var{xyz}
3319@end example
56caf160 3320
c906108c
SS
3321@noindent
3322and
56caf160 3323
c906108c
SS
3324@example
3325./config.sub @code{@var{arch}-@var{xvend}-@var{xos}}
3326@end example
56caf160 3327
c906108c
SS
3328@noindent
3329which should both respond with @code{@var{arch}-@var{xvend}-@var{xos}}
3330and no error messages.
3331
56caf160 3332@noindent
c906108c
SS
3333You need to port BFD, if that hasn't been done already. Porting BFD is
3334beyond the scope of this manual.
3335
56caf160 3336@item
25822942 3337To configure @value{GDBN} itself, edit @file{gdb/configure.host} to recognize
c906108c
SS
3338your system and set @code{gdb_host} to @var{xyz}, and (unless your
3339desired target is already available) also edit @file{gdb/configure.tgt},
3340setting @code{gdb_target} to something appropriate (for instance,
3341@var{xyz}).
3342
56caf160 3343@item
25822942 3344Finally, you'll need to specify and define @value{GDBN}'s host-, native-, and
c906108c
SS
3345target-dependent @file{.h} and @file{.c} files used for your
3346configuration.
56caf160 3347@end itemize
c906108c 3348
25822942 3349@section Configuring @value{GDBN} for Release
c906108c 3350
56caf160
EZ
3351@cindex preparing a release
3352@cindex making a distribution tarball
c906108c
SS
3353From the top level directory (containing @file{gdb}, @file{bfd},
3354@file{libiberty}, and so on):
56caf160 3355
c906108c
SS
3356@example
3357make -f Makefile.in gdb.tar.gz
3358@end example
3359
56caf160 3360@noindent
c906108c
SS
3361This will properly configure, clean, rebuild any files that are
3362distributed pre-built (e.g. @file{c-exp.tab.c} or @file{refcard.ps}),
3363and will then make a tarfile. (If the top level directory has already
3364been configured, you can just do @code{make gdb.tar.gz} instead.)
3365
3366This procedure requires:
56caf160 3367
c906108c 3368@itemize @bullet
56caf160
EZ
3369
3370@item
3371symbolic links;
3372
3373@item
3374@code{makeinfo} (texinfo2 level);
3375
3376@item
3377@TeX{};
3378
3379@item
3380@code{dvips};
3381
3382@item
3383@code{yacc} or @code{bison}.
c906108c 3384@end itemize
56caf160 3385
c906108c
SS
3386@noindent
3387@dots{} and the usual slew of utilities (@code{sed}, @code{tar}, etc.).
3388
3389@subheading TEMPORARY RELEASE PROCEDURE FOR DOCUMENTATION
3390
3391@file{gdb.texinfo} is currently marked up using the texinfo-2 macros,
3392which are not yet a default for anything (but we have to start using
3393them sometime).
3394
3395For making paper, the only thing this implies is the right generation of
3396@file{texinfo.tex} needs to be included in the distribution.
3397
3398For making info files, however, rather than duplicating the texinfo2
3399distribution, generate @file{gdb-all.texinfo} locally, and include the
3400files @file{gdb.info*} in the distribution. Note the plural;
3401@code{makeinfo} will split the document into one overall file and five
3402or so included files.
3403
085dd6e6
JM
3404@node Testsuite
3405
3406@chapter Testsuite
56caf160 3407@cindex test suite
085dd6e6 3408
56caf160
EZ
3409The testsuite is an important component of the @value{GDBN} package.
3410While it is always worthwhile to encourage user testing, in practice
3411this is rarely sufficient; users typically use only a small subset of
3412the available commands, and it has proven all too common for a change
3413to cause a significant regression that went unnoticed for some time.
085dd6e6 3414
56caf160
EZ
3415The @value{GDBN} testsuite uses the DejaGNU testing framework.
3416DejaGNU is built using @code{Tcl} and @code{expect}. The tests
3417themselves are calls to various @code{Tcl} procs; the framework runs all the
3418procs and summarizes the passes and fails.
085dd6e6
JM
3419
3420@section Using the Testsuite
3421
56caf160 3422@cindex running the test suite
25822942 3423To run the testsuite, simply go to the @value{GDBN} object directory (or to the
085dd6e6
JM
3424testsuite's objdir) and type @code{make check}. This just sets up some
3425environment variables and invokes DejaGNU's @code{runtest} script. While
3426the testsuite is running, you'll get mentions of which test file is in use,
3427and a mention of any unexpected passes or fails. When the testsuite is
3428finished, you'll get a summary that looks like this:
56caf160 3429
085dd6e6
JM
3430@example
3431 === gdb Summary ===
3432
3433# of expected passes 6016
3434# of unexpected failures 58
3435# of unexpected successes 5
3436# of expected failures 183
3437# of unresolved testcases 3
3438# of untested testcases 5
3439@end example
56caf160 3440
085dd6e6
JM
3441The ideal test run consists of expected passes only; however, reality
3442conspires to keep us from this ideal. Unexpected failures indicate
56caf160
EZ
3443real problems, whether in @value{GDBN} or in the testsuite. Expected
3444failures are still failures, but ones which have been decided are too
3445hard to deal with at the time; for instance, a test case might work
3446everywhere except on AIX, and there is no prospect of the AIX case
3447being fixed in the near future. Expected failures should not be added
3448lightly, since you may be masking serious bugs in @value{GDBN}.
3449Unexpected successes are expected fails that are passing for some
3450reason, while unresolved and untested cases often indicate some minor
3451catastrophe, such as the compiler being unable to deal with a test
3452program.
3453
3454When making any significant change to @value{GDBN}, you should run the
3455testsuite before and after the change, to confirm that there are no
3456regressions. Note that truly complete testing would require that you
3457run the testsuite with all supported configurations and a variety of
3458compilers; however this is more than really necessary. In many cases
3459testing with a single configuration is sufficient. Other useful
3460options are to test one big-endian (Sparc) and one little-endian (x86)
3461host, a cross config with a builtin simulator (powerpc-eabi,
3462mips-elf), or a 64-bit host (Alpha).
3463
3464If you add new functionality to @value{GDBN}, please consider adding
3465tests for it as well; this way future @value{GDBN} hackers can detect
3466and fix their changes that break the functionality you added.
3467Similarly, if you fix a bug that was not previously reported as a test
3468failure, please add a test case for it. Some cases are extremely
3469difficult to test, such as code that handles host OS failures or bugs
3470in particular versions of compilers, and it's OK not to try to write
3471tests for all of those.
085dd6e6
JM
3472
3473@section Testsuite Organization
3474
56caf160 3475@cindex test suite organization
085dd6e6
JM
3476The testsuite is entirely contained in @file{gdb/testsuite}. While the
3477testsuite includes some makefiles and configury, these are very minimal,
3478and used for little besides cleaning up, since the tests themselves
25822942 3479handle the compilation of the programs that @value{GDBN} will run. The file
085dd6e6 3480@file{testsuite/lib/gdb.exp} contains common utility procs useful for
25822942 3481all @value{GDBN} tests, while the directory @file{testsuite/config} contains
085dd6e6
JM
3482configuration-specific files, typically used for special-purpose
3483definitions of procs like @code{gdb_load} and @code{gdb_start}.
3484
3485The tests themselves are to be found in @file{testsuite/gdb.*} and
3486subdirectories of those. The names of the test files must always end
3487with @file{.exp}. DejaGNU collects the test files by wildcarding
3488in the test directories, so both subdirectories and individual files
3489get chosen and run in alphabetical order.
3490
3491The following table lists the main types of subdirectories and what they
3492are for. Since DejaGNU finds test files no matter where they are
3493located, and since each test file sets up its own compilation and
3494execution environment, this organization is simply for convenience and
3495intelligibility.
3496
56caf160 3497@table @file
085dd6e6 3498@item gdb.base
085dd6e6 3499This is the base testsuite. The tests in it should apply to all
25822942 3500configurations of @value{GDBN} (but generic native-only tests may live here).
085dd6e6 3501The test programs should be in the subset of C that is valid K&R,
56caf160 3502ANSI/ISO, and C++ (@code{#ifdef}s are allowed if necessary, for instance
085dd6e6
JM
3503for prototypes).
3504
3505@item gdb.@var{lang}
56caf160 3506Language-specific tests for any language @var{lang} besides C. Examples are
085dd6e6
JM
3507@file{gdb.c++} and @file{gdb.java}.
3508
3509@item gdb.@var{platform}
085dd6e6
JM
3510Non-portable tests. The tests are specific to a specific configuration
3511(host or target), such as HP-UX or eCos. Example is @file{gdb.hp}, for
3512HP-UX.
3513
3514@item gdb.@var{compiler}
085dd6e6
JM
3515Tests specific to a particular compiler. As of this writing (June
35161999), there aren't currently any groups of tests in this category that
3517couldn't just as sensibly be made platform-specific, but one could
56caf160
EZ
3518imagine a @file{gdb.gcc}, for tests of @value{GDBN}'s handling of GCC
3519extensions.
085dd6e6
JM
3520
3521@item gdb.@var{subsystem}
25822942 3522Tests that exercise a specific @value{GDBN} subsystem in more depth. For
085dd6e6
JM
3523instance, @file{gdb.disasm} exercises various disassemblers, while
3524@file{gdb.stabs} tests pathways through the stabs symbol reader.
085dd6e6
JM
3525@end table
3526
3527@section Writing Tests
56caf160 3528@cindex writing tests
085dd6e6 3529
25822942 3530In many areas, the @value{GDBN} tests are already quite comprehensive; you
085dd6e6
JM
3531should be able to copy existing tests to handle new cases.
3532
3533You should try to use @code{gdb_test} whenever possible, since it
3534includes cases to handle all the unexpected errors that might happen.
3535However, it doesn't cost anything to add new test procedures; for
3536instance, @file{gdb.base/exprs.exp} defines a @code{test_expr} that
3537calls @code{gdb_test} multiple times.
3538
3539Only use @code{send_gdb} and @code{gdb_expect} when absolutely
25822942 3540necessary, such as when @value{GDBN} has several valid responses to a command.
085dd6e6
JM
3541
3542The source language programs do @emph{not} need to be in a consistent
25822942 3543style. Since @value{GDBN} is used to debug programs written in many different
085dd6e6 3544styles, it's worth having a mix of styles in the testsuite; for
25822942 3545instance, some @value{GDBN} bugs involving the display of source lines would
085dd6e6
JM
3546never manifest themselves if the programs used GNU coding style
3547uniformly.
3548
c906108c
SS
3549@node Hints
3550
3551@chapter Hints
3552
3553Check the @file{README} file, it often has useful information that does not
3554appear anywhere else in the directory.
3555
3556@menu
25822942 3557* Getting Started:: Getting started working on @value{GDBN}
33e16fad 3558* Debugging GDB:: Debugging @value{GDBN} with itself
c906108c
SS
3559@end menu
3560
3561@node Getting Started,,, Hints
3562
3563@section Getting Started
3564
25822942 3565@value{GDBN} is a large and complicated program, and if you first starting to
c906108c
SS
3566work on it, it can be hard to know where to start. Fortunately, if you
3567know how to go about it, there are ways to figure out what is going on.
3568
25822942
DB
3569This manual, the @value{GDBN} Internals manual, has information which applies
3570generally to many parts of @value{GDBN}.
c906108c
SS
3571
3572Information about particular functions or data structures are located in
3573comments with those functions or data structures. If you run across a
3574function or a global variable which does not have a comment correctly
25822942 3575explaining what is does, this can be thought of as a bug in @value{GDBN}; feel
c906108c
SS
3576free to submit a bug report, with a suggested comment if you can figure
3577out what the comment should say. If you find a comment which is
3578actually wrong, be especially sure to report that.
3579
3580Comments explaining the function of macros defined in host, target, or
3581native dependent files can be in several places. Sometimes they are
3582repeated every place the macro is defined. Sometimes they are where the
3583macro is used. Sometimes there is a header file which supplies a
3584default definition of the macro, and the comment is there. This manual
3585also documents all the available macros.
3586@c (@pxref{Host Conditionals}, @pxref{Target
3587@c Conditionals}, @pxref{Native Conditionals}, and @pxref{Obsolete
3588@c Conditionals})
3589
56caf160
EZ
3590Start with the header files. Once you have some idea of how
3591@value{GDBN}'s internal symbol tables are stored (see @file{symtab.h},
3592@file{gdbtypes.h}), you will find it much easier to understand the
3593code which uses and creates those symbol tables.
c906108c
SS
3594
3595You may wish to process the information you are getting somehow, to
3596enhance your understanding of it. Summarize it, translate it to another
25822942 3597language, add some (perhaps trivial or non-useful) feature to @value{GDBN}, use
c906108c
SS
3598the code to predict what a test case would do and write the test case
3599and verify your prediction, etc. If you are reading code and your eyes
3600are starting to glaze over, this is a sign you need to use a more active
3601approach.
3602
25822942 3603Once you have a part of @value{GDBN} to start with, you can find more
c906108c
SS
3604specifically the part you are looking for by stepping through each
3605function with the @code{next} command. Do not use @code{step} or you
3606will quickly get distracted; when the function you are stepping through
3607calls another function try only to get a big-picture understanding
3608(perhaps using the comment at the beginning of the function being
3609called) of what it does. This way you can identify which of the
3610functions being called by the function you are stepping through is the
3611one which you are interested in. You may need to examine the data
3612structures generated at each stage, with reference to the comments in
3613the header files explaining what the data structures are supposed to
3614look like.
3615
3616Of course, this same technique can be used if you are just reading the
3617code, rather than actually stepping through it. The same general
3618principle applies---when the code you are looking at calls something
3619else, just try to understand generally what the code being called does,
3620rather than worrying about all its details.
3621
56caf160
EZ
3622@cindex command implementation
3623A good place to start when tracking down some particular area is with
3624a command which invokes that feature. Suppose you want to know how
3625single-stepping works. As a @value{GDBN} user, you know that the
3626@code{step} command invokes single-stepping. The command is invoked
3627via command tables (see @file{command.h}); by convention the function
3628which actually performs the command is formed by taking the name of
3629the command and adding @samp{_command}, or in the case of an
3630@code{info} subcommand, @samp{_info}. For example, the @code{step}
3631command invokes the @code{step_command} function and the @code{info
3632display} command invokes @code{display_info}. When this convention is
3633not followed, you might have to use @code{grep} or @kbd{M-x
3634tags-search} in emacs, or run @value{GDBN} on itself and set a
3635breakpoint in @code{execute_command}.
3636
3637@cindex @code{bug-gdb} mailing list
c906108c
SS
3638If all of the above fail, it may be appropriate to ask for information
3639on @code{bug-gdb}. But @emph{never} post a generic question like ``I was
3640wondering if anyone could give me some tips about understanding
25822942 3641@value{GDBN}''---if we had some magic secret we would put it in this manual.
c906108c
SS
3642Suggestions for improving the manual are always welcome, of course.
3643
33e16fad 3644@node Debugging GDB,,,Hints
c906108c 3645
25822942 3646@section Debugging @value{GDBN} with itself
56caf160 3647@cindex debugging @value{GDBN}
c906108c 3648
25822942 3649If @value{GDBN} is limping on your machine, this is the preferred way to get it
c906108c
SS
3650fully functional. Be warned that in some ancient Unix systems, like
3651Ultrix 4.2, a program can't be running in one process while it is being
56caf160 3652debugged in another. Rather than typing the command @kbd{@w{./gdb
c906108c 3653./gdb}}, which works on Suns and such, you can copy @file{gdb} to
56caf160 3654@file{gdb2} and then type @kbd{@w{./gdb ./gdb2}}.
c906108c 3655
25822942 3656When you run @value{GDBN} in the @value{GDBN} source directory, it will read a
c906108c
SS
3657@file{.gdbinit} file that sets up some simple things to make debugging
3658gdb easier. The @code{info} command, when executed without a subcommand
25822942 3659in a @value{GDBN} being debugged by gdb, will pop you back up to the top level
c906108c
SS
3660gdb. See @file{.gdbinit} for details.
3661
3662If you use emacs, you will probably want to do a @code{make TAGS} after
3663you configure your distribution; this will put the machine dependent
3664routines for your local machine where they will be accessed first by
3665@kbd{M-.}
3666
25822942 3667Also, make sure that you've either compiled @value{GDBN} with your local cc, or
c906108c
SS
3668have run @code{fixincludes} if you are compiling with gcc.
3669
3670@section Submitting Patches
3671
56caf160 3672@cindex submitting patches
c906108c 3673Thanks for thinking of offering your changes back to the community of
25822942 3674@value{GDBN} users. In general we like to get well designed enhancements.
c906108c
SS
3675Thanks also for checking in advance about the best way to transfer the
3676changes.
3677
25822942
DB
3678The @value{GDBN} maintainers will only install ``cleanly designed'' patches.
3679This manual summarizes what we believe to be clean design for @value{GDBN}.
c906108c
SS
3680
3681If the maintainers don't have time to put the patch in when it arrives,
3682or if there is any question about a patch, it goes into a large queue
3683with everyone else's patches and bug reports.
3684
56caf160 3685@cindex legal papers for code contributions
c906108c
SS
3686The legal issue is that to incorporate substantial changes requires a
3687copyright assignment from you and/or your employer, granting ownership
3688of the changes to the Free Software Foundation. You can get the
9e0b60a8
JM
3689standard documents for doing this by sending mail to @code{gnu@@gnu.org}
3690and asking for it. We recommend that people write in "All programs
3691owned by the Free Software Foundation" as "NAME OF PROGRAM", so that
56caf160
EZ
3692changes in many programs (not just @value{GDBN}, but GAS, Emacs, GCC,
3693etc) can be
9e0b60a8
JM
3694contributed with only one piece of legalese pushed through the
3695bureacracy and filed with the FSF. We can't start merging changes until
3696this paperwork is received by the FSF (their rules, which we follow
3697since we maintain it for them).
c906108c
SS
3698
3699Technically, the easiest way to receive changes is to receive each
56caf160
EZ
3700feature as a small context diff or unidiff, suitable for @code{patch}.
3701Each message sent to me should include the changes to C code and
3702header files for a single feature, plus @file{ChangeLog} entries for
3703each directory where files were modified, and diffs for any changes
3704needed to the manuals (@file{gdb/doc/gdb.texinfo} or
3705@file{gdb/doc/gdbint.texinfo}). If there are a lot of changes for a
3706single feature, they can be split down into multiple messages.
9e0b60a8
JM
3707
3708In this way, if we read and like the feature, we can add it to the
c906108c 3709sources with a single patch command, do some testing, and check it in.
56caf160
EZ
3710If you leave out the @file{ChangeLog}, we have to write one. If you leave
3711out the doc, we have to puzzle out what needs documenting. Etc., etc.
c906108c 3712
9e0b60a8
JM
3713The reason to send each change in a separate message is that we will not
3714install some of the changes. They'll be returned to you with questions
3715or comments. If we're doing our job correctly, the message back to you
c906108c 3716will say what you have to fix in order to make the change acceptable.
9e0b60a8
JM
3717The reason to have separate messages for separate features is so that
3718the acceptable changes can be installed while one or more changes are
3719being reworked. If multiple features are sent in a single message, we
3720tend to not put in the effort to sort out the acceptable changes from
3721the unacceptable, so none of the features get installed until all are
3722acceptable.
3723
3724If this sounds painful or authoritarian, well, it is. But we get a lot
3725of bug reports and a lot of patches, and many of them don't get
3726installed because we don't have the time to finish the job that the bug
c906108c
SS
3727reporter or the contributor could have done. Patches that arrive
3728complete, working, and well designed, tend to get installed on the day
9e0b60a8
JM
3729they arrive. The others go into a queue and get installed as time
3730permits, which, since the maintainers have many demands to meet, may not
3731be for quite some time.
c906108c 3732
56caf160
EZ
3733Please send patches directly to
3734@email{gdb-patches@@sourceware.cygnus.com, the @value{GDBN} maintainers}.
c906108c
SS
3735
3736@section Obsolete Conditionals
56caf160 3737@cindex obsolete code
c906108c 3738
25822942 3739Fragments of old code in @value{GDBN} sometimes reference or set the following
c906108c
SS
3740configuration macros. They should not be used by new code, and old uses
3741should be removed as those parts of the debugger are otherwise touched.
3742
3743@table @code
c906108c
SS
3744@item STACK_END_ADDR
3745This macro used to define where the end of the stack appeared, for use
3746in interpreting core file formats that don't record this address in the
25822942
DB
3747core file itself. This information is now configured in BFD, and @value{GDBN}
3748gets the info portably from there. The values in @value{GDBN}'s configuration
c906108c 3749files should be moved into BFD configuration files (if needed there),
25822942 3750and deleted from all of @value{GDBN}'s config files.
c906108c
SS
3751
3752Any @file{@var{foo}-xdep.c} file that references STACK_END_ADDR
3753is so old that it has never been converted to use BFD. Now that's old!
3754
3755@item PYRAMID_CONTROL_FRAME_DEBUGGING
3756pyr-xdep.c
3757@item PYRAMID_CORE
3758pyr-xdep.c
3759@item PYRAMID_PTRACE
3760pyr-xdep.c
3761
3762@item REG_STACK_SEGMENT
3763exec.c
3764
3765@end table
3766
56caf160
EZ
3767@node Index
3768@unnumbered Index
3769
3770@printindex cp
3771
449f3b6c
AC
3772@c TeX can handle the contents at the start but makeinfo 3.12 can not
3773@ifinfo
c906108c 3774@contents
449f3b6c
AC
3775@end ifinfo
3776@ifhtml
3777@contents
3778@end ifhtml
3779
c906108c 3780@bye
This page took 0.712651 seconds and 4 git commands to generate.