xref: /openbsd/gnu/usr.bin/binutils/gdb/README (revision 78b63d65)
1			README for gdb-4.16 release
2		       Updated 10-Apr-96 by Fred Fish
3
4This is GDB, the GNU source-level debugger.
5A summary of new features is in the file `NEWS'.
6
7
8Unpacking and Installation -- quick overview
9==========================
10
11In this release, the GDB debugger sources, the generic GNU include
12files, the BFD ("binary file description") library, the readline
13library, and other libraries all have directories of their own
14underneath the gdb-4.16 directory.  The idea is that a variety of GNU
15tools can share a common copy of these things.  Be aware of variation
16over time--for example don't try to build gdb with a copy of bfd from
17a release other than the gdb release (such as a binutils or gas
18release), especially if the releases are more than a few weeks apart.
19Configuration scripts and makefiles exist to cruise up and down this
20directory tree and automatically build all the pieces in the right
21order.
22
23When you unpack the gdb-4.16.tar.gz file, you'll find a directory
24called `gdb-4.16', which contains:
25
26  COPYING          config.sub*      libiberty/       opcodes/
27  COPYING.LIB      configure*       mmalloc/         readline/
28  Makefile.in      configure.in     move-if-change*  sim/
29  README           etc/             mpw-README       texinfo/
30  bfd/             gdb/             mpw-build.in     utils/
31  config/          include/         mpw-config.in
32  config.guess*    install.sh*      mpw-configure
33
34To build GDB, you can just do:
35
36	cd gdb-4.16
37	./configure
38	make
39	cp gdb/gdb /usr/local/bin/gdb	(or wherever you want)
40
41This will configure and build all the libraries as well as GDB.
42If `configure' can't determine your system type, specify one as its
43argument, e.g., sun4 or decstation.
44
45If you get compiler warnings during this stage, see the `Reporting Bugs'
46section below; there are a few known problems.
47
48GDB can be used as a cross-debugger, running on a machine of one type
49while debugging a program running on a machine of another type.  See below.
50
51
52More Documentation
53******************
54
55   The GDB 4 release includes an already-formatted reference card,
56ready for printing with PostScript or Ghostscript, in the `gdb'
57subdirectory of the main source directory.  (In `gdb-4.16/gdb/refcard.ps'.)
58If you can use PostScript or Ghostscript with your printer, you can
59print the reference card immediately with `refcard.ps'.
60
61   The release also includes the source for the reference card.  You
62can format it, using TeX, by typing:
63
64     make refcard.dvi
65
66   The GDB reference card is designed to print in landscape mode on US
67"letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches
68high.  You will need to specify this form of printing as an option to
69your DVI output program.
70
71   All the documentation for GDB comes as part of the machine-readable
72distribution.  The documentation is written in Texinfo format, which is
73a documentation system that uses a single source file to produce both
74on-line information and a printed manual.  You can use one of the Info
75formatting commands to create the on-line version of the documentation
76and TeX (or `texi2roff') to typeset the printed version.
77
78   GDB includes an already formatted copy of the on-line Info version of
79this manual in the `gdb' subdirectory.  The main Info file is
80`gdb-VERSION-NUMBER/gdb/gdb.info', and it refers to subordinate files
81matching `gdb.info*' in the same directory.  If necessary, you can
82print out these files, or read them with any editor; but they are
83easier to read using the `info' subsystem in GNU Emacs or the
84standalone `info' program, available as part of the GNU Texinfo
85distribution.
86
87   If you want to format these Info files yourself, you need one of the
88Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'.
89
90   If you have `makeinfo' installed, and are in the top level GDB
91source directory (`gdb-4.16', in the case of version 4.16), you can make
92the Info file by typing:
93
94     cd gdb
95     make gdb.info
96
97   If you want to typeset and print copies of this manual, you need TeX,
98a program to print its DVI output files, and `texinfo.tex', the Texinfo
99definitions file.
100
101   TeX is a typesetting program; it does not print files directly, but
102produces output files called DVI files.  To print a typeset document,
103you need a program to print DVI files.  If your system has TeX
104installed, chances are it has such a program.  The precise command to
105use depends on your system; `lpr -d' is common; another (for PostScript
106devices) is `dvips'.  The DVI print command may require a file name
107without any extension or a `.dvi' extension.
108
109   TeX also requires a macro definitions file called `texinfo.tex'.
110This file tells TeX how to typeset a document written in Texinfo
111format.  On its own, TeX cannot read, much less typeset a Texinfo file.
112 `texinfo.tex' is distributed with GDB and is located in the
113`gdb-VERSION-NUMBER/texinfo' directory.
114
115   If you have TeX and a DVI printer program installed, you can typeset
116and print this manual.  First switch to the the `gdb' subdirectory of
117the main source directory (for example, to `gdb-4.16/gdb') and then type:
118
119     make gdb.dvi
120
121
122Installing GDB
123**************
124
125   GDB comes with a `configure' script that automates the process of
126preparing GDB for installation; you can then use `make' to build the
127`gdb' program.
128
129   The GDB distribution includes all the source code you need for GDB in
130a single directory, whose name is usually composed by appending the
131version number to `gdb'.
132
133   For example, the GDB version 4.16 distribution is in the `gdb-4.16'
134directory.  That directory contains:
135
136`gdb-4.16/{COPYING,COPYING.LIB}'
137     Standard GNU license files.  Please read them.
138
139`gdb-4.16/bfd'
140     source for the Binary File Descriptor library
141
142`gdb-4.16/config*'
143     script for configuring GDB, along with other support files
144
145`gdb-4.16/gdb'
146     the source specific to GDB itself
147
148`gdb-4.16/include'
149     GNU include files
150
151`gdb-4.16/libiberty'
152     source for the `-liberty' free software library
153
154`gdb-4.16/mmalloc'
155     source for the GNU memory-mapped malloc package
156
157`gdb-4.16/opcodes'
158     source for the library of opcode tables and disassemblers
159
160`gdb-4.16/readline'
161     source for the GNU command-line interface
162
163'gdb-4.16/sim'
164     source for some simulators (z8000, H8/300, H8/500, etc)
165
166   The simplest way to configure and build GDB is to run `configure'
167from the `gdb-VERSION-NUMBER' source directory, which in this example
168is the `gdb-4.16' directory.
169
170   First switch to the `gdb-VERSION-NUMBER' source directory if you are
171not already in it; then run `configure'.  Pass the identifier for the
172platform on which GDB will run as an argument.
173
174   For example:
175
176     cd gdb-4.16
177     ./configure HOST
178     make
179
180where HOST is an identifier such as `sun4' or `decstation', that
181identifies the platform where GDB will run.
182
183   Running `configure HOST' followed by `make' builds the `bfd',
184`readline', `mmalloc', and `libiberty' libraries, then `gdb' itself.
185The configured source files, and the binaries, are left in the
186corresponding source directories.
187
188   `configure' is a Bourne-shell (`/bin/sh') script; if your system
189does not recognize this automatically when you run a different shell,
190you may need to run `sh' on it explicitly:
191
192     sh configure HOST
193
194   If you run `configure' from a directory that contains source
195directories for multiple libraries or programs, such as the `gdb-4.16'
196source directory for version 4.16, `configure' creates configuration
197files for every directory level underneath (unless you tell it not to,
198with the `--norecursion' option).
199
200   You can run the `configure' script from any of the subordinate
201directories in the GDB distribution, if you only want to configure that
202subdirectory; but be sure to specify a path to it.
203
204   For example, with version 4.16, type the following to configure only
205the `bfd' subdirectory:
206
207     cd gdb-4.16/bfd
208     ../configure HOST
209
210   You can install `gdb' anywhere; it has no hardwired paths. However,
211you should make sure that the shell on your path (named by the `SHELL'
212environment variable) is publicly readable.  Remember that GDB uses the
213shell to start your program--some systems refuse to let GDB debug child
214processes whose programs are not readable.
215
216
217Compiling GDB in another directory
218==================================
219
220   If you want to run GDB versions for several host or target machines,
221you need a different `gdb' compiled for each combination of host and
222target.  `configure' is designed to make this easy by allowing you to
223generate each configuration in a separate subdirectory, rather than in
224the source directory.  If your `make' program handles the `VPATH'
225feature correctly (GNU `make' and SunOS 'make' are two that should),
226running `make' in each of these directories builds the `gdb' program
227specified there.
228
229   To build `gdb' in a separate directory, run `configure' with the
230`--srcdir' option to specify where to find the source. (You also need
231to specify a path to find `configure' itself from your working
232directory.  If the path to `configure' would be the same as the
233argument to `--srcdir', you can leave out the `--srcdir' option; it
234will be assumed.)
235
236   For example, with version 4.16, you can build GDB in a separate
237directory for a Sun 4 like this:
238
239     cd gdb-4.16
240     mkdir ../gdb-sun4
241     cd ../gdb-sun4
242     ../gdb-4.16/configure sun4
243     make
244
245   When `configure' builds a configuration using a remote source
246directory, it creates a tree for the binaries with the same structure
247(and using the same names) as the tree under the source directory.  In
248the example, you'd find the Sun 4 library `libiberty.a' in the
249directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'.
250
251   One popular reason to build several GDB configurations in separate
252directories is to configure GDB for cross-compiling (where GDB runs on
253one machine--the host--while debugging programs that run on another
254machine--the target).  You specify a cross-debugging target by giving
255the `--target=TARGET' option to `configure'.
256
257   When you run `make' to build a program or library, you must run it
258in a configured directory--whatever directory you were in when you
259called `configure' (or one of its subdirectories).
260
261   The `Makefile' that `configure' generates in each source directory
262also runs recursively.  If you type `make' in a source directory such
263as `gdb-4.16' (or in a separate configured directory configured with
264`--srcdir=PATH/gdb-4.16'), you will build all the required libraries,
265and then build GDB.
266
267   When you have multiple hosts or targets configured in separate
268directories, you can run `make' on them in parallel (for example, if
269they are NFS-mounted on each of the hosts); they will not interfere
270with each other.
271
272
273Specifying names for hosts and targets
274======================================
275
276   The specifications used for hosts and targets in the `configure'
277script are based on a three-part naming scheme, but some short
278predefined aliases are also supported.  The full naming scheme encodes
279three pieces of information in the following pattern:
280
281     ARCHITECTURE-VENDOR-OS
282
283   For example, you can use the alias `sun4' as a HOST argument or in a
284`--target=TARGET' option.  The equivalent full name is
285`sparc-sun-sunos4'.
286
287   The `configure' script accompanying GDB does not provide any query
288facility to list all supported host and target names or aliases.
289`configure' calls the Bourne shell script `config.sub' to map
290abbreviations to full names; you can read the script, if you wish, or
291you can use it to test your guesses on abbreviations--for example:
292
293     % sh config.sub sun4
294     sparc-sun-sunos411
295     % sh config.sub sun3
296     m68k-sun-sunos411
297     % sh config.sub decstation
298     mips-dec-ultrix42
299     % sh config.sub hp300bsd
300     m68k-hp-bsd
301     % sh config.sub i386v
302     i386-unknown-sysv
303     % sh config.sub i786v
304     Invalid configuration `i786v': machine `i786v' not recognized
305
306`config.sub' is also distributed in the GDB source directory
307(`gdb-4.16', for version 4.16).
308
309
310`configure' options
311===================
312
313   Here is a summary of the `configure' options and arguments that are
314most often useful for building GDB.  `configure' also has several other
315options not listed here.  *note : (configure.info)What Configure Does,
316for a full explanation of `configure'.
317
318     configure [--help]
319               [--prefix=DIR]
320               [--srcdir=PATH]
321               [--norecursion] [--rm]
322               [--target=TARGET] HOST
323
324You may introduce options with a single `-' rather than `--' if you
325prefer; but you may abbreviate option names if you use `--'.
326
327`--help'
328     Display a quick summary of how to invoke `configure'.
329
330`-prefix=DIR'
331     Configure the source to install programs and files under directory
332     `DIR'.
333
334`--srcdir=PATH'
335     *Warning: using this option requires GNU `make', or another `make'
336     that compatibly implements the `VPATH' feature.*
337     Use this option to make configurations in directories separate
338     from the GDB source directories.  Among other things, you can use
339     this to build (or maintain) several configurations simultaneously,
340     in separate directories.  `configure' writes configuration
341     specific files in the current directory, but arranges for them to
342     use the source in the directory PATH.  `configure' will create
343     directories under the working directory in parallel to the source
344     directories below PATH.
345
346`--norecursion'
347     Configure only the directory level where `configure' is executed;
348     do not propagate configuration to subdirectories.
349
350`--rm'
351     Remove the configuration that the other arguments specify.
352
353`--target=TARGET'
354     Configure GDB for cross-debugging programs running on the specified
355     TARGET.  Without this option, GDB is configured to debug programs
356     that run on the same machine (HOST) as GDB itself.
357
358     There is no convenient way to generate a list of all available
359     targets.
360
361`HOST ...'
362     Configure GDB to run on the specified HOST.
363
364     There is no convenient way to generate a list of all available
365     hosts.
366
367`configure' accepts other options, for compatibility with configuring
368other GNU tools recursively; but these are the only options that affect
369GDB or its supporting libraries.
370
371
372Languages other than C
373=======================
374
375See the GDB manual (doc/gdb.texinfo) for information on this.
376
377Kernel debugging
378=================
379
380I have't done this myself so I can't really offer any advice.
381Remote debugging over serial lines works fine, but the kernel debugging
382code in here has not been tested in years.  Van Jacobson has
383better kernel debugging, but the UC lawyers won't let FSF have it.
384
385
386Remote debugging
387=================
388
389The files m68k-stub.c, i386-stub.c, and sparc-stub.c are examples of
390remote stubs to be used with remote.c.  They are designed to run
391standalone on an m68k, i386, or SPARC cpu and communicate properly with
392the remote.c stub over a serial line.
393
394The file rem-multi.shar contains a general stub that can probably
395run on various different flavors of unix to allow debugging over a
396serial line from one machine to another.
397
398Some working remote interfaces for talking to existing ROM monitors
399are:
400	remote-adapt.c	 AMD 29000 "Adapt"
401	remote-e7000.c	 Hitachi E7000 ICE
402	remote-eb.c	 AMD 29000 "EBMON"
403	remote-es.c	 Ericsson 1800 monitor
404	remote-hms.c	 Hitachi Micro Systems H8/300 monitor
405	remote-mips.c	 MIPS remote debugging protocol
406	remote-mm.c	 AMD 29000 "minimon"
407	remote-nindy.c   Intel 960 "Nindy"
408	remote-os9k.c	 PC running OS/9000
409	remote-sim.c	 Generalized simulator protocol
410	remote-st.c	 Tandem ST-2000 monitor
411	remote-udi.c	 AMD 29000 using the AMD "Universal Debug Interface"
412	remote-vx.c	 VxWorks realtime kernel
413	remote-z8k.c	 Zilog Z8000 simulator
414
415Remote-vx.c and the vx-share subdirectory contain a remote interface for the
416VxWorks realtime kernel, which communicates over TCP using the Sun
417RPC library.  This would be a useful starting point for other remote-
418via-ethernet back ends.
419
420Remote-udi.c and the 29k-share subdirectory contain a remote interface
421for AMD 29000 programs, which uses the AMD "Universal Debug Interface".
422This allows GDB to talk to software simulators, emulators, and/or bare
423hardware boards, via network or serial interfaces.  Note that GDB only
424provides an interface that speaks UDI, not a complete solution.  You
425will need something on the other end that also speaks UDI.
426
427
428Reporting Bugs
429===============
430
431The correct address for reporting bugs found in gdb is
432"bug-gdb@prep.ai.mit.edu".  Please email all bugs, and all requests for
433help with GDB, to that address.  Please include the GDB version number
434(e.g., gdb-4.16), and how you configured it (e.g., "sun4" or "mach386
435host, i586-intel-synopsys target").  Since GDB now supports so many
436different configurations, it is important that you be precise about this.
437If at all possible, you should include the actual banner that GDB prints
438when it starts up, or failing that, the actual configure command that
439you used when configuring GDB.
440
441For more information on how/whether to report bugs, see the GDB Bugs
442section of the GDB manual (gdb/doc/gdb.texinfo).
443
444Known bugs:
445
446  * Under Ultrix 4.2 (DECstation-3100) or Alphas under OSF/1, we have
447    seen problems with backtraces after interrupting the inferior out
448    of a read().  The problem is caused by ptrace() returning an
449    incorrect value for the frame pointer register (register 15 or
450    30).  As far as we can tell, this is a kernel problem.  Any help
451    with this would be greatly appreciated.
452
453  * Under Ultrix 4.4 (DECstation-3100), setting the TERMCAP environment
454    variable to a string without a trailing ':' can cause GDB to dump
455    core upon startup.  Although the core file makes it look as though
456    GDB code failed, the crash actually occurs within a call to the
457    termcap library function tgetent().  The problem can be solved by
458    using the GNU Termcap library.
459
460    Alphas running OSF/1 (versions 1.0 through 2.1) have the same buggy
461    termcap code, but GDB behaves strangely rather than crashing.
462
463  * On DECstations there are warnings about shift counts out of range in
464    various BFD modules.  None of them is a cause for alarm, they are actually
465    a result of bugs in the DECstation compiler.
466
467  * Notes for the DEC Alpha using OSF/1:
468    The debugging output of native cc has two known problems; we view these
469    as compiler bugs.
470    The linker miscompacts symbol tables, which causes gdb to confuse the
471    type of variables or results in `struct <illegal>' type outputs.
472    dbx has the same problems with those executables.  A workaround is to
473    specify -Wl,-b when linking, but that will increase the executable size
474    considerably.
475    If a structure has incomplete type in one file (e.g., "struct foo *"
476    without a definition for "struct foo"), gdb will be unable to find the
477    structure definition from another file.
478    It has been reported that the Ultrix 4.3A compiler on decstations has the
479    same problems.
480
481  * Notes for Solaris 2.x, using the SPARCworks cc compiler:
482    You have to compile your program with the -xs option of the SPARCworks
483    compiler to be able to debug your program with gdb.
484    Under Solaris 2.3 you also need patch 101409-03 (Jumbo linker patch).
485    Under Solaris 2.2, if you have patch 101052 installed, make sure
486    that it is at least at revision 101052-06.
487
488  * Under Irix 5 for SGIs, you must have installed the `compiler_dev.hdr'
489    subsystem that is on the IDO CD, otherwise you will get complaints
490    that certain files such as `/usr/include/syms.h' cannot be found.
491
492  * Unixware 2.x is not yet supported.
493
494  * Notes for BSD/386:
495    To compile gdb-4.16 on BSD/386, you must run the configure script and
496    its subscripts with bash.  Here is an easy way to do this:
497
498	bash -c 'CONFIG_SHELL=/bin/bash ./configure'
499
500    (configure will report i386-unknown-bsd).  Then, compile with the
501    standard "make" command.
502
503GDB can produce warnings about symbols that it does not understand.  By
504default, these warnings are disabled.  You can enable them by executing
505`set complaint 10' (which you can put in your ~/.gdbinit if you like).
506I recommend doing this if you are working on a compiler, assembler,
507linker, or GDB, since it will point out problems that you may be able
508to fix.  Warnings produced during symbol reading indicate some mismatch
509between the object file and GDB's symbol reading code.  In many cases,
510it's a mismatch between the specs for the object file format, and what
511the compiler actually outputs or the debugger actually understands.
512
513
514X Windows versus GDB
515=====================
516
517There is an "xxgdb", which seems to work for simple operations,
518which was posted to comp.sources.x.
519
520For those interested in auto display of source and the availability of
521an editor while debugging I suggest trying gdb-mode in GNU Emacs
522(Try typing M-x gdb RETURN).  Comments on this mode are welcome.
523
524Those interested in experimenting with a new kind of gdb-mode
525should load gdb/gdba.el into GNU Emacs 19.25 or later.  Comments
526on this mode are also welcome.
527
528Writing Code for GDB
529=====================
530
531There is a lot of information about writing code for GDB in the
532internals manual, distributed with GDB in gdb/doc/gdbint.texinfo.  You
533can read it by hand, print it by using TeX and texinfo, or process it
534into an `info' file for use with Emacs' info mode or the standalone
535`info' program.  In particular, see the nodes Getting Started,
536Debugging GDB, New Architectures, Coding Style, Clean Design, and
537Submitting Patches.
538
539If you are pondering writing anything but a short patch, especially
540take note of the information about copyrights in the node Submitting
541Patches.  It can take quite a while to get all the paperwork done, so
542we encourage you to start that process as soon as you decide you are
543planning to work on something, or at least well ahead of when you
544think you will be ready to submit the patches.
545
546
547GDB Testsuite
548=============
549
550There is a DejaGNU based testsuite available for testing your newly
551built GDB, or for regression testing GDBs with local modifications.
552The testsuite is distributed separately from the base GDB distribution
553for the convenience of people that wish to get either GDB or the testsuite
554separately.
555
556The name of the testsuite is gdb-4.16-testsuite.tar.gz.  You unpack it in the
557same directory in which you unpacked the base GDB distribution, and it
558will create and populate the directory gdb-4.16/gdb/testsuite.
559
560Running the testsuite requires the prior installation of DejaGNU, which
561is generally available via ftp.  Once DejaGNU is installed, you can run
562the tests in one of two ways:
563
564  (1)	cd gdb-4.16/gdb		(assuming you also unpacked gdb)
565	make check
566
567or
568
569  (2)	cd gdb-4.16/gdb/testsuite
570	make site.exp	(builds the site specific file)
571	runtest -tool gdb GDB=../gdb    (or GDB=<somepath> as appropriate)
572
573The second method gives you slightly more control in case of problems with
574building one or more test executables or if you are using the testsuite
575'standalone', without it being part of the GDB source tree.
576
577See the DejaGNU documentation for further details.
578
579
580(this is for editing this file with GNU emacs)
581Local Variables:
582mode: text
583End:
584