]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/doc/gdbint.texinfo
Add copyright and contributor line.
[thirdparty/binutils-gdb.git] / gdb / doc / gdbint.texinfo
1 GDB Internals documentation
2 Copyright 1990, 1991 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by John Gilmore.
4
5 This needs to be wrapped in texinfo stuff...
6
7 Cleanups
8
9 Cleanups are a structured way to deal with things that need to be done
10 later. When your code does something (like malloc some memory, or open
11 a file) that needs to be undone later (e.g. free the memory or close
12 the file), it can make a cleanup. The cleanup will be done at some
13 future point: when the command is finished, when an error occurs, or
14 when your code decides it's time to do cleanups.
15
16 You can also discard cleanups, that is, throw them away without doing
17 what they say. This is only done if you ask that it be done.
18
19 Syntax:
20
21 old_chain = make_cleanup (function, arg);
22
23 This makes a cleanup which will cause FUNCTION to be called with ARG
24 (a char *) later. The result, OLD_CHAIN, is a handle that can be
25 passed to do_cleanups or discard_cleanups later. Unless you are
26 going to call do_cleanups or discard_cleanups yourself,
27 you can ignore the result from make_cleanup.
28
29 do_cleanups (old_chain);
30
31 Performs all cleanups done since make_cleanup returned OLD_CHAIN.
32 E.g.: make_cleanup (a, 0); old = make_cleanup (b, 0); do_cleanups (old);
33 will call b() but will not call a(). The cleanup that calls a() will remain
34 in the cleanup chain, and will be done later unless otherwise discarded.
35
36 discard_cleanups (old_chain);
37
38 Same as do_cleanups except that it just removes the cleanups from the
39 chain and does not call the specified functions.
40
41
42 Some functions, e.g. fputs_filtered() or error(), specify that they
43 "should not be called when cleanups are not in place". This means
44 that any actions you need to reverse in the case of an error or
45 interruption must be on the cleanup chain before you call these functions,
46 since they might never return to your code (they "longjmp" instead).
47
48
49
50 Wrapping output lines
51
52 Output that goes through printf_filtered or fputs_filtered or
53 fputs_demangled needs only to have calls to wrap_here() added
54 in places that would be good breaking points. The utility routines
55 will take care of actually wrapping if the line width is exceeded.
56
57 The argument to wrap_here() is an indentation string which is printed
58 ONLY if the line breaks there. This argument is saved away and used
59 later. It must remain valid until the next call to wrap_here() or
60 until a newline has been printed through the *_filtered functions.
61 Don't pass in a local variable and then return!
62
63 It is usually best to call wrap_here() after printing a comma or space.
64 If you call it before printing a space, make sure that your indentation
65 properly accounts for the leading space that will print if the line wraps
66 there.
67
68 Any function or set of functions that produce filtered output must finish
69 by printing a newline, to flush the wrap buffer, before switching to
70 unfiltered ("printf") output. Symbol reading routines that print
71 warnings are a good example.
72
73
74
75 Configuring GDB for release
76
77
78 GDB should be released after doing "config.gdb none" in the top level
79 directory. This will leave a makefile there, but no tm- or xm- files.
80 The makefile is needed, for example, for "make gdb.tar.Z"... If you
81 have tm- or xm-files in the main source directory, C's include rules
82 cause them to be used in preference to tm- and xm-files in the
83 subdirectories where the user will actually configure and build the
84 binaries.
85
86 "config.gdb none" is also a good way to rebuild the top level Makefile
87 after changing Makefile.dist, alldeps.mak, etc.
88
89
90
91
92 The README file
93
94
95 Check the README file, it often has useful information that does not
96 appear anywhere else in the directory.
97
98
99
100
101 Defining a new host or target architecture
102
103
104 When building support for a new host and/or target, this will help you
105 organize where to put the various parts. ARCH stands for the
106 architecture involved.
107
108 Object files needed when the host system is an ARCH are listed in the file
109 xconfig/ARCH, in the Makefile macro "XDEPFILES = ...". You can also
110 define XXXXXX in there.
111
112 There are some "generic" versions of routines that can be used by
113 various host systems. If these routines work for the ARCH host, you
114 can just include the generic file's name (with .o, not .c) in
115 XDEPFILES. Otherwise, you will need to write routines that perform the
116 same functions as the generic file, put them into ARCH-xdep.c, and put
117 ARCH-xdep.o into XDEPFILES. These generic host support files include:
118
119 coredep.c, coredep.o
120
121 fetch_core_registers():
122 Support for reading registers out of a core file. This routine calls
123 register_addr(), see below.
124
125 register_addr():
126 If your xm-ARCH.h file defines the macro REGISTER_U_ADDR(reg) to be the
127 offset within the "user" struct of a register (represented as a GDB
128 register number), coredep.c will define the register_addr() function
129 and use the macro in it. If you do not define REGISTER_U_ADDR, but
130 you are using the standard fetch_core_registers, you
131 will need to define your own version of register_addr, put it into
132 your ARCH-xdep.c file, and be sure ARCH-xdep.o is in the XDEPFILES list.
133 If you have your own fetch_core_registers, you only need to define
134 register_addr if your fetch_core_registers calls it. Many custom
135 fetch_core_registers implementations simply locate the registers
136 themselves.
137
138
139 Files needed when the target system is an ARCH are listed in the file
140 tconfig/ARCH, in the Makefile macro "TDEPFILES = ...". You can also
141 define XXXXXX in there.
142
143 Similar generic support files for target systems are:
144
145 exec.c, exec.o:
146
147 This file defines functions for accessing files that are executable
148 on the target system. These functions open and examine an exec file,
149 extract data from one, write data to one, print information about one,
150 etc. Now that executable files are handled with BFD, every architecture
151 should be able to use the generic exec.c rather than its own custom code.