Tru64 UNIX
Ladebug Debugger Manual


Previous Contents Index


Chapter 4
Customizing the Debugger

This chapter explains how to customize the debugger resource file and how to modify variables to alter debugger settings.

For more information on the Ladebug commands mentioned in this chapter, see Part 5.

4.1 Customizing the Debugger's Graphical User Interface

You can customize the debugger's graphical user interface in two ways:

The following sections discuss using these methods to customize the debugger graphical user interface.

4.1.1 Defining the Startup Configuration for Debugger Windows and Views

To define the startup configuration of the debugger windows and views:

  1. While using the debugger, set up the desired configuration of the windows and views.
  2. Choose Options:Save Options on the Main or Optional Views Window. This creates a new version of the debugger resource file in your home directory with the new settings.

When you later start the debugger, the new configuration appears automatically. Adding views to the startup configuration increases the startup time accordingly.

4.1.2 Displaying or Hiding Line Numbers by Default

The source pane displays source line numbers by default at debugger startup. To hide (or display) line numbers at debugger startup:

  1. While using the debugger, choose File:Display Line Numbers on the Main Window. Line numbers are displayed when a filled-in button appears next to that menu item.
  2. Choose Options:Save Options. This creates a new version of the debugger resource file with the new settings.

When you later start the debugger, line numbers are either displayed or hidden accordingly.

4.1.3 Modifying, Adding, Removing, and Resequencing Push Buttons

The push buttons on the push-button panel are associated with debugger commands. You can:

Note

You cannot modify or remove the Interrupt push button.

To save these modifications for subsequent debugger sessions, choose Options:Save Options on the Main Window or an optional view. This creates a new version of the debugger resource file with the new definitions.

The following sections explain how to customize push buttons interactively through the graphical user interface. You can also customize push buttons by editing the resource file (see Section 4.1.4).

4.1.3.1 Changing a Button's Label or Associated Command

To change a button's label or the debugger command associated with a push button:

  1. Choose Options:Customize... on the Main or Optional View Window. The Customize dialog box appears.
  2. Select the Pushbuttons menu option. The Pushbuttons dialog box appears.
  3. Click on the push button to be modified in the control panel of the dialog box.
  4. If changing the push-button label, enter a new label in the Label field or choose a predefined icon from the Icon menu. (If changing the button label, verify that the Icon menu is set to None.)
  5. If changing the command associated with the push button, enter the new command in the Command field. For online help about the commands, see Section 1.8.3.
    If the command is to operate on a name or language expression selected in a window, include %s in the command name. For example, the following command displays the current value of the variable that is currently selected:


    print %s 
    

    If the command is to operate on a name that has a percent sign (%) as the first character, specify two percent signs.

  6. Click on Modify. The push button is modified in the dialog box push-button display.
  7. Click on Apply. The push button is modified in the push-button panel of the Main Window (see Figure 4-1).

Figure 4-1 Changing the Step Button Label to an Icon


4.1.3.2 Adding a New Button and Associated Command

To add a new button to the push-button panel and assign a debugger command to that push button:

  1. Choose Options:Customize... on the Main Window. The Customize dialog box appears (see Figure 4-2).
  2. Select the Pushbuttons menu option and the Pushbuttons dialog box appears.
  3. Enter the debugger command for the new push button in the Command field (see Section 4.1.3.1). The command up was chosen. This command interprets an entity selected in a window as a zero-terminated ASCII string.
  4. Enter a label for that push button in the Label field or choose a predefined icon from the Icon menu. The uparrow_pixmap label was chosen.
  5. Click on Add. The push button is added to the control panel within the dialog box.
  6. Click on OK. The push button is added to the push-button panel in the Main Window (see Figure 4-2).

Figure 4-2 Adding a Button for the up Command


4.1.3.3 Removing a Button

To remove a push button:

  1. Choose Options:Customize... on the Main Window. The Customize dialog box appears.
  2. Select the Pushbuttons menu option and the Pushbuttons dialog box appears.
  3. Click on the push button to be removed in the control panel of the Customize dialog box.
  4. Click on Remove. The push button is removed from the control panel within the dialog box.
  5. Click on OK. The push button is removed from the push-button panel in the Main Window.

4.1.3.4 Resequencing a Button

To resequence a button:

  1. Choose Options:Customize... on the Main Window. The Customize dialog box appears.
  2. Select the Pushbuttons menu option and the Pushbuttons dialog box appears.
  3. Click on the button you are resequencing. This fills the Command and Label fields with the parameters for that button.
  4. Click on the left or right arrow to move the button one position to the left or right. Continue to click until the button has moved, one position at a time, to its final position.
  5. Click on OK to transfer this position to the push-button panel in the Main Window.

4.1.4 Customizing the Debugger Resource File

The debugger is installed on your system with a debugger resource file ( ladebugresource ) that defines startup defaults. The resource file is located in /usr/lib/X11/app-defaults/ladebugresource.

When you first choose Options:Save Options on the Main or Optional Views Window, the debugger creates your own local debugger resource file in your home directory.

When you subsequently start the debugger, it uses the settings defined in your local resource file (such as window configuration) and uses the system default resource file for the other settings (such as character fonts). Whenever you choose Save Window Configuration, a new version of your local resource file is created.

Using the system default file as reference, you can add customized resource settings to your own local file. When you subsequently choose Options:Save Options, the debugger automatically copies these added settings to the new version of your local file.

To change the following Ladebug parameters, edit the applicable text in the Ladebug resource file.

4.2 Customizing the Debugger Environment: Debugger Variables

The debugger predefines a set of debugger variables. You can display and modify these variables to alter debugger settings. You can also create new debugger variables to use within other commands, or as placeholders of important information.

All debugger variable names start with a dollar sign ($). The set command, used alone, causes the display of all the debugger variables with their current values. The set command also lets you set the value of a debugger variable. Using this command, you can redefine an existing debugger variable or create a new debugger variable.

Use the unset command to delete a debugger variable that you created, or to return a debugger variable to its default value.


Part 3
Language-Specific Topics

This part describes topics specific to the programming languages Ada, C++, COBOL, and Fortran.


Chapter 5
Debugging DEC C++ Programs

5.1 Significant Supported Features

The DIGITAL Ladebug debugger debugs programs compiled with the DEC C++ compiler on the Tru64 UNIX operating system. The following features are supported:

These features are discussed further in this chapter. This chapter also explains the limitations on Ladebug support for the C++ language.

For more information on the Ladebug commands mentioned in this chapter, see Part 5.

5.2 DEC C++ Flags for Debugging

To prepare to use the Ladebug debugger on a C++ program, invoke the compiler with the appropriate debugging flag: -g, -g2, or -g3. For example:


% cxx -g sample.cxx -o sample

The -g flag on the compiler command instructs the compiler to write the program's debugger symbol table into the executable image. This flag also turns off the default optimization, which could cause a confusing debugging session.

Refer to the cxx(1) reference page or other compiler documentation for information about the various -gn flags and their relationship to optimization.

Traceback information and symbol table information are both necessary for debugging. They:

Traceback and symbol table information result in a larger object file. When you have finished debugging your program, you can remove traceback information with the the strip command (see strip(1)). To remove symbol table information, you can compile and link again with -g0 or -g1 to create a new executable program.

Typical uses of the debugging flags at the various stages of program development are as follows:

Note

1 g1 results in a larger object file than -g0 but smaller than the other gn flags.

5.3 Calling Overloaded Functions

To call overloaded functions from the debugger, you must set $overloadmenu to 1 (the default), as follows:


(ladebug) set $overloadmenu = 1

For more information on the $overloadmenu debugger variable, see the Command Reference section.

Then, use the call command.

For example:


(ladebug) call foo(15)

The debugger will call the function that you select from the menu of overloaded names.

5.4 Setting the Class Scope

The debugger maintains the concept of a current context in which to perform lookup of program variable names. The current context includes a file scope and either a function scope or a class scope. The debugger automatically updates the current context when program execution suspends.

The class command lets you set the scope to a class in the program you are debugging.

Explicitly setting the debugger's current context to a class allows for visibility into a class to:

After the class scope is set, you can set breakpoints in the class's member functions and examine data without explicitly mentioning the class name. If you do not want to affect the current context, you can use the scope resolution operator (::) to access a class whose members are not currently visible.

Example 5-1 shows the use of the class command to set the class scope to S in order to make member function foo visible so a breakpoint can be set in foo.

Example 5-1 Setting the Class Scope

(ladebug) stop in main; run
[#1: stop in main ] 
[1] stopped at [int main(void):26 0x120000744] 
     26      int result = s.bar(); 
(ladebug) stop in foo
Symbol foo not visible in current scope. 
foo has no valid breakpoint address 
Warning: Breakpoint not set 
(ladebug)  class S
class S  { 
  int i; 
  int j; 
  S (void); 
  ~S (void); 
  int foo (void); 
  virtual int bar (void); 
} 
(ladebug) stop in foo
[#2: stop in foo (void) ] 
(ladebug) 

5.5 Displaying Class Information

The whatis and print commands display information on a class. Use the whatis command to display static information about the classes. Use the print command to view dynamic information about class objects.

The whatis command displays the class type declaration, including:

For classes that are derived from other classes, the data members and member functions inherited from the base class are not displayed. Any member functions that are redefined from the base class are displayed.

The whatis command used on a class name displays all class information, including constructors.

The print command lets you display the value of data members and static members. Information regarding the public, private, or protected status of class members is not provided, since the debugger relaxes the related status rules to be more helpful to users.

The type signatures of member functions, constructors, and destructors are displayed in a form that is appropriate for later use in resolving references to overloaded functions.

Example 5-2 shows the whatis and print commands in conjunction with a class.

Example 5-2 Displaying Class Information

(ladebug) list 1, 12
      1 class S 
      2 { 
      3   protected: 
      4      int i; 
      5      int j; 
      6 
      7   public: 
      8      S(); 
      9      virtual ~S() {}; 
     10      int foo(void); 
     11      virtual int bar(void); 
     12 }; 
(ladebug) whatis S
class S  { 
  int i; 
  int j; 
  S(void); 
  int foo(void); 
  virtual ~S(void); 
  virtual int bar(void); 
} 
(ladebug) whatis S :: bar
int S::bar(void) 
(ladebug) stop in int S::foo
[#2: stop in int S::foo(void) ] 
(ladebug) run
[1] stopped at [int S::foo(void):48 0x1200020a4]       
     48      return (i = j++); 
(ladebug) print S::i
1 
(ladebug) 

5.6 Displaying Object Information

The whatis and print commands display information on instances of classes (objects). Use the whatis command to display the class type of an object. Use the print command to display the current value of an object.

You can also display individual object members using the member access operators, period (.) and right arrow (->), in a print command.

You can use the scope resolution operator (::) to reference global variables, to reference hidden members in base classes, to explicitly reference a member that is inherited, or otherwise to name a member hidden by the current context.

When you are in the context of a nested class, you must use the scope resolution operator to access members of the enclosing class.

Example 5-3 shows how to use the whatis and print commands to display object information.

Example 5-3 Displaying Object Information

(ladebug) whatis s
class S  { 
  int i; 
  int j; 
  S (void); 
  int foo(void); 
  virtual ~S(void); 
  virtual int bar(void); 
} s 
(ladebug) stop in S::foo; run
[#2: stop in int S::foo(void) ] 
[2] stopped at [int S::foo(void):48 0x1200020a4]       
     48      return (i = j++); 
(ladebug) print *this
class S {  
  i = 1; 
  j = 2; 
} 
(ladebug) print i, j
1 2 
(ladebug) print this->i, this->j
1 2 
(ladebug) 


Previous Next Contents Index