HP OpenVMS Systems Documentation |
OpenVMS Debugger Manual
15.4 Process SetsYou can place processes into groups called process sets with the DEFINE PROCESS_SET command followed by a list of processes separated by commas (,). For example:
There is a predefined process set named all, which is the default process set when the debugger is first invoked. You cannot redefine this process set. At any time during a debugging session, there is a current process set in effect. The current process set is the group of processes to which debugger process-sensitive commands apply by default. See Section 15.6 for a list of debugger commands that are process-sensitive. By default, the current process set is the set of all processes, with the process set name all. You can change the current process set with the SET PROCESS command. The SET PROCESS command does three things:
When used without a qualifier, the SET PROCESS command takes a single parameter, a process-spec, which specifies the current process set. For example:
The SET PROCESS/DYNAMIC command directs the debugger to change the visible process when a debugger event occurs, such as the completion of a STEP command, or the triggering of a breakpoint. The visible process becomes the process that triggered the event. For example:
The command process set is the group of processes to which a debugger command is directed. By default, the command process set is the current process set. You can use a process set prefix to specify a command process set for the current command, which overrides the current process set for that single command. For example:
Process-independent commands ignore any process set prefix, just as
they ignore the current process set.
By default, the debugger command prompt indicates the current process set, using the same syntax as the process-spec. The command prompt is the current process set process-spec followed by a right angle bracket (>). When you define the current process set, the debugger changes its prompt to the name of the current process set, followed by a right angle bracket. For example:
15.6 Process-Sensitive CommandsThere are two types of commands, process-sensitive and process-independent. Process-sensitive commands are those that depend on the state of a process, such as GO, STEP, CALL, and SET BREAK.
Process-independent commands are those that depend on and affect the
state of the debugger and ignore the state of processes, such as SET
DISPLAY, WAIT, ATTACH, and SPAWN.
The visible process is the process shown by default in the source
display (and other such process-oriented displays). When the current
process set is changed with the SET PROCESS command, the visible
process is set to be the first process specified in that command. You
can use the SET PROCESS/VISIBLE command to specify a particular process
as the visible one without changing the current process set.
When debugging an application with multiple processes, it is common to
have some process stopped while other processes are still running. It
can be useful to be able to give commands only to those processes that
are stopped without waiting for all processes to stop. Wait mode
provides that capability.
With regard to executing processes, the debugger has two modes: wait and nowait. You can control whether or not the debugger waits for all running processes to stop before the debugger accepts and executes another command by toggling wait mode with the SET MODE [NO]WAIT command. Wait mode is the default. When the debugger is in wait mode and you enter the GO, STEP, or CALL command, the debugger executes the command in all processes in the command process set, and waits until all those processes stop (for example, at breakpoints) before displaying a prompt and accepting another command. When the debugger is in nowait mode and you enter the GO, STEP, or CALL command, the debugger executes the command in all processes in the command process set, and immediately displays a prompt. You can enter a new command immediately, regardless of whether any or all processes have stopped. This provides great flexibility, especially when debugging multiprocess programs. Control over WAIT mode allows you to to do the following:
A SET MODE [NO]WAIT command remains in effect until the next SET MODE [NO]WAIT command. For example:
You can use the WAIT command to override nowait mode for the duration of one command, to direct the debugger to wait until all processes in the command process set stop before prompting for another command. Nowait mode remains in effect when the command completes. For example:
When commands are processed in a non-interactive manner (within debugger command sequences within FOR, REPEAT, WHILE, IF, and @ commands, and within WHEN clauses), WAIT mode is enabled by default during the execution of the command sequence.
During NOWAIT mode, an EXAMINE command (similar to all
process-independent commands) displays results for those processes in
its command process set that are stopped. If all processes in its
command process set are running, the EXAMINE command reports that
condition and the debugger displays a prompt and accepts a new command.
Similarly, a GO command during NOWAIT mode starts all stopped processes
in the command process set.
Use the SET MODE [NO]INTERRUPT command to toggle the state of interrupt mode. When interrupt mode is toggled on, the debugger stops all processes when one process stops. This can be a disadvantage if an interrupted process is deep into a RTL or system service call because it can leave many irrelevant non-symbolic frames on top of the process stack.
When interrupt mode is toggled off, the debugger does not stop any
other process unless you enter a STOP command. This is the default mode.
Use the STOP command to interrupt running processes. The STOP command interrupts all of the running processes in its command process set. The STOP command completes as soon as it sends a stop request to every running process in the command set. For example:
15.9 Connecting to Another ProgramYou can bring a debuggable program under control of the debugger from a kept debugger session. This could be a client program that runs independently in another process. Because the debugger is not yet aware of that process, you cannot obtain information about it from a SHOW PROCESS command. Enter the CONNECT command and specify the process name of the client program with the debugger %PROCESS_NAME lexical function. For example:
Unexpected results can occur if you enter the CONNECT command if any of
the debugger logicals (DEBUG, DEBUGSHR, DEBUGUISHR, DBGTBKMSG,
DBG$PROCESS, DBG$HELP, DBG$UIHELP, DEBUGAPPCLASS, and VMSDEBUGUIL)
differ between the debugger main process and the process in which the
client runs.
When a program you are debugging (with the kept debugger) spawns a debuggable process, the spawned process waits to be connected to the debugger. At this time the debugger has no information about the newly spawned process, and you cannot get information about that process from a SHOW PROCESS command. You can bring the newly spawned process under debugger control using either of the following methods:
The following example shows this use of the CONNECT command:
In this example, the second STEP command takes you past the LIB$SPAWN call that spawns the process. The CONNECT command brings the waiting process under debugger control. After entering the CONNECT command, you might need to wait a moment for the process to connect. The "predefined trace on..." message indicates that the debugger has taken control of a new process which is identified as process 2. A SHOW PROCESS command, entered at this point, identifies the debugging state for each process and the location at which execution is paused:
Note that the CONNECT command brings all processes that are waiting to be connected to the debugger under debugger control. If no processes are waiting, you can press Ctrl/C to abort the CONNECT command and display the debugger prompt.
Unexpected results can occur if you enter the CONNECT command if any of
the debugger logicals (DEBUG, DEBUGSHR, DEBUGUISHR, DBGTBKMSG,
DBG$PROCESS, DBG$HELP, DBG$UIHELP, DEBUGAPPCLASS, and VMSDEBUGUIL)
differ between the debugger process and the spawned process.
When the main image of a process runs to completion, the process goes into the terminated debugging state (not to be confused with process termination in the operating system sense). This condition is traced by default, as if you had entered the SET TRACE/TERMINATING command.
When a process is in the terminated debugging state, it is still known
to the debugger and appears in a SHOW PROCESS display. You can enter
commands to examine variables, and so on.
To release a process from debugger control without terminating the process, enter the DISCONNECT command. (In contrast, when you specify a process with the EXIT or QUIT command, the process is terminated.) This command is required for programs of the client/server model. For example:
Bear in mind that the debugger kernel runs in the same process as the
image being debugged. If you issue the DISCONNECT command for this
process, you release your process, but the kernel remains activated.
This activation continues until the program image finishes running. If
you install a new version of the debugger while one or more
disconnected but activated kernels inhabit user program space, you can
experience problems with debugger behavior if you try to reconnect to
that program image.
To terminate specified processes without ending the debugging session, use the EXIT or QUIT command, specifying one or more process specifications as parameters. For example,
15.14 Interrupting Program ExecutionPressing Ctrl/C (or the abort-key sequence established with the SET ABORT_KEY command) interrupts execution in every process that is currently running an image. This is indicated as an interrupted state in a SHOW PROCESS display. Note that you can also use Ctrl/C to abort a debugger command.
You can also stop a process with the debugger STOP command.
To end the entire debugging session, use the EXIT or QUIT command without specifying any parameters. EXIT executes any exit handlers that are declared in the program. QUIT does not. Use the QUIT command to terminate running processes. The QUIT command terminates all of the running processes in its command process set without allowing any exit handlers to run. A process set prefix is ignored before a QUIT command. For example:
The QUIT command ignores the current process set. If you do not specify a process, the QUIT command terminates all processes and then terminates the debugging session. Use the EXIT command to terminate running processes. The EXIT command terminates all of the running processes in its command process set without allowing any exit handlers to run. A process set prefix is ignored before an EXIT command. For example:
The EXIT command ignores the current process set. If you do not specify
a process, the EXIT command terminates all processes and then
terminates the debugging session.
This section provides additional details or more advanced concepts and
usages than those covered in Section 15.1.
The debugger consists of two parts: a main debugger image (DEBUGSHR.EXE) that contains most of the debugger code and a smaller kernel debugger image (DEBUG.EXE). This separation reduces potential interference between the debugger and the program being debugged and also makes it possible to have a multiprocess debugging configuration. When you bring a program under control of the kept debugger, the main debugger spawns a subprocess to run the program along with the kernel debugger. An application being debugged might run in several processes. Each process under debugger control is running a local copy of the kernel debugger. The main debugger, which is running in its own process, communicates with the other processes through their kernel debuggers. Although all processes must be in the same UIC group, they do not have to be related in a particular process/subprocess hierarchy. Moreover, the program images running in separate processes do not have to communicate with each other.
See Section 15.16.6 for system requirements related to multiprocess
debugging.
When specifying processes in debugger commands, you can use any of the forms listed in Table 15-2, except when specifying processes with the CONNECT command (see Section 15.9). Use the CONNECT command to bring a process that is not yet known to the debugger under debugger control. Until you bring a new process under control of the debugger, the process does not have a debugger-assigned process number, nor can you reference it with any of the built-in process symbols (for example, %NEXT_PROCESS). Therefore, when specifying a process with CONNECT, you can use only its process name or process identifier (PID).
You can omit the %PROCESS_NAME and %PROCESS_NUMBER built-in symbols when entering commands. For example:
The built-in symbols %VISIBLE_PROCESS, %NEXT_PROCESS, and %PREVIOUS_PROCESS are useful in control structures based on the IF, WHILE, or REPEAT commands and in command procedures.
|