Next: , Previous: Ada Exceptions, Up: Ada


12.4.3.6 Extensions for Ada Tasks

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
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 Running               c
          
     

In this listing, the asterisk before the first task indicates it to be the currently running task.

ID
Represents gdb's internal task number, used to refer to the task in conditional breakpoints and task switching.
TID
The Ada Task_ID.
P-ID
The parent's task ID (gdb's internal task number).
Pri
The base priority of the task.
State
Current state of the task.
  • Unactivated: the task has been created but has not been activated. It cannot be executing.
  • Running: the task currently running.
  • Runnable: 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.
  • Terminated: 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.
  • Accept Statement: 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.
  • Delay Sleep: 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
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 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 taskno
This command is like the thread 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 taskno
break linespec task taskno if ...
These commands are like the 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