8.9. Debugging Ada TasksΒΆ

It is possible to debug a multitasking Ada application because Ada tasks map directly to VxWorks tasks. All the VxWorks task-oriented debugging facilities apply. The following example uses the “Dining Philosophers” sample from the GNAT distribution. That example project can be found under the compiler installation in the directory share/examples/gnat/simple_project/.

After opening the project in GNATbench, place a breakpoint at line 53 of the file “phil.adb”. That will stop any task of that type (all philosophers in this case) whenever it hits that line. Then create a new debug configuration and launch it.

Immediately after launching you should see something similar to the screenshot below:

debugging with tasks.

Notice that no tasks appear in the Debug view. You must “attach” to kernel tasks before they will appear there. Once attached you can then see them and control them.

The first step in attaching the tasks is to select them in the “Kernel Tasks” tree in the Remote Systems view, as shown below. You select all five philosopher tasks, ignoring (arbitrarily) the “maitre_d” task.

debugging with tasks to attach

You then right-click on any one of them to invoke the contextual menu and select the “Attach to Kernel Tasks (Tasks Mode)” menu entry:

debugging with task attach menu

As a result, the selected application-defined kernel tasks now appear in the debugger view (each has hit the breakpoint we set earlier even though their state is “running” from the operating system point of view):

debugging with tasks after attaching

You can now apply all the controls provided. For example, after suspending each task you can show their stacks and navigate the source code by stepping up and down the stack frames. Note that you can now see that each has stopped on the breakpoint.

debugging with tasks at BP