Tru64 UNIX
Ladebug Debugger Manual


Previous Contents Index

  1. Because Ladebug knows the name of the file, it can list the source line.
  2. Note the parameter details. Ladebug knows the name of the parameter (lengthOfList), and its type and value. It also knows that there is only one parameter for buildLocalList and none for main.
  3. More call stack information is available. Ladebug knows the names and types of parameters and their values.

With limited debugging information, Ladebug must approximate the call stack information, as in Example 14-11.

Example 14-11 Displaying the Stack Trace of a C Program Compiled with -g2 and Linked with -x

(ladebug) c
[2] stopped at [buildLocalList: ??? 0x120001398](1)
(ladebug) where
>0  0x120001398 in buildLocalList(0x1200012b4, 0x0, 0x0, 0x0, 0x1, 0x11ffffbf8) 
DebugInformationStrippedFromFile0:???(2)
#1  0x1200014c4 in main(0x1, 0x20000000, 0x120001278, 0x120001200, 0x1200012b4, 
DebugInformationStrippedFromFile0:??? 
(ladebug) c
[3] stopped at [createNewElement: ??? 0x120001328] 
(ladebug) where(3)
>0  0x120001328 in createNewElement(0x3ff80016b18, 0x0, 0x1200014c4, 0x0, 0x1, 
DebugInformationStrippedFromFile0:??? 
#1  0x1200013d8 in buildLocalList(0x1200014c4, 0x0, 0x1, 0x0, 0x100000000,0x10 
DebugInformationStrippedFromFile0:??? 
#2  0x1200014c4 in main(0x1, 0x0, 0x100000000, 0x100000005, 0x1200012b4, 0x0) 
DebugInformationStrippedFromFile0:??? 
(ladebug) quit
 

  1. Ladebug does not have line number information. There is also a difference in the breakpoint location.
  2. Note the significant differences in the call stack parameter information. Because the type and parameter name information has been stripped out, Ladebug provides the first six register parameters per the compiler calling convention.
  3. Ladebug again approximates the call stack information.

14.2.3 Example C++ Program Linked with -x -r

This example program contains two program files, calldriver.C and callstack_intermediates.C, that contain various static and global routines. The static routines are known only within the file while the global (external) routines are known to both files.

In the first form of this program, both calldriver.C and callstack_intermediates.C have full symbolic debugging information. The second form of the program contains limited debugging information; calldriver.C is compiled with -g2 and linked with the -x -r options, stripping out much of the symbol table, so only part of this program has reasonable symbols.

Figure 14-1 shows the structure of the example program.

Figure 14-1 Example C++ Program Linked with -x -r


14.2.3.1 Setting Breakpoints on Static and Global Routines

Example 14-12 invokes the user program with full debugging information and sets breakpoints on four routines.

Example 14-12 Setting Breakpoints on Static and Global Routines in a C++ Program Compiled and Linked with -g2

 
csh> $LADEBUG ../bin/x_callstack01-g
Welcome to the Ladebug Debugger Version 4.0-9 
------------------ 
object file name: ../bin/x_callstack01-g 
Reading symbolic information ...done 
Directory search path for source files: 
 . ../bin /usr/users/debug/ladebug 
(ladebug) stop in full_local
[#1: stop in int full_local(const unsigned) ](1)
(ladebug) stop in full_global
[#2: stop in int full_global(const unsigned) ] 
(ladebug) stop in intermediate_global
[#3: stop in int intermediate_global(const unsigned) ] 
(ladebug) stop in intermediate_local
[#4: stop in int intermediate_local(const unsigned) ] 
(ladebug) run(2)
[3] stopped at [int intermediate_global(const unsigned):41 0x12000206c] 
41 intermediate_global_count++;(3)
 

  1. Ladebug can set breakpoints on all four routines. In the first breakpoint, Ladebug knows the name of the routine and the number and types of the arguments. Be aware that the routines named "..._local" are static and visible only in their own file.
  2. When you enter the run command, ladebug can determine the routine name, the line number, and address for the routine.
  3. Ladebug also knows the file name.

When calldriver.C is compiled with -g2 but linked with -x -r, you get the result shown in Example 14-13 when you run the debugger:

Example 14-13 Setting Breakpoints on Static and Global Routines in a C++ Program Compiled with -g2 and Linked with -x -r

 
csh> $LADEBUG ../bin/x_callstack01-xr
Welcome to the Ladebug Debugger Version 4.0-9 
------------------ 
object file name: ../bin/x_callstack01-xr 
Reading symbolic information ...done 
Directory search path for source files: 
 . ../bin /usr/users/debug/ladebug 
(ladebug) stop in full_local
Symbol full_local undefined.(1)
full_local has no valid breakpoint address 
Warning: Breakpoint not set 
(ladebug) stop in full_global
[#1: stop in full_global ](2)
(ladebug) stop in intermediate_local
[#2: stop in int intermediate_local(const unsigned) ](3)
(ladebug) stop in intermediate_global
[#3: stop in int intermediate_global(const unsigned) ] 
(ladebug) run(4)
[3] stopped at [int intermediate_global(const unsigned):41 0x12000206c] 
(Cannot find source file callstack_intermediates.C) 
 

  1. The static routine in calldriver.C is no longer visible and Ladebug can't set a breakpoint.
  2. There are no parameters, no types, and no return type of the routine. The information is missing from the symbollic debugging information.
  3. The information about these routines is unchanged, since full debugging information is available for callstack_intermediates.C.
  4. The name of the source file has been stripped out, so Ladebug creates a new name (DebugInformationStrippedFromFile2). Because DebugInformationStrippedFromFile2 has the symbol table file number (2) in it, you can run odump()-Fv ../bin/x_callstack01-xr and look for more information about this file.

14.2.3.2 Listing the Source Code

Example 14-14 shows how Ladebug can list the source code for the file callstack_intermediates.C if your executable file contains full debugging information. For this part of the program, Ladebug knows source lines, routine types, and routine parameters.

Example 14-14 Listing the Source Code of a C++ Program

(ladebug) use ../src
Directory search path for source files: 
 . ../bin /usr/users/debug/ladebug ../src 
(ladebug) list
     42 
     43 #ifdef DO_IO 
     44     cout << "intermediate_global: called with (" << i 
     45          << "), count now (" << intermediate_global_count << ")"<<endl; 
     46 #endif // DO_IO 
     47 
     48     const int result = intermediate_local (i); 
     49     return result; 
     50 }  // intermediate_global 
     51 
 

When the program is compiled the same way but linked with -x -r, the results are the same for callstack_intermediates.C. However, you can't see or list the source for callstack_driver.C.

14.2.3.3 Displaying the Stack Trace

Example 14-15 shows how Ladebug displays the stack trace of currently active functions if your executable file contains full debugging information.

Example 14-15 Displaying the Stack Trace of a C++ Program Compiled and Linked with -g2

(ladebug) where(1)
>0  0x12000206c in intermediate_global(i=0) callstack_intermediates.C:41 
#1  0x120001f6c in main() callstack_driver.C:69 
(ladebug) cont(2)
[4] stopped at [int intermediate_local(const unsigned):27 0x120001fec] 
     27     intermediate_local_count++; 
(ladebug) cont
[2] stopped at [int full_global(const unsigned):41 0x120001edc] 
     41     full_global_count++; 
(ladebug) cont
[1] stopped at [int full_local(const unsigned):27 0x120001e70] 
     27     full_local_count++; 
 
(ladebug) where(3)
>0  0x120001e70 in full_local(i=0) callstack_driver.C:27 
#1  0x120001efc in full_global(i=0) callstack_driver.C:48 
#2  0x12000200c in intermediate_local(i=0) callstack_intermediates.C:34 
#3  0x12000208c in intermediate_global(i=0) callstack_intermediates.C:48 
#4  0x120001f6c in main() callstack_driver.C:69 
 
 

  1. Ladebug is able to show the parameter details: the address, the routine name, the parameter and its value, the source file name, and line number.
  2. When you issue the cont command, Ladebug provides full information on the next breakpoint. In this case, it shows the static routine intermediate_local and the number of arguments and its type (const unsigned).
  3. Information is available for static and global routines in both files.

When callstack_driver.C is compiled with -g2 and linked with -x -r, the results are different, as shown in Example 14-16.

Example 14-16 Displaying the Stack Trace of a C++ Program Compiled with -g2 and Linked with -x -r

(ladebug) where
>0  0x12000206c in intermediate_global(i=0) callstack_intermediates.C:41 
#1  0x120001f6c in ../bin/x_callstack01-xr(1)
(ladebug) cont
[2] stopped at [int intermediate_local(const unsigned):27 0x120001fec] 
     27     intermediate_local_count++; 
(ladebug) cont
[1] stopped at [full_global: ??? 0x120001ec8](2)
(ladebug) where
>0  0x120001ec8 in full_global(0x0, 0x870, 0x3ff808941cc, 0x1200022d0, 
0x8e0, 0x3ffc0819100) DebugInformationStrippedFromFile2:???(3)
#1  0x12000200c in intermediate_local(i=0) callstack_intermediates.C:34 
#2  0x12000208c in intermediate_global(i=0) callstack_intermediates.C:48 
#3  0x120001f6c in ../bin/x_callstack01-xr(4)
 

  1. Ladebug cannot associate the program counter with a routine or a file but because the program counter is within a known image, it displays the image name.
  2. Ladebug sets a breakpoint on the global routine full_global but cannot tell in which file or on what line number.
  3. Instead, Ladebug creates a file name and associates it with full_global: DebugInformationStrippedFromFile2. Since it does not know the names or values of the parameters associated with full_global, it lists the first six register parameters, according to the compiler calling convention
  4. Ladebug again cannot associate the program counter with a routine or a file but can display the image name.

14.2.3.4 Printing Static and Local Variables

The results are different when you print static and local variables with full or limited debugging information. Full information produces the results shown in Example 14-17.

Example 14-17 Printing Variables of a C++ Program Compiled and Linked with -g2

(ladebug) print full_local_count(1)
0 
(ladebug) print full_global_count(2)
1 
(ladebug) print intermediate_local_count
Symbol intermediate_local_count not visible in current scope. 
Error: no value for intermediate_local_count(3)
(ladebug) print intermediate_global_count 
1 
 

  1. Ladebug can print the static variable located in this file.
  2. Ladebug can print the global variable.
  3. This is a legitimate message; Ladebug cannot print the value of a static variable defined in the other file that is not visible.

Example 14-18 shows the results with limited debugging information for callstack_driver.C.

Example 14-18 Printing Variables of a C++ Program Compiled with -g2 and Linked with -x -r

(ladebug) print full_local_count
Symbol full_local_count undefined.(1)
Error: no value for full_local_count 
(ladebug) print full_global_count(2)
0 
 

  1. Ladebug does not recognize the static variable in this file, even though it would be visible here when compiled under -g2.
  2. Ladebug can print the global variable. If this were a complicated type, Ladebug would probably show it as an int. Type information is lost in most cases of limited debugging information. Local variable information is also lost in most cases.

14.2.4 Example C++ Program Linked with Various -x and -r Options

The sample program in this section is the same as the program used in Section 14.2.3, except that it was linked with a different series of -x and -r flags. As a result, different parts of the program have symbolic debugging information removed. Both files, calldriver.C and callstack_intermediates.C, contain limited debugging information.

As you go through this example debugging session, compare the results with output of the programs compiled with -g2 in Section 14.2.3.

14.2.4.1 Setting Breakpoints on Static and Global Routines

When you try to set a breakpoint, Ladebug cannot recognize the names of static or global routines. The information about the routines in both calldriver.C and callstack_intermediates.C has been stripped out, as shown in Example 14-19.

Example 14-19 Setting Breakpoints on Static and Global Routines in a C++ Program with Various -x and -r flags

csh> $LADEBUG ../bin/x_callstack03-xr
Welcome to the Ladebug Debugger Version 4.0-9 
------------------ 
object file name: ../bin/x_callstack03-xr 
Reading symbolic information ...done 
Directory search path for source files: 
 . ../bin /usr/users/debug/ladebug 
(ladebug) stop in full_local
Symbol full_local undefined. 
full_local has no valid breakpoint address(1)
Warning: Breakpoint not set 
(ladebug) stop in full_global
[#1: stop in full_global ](2)
(ladebug) stop in intermediate_local
Symbol intermediate_local undefined. 
intermediate_local has no valid breakpoint address(3)
Warning: Breakpoint not set 
(ladebug) stop in intermediate_global 
[#2: stop in intermediate_global ](4)
(ladebug) run
[2] stopped at [intermediate_global: ??? 0x1200015a8] 
 

  1. The static routine is not visible to Ladebug.
  2. Ladebug does not know the return type of the routine, the parameters, or the types.
  3. This static routine is also not visible.
  4. Ladebug does not know the return type of the routine, the parameters, or the types for this global routine in callstack_intermediates.C.

14.2.4.2 Listing the Source Code

With limited debugging information on both files, Ladebug cannot list the source since it does not have the name of the file. It does provide a name for the file (DebugInformationStrippedFromFile7), as shown in Example 14-20, which allows you to distinguish from other information later on.

Example 14-20 Listing the Source Code of a C++ Program with Various -x and -r Flags

(ladebug) use ../src
Directory search path for source files: 
 . ../bin /usr/users/debug/ladebug ../src 
(ladebug) list
(Can't find file DebugInformationStrippedFromFile7) 

14.2.4.3 Displaying the Stack Trace

With limited debugging information, Ladebug displays the stack trace as shown in Example 14-21.

Example 14-21 Displaying the Stack Trace of a C++ Program with Various-x and -r Flags

(ladebug) where
>0  0x1200015a8 in intermediate_global(0x1, 0x0, 0x0, 0x0, 0x1, 0x11ffff9a0) 
DebugInformationStrippedFromFile7:???(1)
#1  0x1200014bc in ../bin/x_callstack03-xr(2)
(ladebug) cont
[1] stopped at [full_global: ??? 0x120001418](3)
(ladebug) where
>0  0x120001418 in full_global(0x0, 0x1400000d8, 0x3ff808941cc, 
0x120001810, 0x6d0, 0x3ffc0819100)DebugInformationStrippedFromFile6:???(4)
#1  0x12000155c in UnknownProcedure0FromFile7(0x0, 0x1400000d8, 0x3ff808941cc, 
0x120001810, 0x6d0, 0x3ffc0819100) DebugInformationStrippedFromFile7:???(5)  
. 
. 
. 
 

  1. In the first (bottom) frame of the stack, Ladebug recognizes the routine name but cannot associate it with a file. It provides the file name DebugInformationStrippedFromFile7 so you can discriminate this routine. It does not know the parameters for the routine so it lists the first six register parameters according to the compiler calling convention.
  2. The filename is not known, so Ladebug displays the image name.
  3. Ladebug sets a breakpoint on the global routine full_global but cannot tell which file or line number.
  4. Ladebug creates a new file name for each file in the program. In this case, it created the name DebugInformationStrippedFromFile6.
  5. Ladebug recognizes that this is a routine but does not know the name, which means it is a static routine (-x -r strips out the names of static routines but retains some routine information). Ladebug creates a routine name (UnknownProcedure0FromFile7). Because Ladebug recognizes the routine name "UnknownProcedure0FromFile7", you can figure out the name of the static routine Ladebug would use by running odump -Pv.

14.2.4.4 Setting a Breakpoint on an Unknown Routine

Ladebug lets you set a breakpoint on the routine name it created in Example 14-10, even though information is lacking for static routines. It can display information on global variables. Information about static variables local to this file is lost, as shown in Example 14-22.

Example 14-22 Setting a Breakpoint on an Unknown Routine in a C++ Program with Various -x and -r Flags

(ladebug) stop in UnknownProcedure0FromFile7
[#3: stop in UnknownProcedure0FromFile7 ] 
(ladebug) print full_local_count
Symbol full_local_count undefined. 
Error: no value for full_local_count 
(ladebug) print full_global_count
0 
(ladebug) print intermediate_local_count
Symbol intermediate_local_count undefined. 
Error: no value for intermediate_local_count 
(ladebug) print intermediate_global_count
1 
(ladebug) quit
 


Previous Next Contents Index