Ada Tasks (GNAT User’s Guide for Native Platforms)

#### 6.1.8 Ada Tasks ¶

`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   Thread Pri State                 Name
           1   8088000   0   807e000  15 Child Activation Wait main_task
           2   80a4000   1   80ae000  15 Accept/Select Wait    b
           3   809a800   1   80a4800  15 Child Activation Wait a
        *  4   80ae800   3   80b8000  15 Running               c

    In this listing, the asterisk before the first task indicates it’s currently running task. The first column lists the task ID used to refer to tasks in the following commands.

- `break` ‘linespec’ `task` ‘taskid’, `break` ‘linespec’ `task` ‘taskid’ `if` …

  > These commands are like the `break ... thread ...`. ‘linespec’ specifies source lines.

  > Use the qualifier `task taskid` with a breakpoint command to specify that you only want `GDB` to stop the program when that particular Ada task reaches this breakpoint. ‘taskid’ is one of the numeric task identifiers assigned by `GDB`, shown in the first column of the `info tasks` display.

  > If you don’t specify `task taskid` 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 taskid` before the breakpoint condition (before the `if`).

- `task taskno`

  > This command allows switching to the task referred by ‘taskno’. In particular, it allows browsing the backtrace of the specified task. You should switch back to the original task before continuing execution; otherwise the scheduling of the program may be disturbed.

For more detailed information on tasking support, see Debugging with GDB.