Debugging Tasks

It is possible to debug a multitasking application from GNATBench. 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 18 of the file diners.adb. Then create a new debug configuration and select debug. After hitting that breakpoint and halting you should see something similar to the screenshot below:

debugging with
tasks.

Instead of seeing one task and one stack in the debug window, we now have a number of them displayed in a tree view. From that window it is now possible to navigate from thread to thread and up and down the threads individual stacks. This allows you to view local variables or evaluate expressions in the context of the thread and stack frame of your choosing.

When a breakpoint is hit by any thread, all threads will be suspended, and resuming will cause every thread to resume.

In addition to the interface provided by Eclipse, experienced GDB users may find it useful to interact with the debugger directly via the debugger console at the bottom of the screen. First select the "Consoles" drop down menu from the monitor icon of the Console tab and select the console for gdb. Next examine Ada specific status information about the tasks running in an application via the "info tasks" command as in the screenshot below.

debugging with
tasks.