Support for Ada tasks is analogous to that for threads (see Threads). GDB provides the following task-related commands:
This command shows a list of current Ada tasks, as in the following example:
(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
In this listing, the asterisk before the last task indicates it to be the task currently being inspected.
Represents GDB’s internal task number.
The Ada task ID.
The parent’s task ID (GDB’s internal task number).
The base priority of the task.
Current state of the task.
The task has been created but has not been activated. It cannot be executing.
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.
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.
Child Activation Wait
The task is waiting for created tasks to complete activation.
The task is waiting on an accept or selective wait statement.
Waiting on entry call
The task is waiting on an entry call.
Async Select Wait
The task is waiting to start the abortable part of an asynchronous select statement.
The task is waiting on a select statement with only a delay alternative open.
Child Termination Wait
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.
Wait Child in Term Alt
The task is sleeping waiting for tasks on terminate alternatives to finish terminating.
Accepting RV with taskno
The task is accepting a rendez-vous with the task taskno.
Name of the task in the program.
info task taskno
This command shows detailled informations on the specified task, as in the following example:
(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: 0x807f378 Parent: 1 (main_task) Base Priority: 15 State: Runnable
This command prints the ID of the current task.
(gdb) info tasks ID TID P-ID Pri State Name 1 8077870 0 15 Child Activation Wait main_task * 2 807c458 1 15 Runnable t (gdb) task [Current task is 2]
This command is like the
command (see Threads). It switches the context of debugging
from the current task to the given task.
(gdb) info tasks ID TID P-ID Pri State Name 1 8077870 0 15 Child Activation Wait main_task * 2 807c458 1 15 Runnable t (gdb) task 1 [Switching to task 1] #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
break location task taskno
break location task taskno if …
These commands are like the
break … thread …
command (see Thread Stops). The
location argument specifies source lines, as described
in Specify Location.
Use the qualifier ‘task taskno’ with a breakpoint command to specify that you only want GDB to stop the program when a particular Ada task reaches this breakpoint. The taskno is one of the numeric task identifiers assigned by GDB, shown in the first column of the ‘info tasks’ display.
If you do not specify ‘task taskno’ when you set a breakpoint, the breakpoint applies to all tasks of your program.
You can use the
task qualifier on conditional breakpoints as
well; in this case, place ‘task taskno’ before the
breakpoint condition (before the
(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