1 |
1026 |
ivang |
@c
|
2 |
|
|
@c RTEMS Remote Debugger Server Specifications
|
3 |
|
|
@c
|
4 |
|
|
@c Written by: Eric Valette
|
5 |
|
|
@c Emmanuel Raguet
|
6 |
|
|
@c
|
7 |
|
|
@c
|
8 |
|
|
@c objectives.t,v 1.3 2002/01/17 21:47:46 joel Exp
|
9 |
|
|
@c
|
10 |
|
|
|
11 |
|
|
@chapter Objectives
|
12 |
|
|
|
13 |
|
|
@c XXX reference
|
14 |
|
|
This section is intended to clearly define the current objectives of our work.
|
15 |
|
|
First, we will try here to list some ambitious requirements for the debugger
|
16 |
|
|
in section @b{List of Requirements}. These requirements will deliberately be much more
|
17 |
|
|
ambitious than what we will provide directly ourselves in the hope that the
|
18 |
|
|
Internet development model will enable others to implement some features we
|
19 |
|
|
rejected for man-power reasons in the first step. We are committed to do the
|
20 |
|
|
core work and redistribute it but would appreciate any comment and enhancement.
|
21 |
|
|
Then, in section @b{Requirements Analysis} we will analyze each requirement to see
|
22 |
|
|
what technical problem must be solved if we want to fullfill it. After this
|
23 |
|
|
analysis, we will determine in section @b{Requirements Selection} the requirements we
|
24 |
|
|
chose to implement and the ones we will not. We will then clearly identify the
|
25 |
|
|
limits of our solution in section @b{Implied Restrictions}.
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
@section List of Requirements
|
29 |
|
|
|
30 |
|
|
We will identify here possible requirements for the type of debug that may be
|
31 |
|
|
provided :
|
32 |
|
|
|
33 |
|
|
@table @b
|
34 |
|
|
|
35 |
|
|
@item [(R1)]:
|
36 |
|
|
We want to use GDB as the front-end debugger,
|
37 |
|
|
|
38 |
|
|
@item [(R2)]:
|
39 |
|
|
We want to support at least Intel and PowerPC as target processor architecture,
|
40 |
|
|
|
41 |
|
|
@item [(R3)]:
|
42 |
|
|
We want to use the GDB thread debugging interface,
|
43 |
|
|
|
44 |
|
|
@item [(R4)]:
|
45 |
|
|
We want to be able to debug a remote target over a serial line,
|
46 |
|
|
|
47 |
|
|
@item [(R5)]:
|
48 |
|
|
We want to be able to debug a remote target over Ethernet,
|
49 |
|
|
|
50 |
|
|
@item [(R6)]:
|
51 |
|
|
The set of target code path we will be able to debug using RGDBSD must
|
52 |
|
|
be clearly identified. It will be called Debug Path Set (@emph{DPS}) in the
|
53 |
|
|
remaining of this document,
|
54 |
|
|
|
55 |
|
|
@item [(R7)]:
|
56 |
|
|
@emph{DPS} must include the RTEMS core executive itself,
|
57 |
|
|
|
58 |
|
|
@item [(R8)]:
|
59 |
|
|
@emph{DPS} must include the FreeBSD stack,
|
60 |
|
|
|
61 |
|
|
@item [(R9)]:
|
62 |
|
|
@emph{DPS} must include anything but the FreeBSD stack and the RTEMS
|
63 |
|
|
core executive,
|
64 |
|
|
|
65 |
|
|
@item [(R10)]:
|
66 |
|
|
We want to enable several persons to debug different parts of the code
|
67 |
|
|
running on the target,
|
68 |
|
|
|
69 |
|
|
@item [(R11)]:
|
70 |
|
|
As much as possible the system must be frozen during a debug session
|
71 |
|
|
so that debugging a particular portion of code does not prevent another part
|
72 |
|
|
from functioning,
|
73 |
|
|
@end table
|
74 |
|
|
|
75 |
|
|
@section Requirements Analysis
|
76 |
|
|
|
77 |
|
|
@table @b
|
78 |
|
|
|
79 |
|
|
@item [(R1)]:
|
80 |
|
|
Worth recalling it. It mainly imposes few restrictions on the binary
|
81 |
|
|
files type, target processor type as :
|
82 |
|
|
|
83 |
|
|
@itemize @bullet
|
84 |
|
|
|
85 |
|
|
@item the binary format must be understood by GDB (to find debugging information).
|
86 |
|
|
Elf, Coff and A.out are the main formats currently supported. Elf/Dwarf 2.0
|
87 |
|
|
binary support will be our main target as they are the preferred format for
|
88 |
|
|
Intel and PowerPC processors. No change in GDB will be required for other binaries
|
89 |
|
|
except may be a new configuration file changing the binary/debug file format,
|
90 |
|
|
|
91 |
|
|
@item the processor must be supported for disassemble/step instruction command,
|
92 |
|
|
|
93 |
|
|
@item the target system must be supported. As far as I know RTEMS is not currently
|
94 |
|
|
@emph{officially} supported anyway,
|
95 |
|
|
@end itemize
|
96 |
|
|
|
97 |
|
|
@item [(R2)]:
|
98 |
|
|
Our primary targets are Intel and PowerPC. We however do not think implementing
|
99 |
|
|
RGDBSD for other processors will be a heavy task. It will mainly require :
|
100 |
|
|
|
101 |
|
|
@enumerate
|
102 |
|
|
@item Implementing exception handling for the target processor,
|
103 |
|
|
|
104 |
|
|
@item Interfacing the generic part of RGDBSD with the low level exception handling
|
105 |
|
|
and make RGDBSD aware of exception used for debugging (usually illegal instruction
|
106 |
|
|
or dedicated trap, single step),
|
107 |
|
|
|
108 |
|
|
@item Making GDB aware of the frame layout pushed on exceptions,
|
109 |
|
|
|
110 |
|
|
@item Implement the code for data transfer for the exception frame,
|
111 |
|
|
|
112 |
|
|
@item Implement code to copy data cache back to main memory and invalidate instruction
|
113 |
|
|
cache. This is needed in order to be sure opcode modification used to set breakpoint
|
114 |
|
|
that use the data cache will be proagated to the instruction cache,
|
115 |
|
|
@end enumerate
|
116 |
|
|
|
117 |
|
|
As soon as we will have completed the first core work a document describing
|
118 |
|
|
how to port it to a new processor should be written. So far we will organize
|
119 |
|
|
the source tree with processor dependent directories so that port will be as
|
120 |
|
|
easy as possible. May be a bare processor support should be created,
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
@item [(R3)]:
|
124 |
|
|
GDB already has an interface for manipulating multi-threaded programs.
|
125 |
|
|
This interface is rather weak at the moment but it will certainly be improved
|
126 |
|
|
in the future with the generalization of POSIX thread API on Linux and other
|
127 |
|
|
operating systems. This implies that either GDB or RGDBSD is able to obtain
|
128 |
|
|
the list of threads currently executing. The choice of implementing this in
|
129 |
|
|
GDB or RGDBSD is a tradeof between target code size and simplicity,
|
130 |
|
|
|
131 |
|
|
@item [(R4)]:
|
132 |
|
|
Regular GDB code contains clients code for debugging over a serial line.
|
133 |
|
|
However only few functions are implemented. We would like to provide a better
|
134 |
|
|
support and to uniformize serial line debugging with debugging over Ethernet
|
135 |
|
|
via the use of SLIP,
|
136 |
|
|
|
137 |
|
|
@item [(R5)]:
|
138 |
|
|
Regular GDB code contains client code for debugging over Ethernet for
|
139 |
|
|
VxWorks via the SUN RPC library. So there will be at least one starting point
|
140 |
|
|
to implement remote debugging over Ethernet via SUN RPC. The Chorus remote debugging
|
141 |
|
|
code has been disclosed under GPL and also contains code for debugging suing
|
142 |
|
|
SUN RPC,
|
143 |
|
|
|
144 |
|
|
@item [(R6)]:
|
145 |
|
|
Due to a classical chicken and egg problems, the remote debugging daemon
|
146 |
|
|
cannot be used to debug code it uses to function. Thus depending on the API
|
147 |
|
|
used by RGDBSD, some parts of the target system will not be debuggable via GDB.
|
148 |
|
|
The most important point is documentation because my feeling is that implementing
|
149 |
|
|
RGDBSD on a totally different @emph{dedicated} nano kernel should be possible,
|
150 |
|
|
|
151 |
|
|
@item [(R7)]:
|
152 |
|
|
RTEMS core executive is a real-time OS which implements priority level
|
153 |
|
|
scheduling, synchronization objects, and interrupt handling. As mentioned in
|
154 |
|
|
previous item, we may not debug theses features if RGDBSD uses them. This requirement
|
155 |
|
|
is thus very strong because it impose that :
|
156 |
|
|
|
157 |
|
|
@enumerate
|
158 |
|
|
|
159 |
|
|
@item RGDBSD is totally interrupt driven (no thread API available),
|
160 |
|
|
|
161 |
|
|
@item But it does not use RTEMS interrupt management,
|
162 |
|
|
|
163 |
|
|
@item Nor does not use RTEMS exception management,
|
164 |
|
|
|
165 |
|
|
@item RGDBSD must provide its own UDP/IP stack as the current FreeBSD code rely on
|
166 |
|
|
tasks switching and RTEMS provided synchronization object for input path handling,
|
167 |
|
|
@end enumerate
|
168 |
|
|
|
169 |
|
|
So our feeling is that the @b{(R7)} more or less requires to write a @emph{dedicated}
|
170 |
|
|
nano kernel with a very small dedicated UDP/IP stack.
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
@item [(R8)]:
|
174 |
|
|
GDB remote debugging over Ethernet code communicates with the remote
|
175 |
|
|
target via the SUN RPC protocol. This requires a UDP/IP protocol and a minimal
|
176 |
|
|
socket like interface. In RTEMS environment, this feature is currently provided
|
177 |
|
|
by the FreeBSD stack. Again, if we use the FreeBSD stack itself for remote communication,
|
178 |
|
|
it will be impossible to debug this stack as a breakpoint in the stack code
|
179 |
|
|
will stop its execution and there would be no more way to communicate with the
|
180 |
|
|
target. A solution consists in implementing a minimal, dedicated UDP/IP stack
|
181 |
|
|
(with at least IP and UDP protocols, a minimal BSD sockets) and a simple SUN
|
182 |
|
|
RPC library, which will be both dedicated to the debug. We can use RTEMS API
|
183 |
|
|
to implement it if @b{(R7)} is not required. As the two stack will need
|
184 |
|
|
to share the same chip, a kind of shared filter must be implemented at the bottom
|
185 |
|
|
of the two stacks so that Ethernet frames can be dynamically directed either
|
186 |
|
|
to the dedicated UDP/IP debug stack or to the regular FreeBSD stack. The fact
|
187 |
|
|
that in the current design, the low level ethernet input routine mainly signal
|
188 |
|
|
a thread should facilitate the design of this filter. The output path is less
|
189 |
|
|
complicated as it is run by a task and thus can sleep on a synchronization object,
|
190 |
|
|
|
191 |
|
|
@item [(R9)]:
|
192 |
|
|
This requirement represents what we find reasonable as a first target.
|
193 |
|
|
However, we can still present to the final user this kind of debugging via different
|
194 |
|
|
model. RTEMS can be represented as a single threaded system or, because RTEMS
|
195 |
|
|
is a multitasking system, as an ensemble of separate tasks. In the first representation,
|
196 |
|
|
the debugger sees only 1 ``task'' without distinguishing the core executive
|
197 |
|
|
part from the applicative part. This is the simplest way to implement the debugger
|
198 |
|
|
but also implies that there is no way to protect the core executive. Some of
|
199 |
|
|
these tasks are system tasks (tasks form the core executive and from the FreeBSD
|
200 |
|
|
stack), the other ones are tasks implemented by the developer. The developer
|
201 |
|
|
wants to debug his tasks, and sometimes only one of his tasks. We can provide
|
202 |
|
|
a way to debug not the entire system but only the concerned task by testing
|
203 |
|
|
if the current running task is a debugged task (test on the task identifier).
|
204 |
|
|
GDB offers an API to ``detach'' thread so that if a detached thread hits a
|
205 |
|
|
breakpoint it is automatically restarted without user intervention,
|
206 |
|
|
|
207 |
|
|
@item [(R10)]:
|
208 |
|
|
Several developers can work on a large project, each on a specific
|
209 |
|
|
module. Sometimes only one target is available for everyone. This requirements
|
210 |
|
|
is not really meaningfull until RTEMS supports dynamic code loading,
|
211 |
|
|
|
212 |
|
|
@item [(R11)]:
|
213 |
|
|
This requirement heavily depends on the @b{(R7)} and @b{(R8)}
|
214 |
|
|
requirements.
|
215 |
|
|
@end table
|
216 |
|
|
|
217 |
|
|
@section Requirements Selection
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
@subsection Requirement We Will Take Into Account For the First Implementation
|
221 |
|
|
|
222 |
|
|
@table @b
|
223 |
|
|
|
224 |
|
|
@item [(R1)]:
|
225 |
|
|
Obviously.
|
226 |
|
|
|
227 |
|
|
@item [(R2)]:
|
228 |
|
|
As these are our targets. Of course other will be free to contribute.
|
229 |
|
|
We will however document the works that needs to be done in order to port the
|
230 |
|
|
debug code to other processors,
|
231 |
|
|
|
232 |
|
|
@item [(R3)]:
|
233 |
|
|
We think it is feasible with only few RTEMS modifications,
|
234 |
|
|
|
235 |
|
|
@item [(R5)]:
|
236 |
|
|
We think serial line debugging is nowadays too restrictive as most equipment
|
237 |
|
|
are now connected via Ethernet,
|
238 |
|
|
|
239 |
|
|
@item [(R6)]:
|
240 |
|
|
This is a documentation problem and should be fairly easy to describe
|
241 |
|
|
once we have the RGDBSD code,
|
242 |
|
|
|
243 |
|
|
@item [(R9)]:
|
244 |
|
|
We will try to provide the multi-thread target system presentation,
|
245 |
|
|
@end table
|
246 |
|
|
|
247 |
|
|
@subsection Requirements We Will Not Implement
|
248 |
|
|
|
249 |
|
|
@table @b
|
250 |
|
|
|
251 |
|
|
@item [(R4)]:
|
252 |
|
|
it will not be implemented for the moment. It is just a matter on implementing
|
253 |
|
|
SLIP in the FreeBSD stack and alternative solutions already exist in the meantime,
|
254 |
|
|
|
255 |
|
|
@item [(R7)]:
|
256 |
|
|
To simplify the first developments, we don't plan to implement a @emph{dedicated}
|
257 |
|
|
nano-kernel to allow the RTEMS kernel to be debugged. It means that, if any
|
258 |
|
|
breakpoint is set in the kernel, unpredictable behaviors can occur. So, developers
|
259 |
|
|
must keep in mind to avoid stopping the kernel. They must also keep in mind,
|
260 |
|
|
in order to not stop the kernel, that the user's tasks must have a lower priority
|
261 |
|
|
than the tasks used for debug. The solution is to use a specific very-high priority
|
262 |
|
|
level for the system tasks used directly or indirectly by RGDBSD. The SYSTEM_TASK
|
263 |
|
|
attribute that already exists should be fine.
|
264 |
|
|
|
265 |
|
|
@item [(R8)]:
|
266 |
|
|
To avoid increasing the code size and the used memory and because the
|
267 |
|
|
FreeBSD stack doesn't need to be debug any more, we choose not to implement
|
268 |
|
|
a minimal TCP/IP stack but rather to use the FreeBSD one as communication protocol,
|
269 |
|
|
|
270 |
|
|
@item [(R10)]:
|
271 |
|
|
We will see later when a file system will be available and we can implement
|
272 |
|
|
@b{exec} system call,
|
273 |
|
|
|
274 |
|
|
@item [(R11)]:
|
275 |
|
|
Without a separate TCP/IP stack it will be hard to freeze the system
|
276 |
|
|
as some interrupts must occur in order to enable the FreeBSD stack to function,
|
277 |
|
|
@end table
|
278 |
|
|
|
279 |
|
|
@section Implied Restrictions
|
280 |
|
|
|
281 |
|
|
High priority level must be used for these features :
|
282 |
|
|
|
283 |
|
|
@itemize @bullet
|
284 |
|
|
|
285 |
|
|
@item FreeBSD interrupt handling thread,
|
286 |
|
|
|
287 |
|
|
@item Debugger threads.
|
288 |
|
|
@end itemize
|
289 |
|
|
|
290 |
|
|
This will allows these tasks not to be stopped when a process is stopped
|
291 |
|
|
in debug mode
|
292 |
|
|
|
293 |
|
|
If we don't want to use a ``specific'' priority level, we must affect
|
294 |
|
|
priority to each of these tasks as follow :
|
295 |
|
|
|
296 |
|
|
@itemize @bullet
|
297 |
|
|
|
298 |
|
|
@item FreeBSD stack (high priority)
|
299 |
|
|
|
300 |
|
|
@item Debugger (less high priority)
|
301 |
|
|
@end itemize
|
302 |
|
|
|
303 |
|
|
The user must remember the higher priority level he can use for his
|
304 |
|
|
software in order not to block one of the previous threads and to not put breakpoints
|
305 |
|
|
in part of the code executed by RGDBSD.
|
306 |
|
|
|
307 |
|
|
|