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