1 |
1026 |
ivang |
@c
|
2 |
|
|
@c COPYRIGHT (c) 1988-2002.
|
3 |
|
|
@c On-Line Applications Research Corporation (OAR).
|
4 |
|
|
@c All rights reserved.
|
5 |
|
|
@c
|
6 |
|
|
@c gdb.t,v 1.13 2002/06/28 19:16:45 joel Exp
|
7 |
|
|
@c
|
8 |
|
|
|
9 |
|
|
@chapter Building the GNU Debugger
|
10 |
|
|
|
11 |
|
|
The GNU Debugger GDB supports many configurations but requires some
|
12 |
|
|
means of communicating between the host computer and target board.
|
13 |
|
|
This communication can be via a serial port, Ethernet, BDM, or ROM emulator.
|
14 |
|
|
The communication protocol can be the GDB remote protocol or GDB
|
15 |
|
|
can talk directly to a ROM monitor. This setup is target board
|
16 |
|
|
specific. The following configurations have been
|
17 |
|
|
successfully used with RTEMS applications:
|
18 |
|
|
|
19 |
|
|
@itemize @bullet
|
20 |
|
|
@item Sparc Instruction Simulator (SIS)
|
21 |
|
|
@item PowerPC Instruction Simulator (PSIM)
|
22 |
|
|
@item DINK32
|
23 |
|
|
@item BDM with 68360 and MPC860 CPUs
|
24 |
|
|
@item Motorola Mxxxbug found on M68xxx MVME boards
|
25 |
|
|
@item Motorola PPCbug found on PowerPC MVME boards
|
26 |
|
|
@end itemize
|
27 |
|
|
|
28 |
|
|
GDB is currently RTEMS thread/task aware only if you are using the
|
29 |
|
|
remote debugging support via Ethernet. These are configured
|
30 |
|
|
using gdb targets of the form CPU-RTEMS. Note the capital RTEMS.
|
31 |
|
|
|
32 |
|
|
It is recommended that when toolset binaries are available for
|
33 |
|
|
your particular host, that they be used. Prebuilt binaries
|
34 |
|
|
are much easier to install but in the case of gdb may or may
|
35 |
|
|
not include support for your particular target board.
|
36 |
|
|
|
37 |
|
|
@c
|
38 |
|
|
@c Getting Ready to Build GDB
|
39 |
|
|
@c
|
40 |
|
|
@section Getting Ready to Build GDB
|
41 |
|
|
|
42 |
|
|
This section describes the process of unarchiving GDB
|
43 |
|
|
as well as applying RTEMS specific patches. This is required when building
|
44 |
|
|
the tools via the instructions in the
|
45 |
|
|
@ref{Using the GDB configure Script Directly} or
|
46 |
|
|
@ref{Using the bit_gdb Script} sections. It is @b{NOT} required when
|
47 |
|
|
using RPM to build tool binaries.
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
@c
|
51 |
|
|
@c Unarchive the GDB Distribution
|
52 |
|
|
@c
|
53 |
|
|
@subsection Unarchive the GDB Distribution
|
54 |
|
|
|
55 |
|
|
Unarchive the compressed tar files for GDB using the appropriate
|
56 |
|
|
command based upon the compression program used for the source
|
57 |
|
|
distribution you downloaded.
|
58 |
|
|
|
59 |
|
|
@example
|
60 |
|
|
cd tools
|
61 |
|
|
tar xzf ../archive/@{GDB-UNTAR}.tar.gz # for gzip'ed gdb
|
62 |
|
|
tar xIf ../archive/@{GDB-UNTAR}.tar.bz2 # for bzip'ed gdb
|
63 |
|
|
@endif
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
@example
|
67 |
|
|
cd tools
|
68 |
|
|
tar xzf ../archive/@value{GDB-TAR}
|
69 |
|
|
@end example
|
70 |
|
|
|
71 |
|
|
The directory @value{GDB-UNTAR} is created under the tools directory.
|
72 |
|
|
|
73 |
|
|
@c
|
74 |
|
|
@c Apply RTEMS Patch to GDB
|
75 |
|
|
@c
|
76 |
|
|
|
77 |
|
|
@subsection Apply RTEMS Patch to GDB
|
78 |
|
|
|
79 |
|
|
@ifclear GDB-RTEMSPATCH
|
80 |
|
|
No RTEMS specific patches are required for @value{GDB-VERSION} to
|
81 |
|
|
support @value{RTEMS-VERSION}.
|
82 |
|
|
@end ifclear
|
83 |
|
|
|
84 |
|
|
@ifset GDB-RTEMSPATCH
|
85 |
|
|
|
86 |
|
|
Apply the patch using the following command sequence:
|
87 |
|
|
|
88 |
|
|
@example
|
89 |
|
|
cd tools/@value{GDB-UNTAR}
|
90 |
|
|
zcat archive/@value{GDB-RTEMSPATCH} | patch -p1
|
91 |
|
|
@end example
|
92 |
|
|
|
93 |
|
|
Check to see if any of these patches have been rejected using the following
|
94 |
|
|
sequence:
|
95 |
|
|
|
96 |
|
|
@example
|
97 |
|
|
cd tools/@value{GDB-UNTAR}
|
98 |
|
|
find . -name "*.rej" -print
|
99 |
|
|
@end example
|
100 |
|
|
|
101 |
|
|
If any files are found with the .rej extension, a patch has been rejected.
|
102 |
|
|
This should not happen with a good patch file.
|
103 |
|
|
|
104 |
|
|
@end ifset
|
105 |
|
|
|
106 |
|
|
@c
|
107 |
|
|
@c Building the GNU Debugger GDB
|
108 |
|
|
@c
|
109 |
|
|
|
110 |
|
|
@section Building the GNU Debugger GDB
|
111 |
|
|
|
112 |
|
|
There are three methods of build the GNU Debugger:
|
113 |
|
|
|
114 |
|
|
@itemize @bullet
|
115 |
|
|
@item RPM
|
116 |
|
|
@item direct invocation of configure and make
|
117 |
|
|
@item using the @code{bit_gdb} script
|
118 |
|
|
@end itemize
|
119 |
|
|
|
120 |
|
|
Direct invocation of configure and make provides more control
|
121 |
|
|
and easier recovery from problems when building.
|
122 |
|
|
|
123 |
|
|
@c
|
124 |
|
|
@c Using RPM to Build GDB
|
125 |
|
|
@c
|
126 |
|
|
|
127 |
|
|
@subsection Using RPM to Build GDB
|
128 |
|
|
|
129 |
|
|
This section describes the process of building binutils, gcc, and
|
130 |
|
|
newlib using RPM. RPM is a packaging format which can be used to
|
131 |
|
|
distribute binary files as well as to capture the procedure and
|
132 |
|
|
source code used to produce those binary files. Before
|
133 |
|
|
attempting to build any RPM from source, it is necessary to
|
134 |
|
|
ensure that all required source and patches are in the @code{SOURCES}
|
135 |
|
|
directory under the RPM root (probably @code{/usr/src/redhat} or
|
136 |
|
|
@code{/usr/local/src/redhat} on your machine. This procedure
|
137 |
|
|
starts by installing the source RPMs as shown in the following
|
138 |
|
|
example:
|
139 |
|
|
|
140 |
|
|
@example
|
141 |
|
|
rpm -i i386-rtems-gdb-collection-4.18-4.nosrc.rpm
|
142 |
|
|
@end example
|
143 |
|
|
|
144 |
|
|
Because RTEMS tool RPMS are called "nosrc" to indicate that one or
|
145 |
|
|
more source files required to produce the RPMs are not present.
|
146 |
|
|
The RTEMS source GDB RPM does not include the large @code{.tar.gz} or
|
147 |
|
|
@code{.tgz} files for GDB. This is shared by all RTEMS RPMs
|
148 |
|
|
regardless of target CPU and there was no reason
|
149 |
|
|
to duplicate them. You will have to get the required source
|
150 |
|
|
archive files by hand and place them in the @code{SOURCES} directory
|
151 |
|
|
before attempting to build. If you forget to do this, RPM is
|
152 |
|
|
smart -- it will tell you what is missing. To determine what is
|
153 |
|
|
included or referenced by a particular RPM, use a command like the
|
154 |
|
|
following:
|
155 |
|
|
|
156 |
|
|
@example
|
157 |
|
|
$ rpm -q -l -p i386-rtems-gdb-collection-4.18-4.nosrc.rpm
|
158 |
|
|
gdb-4.18-rtems-20000524.diff
|
159 |
|
|
gdb-4.18.tar.gz
|
160 |
|
|
i386-rtems-gdb-4.18.spec
|
161 |
|
|
@end example
|
162 |
|
|
|
163 |
|
|
Notice that there is a patch file (the @code{.diff} file), a source archive
|
164 |
|
|
file (the @code{.tar.gz}), and a file describing the build procedure and
|
165 |
|
|
files produced (the @code{.spec} file). The @code{.spec} file is placed
|
166 |
|
|
in the @code{SPECS} directory under the RPM root directory.
|
167 |
|
|
|
168 |
|
|
c
|
169 |
|
|
@c Configuring and Building GDB using RPM
|
170 |
|
|
@c
|
171 |
|
|
|
172 |
|
|
@subsubsection Configuring and Building GDB using RPM
|
173 |
|
|
|
174 |
|
|
The following example illustrates the invocation of RPM to build a new,
|
175 |
|
|
locally compiled, binutils binary RPM that matches the installed source
|
176 |
|
|
RPM. This example assumes that all of the required source is installed.
|
177 |
|
|
|
178 |
|
|
@example
|
179 |
|
|
cd /SPECS
|
180 |
|
|
rpm -bb i386-rtems-gdb-4.18.spec
|
181 |
|
|
@end example
|
182 |
|
|
|
183 |
|
|
If the build completes successfully, RPMS like the following will
|
184 |
|
|
be generated in a build-host architecture specific subdirectory
|
185 |
|
|
of the RPMS directory under the RPM root directory.
|
186 |
|
|
|
187 |
|
|
@example
|
188 |
|
|
rtems-base-gdb-4.18-4.i386.rpm
|
189 |
|
|
i386-rtems-gdb-4.18-4.i386.rpm
|
190 |
|
|
@end example
|
191 |
|
|
|
192 |
|
|
NOTE: It may be necessary to remove the build tree in the
|
193 |
|
|
@code{BUILD} directory under the RPM root directory.
|
194 |
|
|
|
195 |
|
|
@c
|
196 |
|
|
@c Using the GDB configure Script Directly
|
197 |
|
|
@c
|
198 |
|
|
|
199 |
|
|
@subsection Using the GDB configure Script Directly
|
200 |
|
|
|
201 |
|
|
This section describes how to configure the GNU debugger for
|
202 |
|
|
standard RTEMS configurations as well as some alternative
|
203 |
|
|
configurations that have been used in the past.
|
204 |
|
|
|
205 |
|
|
@subsubsection Standard RTEMS GDB Configuration
|
206 |
|
|
|
207 |
|
|
The following example illustrates the invocation of configure
|
208 |
|
|
and make to build and install @value{GDB-UNTAR} for the
|
209 |
|
|
m68k-rtems target:
|
210 |
|
|
|
211 |
|
|
@example
|
212 |
|
|
mkdir b-gdb
|
213 |
|
|
cd b-gdb
|
214 |
|
|
../@value{GDB-UNTAR}/configure --target=m68k-rtems \
|
215 |
|
|
--prefix=/opt/rtems
|
216 |
|
|
make all
|
217 |
|
|
make info
|
218 |
|
|
make install
|
219 |
|
|
@end example
|
220 |
|
|
|
221 |
|
|
For some configurations, it is necessary to specify extra options
|
222 |
|
|
to @code{configure} to enable and configure option components
|
223 |
|
|
such as a processor simulator. The following is a list of
|
224 |
|
|
configurations for which there are extra options:
|
225 |
|
|
|
226 |
|
|
@table @b
|
227 |
|
|
@item i960-rtems
|
228 |
|
|
@code{--enable-sim}
|
229 |
|
|
|
230 |
|
|
@item powerpc-rtems
|
231 |
|
|
@code{--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware}
|
232 |
|
|
|
233 |
|
|
@item sparc-rtems
|
234 |
|
|
@code{--enable-sim}
|
235 |
|
|
|
236 |
|
|
@end table
|
237 |
|
|
|
238 |
|
|
After @value{GDB-UNTAR} is built and installed the
|
239 |
|
|
build directory @code{b-gdb} may be removed.
|
240 |
|
|
|
241 |
|
|
For more information on the invocation of @code{configure}, please
|
242 |
|
|
refer to the documentation for @value{GDB-UNTAR} or
|
243 |
|
|
invoke the @value{GDB-UNTAR} configure command with the
|
244 |
|
|
@code{--help} option.
|
245 |
|
|
|
246 |
|
|
@subsection Using the bit_gdb Script
|
247 |
|
|
|
248 |
|
|
The simplest way to build gdb for RTEMS is to use the @code{bit_gdb} script.
|
249 |
|
|
This script interprets the settings in the @code{user.cfg} file to
|
250 |
|
|
produce the GDB configuration most appropriate for the target CPU.
|
251 |
|
|
|
252 |
|
|
This script is invoked as follows:
|
253 |
|
|
|
254 |
|
|
@example
|
255 |
|
|
./bit_gdb CPU
|
256 |
|
|
@end example
|
257 |
|
|
|
258 |
|
|
Where CPU is one of the RTEMS supported CPU families from the following
|
259 |
|
|
list:
|
260 |
|
|
|
261 |
|
|
@itemize @bullet
|
262 |
|
|
@item hppa1.1
|
263 |
|
|
@item i386
|
264 |
|
|
@item i386-coff
|
265 |
|
|
@item i386-elf
|
266 |
|
|
@item i960
|
267 |
|
|
@item m68k
|
268 |
|
|
@item m68k-coff
|
269 |
|
|
@item mips64orion
|
270 |
|
|
@item powerpc
|
271 |
|
|
@item sh
|
272 |
|
|
@item sh-elf
|
273 |
|
|
@item sparc
|
274 |
|
|
@end itemize
|
275 |
|
|
|
276 |
|
|
If gdb supports a CPU instruction simulator for this configuration, then
|
277 |
|
|
it is included in the build.
|
278 |
|
|
|