HP OpenVMS Systems Documentation
OpenVMS Debugger Manual
Figure 17-1 shows a task stack.
Figure 17-1 Diagram of a Task Stack
The SHOW TASK/STATISTICS command reports some statistics about all tasks in your program. Example 17-5 shows the output of the SHOW TASK/STATISTICS/FULL command for a sample program with POSIX Threads tasks. This information enables you to measure the performance of your program. The larger the number of total schedulings (also known as context switches), the more tasking overhead there is.
17.4.2 Displaying Task Information About Ada Tasks
The SHOW TASK/ALL command displays information about all of the tasks of the program that currently exist---namely, tasks that have been created and whose master has not yet terminated (see Example 17-6).
Key to Example 17-6:
1 An unhandled exception is one for which there is no handler in the current frame or for which there is a handler that executes a raise statement and propagates the exception to an outer scope.
Figure 17-1 shows a task stack.
The SHOW TASK/FULL command provides detailed information about each task selected for display. Example 17-7 shows the output of this command for a sample Ada task.
Key to Example 17-7:
The SHOW TASK/STATISTICS command reports some statistics about all tasks in your program. Example 17-8 shows the output of the SHOW TASK/STATISTICS/FULL command for a sample Ada tasking program on a VAX system. This information enables you to measure the performance of your program. The larger the number of total schedulings (also known as context switches), the more tasking overhead there is.
For more information, see the SET TASK command description.
Task switching might be confusing when you are debugging a program. Placing a task on hold with the SET TASK/HOLD command restricts the state transitions the task can make once the program is subsequently allowed to execute.
A task placed on hold can enter any state except the RUNNING state. If necessary, you can force it into the RUNNING state by using the SET TASK/ACTIVE command.
The SET TASK/HOLD/ALL command freezes the state of all tasks except the active task. You can use this command in combination with the SET TASK/ACTIVE command, to observe the behavior of one or more specified tasks in isolation, by executing the active task with the STEP or GO command, and then switching execution to another task with the SET TASK/ACTIVE command. For example:
When you no longer want to hold a task, use the SET TASK/NOHOLD command.
Tasking programs that use time slicing are difficult to debug because time slicing makes the relative behavior of tasks asynchronous. Without time slicing, task execution is determined solely by task priority; task switches are predictable and the behavior of the program is repeatable from one run to the next. With time slicing, task priorities still govern task switches, but tasks of the same priority also take turns executing for a specified period of time. Thus, time slicing causes tasks to execute more independently from each other, and the behavior of a program that uses time slicing might not be repeatable from one run of the program to the next.
The SET TASK/TIME_SLICE=t command (supported for VAX Ada only) enables you to specify a new time slice or disable time slicing (with SET TASK/TIME_SLICE=0.0). Thus, you can tune the execution of your tasking programs or diagnose problems that depend on the order in which tasks execute.
Note that there is an interaction between time slicing and the debugger
watchpoint implementation. When you set watchpoints, the debugger might
automatically increase the value of the time-slice interval to 10.0
seconds. Slowing the time-slice rate prevents some problems.
The following sections explain how to do the following functions:
17.6.1 Setting Task-Specific and Task-Independent Debugger Eventpoints
An eventpoint is an event that you can use to return control to the debugger. Breakpoints, tracepoints, watchpoints, and the completion of STEP commands are eventpoints.
A task-independent eventpoint can be triggered by the execution of any task in a program, regardless of which task is active when the eventpoint is set. Task-independent eventpoints are generally specified by an address expression such as a line number or a name. All watchpoints are task-independent eventpoints. The following are examples of setting task-independent eventpoints:
A task-specific eventpoint can be set only for the task that is active when the command is entered. A task-specific eventpoint is triggered only when that same task is active. For example, the STEP/LINE command is a task-specific eventpoint: other tasks might execute the same source line and not trigger the event.
If you use the SET BREAK, SET TRACE, or STEP commands with the following qualifiers, the resulting eventpoints are task specific:
Any other eventpoints that you set with those commands and any eventpoints that you set with the SET WATCH command are task independent. The following are examples of setting task-specific eventpoints:
You can conditionalize eventpoints that are normally task-independent to make them task specific. For example:
17.6.2 Setting Breakpoints on POSIX Threads Tasking Constructs
You can set a breakpoint on a thread start routine. The breakpoint will trigger just before the start routine begins execution. In Example 17-1, this type of breakpoint is set as follows:
Unlike Ada tasks, you cannot specify the body of a POSIX Threads task by name but the start routine is similar.
Specifying a WHEN clause with the SET BREAK command ensures that you catch the point at which a particular thread begins execution. For example:
In Example 17-1, this conditional breakpoint will trigger when the second worker thread begins executing its start routine.
Other useful places to set breakpoints are just prior to and immediately after condition waits, joins, and locking of mutexes. You can set such breakpoints by specifying either a line number or the routine name.