Chapter 1. WorkShop Debugger Overview

The SGI ProDev WorkShop Debugger is a UNIX source-level debugging tool for SGI MIPS systems. It displays program data and execution status in real time. This tool can be used to debug Ada (1.4.2 and older versions), C, C++, FORTRAN 77, and Fortran 90 programs.

For an introductory tutorial to the principles of debugging, particularly with the WorkShop Debugger, see Chapter 2, “Basic Debugger Usage”.

This chapter presents an overview of the WorkShop Debugger and is divided into the following sections:

Main Debugger Features

The following sections outline the primary features and functions of the WorkShop Debugger and include references to comprehensive information found throughout this manual:

The Debugger Main View Window

When you start the Debugger with an executable file, the Main View window displays, loaded with source code, ready to execute your program with your specified arguments. Most of your debugging work takes place in the Main View window, which includes the following:

  • A menu bar for performing debugger functions.

  • A control panel for specifying and controlling program execution.

  • A source code display area which displays the code for the program you are debugging.

  • A source filename field which tells gives you the path to the file displayed in the source code display area.

  • A status area for viewing the current status of the program.

  • The Debugger command line in which to enter debugging commands (see the ProDev WorkShop: Debugger Reference Manual for command syntax).

The major areas of the Main View window are shown in Figure 1-1. For a comprehensive description of the Main View window, see the ProDev WorkShop: Debugger Reference Manual.

Figure 1-1. The WorkShop Debugger Main View Window

The WorkShop Debugger Main View Window

About Traps

Part of the debugging process requires that you inspect data at various points during program execution. A trap is a mechanism for gathering this data. Traps are also referred to as breakpoints, watchpoints, samples, signals, and system calls. There are two categories of traps:

  • A stop trap halts a process so that you can manually examine data.

  • A sample trap collects specific performance data without stopping.

The Debugger lets you set traps at the following points:

  • At a line in a file (a breakpoint). These are the most commonly used stop traps. You can set them by clicking in the annotation column to the left of an executable statement in the source code display panel. (See the annotation column in Figure 1-1.)

  • At an instruction address.

  • On entry to or exit from a function.

  • When a signal is received (a signal trap).

  • When a system call is made, at either the entry or exit point (a system call).

  • When a given variable or address is written to, read from, or executed (a watchpoint).

  • At set time intervals (a pollpoint).

For more information on traps, refer to Chapter 5, “Setting Traps (Breakpoints)”.

Viewing Program Data

When you stop a process, the Views menu at the Main View window menu bar provides several options for viewing your data. These Views menu options allow you to inspect the following types of data:

  • Array Browser: this option allows you to inspect the values of an array variable.

  • Call Stack: this option allows you to inspect the call stack at the breakpoints.

  • Data Explorer: this option allows you to inspect data structure.

  • Data View: this option allows you to interactively inspect separate data structures in a view. Pointers can be followed by diving (right mouse click) on the field to dereference it.

  • Disassembly View: this option allows you to inspect the disassembled code.

  • Expression View: this option allows you to inspect the value of specified expressions.

  • Memory View: this option allows you to inspect the values in specified memory locations.

  • Multiprocess View: this option allows you to inspect the values of multiple and / or pthreaded processes.

  • Register View: this option allows you to inspect registers.

  • Variable Browser: this option allows you to inspect the values, types, or addresses of variables.

You can also view data by using the data diving techniques described in “Using the Mouse for Data Diving”.

Integrating the Debugger with Other WorkShop Tools

ProDev WorkShop tools are designed so that you can move easily between them in a work session.

Procedure 1-1. Accessing the Performance Analyzer from the Main View Window

You can run the Performance Analyzer from the Main View window as follows:

The Performance Analyzer window will display your results. For more information about the Performance Analyzer, see the ProDev Workshop: Performance Analyzer User's Guide.

  1. Select Perf -> Select Task ->  Task in List from the menu bar.

  2. Click on the Run button in the Control Panel. The executable is run.

  3. Select Perf -> Examine Results from the menu bar.

Procedure 1-2. Accessing the Static Analyzer from the Main View Window

The Static Analyzer displays information that makes it easier to determine where to set traps in your source code. To launch the Static Analyzer, select Admin -> Launch Tool -> Static Analyzer from the menu bar.

For more information about the Static Analyzer, see the ProDev Workshop: Static Analyzer User's Guide.

    Procedure 1-3. Accessing Editors from the Main View Window

    After you have isolated your code problem with the WorkShop tools, you will want to correct and recompile your source. WorkShop offers several ways to do this:

    • You can select the following from the Source Menu to make code changes in the source pane of the Main View window:

      • Select Source > Make Editable. Make your changes accordingly. (Make Editable toggles with Make Read Only.)

      • Select Source > Save to save your changes.

      • Select Source > Recompile to recompile your changed code.

    • You can invoke an editor from the Views menu that is a separate window in which to edit your code: Views -> Source View (you must select Make Editable from the File menu at this point to proceed).

    • You can call up a fork editor window to launch your own editor by using Source -> Fork Editor (first path).

    • You can call up a fork editor window to launch your own editor by using Views -> Source View (second path) . Then, from the Source View window select File -> Fork Editor.

      Procedure 1-4. Accessing Configuration Management Tools

      If you use ClearCase (an SGI product), RCS, or SCCS for configuration management, you can integrate the tool into the WorkShop environment by entering the following command:

      % cvconfig [clearcase | rcs | sccs] 

      This will allow you to use Versioning source control (from the Source menu) to check files in and out.

        Procedure 1-5. Recompiling from the Main View Window

        You can recompile your code from the Build View window, accessible from the menu bar by using Source ->  Recompile.

        For more information about the Build View window, see “Build View Window” in Appendix A.

        To examine build dependencies for your code, launch the Build Analyzer from the menu bar as follows: Admin -> Launch Tool ->  Build Analyzer.

        For more information about the Build Analyzer window, see “Build Analyzer Window” in Appendix A.

        For general information on the Build Manager tools, see Appendix A, “Using the Build Manager”.

          Using the Mouse for Data Diving

          Dynamic menus are available in all of the Debugger views and windows. To access the dynamic menus, position the mouse over the item you are interested in and click the right mouse button. A menu of actions that can be done with that object is displayed.

          Data diving is available in several debugger views and screens. Click the right mouse button over any item and a default action occurs (when appropriate).

          Depending on the cursor location, the result of a mouse action will vary:

          • In the Source View, a click of the mouse button over a variable displays the variable in the Data View window. Holding a mouse button down brings up a menu of available actions.

          • Holding a mouse button down over a blank area in a view brings up a menu that allows you to Jump To the selected line or Continue To the selected line.

          • When in the icon canvas area (the part of the screen to the left of the source code listing), holding a mouse button down provides a list of actions that can be performed against that line of code (for example, set and delete traps, enable or disable traps, or access the trap manager). Clicking the mouse in the icon canvas area sets or deletes a breakpoint.

          • A right mouse button click on a user function in the Source View displays the source for that function.

          Debugging with Fix+Continue

          Fix+Continue gives you the ability to make changes to a program written in C or C++ without having to recompile and link the entire program before continuing to debug the code. With Fix+Continue, you can edit a function, parse the new functions, and continue execution of the program being debugged. Fix+Continue commands may be issued from the Fix+Continue window, which you launch from the Fix+Continue item on the Main View menu bar.

          You can also issue Fix+Continue commands from the Debugger's command line.

          See Chapter 8, “Debugging with Fix+Continue”, for a comprehensive description of the theory and operation of Fix+Continue, including a short tutorial.

          Debugging with the X/Motif Analyzer

          The X/Motif Analyzer provides specific debugging support for X/Motif applications. The X/Motif analyzer is integrated with the Debugger. You issue X/Motif analyzer commands graphically from the X/Motif analyzer subwindow of the Debugger Main View. Select Views -> X/Motif Analyzer from the Main View window to access this subwindow.

          See Chapter 11, “X/Motif Analyzer” for a comprehensive description of the theory and operation of the X/Motif Analyzer, including a short tutorial.

          Customizing the Debugger

          WorkShop provides you with a number of ways that you can customize your Debugger as best suited to the needs of your development environment.

          See Chapter 12, “Customizing the Debugger”, for more tips on customizing the Debugger to your specific needs.