1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: Ada Tasks</title>
<meta name="description" content="Debugging with GDB: Ada Tasks">
<meta name="keywords" content="Debugging with GDB: Ada Tasks">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Ada.html#Ada" rel="up" title="Ada">
<link href="Ada-Tasks-and-Core-Files.html#Ada-Tasks-and-Core-Files" rel="next" title="Ada Tasks and Core Files">
<link href="Ada-Exceptions.html#Ada-Exceptions" rel="previous" title="Ada Exceptions">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Ada-Tasks"></a>
<div class="header">
<p>
Next: <a href="Ada-Tasks-and-Core-Files.html#Ada-Tasks-and-Core-Files" accesskey="n" rel="next">Ada Tasks and Core Files</a>, Previous: <a href="Ada-Exceptions.html#Ada-Exceptions" accesskey="p" rel="previous">Ada Exceptions</a>, Up: <a href="Ada.html#Ada" accesskey="u" rel="up">Ada</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Extensions-for-Ada-Tasks"></a>
<h4 class="subsubsection">15.4.10.7 Extensions for Ada Tasks</h4>
<a name="index-Ada_002c-tasking"></a>
<p>Support for Ada tasks is analogous to that for threads (see <a href="Threads.html#Threads">Threads</a>).
<small>GDB</small> provides the following task-related commands:
</p>
<dl compact="compact">
<dd><a name="index-info-tasks"></a>
</dd>
<dt><code>info tasks</code></dt>
<dd><p>This command shows a list of current Ada tasks, as in the following example:
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) info tasks
ID TID P-ID Pri State Name
1 8088000 0 15 Child Activation Wait main_task
2 80a4000 1 15 Accept Statement b
3 809a800 1 15 Child Activation Wait a
* 4 80ae800 3 15 Runnable c
</pre></div>
<p>In this listing, the asterisk before the last task indicates it to be the
task currently being inspected.
</p>
<dl compact="compact">
<dt>ID</dt>
<dd><p>Represents <small>GDB</small>’s internal task number.
</p>
</dd>
<dt>TID</dt>
<dd><p>The Ada task ID.
</p>
</dd>
<dt>P-ID</dt>
<dd><p>The parent’s task ID (<small>GDB</small>’s internal task number).
</p>
</dd>
<dt>Pri</dt>
<dd><p>The base priority of the task.
</p>
</dd>
<dt>State</dt>
<dd><p>Current state of the task.
</p>
<dl compact="compact">
<dt><code>Unactivated</code></dt>
<dd><p>The task has been created but has not been activated. It cannot be
executing.
</p>
</dd>
<dt><code>Runnable</code></dt>
<dd><p>The task is not blocked for any reason known to Ada. (It may be waiting
for a mutex, though.) It is conceptually "executing" in normal mode.
</p>
</dd>
<dt><code>Terminated</code></dt>
<dd><p>The task is terminated, in the sense of ARM 9.3 (5). Any dependents
that were waiting on terminate alternatives have been awakened and have
terminated themselves.
</p>
</dd>
<dt><code>Child Activation Wait</code></dt>
<dd><p>The task is waiting for created tasks to complete activation.
</p>
</dd>
<dt><code>Accept or Select Term</code></dt>
<dd><p>The task is waiting on an accept or selective wait statement.
</p>
</dd>
<dt><code>Waiting on entry call</code></dt>
<dd><p>The task is waiting on an entry call.
</p>
</dd>
<dt><code>Async Select Wait</code></dt>
<dd><p>The task is waiting to start the abortable part of an asynchronous
select statement.
</p>
</dd>
<dt><code>Delay Sleep</code></dt>
<dd><p>The task is waiting on a select statement with only a delay
alternative open.
</p>
</dd>
<dt><code>Child Termination Wait</code></dt>
<dd><p>The task is sleeping having completed a master within itself, and is
waiting for the tasks dependent on that master to become terminated or
waiting on a terminate Phase.
</p>
</dd>
<dt><code>Wait Child in Term Alt</code></dt>
<dd><p>The task is sleeping waiting for tasks on terminate alternatives to
finish terminating.
</p>
</dd>
<dt><code>Asynchronous Hold</code></dt>
<dd><p>The task has been held by <code>Ada.Asynchronous_Task_Control.Hold_Task</code>.
</p>
</dd>
<dt><code>Activating</code></dt>
<dd><p>The task has been created and is being made runnable.
</p>
</dd>
<dt><code>Selective Wait</code></dt>
<dd><p>The task is waiting in a selective wait statement.
</p>
</dd>
<dt><code>Accepting RV with <var>taskno</var></code></dt>
<dd><p>The task is accepting a rendez-vous with the task <var>taskno</var>.
</p>
</dd>
<dt><code>Waiting on RV with <var>taskno</var></code></dt>
<dd><p>The task is waiting for a rendez-vous with the task <var>taskno</var>.
</p></dd>
</dl>
</dd>
<dt>Name</dt>
<dd><p>Name of the task in the program.
</p>
</dd>
</dl>
<a name="index-info-task-taskno"></a>
</dd>
<dt><code>info task <var>taskno</var></code></dt>
<dd><p>This command shows detailed informations on the specified task, as in
the following example:
</p><div class="smallexample">
<pre class="smallexample">(gdb) info tasks
ID TID P-ID Pri State Name
1 8077880 0 15 Child Activation Wait main_task
* 2 807c468 1 15 Runnable task_1
(gdb) info task 2
Ada Task: 0x807c468
Name: "task_1"
Thread: 0
LWP: 0x1fac
Parent: 1 ("main_task")
Base Priority: 15
State: Runnable
</pre></div>
</dd>
<dt><code>task</code></dt>
<dd><a name="index-task-_0028Ada_0029"></a>
<a name="index-current-Ada-task-ID"></a>
<p>This command prints the ID and name of the current task.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) info tasks
ID TID P-ID Pri State Name
1 8077870 0 15 Child Activation Wait main_task
* 2 807c458 1 15 Runnable some_task
(gdb) task
[Current task is 2 "some_task"]
</pre></div>
</dd>
<dt><code>task <var>taskno</var></code></dt>
<dd><a name="index-Ada-task-switching"></a>
<p>This command is like the <code>thread <var>thread-id</var></code>
command (see <a href="Threads.html#Threads">Threads</a>). It switches the context of debugging
from the current task to the given task.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) info tasks
ID TID P-ID Pri State Name
1 8077870 0 15 Child Activation Wait main_task
* 2 807c458 1 15 Runnable some_task
(gdb) task 1
[Switching to task 1 "main_task"]
#0 0x8067726 in pthread_cond_wait ()
(gdb) bt
#0 0x8067726 in pthread_cond_wait ()
#1 0x8056714 in system.os_interface.pthread_cond_wait ()
#2 0x805cb63 in system.task_primitives.operations.sleep ()
#3 0x806153e in system.tasking.stages.activate_tasks ()
#4 0x804aacc in un () at un.adb:5
</pre></div>
</dd>
<dt><code>task apply [<var>task-id-list</var> | all] [<var>flag</var>]… <var>command</var></code></dt>
<dd><p>The <code>task apply</code> command is the Ada tasking analogue of
<code>thread apply</code> (see <a href="Threads.html#Threads">Threads</a>). It allows you to apply the
named <var>command</var> to one or more tasks. Specify the tasks that you
want affected using a list of task IDs, or specify <code>all</code> to apply
to all tasks.
</p>
<p>The <var>flag</var> arguments control what output to produce and how to
handle errors raised when applying <var>command</var> to a task.
<var>flag</var> must start with a <code>-</code> directly followed by one letter
in <code>qcs</code>. If several flags are provided, they must be given
individually, such as <code>-c -q</code>.
</p>
<p>By default, <small>GDB</small> displays some task information before the
output produced by <var>command</var>, and an error raised during the
execution of a <var>command</var> will abort <code>task apply</code>. The
following flags can be used to fine-tune this behavior:
</p>
<dl compact="compact">
<dt><code>-c</code></dt>
<dd><p>The flag <code>-c</code>, which stands for ‘<samp>continue</samp>’, causes any
errors in <var>command</var> to be displayed, and the execution of
<code>task apply</code> then continues.
</p></dd>
<dt><code>-s</code></dt>
<dd><p>The flag <code>-s</code>, which stands for ‘<samp>silent</samp>’, causes any errors
or empty output produced by a <var>command</var> to be silently ignored.
That is, the execution continues, but the task information and errors
are not printed.
</p></dd>
<dt><code>-q</code></dt>
<dd><p>The flag <code>-q</code> (‘<samp>quiet</samp>’) disables printing the task
information.
</p></dd>
</dl>
<p>Flags <code>-c</code> and <code>-s</code> cannot be used together.
</p>
</dd>
<dt><code>break <var>locspec</var> task <var>taskno</var></code></dt>
<dt><code>break <var>locspec</var> task <var>taskno</var> if …</code></dt>
<dd><a name="index-breakpoints-and-tasks_002c-in-Ada"></a>
<a name="index-task-breakpoints_002c-in-Ada"></a>
<a name="index-break-_2026-task-taskno-_0028Ada_0029"></a>
<p>These commands are like the <code>break … thread …</code>
command (see <a href="Thread-Stops.html#Thread-Stops">Thread Stops</a>). See <a href="Location-Specifications.html#Location-Specifications">Location Specifications</a>, for
the various forms of <var>locspec</var>.
</p>
<p>Use the qualifier ‘<samp>task <var>taskno</var></samp>’ with a breakpoint command
to specify that you only want <small>GDB</small> to stop the program when a
particular Ada task reaches this breakpoint. The <var>taskno</var> is one of the
numeric task identifiers assigned by <small>GDB</small>, shown in the first
column of the ‘<samp>info tasks</samp>’ display.
</p>
<p>If you do not specify ‘<samp>task <var>taskno</var></samp>’ when you set a
breakpoint, the breakpoint applies to <em>all</em> tasks of your
program.
</p>
<p>You can use the <code>task</code> qualifier on conditional breakpoints as
well; in this case, place ‘<samp>task <var>taskno</var></samp>’ before the
breakpoint condition (before the <code>if</code>).
</p>
<p>For example,
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) info tasks
ID TID P-ID Pri State Name
1 140022020 0 15 Child Activation Wait main_task
2 140045060 1 15 Accept/Select Wait t2
3 140044840 1 15 Runnable t1
* 4 140056040 1 15 Runnable t3
(gdb) b 15 task 2
Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15.
(gdb) cont
Continuing.
task # 1 running
task # 2 running
Breakpoint 5, test_task_debug () at test_task_debug.adb:15
15 flush;
(gdb) info tasks
ID TID P-ID Pri State Name
1 140022020 0 15 Child Activation Wait main_task
* 2 140045060 1 15 Runnable t2
3 140044840 1 15 Runnable t1
4 140056040 1 15 Delay Sleep t3
</pre></div>
</dd>
</dl>
<hr>
<div class="header">
<p>
Next: <a href="Ada-Tasks-and-Core-Files.html#Ada-Tasks-and-Core-Files" accesskey="n" rel="next">Ada Tasks and Core Files</a>, Previous: <a href="Ada-Exceptions.html#Ada-Exceptions" accesskey="p" rel="previous">Ada Exceptions</a>, Up: <a href="Ada.html#Ada" accesskey="u" rel="up">Ada</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|