| Previous | Contents | Index |
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 |
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
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) |
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) |
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 |
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) |
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 |
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 |
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] |
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) |
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) . . . |
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 |