Next: Ada Tasks and Core Files, Previous: Ada Exceptions, Up: Ada
Support for Ada tasks is analogous to that for threads (see Threads). gdb provides the following task-related commands:
info tasks
(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.
Unactivated
Runnable
Terminated
Child Activation Wait
Accept Statement
Waiting on entry call
Async Select Wait
Delay Sleep
Child Termination Wait
Wait Child in Term Alt
Accepting RV with
tasknoinfo task
taskno(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
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]
task
tasknothread
threadno
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
linespec task
tasknobreak
linespec task
taskno if ...
break ... thread ...
command (see Thread Stops). The
linespec 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 if
).
For example,
(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