| 1 | README for gdb-4.7 release |
| 2 | Stu Grossman & John Gilmore 23 October 1992 |
| 3 | |
| 4 | This is GDB, the GNU source-level debugger, presently running under un*x. |
| 5 | A summary of new features is in the file `NEWS'. |
| 6 | |
| 7 | |
| 8 | Unpacking and Installation -- quick overview |
| 9 | ========================== |
| 10 | |
| 11 | In this release, the GDB debugger sources, the generic GNU include |
| 12 | files, the BFD ("binary file description") library, the readline library, |
| 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 |
| 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. |
| 18 | |
| 19 | When you unpack the gdb-4.7.tar.Z file, you'll get a directory called |
| 20 | `gdb-4.7', which contains: |
| 21 | |
| 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/ |
| 27 | |
| 28 | To build GDB, you can just do: |
| 29 | |
| 30 | cd gdb-4.7 |
| 31 | ./configure HOSTTYPE (e.g. sun4, decstation) |
| 32 | make |
| 33 | cp gdb/gdb /usr/local/bin/gdb (or wherever you want) |
| 34 | |
| 35 | This will configure and build all the libraries as well as GDB. |
| 36 | If you get compiler warnings during this stage, see the `Reporting Bugs' |
| 37 | section below; there are a few known problems. |
| 38 | |
| 39 | GDB can be used as a cross-debugger, running on a machine of one type |
| 40 | while debugging a program running on a machine of another type. See below. |
| 41 | |
| 42 | |
| 43 | More Documentation |
| 44 | ****************** |
| 45 | |
| 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'. |
| 51 | |
| 52 | The release also includes the source for the reference card. You |
| 53 | can format it, using TeX, by typing: |
| 54 | |
| 55 | make refcard.dvi |
| 56 | |
| 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. |
| 61 | |
| 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. |
| 68 | |
| 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 |
| 71 | `gdb-VERSION-NUMBER/gdb/gdb.info', and it refers to subordinate files |
| 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. |
| 77 | |
| 78 | If you want to format these Info files yourself, you need one of the |
| 79 | Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'. |
| 80 | |
| 81 | If you have `makeinfo' installed, and are in the top level GDB |
| 82 | source directory (`gdb-4.7', in the case of version 4.7), you can make |
| 83 | the Info file by typing: |
| 84 | |
| 85 | cd gdb |
| 86 | make gdb.info |
| 87 | |
| 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 |
| 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 |
| 104 | `gdb-VERSION-NUMBER/texinfo' directory. |
| 105 | |
| 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: |
| 109 | |
| 110 | make gdb.dvi |
| 111 | |
| 112 | |
| 113 | Installing GDB |
| 114 | *************** |
| 115 | |
| 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 |
| 118 | program. |
| 119 | |
| 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 |
| 122 | version number to `gdb'. |
| 123 | |
| 124 | For example, the GDB version 4.7 distribution is in the `gdb-4.7' |
| 125 | directory. That directory contains: |
| 126 | |
| 127 | `gdb-4.7/configure (and supporting files)' |
| 128 | script for configuring GDB and all its supporting libraries. |
| 129 | |
| 130 | `gdb-4.7/gdb' |
| 131 | the source specific to GDB itself |
| 132 | |
| 133 | `gdb-4.7/bfd' |
| 134 | source for the Binary File Descriptor library |
| 135 | |
| 136 | `gdb-4.7/include' |
| 137 | GNU include files |
| 138 | |
| 139 | `gdb-4.7/libiberty' |
| 140 | source for the `-liberty' free software library |
| 141 | |
| 142 | `gdb-4.7/opcodes' |
| 143 | source for the library of opcode tables and disassemblers |
| 144 | |
| 145 | `gdb-4.7/readline' |
| 146 | source for the GNU command-line interface |
| 147 | |
| 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 | |
| 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 |
| 156 | is the `gdb-4.7' directory. |
| 157 | |
| 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. |
| 161 | |
| 162 | For example: |
| 163 | |
| 164 | cd gdb-4.7 |
| 165 | ./configure HOST |
| 166 | make |
| 167 | |
| 168 | where HOST is an identifier such as `sun4' or `decstation', that |
| 169 | identifies the platform where GDB will run. |
| 170 | |
| 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. |
| 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, |
| 178 | you may need to run `sh' on it explicitly: |
| 179 | |
| 180 | sh configure HOST |
| 181 | |
| 182 | If you run `configure' from a directory that contains source |
| 183 | directories for multiple libraries or programs, such as the `gdb-4.7' |
| 184 | source directory for version 4.7, `configure' creates configuration |
| 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 |
| 189 | directories in the GDB distribution, if you only want to configure that |
| 190 | subdirectory; but be sure to specify a path to it. |
| 191 | |
| 192 | For example, with version 4.7, type the following to configure only |
| 193 | the `bfd' subdirectory: |
| 194 | |
| 195 | cd gdb-4.7/bfd |
| 196 | ../configure HOST |
| 197 | |
| 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. |
| 203 | |
| 204 | |
| 205 | Compiling GDB in Another Directory |
| 206 | =================================== |
| 207 | |
| 208 | If you want to run GDB versions for several host or target machines, |
| 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' |
| 213 | feature (GNU `make' does), running `make' in each of these directories |
| 214 | then builds the `gdb' program specified there. |
| 215 | |
| 216 | To build `gdb' in a separate directory, run `configure' with the |
| 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.) |
| 222 | |
| 223 | For example, with version 4.7, you can build GDB in a separate |
| 224 | directory for a Sun 4 like this: |
| 225 | |
| 226 | cd gdb-4.7 |
| 227 | mkdir ../gdb-sun4 |
| 228 | cd ../gdb-sun4 |
| 229 | ../gdb-4.7/configure sun4 |
| 230 | make |
| 231 | |
| 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'. |
| 237 | |
| 238 | One popular reason to build several GDB configurations in separate |
| 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'. |
| 243 | |
| 244 | When you run `make' to build a program or library, you must run it |
| 245 | in a configured directory--whatever directory you were in when you |
| 246 | called `configure' (or one of its subdirectories). |
| 247 | |
| 248 | The `Makefile' generated by `configure' for each source directory |
| 249 | also runs recursively. If you type `make' in a source directory such |
| 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, |
| 252 | then build GDB. |
| 253 | |
| 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. |
| 258 | |
| 259 | |
| 260 | Specifying Names for Hosts and Targets |
| 261 | ======================================= |
| 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 |
| 265 | predefined aliases are also supported. The full naming scheme encodes |
| 266 | three pieces of information in the following pattern: |
| 267 | |
| 268 | ARCHITECTURE-VENDOR-OS |
| 269 | |
| 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 |
| 272 | `sparc-sun-sunos4'. |
| 273 | |
| 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 |
| 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: |
| 279 | |
| 280 | % sh config.sub sun4 |
| 281 | sparc-sun-sunos411 |
| 282 | % sh config.sub sun3 |
| 283 | m68k-sun-sunos411 |
| 284 | % sh config.sub decstation |
| 285 | mips-dec-ultrix42 |
| 286 | % sh config.sub hp300bsd |
| 287 | m68k-hp-bsd |
| 288 | % sh config.sub i386v |
| 289 | i386-unknown-sysv |
| 290 | % sh config.sub i786v |
| 291 | Invalid configuration `i786v': machine `i786v' not recognized |
| 292 | |
| 293 | `config.sub' is also distributed in the GDB source directory |
| 294 | (`gdb-4.7', for version 4.7). |
| 295 | |
| 296 | |
| 297 | `configure' Options |
| 298 | ==================== |
| 299 | |
| 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'. |
| 304 | |
| 305 | configure [--help] |
| 306 | [--prefix=DIR] |
| 307 | [--srcdir=PATH] |
| 308 | [--norecursion] [--rm] |
| 309 | [--target=TARGET] HOST |
| 310 | |
| 311 | You may introduce options with a single `-' rather than `--' if you |
| 312 | prefer; but you may abbreviate option names if you use `--'. |
| 313 | |
| 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'. |
| 320 | |
| 321 | `--srcdir=PATH' |
| 322 | *Warning: using this option requires GNU `make', or another `make' |
| 323 | that implements the `VPATH' feature.* |
| 324 | Use this option to make configurations in directories separate |
| 325 | from the GDB source directories. Among other things, you can use |
| 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. |
| 332 | |
| 333 | `--norecursion' |
| 334 | Configure only the directory level where `configure' is executed; |
| 335 | do not propagate configuration to subdirectories. |
| 336 | |
| 337 | `--rm' |
| 338 | Remove the configuration that the other arguments specify. |
| 339 | |
| 340 | `--target=TARGET' |
| 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. |
| 344 | |
| 345 | There is no convenient way to generate a list of all available |
| 346 | targets. |
| 347 | |
| 348 | `HOST ...' |
| 349 | Configure GDB to run on the specified HOST. |
| 350 | |
| 351 | There is no convenient way to generate a list of all available |
| 352 | hosts. |
| 353 | |
| 354 | `configure' accepts other options, for compatibility with configuring |
| 355 | other GNU tools recursively; but these are the only options that affect |
| 356 | GDB or its supporting libraries. |
| 357 | |
| 358 | |
| 359 | |
| 360 | Languages other than C |
| 361 | ======================= |
| 362 | |
| 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 |
| 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. |
| 370 | |
| 371 | |
| 372 | Kernel debugging |
| 373 | ================= |
| 374 | |
| 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 |
| 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. |
| 379 | |
| 380 | |
| 381 | Remote debugging |
| 382 | ================= |
| 383 | |
| 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. |
| 388 | |
| 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 |
| 391 | serial line from one machine to another. |
| 392 | |
| 393 | Some working remote interfaces for talking to existing ROM monitors |
| 394 | are: |
| 395 | remote-eb.c AMD 29000 "EBMON" |
| 396 | remote-hms.c Hitachi Micro Systems H8/300 monitor |
| 397 | remote-nindy.c Intel 960 "Nindy" |
| 398 | remote-adapt.c AMD 29000 "Adapt" |
| 399 | remote-mm.c AMD 29000 "minimon" |
| 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. |
| 405 | |
| 406 | |
| 407 | Reporting Bugs |
| 408 | =============== |
| 409 | |
| 410 | The correct address for reporting bugs found in gdb is |
| 411 | "bug-gdb@prep.ai.mit.edu". Please email all bugs to that address. |
| 412 | Please include the GDB version number (e.g. gdb-4.7), and how |
| 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. |
| 421 | |
| 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 |
| 428 | between the object file and GDB's symbol reading code. In many cases, |
| 429 | it's a mismatch between the specs for the object file format, and what |
| 430 | the compiler actually outputs or the debugger actually understands. |
| 431 | |
| 432 | If you port gdb to a new machine, please send the required changes to |
| 433 | bug-gdb@prep.ai.mit.edu. There's lots of information about doing your |
| 434 | own port in the file gdb-4.7/gdb/doc/gdbint.texinfo, which you can |
| 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 gnu@prep.ai.mit.edu, as described in the section |
| 438 | `Writing Code for GDB' below. |
| 439 | |
| 440 | |
| 441 | X Windows versus GDB |
| 442 | ===================== |
| 443 | |
| 444 | xgdb is obsolete. We are not doing any development or support of it. |
| 445 | |
| 446 | There is an "xxgdb", which shows more promise, which was posted to |
| 447 | comp.sources.x. |
| 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 | |
| 453 | |
| 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. |
| 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 | |
| 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 gnu@prep.ai.mit.edu. 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 | |
| 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 gnu@prep.ai.mit.edu. |
| 479 | |
| 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 |
| 488 | defined can sometimes be OK (e.g. SET_STACK_LIMIT_HUGE) but should be |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 |
| 528 | was very painful. In GDB 4.x, these have all been consolidated |
| 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 | |
| 535 | |
| 536 | Debugging gdb with itself |
| 537 | ========================== |
| 538 | |
| 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". |
| 544 | |
| 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. |
| 550 | |
| 551 | I strongly recommend printing out the reference card and using it. |
| 552 | Send reference-card suggestions to bug-gdb@prep.ai.mit.edu, just like bugs. |
| 553 | |
| 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 | |
| 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. |
| 561 | \f |
| 562 | (this is for editing this file with GNU emacs) |
| 563 | Local Variables: |
| 564 | mode: text |
| 565 | End: |