You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ada-Tasks.html 11KB

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