]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdb-int.texinfo
Initial revision
[thirdparty/binutils-gdb.git] / gdb / gdb-int.texinfo
CommitLineData
bd5635a1
RP
1\input texinfo
2@setfilename gdb-internals
3@ifinfo
4This file documents the internals of the GNU debugger GDB.
5
6Copyright (C) 1990, 1991 Free Software Foundation, Inc.
7Contributed by Cygnus Support. Written by John Gilmore.
8
9Permission is granted to make and distribute verbatim copies of
10this manual provided the copyright notice and this permission notice
11are preserved on all copies.
12
13@ignore
14Permission is granted to process this file through Tex and print the
15results, provided the printed document carries copying permission
16notice identical to this one except for the removal of this paragraph
17(this paragraph not being relevant to the printed manual).
18
19@end ignore
20Permission is granted to copy or distribute modified versions of this
21manual under the terms of the GPL (for which purpose this text may be
22regarded as a program in the language TeX).
23@end ifinfo
24
25@setchapternewpage odd
26@settitle GDB Internals
27@titlepage
28@title{Working in GDB}
29@subtitle{A guide to the internals of the GNU debugger}
30@author John Gilmore
31@author Cygnus Support
32@page
33@tex
34\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
35\xdef\manvers{\$Revision$} % For use in headers, footers too
36{\parskip=0pt
37\hfill Cygnus Support\par
38\hfill \manvers\par
39\hfill \TeX{}info \texinfoversion\par
40}
41@end tex
42
43@vskip 0pt plus 1filll
44Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc.
45
46Permission is granted to make and distribute verbatim copies of
47this manual provided the copyright notice and this permission notice
48are preserved on all copies.
49
50@end titlepage
51
52@node Top, Cleanups, (dir), (dir)
53
54@menu
55* Cleanups:: Cleanups
56* Wrapping:: Wrapping output lines
57* Releases:: Configuring GDB for release
58* README:: The README file
59* New Architectures:: Defining a new host or target architecture
60* Host versus Targt:: What features are in which files
61
62@end menu
63
64@node Cleanups, Wrapping, Top, Top
65@chapter Cleanups
66
67Cleanups are a structured way to deal with things that need to be done
68later. When your code does something (like malloc some memory, or open
69a file) that needs to be undone later (e.g. free the memory or close
70the file), it can make a cleanup. The cleanup will be done at some
71future point: when the command is finished, when an error occurs, or
72when your code decides it's time to do cleanups.
73
74You can also discard cleanups, that is, throw them away without doing
75what they say. This is only done if you ask that it be done.
76
77Syntax:
78
79@table @code
80@item old_chain = make_cleanup (function, arg);
81This makes a cleanup which will cause FUNCTION to be called with ARG
82(a char *) later. The result, OLD_CHAIN, is a handle that can be
83passed to do_cleanups or discard_cleanups later. Unless you are
84going to call do_cleanups or discard_cleanups yourself,
85you can ignore the result from make_cleanup.
86
87
88@item do_cleanups (old_chain);
89Performs all cleanups done since make_cleanup returned OLD_CHAIN.
90E.g.: make_cleanup (a, 0); old = make_cleanup (b, 0); do_cleanups (old);
91will call b() but will not call a(). The cleanup that calls a() will remain
92in the cleanup chain, and will be done later unless otherwise discarded.
93
94@item discard_cleanups (old_chain);
95Same as do_cleanups except that it just removes the cleanups from the
96chain and does not call the specified functions.
97
98@end table
99
100Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they
101``should not be called when cleanups are not in place''. This means
102that any actions you need to reverse in the case of an error or
103interruption must be on the cleanup chain before you call these functions,
104since they might never return to your code (they @samp{longjmp} instead).
105
106
107@node Wrapping, Releases, Cleanups, Top
108@chapter Wrapping output lines
109
110Output that goes through printf_filtered or fputs_filtered or
111fputs_demangled needs only to have calls to wrap_here() added
112in places that would be good breaking points. The utility routines
113will take care of actually wrapping if the line width is exceeded.
114
115The argument to wrap_here() is an indentation string which is printed
116ONLY if the line breaks there. This argument is saved away and used
117later. It must remain valid until the next call to wrap_here() or
118until a newline has been printed through the *_filtered functions.
119Don't pass in a local variable and then return!
120
121It is usually best to call wrap_here() after printing a comma or space.
122If you call it before printing a space, make sure that your indentation
123properly accounts for the leading space that will print if the line wraps
124there.
125
126Any function or set of functions that produce filtered output must finish
127by printing a newline, to flush the wrap buffer, before switching to
128unfiltered ("printf") output. Symbol reading routines that print
129warnings are a good example.
130
131
132@node Releases, README, Wrapping, Top
133@chapter Configuring GDB for release
134
135
136GDB should be released after doing @samp{config.gdb none} in the top level
137directory. This will leave a makefile there, but no tm- or xm- files.
138The makefile is needed, for example, for @samp{make gdb.tar.Z}@dots{} If you
139have tm- or xm-files in the main source directory, C's include rules
140cause them to be used in preference to tm- and xm-files in the
141subdirectories where the user will actually configure and build the
142binaries.
143
144@samp{config.gdb none} is also a good way to rebuild the top level Makefile
145after changing Makefile.dist, alldeps.mak, etc.
146
147
148
149@node README, New Architectures, Releases, Top
150@chapter The README file
151
152
153Check the README file, it often has useful information that does not
154appear anywhere else in the directory.
155
156
157
158@node New Architectures, Host versus Target, README, Top
159@chapter Defining a new host or target architecture
160
161
162When building support for a new host and/or target, this will help you
163organize where to put the various parts. @var{ARCH} stands for the
164architecture involved.
165
166Object files needed when the host system is an @var{ARCH} are listed in
167the file @file{xconfig/@var{ARCH}}, in the Makefile macro @samp{XDEPFILES
168= }@dots{}. You can also define XXXXXX in there.
169
170There are some ``generic'' versions of routines that can be used by
171various host systems. If these routines work for the @var{ARCH} host,
172you can just include the generic file's name (with .o, not .c) in
173@code{XDEPFILES}. Otherwise, you will need to write routines that
174perform the same functions as the generic file, put them into
175@code{@var{ARCH}-xdep.c}, and put @code{@var{ARCH}-xdep.o} into
176@code{XDEPFILES}. These generic host support files include:
177
178@example
179 coredep.c, coredep.o
180@end example
181
182@table @code
183@item fetch_core_registers()
184Support for reading registers out of a core file. This routine calls
185@code{register_addr(}), see below.
186
187@item register_addr()
188If your @code{xm-@var{ARCH}.h} file defines the macro @code{REGISTER_U_ADDR(reg)} to be the
189offset within the @samp{user} struct of a register (represented as a GDB
190register number), @file{coredep.c} will define the @code{register_addr()} function
191and use the macro in it. If you do not define @code{REGISTER_U_ADDR}, but
192you are using the standard @code{fetch_core_registers}, you
193will need to define your own version of @code{register_addr}, put it into
194your @code{@var{ARCH}-xdep.c} file, and be sure @code{@var{ARCH}-xdep.o} is in the @code{XDEPFILES} list.
195If you have your own @code{fetch_core_registers}, you only need to define
196@code{register_addr} if your @code{fetch_core_registers} calls it. Many custom
197@code{fetch_core_registers} implementations simply locate the registers
198themselves.
199@end table
200
201Files needed when the target system is an @var{ARCH} are listed in the file
202@file{tconfig/@var{ARCH}}, in the @code{Makefile} macro @samp{TDEPFILES = }@dots{}. You can also
203define XXXXXX in there.
204
205Similar generic support files for target systems are:
206
207@example
208 exec.c, exec.o:
209@end example
210
211This file defines functions for accessing files that are executable
212on the target system. These functions open and examine an exec file,
213extract data from one, write data to one, print information about one,
214etc. Now that executable files are handled with BFD, every architecture
215should be able to use the generic exec.c rather than its own custom code.
216
217@node Host versus Target, , README, Top
218@chapter What is considered ``host-dependent'' versus ``target-dependent''?
219
220The xconfig/*, xm-*.h and *-xdep.c files are for host support. The
221question is, what features or aspects of a debugging or cross-debugging
222environment are considered to be ``host'' support.
223
224Defines and include files needed to build on the host are host support.
225Examples are tty support, system defined types, host byte order, host
226float format.
227
228Unix child process support is considered an aspect of the host. Since
229when you fork on the host you are still on the host, the various macros
230needed for finding the registers in the upage, running ptrace, and such
231are all in the host-dependent files.
232
233This is still somewhat of a grey area; I (John Gilmore) didn't do the
234xm- and tm- split for gdb (it was done by Jim Kingdon) so I have had to
235figure out the grounds on which it was split, and make my own choices
236as I evolve it. I have moved many things out of the xdep files
237actually, partly as a result of BFD and partly by removing duplicated
238code.
239
240@contents
241@bye
242