Support for Ada tasks is analogous to that for threads (see Threads). When in Ada mode (that is, when the “current language” is Ada), GDB allows 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 Running c
In this listing, the asterisk before the first task indicates it to be the currently running task.
Task_ID
.
info 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 Running task_1 (gdb) info task 2 Ada Task: 0x807c468 Name: task_1 Thread: 0x807f378 Parent: 1 (main_task) Base Priority: 15 State: Runnable
task
tasknothread
threadno
(see Thread Stops). This command is not implemented
on all the targets. Currently supported targets are DEC Unix and Linux.
(gdb) info tasks ID TID P-ID Pri State Name 1 8077870 0 15 Child Activation Wait main_task * 2 807c458 1 15 Running 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 #5 0x8049d56 in main (argc=1, argv=3221223804, envp=3221223812) at b~un.adb:163
break
linespec task
tasknobreak
linespec task
taskno if ...
break ... thread ...
(see Thread Stops).
linespec specifies source lines, as described
in Setting breakpoints.
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. 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 Running 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.tB.1 (_task=0x11ffffc60) 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 Running t2 3 140044840 1 15 Runnable t1 4 140056040 1 15 Delay Sleep t3