]>
Commit | Line | Data |
---|---|---|
c50c5197 JG |
1 | README for gdb-4.7 release |
2 | Stu Grossman & John Gilmore 23 October 1992 | |
c45c19f8 | 3 | |
846058ed | 4 | This is GDB, the GNU source-level debugger, presently running under un*x. |
c50c5197 | 5 | A summary of new features is in the file `NEWS'. |
c45c19f8 | 6 | |
bd5635a1 | 7 | |
846058ed JG |
8 | Unpacking and Installation -- quick overview |
9 | ========================== | |
bd5635a1 | 10 | |
fbda4193 JG |
11 | In this release, the GDB debugger sources, the generic GNU include |
12 | files, the BFD ("binary file description") library, the readline library, | |
c50c5197 JG |
13 | and other libraries all have directories of their own underneath |
14 | the gdb-4.7 directory. The idea is that a variety of GNU tools can | |
fbda4193 JG |
15 | share a common copy of these things. Configuration scripts and |
16 | makefiles exist to cruise up and down this directory tree and | |
17 | automatically build all the pieces in the right order. | |
bd5635a1 | 18 | |
c50c5197 JG |
19 | When you unpack the gdb-4.7.tar.Z file, you'll get a directory called |
20 | `gdb-4.7', which contains: | |
bd5635a1 | 21 | |
c50c5197 JG |
22 | COPYING.LIB config/ configure.texi mmalloc/ |
23 | Makefile.in config.sub* gdb/ move-if-change* | |
24 | README configure* glob/ opcodes/ | |
25 | bfd/ configure.in include/ readline/ | |
26 | cfg-paper.texi configure.man libiberty/ texinfo/ | |
170d0c85 | 27 | |
846058ed | 28 | To build GDB, you can just do: |
170d0c85 | 29 | |
c50c5197 | 30 | cd gdb-4.7 |
fbda4193 | 31 | ./configure HOSTTYPE (e.g. sun4, decstation) |
170d0c85 | 32 | make |
846058ed | 33 | cp gdb/gdb /usr/local/bin/gdb (or wherever you want) |
170d0c85 | 34 | |
846058ed | 35 | This will configure and build all the libraries as well as GDB. |
c45c19f8 JG |
36 | If you get compiler warnings during this stage, see the `Reporting Bugs' |
37 | section below; there are a few known problems. | |
361cc81a | 38 | |
c45c19f8 | 39 | GDB can be used as a cross-debugger, running on a machine of one type |
846058ed JG |
40 | while debugging a program running on a machine of another type. See below. |
41 | ||
42 | ||
43 | More Documentation | |
c50c5197 | 44 | ****************** |
846058ed | 45 | |
c50c5197 JG |
46 | The GDB 4 release includes an already-formatted reference card, ready |
47 | for printing with PostScript or GhostScript, in the `gdb' subdirectory | |
48 | of the main source directory--in `gdb-4.7/gdb/refcard.ps' of the | |
49 | version 4.7 release. If you can use PostScript or GhostScript with your | |
50 | printer, you can print the reference card immediately with `refcard.ps'. | |
846058ed | 51 | |
c50c5197 JG |
52 | The release also includes the source for the reference card. You |
53 | can format it, using TeX, by typing: | |
846058ed | 54 | |
575945e3 | 55 | make refcard.dvi |
846058ed | 56 | |
575945e3 JG |
57 | The GDB reference card is designed to print in landscape mode on US |
58 | "letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches | |
59 | high. You will need to specify this form of printing as an option to | |
60 | your DVI output program. | |
846058ed | 61 | |
c50c5197 JG |
62 | All the documentation for GDB comes as part of the machine-readable |
63 | distribution. The documentation is written in Texinfo format, which is | |
64 | a documentation system that uses a single source file to produce both | |
65 | on-line information and a printed manual. You can use one of the Info | |
66 | formatting commands to create the on-line version of the documentation | |
67 | and TeX (or `texi2roff') to typeset the printed version. | |
846058ed | 68 | |
c50c5197 JG |
69 | GDB includes an already formatted copy of the on-line Info version of |
70 | this manual in the `gdb' subdirectory. The main Info file is | |
575945e3 | 71 | `gdb-VERSION-NUMBER/gdb/gdb.info', and it refers to subordinate files |
c50c5197 JG |
72 | matching `gdb.info*' in the same directory. If necessary, you can |
73 | print out these files, or read them with any editor; but they are | |
74 | easier to read using the `info' subsystem in GNU Emacs or the | |
75 | standalone `info' program, available as part of the GNU Texinfo | |
76 | distribution. | |
846058ed | 77 | |
575945e3 | 78 | If you want to format these Info files yourself, you need one of the |
c50c5197 | 79 | Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'. |
846058ed | 80 | |
575945e3 | 81 | If you have `makeinfo' installed, and are in the top level GDB |
c50c5197 | 82 | source directory (`gdb-4.7', in the case of version 4.7), you can make |
575945e3 | 83 | the Info file by typing: |
846058ed | 84 | |
575945e3 JG |
85 | cd gdb |
86 | make gdb.info | |
846058ed | 87 | |
575945e3 JG |
88 | If you want to typeset and print copies of this manual, you need |
89 | TeX, a printing program such as `lpr', and `texinfo.tex', the Texinfo | |
90 | definitions file. | |
91 | ||
92 | TeX is typesetting program; it does not print files directly, but | |
93 | produces output files called DVI files. To print a typeset document, | |
94 | you need a program to print DVI files. If your system has TeX | |
95 | installed, chances are it has such a program. The precise command to | |
96 | use depends on your system; `lpr -d' is common; another is `dvips'. | |
97 | The DVI print command may require a file name without any extension or | |
98 | a `.dvi' extension. | |
99 | ||
100 | TeX also requires a macro definitions file called `texinfo.tex'. | |
101 | This file tells TeX how to typeset a document written in Texinfo | |
c50c5197 JG |
102 | format. On its own, TeX cannot read, much less typeset a Texinfo file. |
103 | `texinfo.tex' is distributed with GDB and is located in the | |
575945e3 JG |
104 | `gdb-VERSION-NUMBER/texinfo' directory. |
105 | ||
c50c5197 JG |
106 | If you have TeX and a DVI printer program installed, you can typeset |
107 | and print this manual. First switch to the the `gdb' subdirectory of | |
108 | the main source directory (for example, to `gdb-4.7/gdb') and then type: | |
170d0c85 | 109 | |
846058ed | 110 | make gdb.dvi |
170d0c85 | 111 | |
c50c5197 | 112 | |
846058ed | 113 | Installing GDB |
c50c5197 | 114 | *************** |
c45c19f8 | 115 | |
846058ed JG |
116 | GDB comes with a `configure' script that automates the process of |
117 | preparing GDB for installation; you can then use `make' to build the | |
c50c5197 | 118 | program. |
c45c19f8 | 119 | |
c50c5197 JG |
120 | The GDB distribution includes all the source code you need for GDB in |
121 | a single directory, whose name is usually composed by appending the | |
575945e3 JG |
122 | version number to `gdb'. |
123 | ||
c50c5197 | 124 | For example, the GDB version 4.7 distribution is in the `gdb-4.7' |
575945e3 | 125 | directory. That directory contains: |
c45c19f8 | 126 | |
c50c5197 | 127 | `gdb-4.7/configure (and supporting files)' |
fbda4193 | 128 | script for configuring GDB and all its supporting libraries. |
c45c19f8 | 129 | |
c50c5197 | 130 | `gdb-4.7/gdb' |
c45c19f8 JG |
131 | the source specific to GDB itself |
132 | ||
c50c5197 JG |
133 | `gdb-4.7/bfd' |
134 | source for the Binary File Descriptor library | |
c45c19f8 | 135 | |
c50c5197 | 136 | `gdb-4.7/include' |
c45c19f8 JG |
137 | GNU include files |
138 | ||
c50c5197 | 139 | `gdb-4.7/libiberty' |
c45c19f8 JG |
140 | source for the `-liberty' free software library |
141 | ||
c50c5197 JG |
142 | `gdb-4.7/opcodes' |
143 | source for the library of opcode tables and disassemblers | |
144 | ||
145 | `gdb-4.7/readline' | |
c45c19f8 JG |
146 | source for the GNU command-line interface |
147 | ||
c50c5197 JG |
148 | `gdb-4.7/glob' |
149 | source for the GNU filename pattern-matching subroutine | |
150 | ||
151 | `gdb-4.7/mmalloc' | |
152 | source for the GNU memory-mapped malloc package | |
153 | ||
575945e3 JG |
154 | The simplest way to configure and build GDB is to run `configure' |
155 | from the `gdb-VERSION-NUMBER' source directory, which in this example | |
c50c5197 | 156 | is the `gdb-4.7' directory. |
575945e3 | 157 | |
c50c5197 JG |
158 | First switch to the `gdb-VERSION-NUMBER' source directory if you are |
159 | not already in it; then run `configure'. Pass the identifier for the | |
160 | platform on which GDB will run as an argument. | |
575945e3 JG |
161 | |
162 | For example: | |
c45c19f8 | 163 | |
c50c5197 | 164 | cd gdb-4.7 |
c45c19f8 JG |
165 | ./configure HOST |
166 | make | |
167 | ||
575945e3 JG |
168 | where HOST is an identifier such as `sun4' or `decstation', that |
169 | identifies the platform where GDB will run. | |
170 | ||
c50c5197 JG |
171 | Running `configure HOST' followed by `make' builds the `bfd', |
172 | `readline', `mmalloc', and `libiberty' libraries, then `gdb' itself. | |
173 | The configured source files, and the binaries, are left in the | |
174 | corresponding source directories. | |
fbda4193 JG |
175 | |
176 | `configure' is a Bourne-shell (`/bin/sh') script; if your system | |
177 | does not recognize this automatically when you run a different shell, | |
575945e3 JG |
178 | you may need to run `sh' on it explicitly: |
179 | ||
180 | sh configure HOST | |
fbda4193 | 181 | |
575945e3 | 182 | If you run `configure' from a directory that contains source |
c50c5197 JG |
183 | directories for multiple libraries or programs, such as the `gdb-4.7' |
184 | source directory for version 4.7, `configure' creates configuration | |
575945e3 JG |
185 | files for every directory level underneath (unless you tell it not to, |
186 | with the `--norecursion' option). | |
187 | ||
188 | You can run the `configure' script from any of the subordinate | |
c50c5197 JG |
189 | directories in the GDB distribution, if you only want to configure that |
190 | subdirectory; but be sure to specify a path to it. | |
575945e3 | 191 | |
c50c5197 | 192 | For example, with version 4.7, type the following to configure only |
575945e3 | 193 | the `bfd' subdirectory: |
fbda4193 | 194 | |
c50c5197 | 195 | cd gdb-4.7/bfd |
fbda4193 JG |
196 | ../configure HOST |
197 | ||
c50c5197 JG |
198 | You can install `gdb' anywhere; it has no hardwired paths. However, |
199 | you should make sure that the shell on your path (named by the `SHELL' | |
200 | environment variable) is publicly readable. Remember that GDB uses the | |
201 | shell to start your program--some systems refuse to let GDB debug child | |
202 | processes whose programs are not readable. | |
c45c19f8 | 203 | |
c45c19f8 | 204 | |
575945e3 | 205 | Compiling GDB in Another Directory |
c50c5197 | 206 | =================================== |
846058ed | 207 | |
fbda4193 | 208 | If you want to run GDB versions for several host or target machines, |
c50c5197 JG |
209 | you'll need a different `gdb' compiled for each combination of host and |
210 | target. `configure' is designed to make this easy by allowing you to | |
211 | generate each configuration in a separate subdirectory, rather than in | |
212 | the source directory. If your `make' program handles the `VPATH' | |
575945e3 JG |
213 | feature (GNU `make' does), running `make' in each of these directories |
214 | then builds the `gdb' program specified there. | |
846058ed | 215 | |
575945e3 | 216 | To build `gdb' in a separate directory, run `configure' with the |
c50c5197 JG |
217 | `--srcdir' option to specify where to find the source. (You'll also |
218 | need to specify a path to find `configure' itself from your working | |
219 | directory. If the path to `configure' would be the same as the | |
220 | argument to `--srcdir', you can leave out the `--srcdir' option; it | |
221 | will be assumed.) | |
c45c19f8 | 222 | |
c50c5197 | 223 | For example, with version 4.7, you can build GDB in a separate |
575945e3 | 224 | directory for a Sun 4 like this: |
c45c19f8 | 225 | |
c50c5197 | 226 | cd gdb-4.7 |
575945e3 JG |
227 | mkdir ../gdb-sun4 |
228 | cd ../gdb-sun4 | |
c50c5197 | 229 | ../gdb-4.7/configure sun4 |
575945e3 | 230 | make |
c45c19f8 | 231 | |
575945e3 JG |
232 | When `configure' builds a configuration using a remote source |
233 | directory, it creates a tree for the binaries with the same structure | |
234 | (and using the same names) as the tree under the source directory. In | |
235 | the example, you'd find the Sun 4 library `libiberty.a' in the | |
236 | directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'. | |
c45c19f8 | 237 | |
c50c5197 | 238 | One popular reason to build several GDB configurations in separate |
575945e3 JG |
239 | directories is to configure GDB for cross-compiling (where GDB runs on |
240 | one machine--the host--while debugging programs that run on another | |
241 | machine--the target). You specify a cross-debugging target by giving | |
242 | the `--target=TARGET' option to `configure'. | |
846058ed | 243 | |
fbda4193 | 244 | When you run `make' to build a program or library, you must run it |
575945e3 JG |
245 | in a configured directory--whatever directory you were in when you |
246 | called `configure' (or one of its subdirectories). | |
846058ed | 247 | |
fbda4193 | 248 | The `Makefile' generated by `configure' for each source directory |
575945e3 | 249 | also runs recursively. If you type `make' in a source directory such |
c50c5197 JG |
250 | as `gdb-4.7' (or in a separate configured directory configured with |
251 | `--srcdir=PATH/gdb-4.7'), you will build all the required libraries, | |
575945e3 | 252 | then build GDB. |
c45c19f8 | 253 | |
575945e3 JG |
254 | When you have multiple hosts or targets configured in separate |
255 | directories, you can run `make' on them in parallel (for example, if | |
256 | they are NFS-mounted on each of the hosts); they will not interfere | |
257 | with each other. | |
fbda4193 JG |
258 | |
259 | ||
846058ed | 260 | Specifying Names for Hosts and Targets |
c50c5197 | 261 | ======================================= |
846058ed JG |
262 | |
263 | The specifications used for hosts and targets in the `configure' | |
264 | script are based on a three-part naming scheme, but some short | |
fbda4193 JG |
265 | predefined aliases are also supported. The full naming scheme encodes |
266 | three pieces of information in the following pattern: | |
846058ed JG |
267 | |
268 | ARCHITECTURE-VENDOR-OS | |
269 | ||
c50c5197 JG |
270 | For example, you can use the alias `sun4' as a HOST argument or in a |
271 | `--target=TARGET' option, but the equivalent full name is | |
fbda4193 | 272 | `sparc-sun-sunos4'. |
846058ed | 273 | |
575945e3 JG |
274 | The `configure' script accompanying GDB does not provide any query |
275 | facility to list all supported host and target names or aliases. | |
276 | `configure' calls the Bourne shell script `config.sub' to map | |
fbda4193 JG |
277 | abbreviations to full names; you can read the script, if you wish, or |
278 | you can use it to test your guesses on abbreviations--for example: | |
846058ed JG |
279 | |
280 | % sh config.sub sun4 | |
c50c5197 | 281 | sparc-sun-sunos411 |
846058ed | 282 | % sh config.sub sun3 |
c50c5197 | 283 | m68k-sun-sunos411 |
846058ed | 284 | % sh config.sub decstation |
c50c5197 | 285 | mips-dec-ultrix42 |
846058ed JG |
286 | % sh config.sub hp300bsd |
287 | m68k-hp-bsd | |
288 | % sh config.sub i386v | |
c50c5197 JG |
289 | i386-unknown-sysv |
290 | % sh config.sub i786v | |
291 | Invalid configuration `i786v': machine `i786v' not recognized | |
fbda4193 | 292 | |
575945e3 | 293 | `config.sub' is also distributed in the GDB source directory |
c50c5197 | 294 | (`gdb-4.7', for version 4.7). |
fbda4193 | 295 | |
846058ed JG |
296 | |
297 | `configure' Options | |
c50c5197 | 298 | ==================== |
c45c19f8 | 299 | |
c50c5197 JG |
300 | Here is a summary of the `configure' options and arguments that are |
301 | most often useful for building GDB. `configure' also has several other | |
302 | options not listed here. *note : (configure.info)What Configure Does, | |
303 | for a full explanation of `configure'. | |
c45c19f8 | 304 | |
c50c5197 JG |
305 | configure [--help] |
306 | [--prefix=DIR] | |
307 | [--srcdir=PATH] | |
575945e3 JG |
308 | [--norecursion] [--rm] |
309 | [--target=TARGET] HOST | |
c45c19f8 | 310 | |
575945e3 JG |
311 | You may introduce options with a single `-' rather than `--' if you |
312 | prefer; but you may abbreviate option names if you use `--'. | |
c45c19f8 | 313 | |
c50c5197 JG |
314 | `--help' |
315 | Display a quick summary of how to invoke `configure'. | |
316 | ||
317 | `-prefix=DIR' | |
318 | Configure the source to install programs and files under directory | |
319 | `DIR'. | |
c45c19f8 | 320 | |
575945e3 | 321 | `--srcdir=PATH' |
c50c5197 JG |
322 | *Warning: using this option requires GNU `make', or another `make' |
323 | that implements the `VPATH' feature.* | |
575945e3 JG |
324 | Use this option to make configurations in directories separate |
325 | from the GDB source directories. Among other things, you can use | |
c50c5197 JG |
326 | this to build (or maintain) several configurations simultaneously, |
327 | in separate directories. `configure' writes configuration | |
328 | specific files in the current directory, but arranges for them to | |
329 | use the source in the directory PATH. `configure' will create | |
330 | directories under the working directory in parallel to the source | |
331 | directories below PATH. | |
575945e3 JG |
332 | |
333 | `--norecursion' | |
334 | Configure only the directory level where `configure' is executed; | |
335 | do not propagate configuration to subdirectories. | |
336 | ||
337 | `--rm' | |
846058ed | 338 | Remove the configuration that the other arguments specify. |
c45c19f8 | 339 | |
575945e3 | 340 | `--target=TARGET' |
c50c5197 JG |
341 | Configure GDB for cross-debugging programs running on the specified |
342 | TARGET. Without this option, GDB is configured to debug programs | |
343 | that run on the same machine (HOST) as GDB itself. | |
846058ed JG |
344 | |
345 | There is no convenient way to generate a list of all available | |
346 | targets. | |
c45c19f8 JG |
347 | |
348 | `HOST ...' | |
575945e3 | 349 | Configure GDB to run on the specified HOST. |
846058ed JG |
350 | |
351 | There is no convenient way to generate a list of all available | |
352 | hosts. | |
c45c19f8 JG |
353 | |
354 | `configure' accepts other options, for compatibility with configuring | |
c50c5197 JG |
355 | other GNU tools recursively; but these are the only options that affect |
356 | GDB or its supporting libraries. | |
357 | ||
bd5635a1 | 358 | |
bd5635a1 | 359 | |
c50c5197 JG |
360 | Languages other than C |
361 | ======================= | |
bd5635a1 | 362 | |
575945e3 JG |
363 | GDB provides some support for debugging C++ progams. Partial Modula-2 |
364 | support is now in GDB. GDB should work with FORTRAN programs. (If you | |
365 | have problems, please send a bug report; you may have to refer to some | |
fbda4193 JG |
366 | FORTRAN variables with a trailing underscore). I am not aware of |
367 | anyone who is working on getting gdb to use the syntax of any other | |
368 | language. Pascal programs which use sets, subranges, file variables, | |
369 | or nested functions will not currently work. | |
bd5635a1 | 370 | |
bd5635a1 | 371 | |
c50c5197 JG |
372 | Kernel debugging |
373 | ================= | |
bd5635a1 | 374 | |
c45c19f8 JG |
375 | I have't done this myself so I can't really offer any advice. |
376 | Remote debugging over serial lines works fine, but the kernel debugging | |
c50c5197 JG |
377 | code in here has not been tested in years. Van Jacobson has |
378 | better kernel debugging, but the UC lawyers won't let FSF have it. | |
bd5635a1 | 379 | |
bd5635a1 | 380 | |
c50c5197 JG |
381 | Remote debugging |
382 | ================= | |
bd5635a1 | 383 | |
c50c5197 JG |
384 | The files m68k-stub.c, i386-stub.c, and sparc-stub.c are examples of |
385 | remote stubs to be used with remote.c. They are designed to run | |
386 | standalone on a 68k, 386, or SPARC cpu and communicate properly with | |
387 | the remote.c stub over a serial line. | |
361cc81a | 388 | |
170d0c85 RP |
389 | The file rem-multi.shar contains a general stub that can probably |
390 | run on various different flavors of unix to allow debugging over a | |
361cc81a | 391 | serial line from one machine to another. |
bd5635a1 | 392 | |
fbda4193 JG |
393 | Some working remote interfaces for talking to existing ROM monitors |
394 | are: | |
395 | remote-eb.c AMD 29000 "EBMON" | |
c50c5197 | 396 | remote-hms.c Hitachi Micro Systems H8/300 monitor |
fbda4193 JG |
397 | remote-nindy.c Intel 960 "Nindy" |
398 | remote-adapt.c AMD 29000 "Adapt" | |
399 | remote-mm.c AMD 29000 "minimon" | |
170d0c85 RP |
400 | |
401 | Remote-vx.c and the vx-share subdirectory contain a remote interface for the | |
402 | VxWorks realtime kernel, which communicates over TCP using the Sun | |
403 | RPC library. This would be a useful starting point for other remote- | |
404 | via-ethernet back ends. | |
bd5635a1 | 405 | |
c45c19f8 | 406 | |
c50c5197 JG |
407 | Reporting Bugs |
408 | =============== | |
c45c19f8 JG |
409 | |
410 | The correct address for reporting bugs found in gdb is | |
bd5635a1 | 411 | "[email protected]". Please email all bugs to that address. |
c50c5197 | 412 | Please include the GDB version number (e.g. gdb-4.7), and how |
fbda4193 JG |
413 | you configured it (e.g. "sun4" or "mach386 host, i586-intel-synopsys |
414 | target"). | |
415 | ||
416 | A known bug: | |
417 | ||
418 | * If you run with a watchpoint enabled, breakpoints will become | |
419 | erratic and might not stop the program. Disabling or deleting the | |
420 | watchpoint will fix the problem. | |
bd5635a1 | 421 | |
846058ed JG |
422 | GDB can produce warnings about symbols that it does not understand. By |
423 | default, these warnings are disabled. You can enable them by executing | |
424 | `set complaint 10' (which you can put in your ~/.gdbinit if you like). | |
425 | I recommend doing this if you are working on a compiler, assembler, | |
426 | linker, or gdb, since it will point out problems that you may be able | |
427 | to fix. Warnings produced during symbol reading indicate some mismatch | |
fbda4193 | 428 | between the object file and GDB's symbol reading code. In many cases, |
846058ed | 429 | it's a mismatch between the specs for the object file format, and what |
fbda4193 | 430 | the compiler actually outputs or the debugger actually understands. |
c45c19f8 | 431 | |
fbda4193 JG |
432 | If you port gdb to a new machine, please send the required changes to |
433 | [email protected]. There's lots of information about doing your | |
c50c5197 | 434 | own port in the file gdb-4.7/gdb/doc/gdbint.texinfo, which you can |
fbda4193 JG |
435 | print out, or read with `info' (see the Makefile.in there). If your |
436 | changes are more than a few lines, obtain and send in a copyright | |
437 | assignment from [email protected], as described in the section | |
c50c5197 | 438 | `Writing Code for GDB' below. |
c45c19f8 JG |
439 | |
440 | ||
c50c5197 JG |
441 | X Windows versus GDB |
442 | ===================== | |
bd5635a1 | 443 | |
361cc81a | 444 | xgdb is obsolete. We are not doing any development or support of it. |
bd5635a1 | 445 | |
c45c19f8 JG |
446 | There is an "xxgdb", which shows more promise, which was posted to |
447 | comp.sources.x. | |
bd5635a1 RP |
448 | |
449 | For those intersted in auto display of source and the availability of | |
450 | an editor while debugging I suggest trying gdb-mode in gnu-emacs | |
451 | (Try typing M-x gdb RETURN). Comments on this mode are welcome. | |
452 | ||
c45c19f8 | 453 | |
c50c5197 JG |
454 | Writing Code for GDB |
455 | ===================== | |
456 | ||
457 | Documentation about GDB's internals is in the subdirectory doc, as | |
458 | `gdbint.texinfo'. In particular, there is a `cookbook' there on how | |
459 | to port GDB to a new machine. You can read it by hand, print it | |
460 | by using TeX and texinfo, or process it into an `info' file for use | |
461 | with Emacs' info mode or the standalone `info' program. | |
bd5635a1 RP |
462 | |
463 | We appreciate having users contribute code that is of general use, but | |
464 | for it to be included in future GDB releases it must be cleanly | |
465 | written. We do not want to include changes that will needlessly make | |
466 | future maintainance difficult. It is not much harder to do things | |
467 | right, and in the long term it is worth it to the GNU project, and | |
468 | probably to you individually as well. | |
469 | ||
bd5635a1 RP |
470 | If you make substantial changes, you'll have to file a copyright |
471 | assignment with the Free Software Foundation before we can produce a | |
472 | release that includes your changes. Send mail requesting the copyright | |
473 | assignment to [email protected]. Do this early, like before the | |
474 | changes actually work, or even before you start them, because a manager | |
475 | or lawyer on your end will probably make this a slow process. | |
476 | ||
fbda4193 JG |
477 | Please code according to the GNU coding standards. If you do not have |
478 | a copy, you can request one by sending mail to [email protected]. | |
479 | ||
bd5635a1 RP |
480 | Please try to avoid making machine-specific changes to |
481 | machine-independent files. If this is unavoidable, put a hook in the | |
482 | machine-independent file which calls a (possibly) machine-dependent | |
483 | macro (for example, the IGNORE_SYMBOL macro can be used for any | |
484 | symbols which need to be ignored on a specific machine. Calling | |
485 | IGNORE_SYMBOL in dbxread.c is a lot cleaner than a maze of #if | |
486 | defined's). The machine-independent code should do whatever "most" | |
487 | machines want if the macro is not defined in param.h. Using #if | |
361cc81a | 488 | defined can sometimes be OK (e.g. SET_STACK_LIMIT_HUGE) but should be |
bd5635a1 RP |
489 | conditionalized on a specific feature of an operating system (set in |
490 | tm.h or xm.h) rather than something like #if defined(vax) or #if | |
491 | defined(SYSV). If you use an #ifdef on some symbol that is defined | |
492 | in a header file (e.g. #ifdef TIOCSETP), *please* make sure that you | |
493 | have #include'd the relevant header file in that module! | |
494 | ||
c50c5197 JG |
495 | There is a list of all known `feature-test macros' in gdbint.texinfo. |
496 | Each such macro should be defined (or left undefined) in a host-dependent, | |
497 | target-dependent, or native-dependent include file. Not all of the | |
498 | macros are cleanly separated this way, yet. As you make changes, move | |
499 | the code toward cleanliness. | |
500 | ||
bd5635a1 RP |
501 | It is better to replace entire routines which may be system-specific, |
502 | rather than put in a whole bunch of hooks which are probably not going | |
503 | to be helpful for any purpose other than your changes. For example, | |
504 | if you want to modify dbxread.c to deal with DBX debugging symbols | |
505 | which are in COFF files rather than BSD a.out files, do something | |
506 | along the lines of a macro GET_NEXT_SYMBOL, which could have | |
507 | different definitions for COFF and a.out, rather than trying to put | |
508 | the necessary changes throughout all the code in dbxread.c that | |
509 | currently assumes BSD format. | |
510 | ||
fbda4193 JG |
511 | When generalizing GDB along a particular interface, please use an |
512 | attribute-struct rather than inserting tests or switch statements | |
513 | everywhere. For example, GDB has been generalized to handle multiple | |
514 | kinds of remote interfaces -- not by #ifdef's everywhere, but by | |
515 | defining the "target_ops" structure and having a current target (as | |
516 | well as a stack of targets below it, for memory references). Whenever | |
517 | something needs to be done that depends on which remote interface we | |
518 | are using, a flag in the current target_ops structure is tested (e.g. | |
519 | `target_has_stack'), or a function is called through a pointer in the | |
520 | current target_ops structure. In this way, when a new remote interface | |
521 | is added, only one module needs to be touched -- the one that actually | |
522 | implements the new remote interface. Other examples of | |
523 | attribute-structs are BFD access to multiple kinds of object file | |
524 | formats, or GDB's access to multiple source languages. | |
525 | ||
bd5635a1 RP |
526 | Please avoid duplicating code. For example, in GDB 3.x all the stuff |
527 | in infptrace.c was duplicated in *-dep.c, and so changing something | |
c45c19f8 | 528 | was very painful. In GDB 4.x, these have all been consolidated |
bd5635a1 RP |
529 | into infptrace.c. infptrace.c can deal with variations between |
530 | systems the same way any system-independent file would (hooks, #if | |
531 | defined, etc.), and machines which are radically different don't need | |
532 | to use infptrace.c at all. The same was true of core_file_command | |
533 | and exec_file_command. | |
534 | ||
bd5635a1 | 535 | |
c50c5197 JG |
536 | Debugging gdb with itself |
537 | ========================== | |
bd5635a1 | 538 | |
c45c19f8 JG |
539 | If gdb is limping on your machine, this is the preferred way to get it |
540 | fully functional. Be warned that in some ancient Unix systems, like | |
541 | Ultrix 4.0, a program can't be running in one process while it is being | |
542 | debugged in another. Rather than doing "./gdb ./gdb", which works on | |
543 | Suns and such, you can copy gdb to gdb2 and then do "./gdb ./gdb2". | |
bd5635a1 | 544 | |
fbda4193 JG |
545 | When you run gdb in the gdb source directory, it will read a ".gdbinit" |
546 | file that sets up some simple things to make debugging gdb easier. The | |
547 | "info" command, when executed without a subcommand in a gdb being | |
548 | debugged by gdb, will pop you back up to the top level gdb. See | |
549 | .gdbinit for details. | |
c45c19f8 | 550 | |
846058ed JG |
551 | I strongly recommend printing out the reference card and using it. |
552 | Send reference-card suggestions to [email protected], just like bugs. | |
553 | ||
c45c19f8 JG |
554 | If you use emacs, you will probably want to do a "make TAGS" after you |
555 | configure your distribution; this will put the machine dependent | |
556 | routines for your local machine where they will be accessed first by a | |
557 | M-period. | |
558 | ||
fbda4193 JG |
559 | Also, make sure that you've either compiled gdb with your local cc, or |
560 | have run `fixincludes' if you are compiling with gcc. | |
bd5635a1 RP |
561 | \f |
562 | (this is for editing this file with GNU emacs) | |
563 | Local Variables: | |
564 | mode: text | |
565 | End: |