Controlling Program Execution
Knowing what’s going on and where your program is executing is simple in a serial debugging environment. Your program is either stopped or running. When it is running, an event such as arriving at a breakpoint can occur. This event tells TotalView to stop the program. Sometime later, you tell the serial program to continue executing. Multi-process and multi-threaded programs are more complicated. Each thread and each process has its own execution state. When a thread (or set of threads) triggers a breakpoint, TotalView must decide what it should do about other threads and processes because it may need to stop some and let others continue to run.
Advancing Program Execution
Debugging begins by entering a
dload or
dattach command. If you use the
dload command, you must use the
drun (or perhaps
drerun if there’s a starter program) command to start the program executing. These three commands work at the process level and you can’t use them to start individual threads. (This is also true for the
dkill command.)
To advance program execution, you enter a command that causes one or more threads to execute instructions. The commands are applied to a P/T set. (P/T sets are discussed in
Chapter 12, “About Groups, Processes, and Threads,” and
Chapter 20, “Group, Process, and Thread Control,” .) Because the set doesn’t have to include all processes and threads, you can cause some processes to be executed while holding others back. You can also advance program execution by increments,
stepping the program forward, and you can define the size of the increment. For example,
dnext 3 executes the next three statements, and then pauses what you’ve been stepping.
Typically, debugging a program means that you have the program run, and then you stop it and examine its state. In this sense, a debugger can be thought of as a tool that lets you alter a program’s state in a controlled way, and debugging is the process of stopping a process to examine its state. However, the term stop has a slightly different meaning in a multi-process, multi-threaded program. In these programs, stopping means that the CLI holds one or more threads at a location until you enter a command that tells them to start executing again. Other threads, however, may continue executing.
For more detailed information on debugging in general, see
Part II, “Debugging Tools and Tasks,”.