Chapter 6. Controlling Program Execution

This chapter shows you how to control the execution of your program with WorkShop Debugger. It includes the following topics:

The Main View Window Control Panel

The Main View window control panel allows you to choose an executable, and control its execution:

Figure 6-1. The Main View Window Control Panel

The Main View Window Control Panel

Features of the Main View Window Control Panel

The control panel includes the following items:

  • Command field: use this field to enter shell commands (with arguments) to run your program.

  • Execution control buttons, which enable control of the program. These buttons are described in more detail in “Execution Control Buttons”.

  • Status field: displays information about the execution status of your program. The top line in this box indicates whether the program is running or stopped. The message No executable displays if no executable is loaded. When your program stops at a breakpoint, an additional status line lists the current stack frame.

    To see all of the stack frames, select Views ->  Call Stack from the Menu Bar.

Execution Control Buttons

The execution control buttons enable you to control program execution. Most of these buttons are not active until the Run button has been selected and the program is executed. The Print button does not affect program execution. It is described in the ProDev WorkShop: Debugger Reference Manual.

  • Kill: kills the active process.

  • Run: creates a new process for your program and starts its execution. The Run button is also used to re-run a program.

  • All/Single: if set to All , the Cont, Stop, Step, Next, and Return actions apply to all processor or threads. If set to Single, then only the currently focused process or thread is acted upon.

  • The lock icon (Stay Focused/Follow Interesting ): if the lock icon is locked, it indicates that the focus of Main View will attempt to stay focused on this thread. If the lock is unlocked, the debugger follows the interesting thread. This means it focuses on threads that reach a user breakpoint.

  • Cont: resumes program execution after a halt and continues until a breakpoint or other event stops execution.

  • Stop: stops execution of your program. When program execution stops, the current source line is highlighted in the Main View window and annotated with an arrow.

  • Step: step into function or subroutine calls by default if the function that is stepped into was compiled with -g (full debugging information). For libraries like libc.so, step does not step into it by default.

  • Next: steps over function or subroutine calls to the next source line. To step a specific number of lines, right-click on this button to display a pop-up menu. You can select one of the fixed values or enter your own number of steps by selecting N. If you select N, a dialog box appears, allowing you to enter the number of instructions to step over.

  • Return: executes the remaining instructions in the current function or subroutine, and stops execution at the return from this subprogram.

  • Sample: collects performance data. Before this button is operative, a performance task must have been previously specified in the Performance Task window and data collection must have been enabled.

    For further information about using the Performance Analyzer, see ProDev Workshop: Performance Analyzer User's Guide

Controlling Program Execution Continue To/Jump To

The PC (program counter) menu is accessible by holding the mouse down over a line of code in the Source View window in the Main View window. The Continue To and Jump To menu picks allow you to control program execution without setting breakpoints.

These tools are inoperative until a process has been executing and is stopped. At that point, you must place your cursor on a source line that you wish to target, then hold down the mouse button and select an item from the PC menu depending on your requirements.

  • Continue To: this tool lets you select a target location in the current program (by placing the cursor in the line). The process proceeds from the current program counter to that point, provided there are no interruptions. It then stops there, as it would for a stop trap. Continue To is equivalent to setting a one-time trap. If the process is interrupted before reaching your target location, then the command is cancelled. Continue To is useful to move past the end of a for or while loop that is stepped in, but which has no further interest to you.

  • Jump To: this tool lets you select a target location in the current program (by placing the cursor in the line). This location must be in the same function. Instead of starting from the current program counter, Jump To skips over any intervening code and restarts the process at your target. This is particularly useful if you want to get around bad code or irrelevant portions of the program. It also lets you back up and reexecute a portion of code.

Execution View

The Execution View window is a simple shell that lets you set environment variables and inspect error messages. If your program is designed to be interactive using standard I/O, this interaction takes place in the Execution View window. Any standard I/O that is not redirected by your Target Command is displayed in the Execution View window.

When you launch the debugger, the Execution View window is launched in iconified form.