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.

  • 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 Appendix A, “Debugger Reference”.

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

  • Kill: kills the active process.

  • 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 will follow the interesting thread. This means it will focus on threads that reach a user breakpoint.

  • 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 will be acted upon.

  • 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 will 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 the pop-up menu shown in Figure 6-2. You can select one of the fixed values or enter your own number of steps by selecting N. If you select N, the dialog box shown at the right in Figure 6-2 displays.

    Figure 6-2. Pop-up Menu and Next Dialog

    Pop-up Menu and Next Dialog

  • 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 Using the PC Menu

The PC (program counter) menu in the Main View window includes two tools, Continue To and Jump To, which 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 you wish to target, then select 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 will take 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.