aa1fd565f9d7cb5f7faba063abc17173762ab4c0
[external/binutils.git] / gdb / doc / gdbint.info-3
1 This is Info file gdbint.info, produced by Makeinfo version 1.68 from
2 the input file ./gdbint.texinfo.
3
4 START-INFO-DIR-ENTRY
5 * Gdb-Internals: (gdbint).      The GNU debugger's internals.
6 END-INFO-DIR-ENTRY
7
8    This file documents the internals of the GNU debugger GDB.
9
10    Copyright 1990-1999 Free Software Foundation, Inc.  Contributed by
11 Cygnus Solutions.  Written by John Gilmore.  Second Edition by Stan
12 Shebs.
13
14    Permission is granted to make and distribute verbatim copies of this
15 manual provided the copyright notice and this permission notice are
16 preserved on all copies.
17
18    Permission is granted to copy or distribute modified versions of this
19 manual under the terms of the GPL (for which purpose this text may be
20 regarded as a program in the language TeX).
21
22 \1f
23 File: gdbint.info,  Node: Porting GDB,  Next: Hints,  Prev: Coding,  Up: Top
24
25 Porting GDB
26 ***********
27
28    Most of the work in making GDB compile on a new machine is in
29 specifying the configuration of the machine.  This is done in a
30 dizzying variety of header files and configuration scripts, which we
31 hope to make more sensible soon.  Let's say your new host is called an
32 XYZ (e.g.  `sun4'), and its full three-part configuration name is
33 `ARCH-XVEND-XOS' (e.g.  `sparc-sun-sunos4').  In particular:
34
35    In the top level directory, edit `config.sub' and add ARCH, XVEND,
36 and XOS to the lists of supported architectures, vendors, and operating
37 systems near the bottom of the file.  Also, add XYZ as an alias that
38 maps to `ARCH-XVEND-XOS'.  You can test your changes by running
39
40      ./config.sub XYZ
41
42 and
43      ./config.sub `ARCH-XVEND-XOS'
44
45 which should both respond with `ARCH-XVEND-XOS' and no error messages.
46
47    You need to port BFD, if that hasn't been done already.  Porting BFD
48 is beyond the scope of this manual.
49
50    To configure GDB itself, edit `gdb/configure.host' to recognize your
51 system and set `gdb_host' to XYZ, and (unless your desired target is
52 already available) also edit `gdb/configure.tgt', setting `gdb_target'
53 to something appropriate (for instance, XYZ).
54
55    Finally, you'll need to specify and define GDB's host-, native-, and
56 target-dependent `.h' and `.c' files used for your configuration.
57
58 Configuring GDB for Release
59 ===========================
60
61    From the top level directory (containing `gdb', `bfd', `libiberty',
62 and so on):
63      make -f Makefile.in gdb.tar.gz
64
65    This will properly configure, clean, rebuild any files that are
66 distributed pre-built (e.g. `c-exp.tab.c' or `refcard.ps'), and will
67 then make a tarfile.  (If the top level directory has already been
68 configured, you can just do `make gdb.tar.gz' instead.)
69
70    This procedure requires:
71    * symbolic links
72
73    * `makeinfo' (texinfo2 level)
74
75    * TeX
76
77    * `dvips'
78
79    * `yacc' or `bison'
80
81 ... and the usual slew of utilities (`sed', `tar', etc.).
82
83 TEMPORARY RELEASE PROCEDURE FOR DOCUMENTATION
84 ---------------------------------------------
85
86    `gdb.texinfo' is currently marked up using the texinfo-2 macros,
87 which are not yet a default for anything (but we have to start using
88 them sometime).
89
90    For making paper, the only thing this implies is the right
91 generation of `texinfo.tex' needs to be included in the distribution.
92
93    For making info files, however, rather than duplicating the texinfo2
94 distribution, generate `gdb-all.texinfo' locally, and include the files
95 `gdb.info*' in the distribution.  Note the plural; `makeinfo' will
96 split the document into one overall file and five or so included files.
97
98 \1f
99 File: gdbint.info,  Node: Hints,  Prev: Porting GDB,  Up: Top
100
101 Hints
102 *****
103
104    Check the `README' file, it often has useful information that does
105 not appear anywhere else in the directory.
106
107 * Menu:
108
109 * Getting Started::             Getting started working on GDB
110 * Debugging GDB::               Debugging GDB with itself
111
112 \1f
113 File: gdbint.info,  Node: Getting Started,  Up: Hints
114
115 Getting Started
116 ===============
117
118    GDB is a large and complicated program, and if you first starting to
119 work on it, it can be hard to know where to start.  Fortunately, if you
120 know how to go about it, there are ways to figure out what is going on.
121
122    This manual, the GDB Internals manual, has information which applies
123 generally to many parts of GDB.
124
125    Information about particular functions or data structures are
126 located in comments with those functions or data structures.  If you
127 run across a function or a global variable which does not have a
128 comment correctly explaining what is does, this can be thought of as a
129 bug in GDB; feel free to submit a bug report, with a suggested comment
130 if you can figure out what the comment should say.  If you find a
131 comment which is actually wrong, be especially sure to report that.
132
133    Comments explaining the function of macros defined in host, target,
134 or native dependent files can be in several places.  Sometimes they are
135 repeated every place the macro is defined.  Sometimes they are where the
136 macro is used.  Sometimes there is a header file which supplies a
137 default definition of the macro, and the comment is there.  This manual
138 also documents all the available macros.
139
140    Start with the header files.  Once you some idea of how GDB's
141 internal symbol tables are stored (see `symtab.h', `gdbtypes.h'), you
142 will find it much easier to understand the code which uses and creates
143 those symbol tables.
144
145    You may wish to process the information you are getting somehow, to
146 enhance your understanding of it.  Summarize it, translate it to another
147 language, add some (perhaps trivial or non-useful) feature to GDB, use
148 the code to predict what a test case would do and write the test case
149 and verify your prediction, etc.  If you are reading code and your eyes
150 are starting to glaze over, this is a sign you need to use a more active
151 approach.
152
153    Once you have a part of GDB to start with, you can find more
154 specifically the part you are looking for by stepping through each
155 function with the `next' command.  Do not use `step' or you will
156 quickly get distracted; when the function you are stepping through
157 calls another function try only to get a big-picture understanding
158 (perhaps using the comment at the beginning of the function being
159 called) of what it does.  This way you can identify which of the
160 functions being called by the function you are stepping through is the
161 one which you are interested in.  You may need to examine the data
162 structures generated at each stage, with reference to the comments in
163 the header files explaining what the data structures are supposed to
164 look like.
165
166    Of course, this same technique can be used if you are just reading
167 the code, rather than actually stepping through it.  The same general
168 principle applies--when the code you are looking at calls something
169 else, just try to understand generally what the code being called does,
170 rather than worrying about all its details.
171
172    A good place to start when tracking down some particular area is
173 with a command which invokes that feature.  Suppose you want to know how
174 single-stepping works.  As a GDB user, you know that the `step' command
175 invokes single-stepping.  The command is invoked via command tables
176 (see `command.h'); by convention the function which actually performs
177 the command is formed by taking the name of the command and adding
178 `_command', or in the case of an `info' subcommand, `_info'.  For
179 example, the `step' command invokes the `step_command' function and the
180 `info display' command invokes `display_info'.  When this convention is
181 not followed, you might have to use `grep' or `M-x tags-search' in
182 emacs, or run GDB on itself and set a breakpoint in `execute_command'.
183
184    If all of the above fail, it may be appropriate to ask for
185 information on `bug-gdb'.  But *never* post a generic question like "I
186 was wondering if anyone could give me some tips about understanding
187 GDB"--if we had some magic secret we would put it in this manual.
188 Suggestions for improving the manual are always welcome, of course.
189
190 \1f
191 File: gdbint.info,  Node: Debugging GDB,  Up: Hints
192
193 Debugging GDB with itself
194 =========================
195
196    If GDB is limping on your machine, this is the preferred way to get
197 it fully functional.  Be warned that in some ancient Unix systems, like
198 Ultrix 4.2, a program can't be running in one process while it is being
199 debugged in another.  Rather than typing the command `./gdb ./gdb',
200 which works on Suns and such, you can copy `gdb' to `gdb2' and then
201 type `./gdb ./gdb2'.
202
203    When you run GDB in the GDB source directory, it will read a
204 `.gdbinit' file that sets up some simple things to make debugging gdb
205 easier.  The `info' command, when executed without a subcommand in a
206 GDB being debugged by gdb, will pop you back up to the top level gdb.
207 See `.gdbinit' for details.
208
209    If you use emacs, you will probably want to do a `make TAGS' after
210 you configure your distribution; this will put the machine dependent
211 routines for your local machine where they will be accessed first by
212 `M-.'
213
214    Also, make sure that you've either compiled GDB with your local cc,
215 or have run `fixincludes' if you are compiling with gcc.
216
217 Submitting Patches
218 ==================
219
220    Thanks for thinking of offering your changes back to the community of
221 GDB users.  In general we like to get well designed enhancements.
222 Thanks also for checking in advance about the best way to transfer the
223 changes.
224
225    The GDB maintainers will only install "cleanly designed" patches.
226 You may not always agree on what is clean design.
227
228    If the maintainers don't have time to put the patch in when it
229 arrives, or if there is any question about a patch, it goes into a
230 large queue with everyone else's patches and bug reports.
231
232    The legal issue is that to incorporate substantial changes requires a
233 copyright assignment from you and/or your employer, granting ownership
234 of the changes to the Free Software Foundation.  You can get the
235 standard document for doing this by sending mail to
236 `gnu@prep.ai.mit.edu' and asking for it.  I recommend that people write
237 in "All programs owned by the Free Software Foundation" as "NAME OF
238 PROGRAM", so that changes in many programs (not just GDB, but GAS,
239 Emacs, GCC, etc) can be contributed with only one piece of legalese
240 pushed through the bureacracy and filed with the FSF.  I can't start
241 merging changes until this paperwork is received by the FSF (their
242 rules, which I follow since I maintain it for them).
243
244    Technically, the easiest way to receive changes is to receive each
245 feature as a small context diff or unidiff, suitable for "patch".  Each
246 message sent to me should include the changes to C code and header
247 files for a single feature, plus ChangeLog entries for each directory
248 where files were modified, and diffs for any changes needed to the
249 manuals (gdb/doc/gdb.texi or gdb/doc/gdbint.texi).  If there are a lot
250 of changes for a single feature, they can be split down into multiple
251 messages.
252
253    In this way, if I read and like the feature, I can add it to the
254 sources with a single patch command, do some testing, and check it in.
255 If you leave out the ChangeLog, I have to write one.  If you leave out
256 the doc, I have to puzzle out what needs documenting.  Etc.
257
258    The reason to send each change in a separate message is that I will
259 not install some of the changes.  They'll be returned to you with
260 questions or comments.  If I'm doing my job, my message back to you
261 will say what you have to fix in order to make the change acceptable.
262 The reason to have separate messages for separate features is so that
263 other changes (which I *am* willing to accept) can be installed while
264 one or more changes are being reworked.  If multiple features are sent
265 in a single message, I tend to not put in the effort to sort out the
266 acceptable changes from the unacceptable, so none of the features get
267 installed until all are acceptable.
268
269    If this sounds painful or authoritarian, well, it is.  But I get a
270 lot of bug reports and a lot of patches, and most of them don't get
271 installed because I don't have the time to finish the job that the bug
272 reporter or the contributor could have done.  Patches that arrive
273 complete, working, and well designed, tend to get installed on the day
274 they arrive.  The others go into a queue and get installed if and when
275 I scan back over the queue - which can literally take months sometimes.
276 It's in both our interests to make patch installation easy - you get
277 your changes installed, and I make some forward progress on GDB in a
278 normal 12-hour day (instead of them having to wait until I have a
279 14-hour or 16-hour day to spend cleaning up patches before I can
280 install them).
281
282    Please send patches directly to the GDB maintainers at
283 `gdb-patches@cygnus.com'.
284
285 Obsolete Conditionals
286 =====================
287
288    Fragments of old code in GDB sometimes reference or set the following
289 configuration macros.  They should not be used by new code, and old uses
290 should be removed as those parts of the debugger are otherwise touched.
291
292 `STACK_END_ADDR'
293      This macro used to define where the end of the stack appeared, for
294      use in interpreting core file formats that don't record this
295      address in the core file itself.  This information is now
296      configured in BFD, and GDB gets the info portably from there.  The
297      values in GDB's configuration files should be moved into BFD
298      configuration files (if needed there), and deleted from all of
299      GDB's config files.
300
301      Any `FOO-xdep.c' file that references STACK_END_ADDR is so old
302      that it has never been converted to use BFD.  Now that's old!
303
304 `PYRAMID_CONTROL_FRAME_DEBUGGING'
305      pyr-xdep.c
306
307 `PYRAMID_CORE'
308      pyr-xdep.c
309
310 `PYRAMID_PTRACE'
311      pyr-xdep.c
312
313 `REG_STACK_SEGMENT'
314      exec.c
315
316