| Previous | Contents | Index |
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:
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:
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:
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:
print %s |
Figure 4-1 Changing the Step Button Label to an Icon
To add a new button to the push-button panel and assign a debugger command to that push button:
Figure 4-2 Adding a Button for the up Command
To remove a push button:
To resequence a button:
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.
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.
This part describes topics specific to the programming languages Ada, C++, COBOL, and Fortran.
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:
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)
|
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)
|
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 |