Ada-Tasks.html 11 KB

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