|
HP OpenVMS systems documentation |
Previous | Contents | Index |
The example continues by invoking the system code debugger's character-cell interface on the host system.
Example 11-3 Invoking the Alpha System Code Debugger |
---|
$ define dbg$decw$display " " $ debug/keep OpenVMS Alpha Debug64 Version V8.2-014 DBG> |
Example 11-4 Invoking the I64 System Code Debugger |
---|
$ define dbg$decw$display " " $ debug/keep OpenVMS I64 Debug64 Version V8.2-014 DBG> |
Use the CONNECT command to connect to the target system. In this example, the target system's default password is the null string, and the logical name DBGHK$IMAGE_PATH is used for the image path; so the command qualifiers /PASSWORD and /IMAGE_PATH are not being used. You may need to use them.
When you have connected to the target system, the DBG> prompt is displayed. Enter the SHOW IMAGE command to see what has been loaded. Because you are reaching a breakpoint early in the boot process, there are very few images. See Example 11-5. Notice that SYS$BASE_IMAGE has an asterisk next to it. This is the currently set image, and all symbols currently loaded in the debugger come from that image.
Example 11-5 Connecting to the Target System |
---|
DBG> connect %node_name TSTSYS %DEBUG-I-INIBRK, target system interrupted %DEBUG-I-DYNMODSET, setting module SYSTEM_ROUTINES DBG> show image image name set base address end address ERRORLOG no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80084000 FFFFFFFF80086FFF NPRW1 FFFFFFFF80CA3600 FFFFFFFF80CA3BFF EXEC_INIT no FFFFFFFF8306E000 FFFFFFFF830A2000 *SYS$BASE_IMAGE yes 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80002000 FFFFFFFF8000EDFF NPRW1 FFFFFFFF80C05C00 FFFFFFFF80C2AFFF SYS$CNBTDRIVER no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF8001A000 FFFFFFFF8001AFFF NPRW1 FFFFFFFF80C2D600 FFFFFFFF80C2D9FF SYS$CPU_ROUTINES_0402 no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80010000 FFFFFFFF800191FF NPRW1 FFFFFFFF80C2B000 FFFFFFFF80C2D5FF SYS$ESBTDRIVER no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF8002C000 FFFFFFFF8002E1FF NPRW1 FFFFFFFF80C30C00 FFFFFFFF80C30FFF SYS$NISCA_BTDRIVER no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF8001C000 FFFFFFFF8002ADFF NPRW1 FFFFFFFF80C2DA00 FFFFFFFF80C30BFF SYS$OPDRIVER no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80030000 FFFFFFFF800337FF NPRW1 FFFFFFFF80C31000 FFFFFFFF80C319FF SYS$PUBLIC_VECTORS no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80000000 FFFFFFFF80001FFF NPRW1 FFFFFFFF80C00000 FFFFFFFF80C05BFF SYSTEM_DEBUG no FFFFFFFF82FFE000 FFFFFFFF83056000 SYSTEM_PRIMITIVES_MIN no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80034000 FFFFFFFF800775FF NPRW1 FFFFFFFF80C31A00 FFFFFFFF80CA11FF SYSTEM_SYNCHRONIZATION_UNI no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80078000 FFFFFFFF800835FF NPRW1 FFFFFFFF80CA1200 FFFFFFFF80CA35FF total images: 12 bytes allocated: 1517736 |
Example 11-6 shows the target system's console display during the connect sequence. Note that for security reasons, the name of the host system, the user's name, and process ID are displayed.
Example 11-6 Target System Connection Display |
---|
DBGTK: Connection attempt from host HSTSYS user GUEST process 2E801C2F DBGTK: Connection attempt succeeded |
To set a breakpoint at the first routine in the C_TEST_ROUTINES module of the SYSTEM_DEBUG.EXE execlet, do the following:
Example 11-7 Setting a Breakpoint |
---|
DBG> set image system_debug DBG> show module module name symbols language size AUX_TARGET no C 15928 BUFSRV_TARGET no C 11288 BUGCHECK_CODES no BLISS 26064 CRTLPRINTF no C 29920 C_TEST_ROUTINES no C 3808 FATAL_EXC no C 1592 HIGH_ADDRESS no C 372 LIB$CALLING_STANDARD_AUX no MACRO64 1680 LINMGR_TARGET no C 13320 LOW_ADDRESS no C 368 OBJMGR no C 5040 PLUMGR no C 19796 POOL no C 116 PROTOMGR_TARGET no C 17868 SOCMGR no C 3324 SYS$DOINIT no AMACRO 81740 TARGET_KERNEL no C 207244 TMRMGR_TARGET no C 3516 XDELTA no BLISS 189940 XDELTA_ISRS no MACRO64 2428 total modules: 20. bytes allocated: 1585168. DBG> set module c_test_routines DBG> show module c_test_routines module name symbols size C_TEST_ROUTINES yes 3808 total C modules: 1. bytes allocated: 1592264. DBG> set language c DBG> show symbol test_c_code* routine C_TEST_ROUTINES\test_c_code5 routine C_TEST_ROUTINES\test_c_code4 routine C_TEST_ROUTINES\test_c_code3 routine C_TEST_ROUTINES\test_c_code2 routine C_TEST_ROUTINES\test_c_code DBG> set break test_c_code |
Now that the breakpoint is set, you can proceed and activate the breakpoint. When that occurs, the debugger tries to open the source code for that location in the same place as where the module was compiled. Because that is not the same place as on your system, you need to tell the debugger where to find the source code. This is done with the debugger's SET SOURCE command, which takes a search list as a parameter so you can make it point to many places.
Example 11-8 Finding the Source Code |
---|
DBG> set source/latest sys$examples,sys$library DBG> go break at routine C_TEST_ROUTINES\test_c_code 166: x = xdt$fregsav[0]; |
Now that the debugger has access to the source, you can put the debugger into screen mode to see exactly where you are and the code surrounding it.
Example 11-9 Using the Set Mode Screen Command |
---|
DBG> Set Mode Screen; Set Step Nosource - SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); 158: xdt$fregsav[3] = test; 159: return xdt$fregsav[23]; 160: } 161: void test_c_code(void) 162: { 163: int x,y; 164: int64 x64,y64; 165: -> 166: x = xdt$fregsav[0]; 167: y = xdt$fregsav[1]; 168: x64 = xdt$fregsav[2]; 169: y64 = xdt$fregsav[3]; 170: xdt$fregsav[14] = test_c_code2(x64+y64,x+y,x64+x,&y64); 171: test_c_code4(); 172: return; 173: } - OUT -output------------------------------------------------------------------- - PROMPT -error-program-prompt-------------------------------------------------- DBG> |
Now, you want to set another breakpoint inside the test_c_code3 routine. You use the debugger's SCROLL/UP command (8 on the keypad) to move to that routine and see that line 146 would be a good place to set the breakpoint. It is at a recursive call. Then you proceed to that breakpoint with the GO command.
Example 11-10 Using the SCROLL/UP DEBUG Command |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 133: void test_c_code4(void) 134: { 135: int i,k; 136: for(k=0;k<1000;k++) 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) 146: subrtnCount = test_c_code3(subrtnCount); 147: return subrtnCount; 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else - OUT -output------------------------------------------------------------------- - PROMPT -error-program-prompt-------------------------------------------------- DBG> Scroll/Up DBG> set break %line 146 DBG> go DBG> |
When you reach that breakpoint, the source code display is updated to show where you currently are, which is indicated by an arrow. A message also appears in the OUT display indicating you reach the breakpoint at that line.
Example 11-11 Breakpoint Display |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 135: int i,k; 136: for(k=0;k<1000;k++) 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) -> 146: subrtnCount = test_c_code3(subrtnCount); 147: return subrtnCount; 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 - PROMPT -error-program-prompt-------------------------------------------------- DBG> Scroll/Up DBG> set break %line 146 DBG> go DBG> |
Now you try the debugger's STEP command. The default behavior for STEP is STEP/OVER, unlike XDELTA and DELTA, which is STEP/INTO, so, normally you would expect to step to line 147 in the code. However, because you have a breakpoint inside test_c_code3 that is called at line 146, you will reach that event first.
Example 11-12 Using the Debug Step Command |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 135: int i,k; 136: for(k=0;k<1000;k++) 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) -> 146: subrtnCount = test_c_code3(subrtnCount); 147: return subrtnCount; 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 break at C_TEST_ROUTINES\test_c_code3\%LINE 146 - PROMPT -error-program-prompt-------------------------------------------------- DBG> DBG> set break %line 146 DBG> go DBG> Step DBG> |
Now, you try a couple of other commands, EXAMINE and SHOW CALLS. The EXAMINE command allows you to look at all the C variables. Note that the C_TEST_ROUTINES module is compiled with the /NOOPTIMIZE switch which allows access to all variables. The SHOW CALLS command shows you the call sequence from the beginning of the stack. In this case, you started out in the image EXEC_INIT. (The debugger prefixes all images other than the main image with SHARE$ so it shows up as SHARE$EXEC_INIT.)
Example 11-13 Using the Examine and Show Calls Commands |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 135: int i,k; 136: for(k=0;k<1000;k++) 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) -> 146: subrtnCount = test_c_code3(subrtnCount); 147: return subrtnCount; 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 break at C_TEST_ROUTINES\test_c_code3\%LINE 146 C_TEST_ROUTINES\test_c_code3\subrtnCount: 8 module name routine name line rel PC abs PC *C_TEST_ROUTINES test_c_code3 146 00000000000000C4 FFFFFFFF83002D64 *C_TEST_ROUTINES test_c_code3 146 00000000000000D4 FFFFFFFF83002D74 *C_TEST_ROUTINES test_c_code2 157 00000000000001A0 FFFFFFFF83002E40 *C_TEST_ROUTINES test_c_code 170 0000000000000260 FFFFFFFF83002F00 *XDELTA XDT$SYSDBG_INIT 9371 0000000000000058 FFFFFFFF83052238 *SYS$DOINIT INI$DOINIT 1488 0000000000000098 FFFFFFFF830520B8 SHARE$EXEC_INIT 0000000000018C74 FFFFFFFF83086C74 SHARE$EXEC_INIT 0000000000014BD0 FFFFFFFF83082BD0 - PROMPT -error-program-prompt-------------------------------------------------- DBG> DBG> set break %line 146 DBG> go DBG> Step DBG> examine subrtnCount DBG> show calls DBG> |
If you want to proceed because you are done debugging this code, first cancel all the breakpoints and then enter the GO command. Notice, however, that you do not keep running but receive a message that you have stepped to line 147. This happens because the STEP command used earlier never completed. It was interrupted by the breakpoint on line 146.
Note that the debugger remembers all step events and only removes them once they have completed.
Example 11-14 Canceling the Breakpoints |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 136: for(k=0;k<1000;k++) 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) 146: subrtnCount = test_c_code3(subrtnCount); -> 147: return subrtnCount; 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); 158: xdt$fregsav[3] = test; - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 break at C_TEST_ROUTINES\test_c_code3\%LINE 146 C_TEST_ROUTINES\test_c_code3\subrtnCount: 8 module name routine name line rel PC abs PC *C_TEST_ROUTINES test_c_code3 146 00000000000000C4 FFFFFFFF83002D64 *C_TEST_ROUTINES test_c_code3 146 00000000000000D4 FFFFFFFF83002D74 *C_TEST_ROUTINES test_c_code2 157 00000000000001A0 FFFFFFFF83002E40 *C_TEST_ROUTINES test_c_code 170 0000000000000260 FFFFFFFF83002F00 *XDELTA XDT$SYSDBG_INIT 9371 0000000000000058 FFFFFFFF83052238 *SYS$DOINIT INI$DOINIT 1488 0000000000000098 FFFFFFFF830520B8 SHARE$EXEC_INIT 0000000000018C74 FFFFFFFF83086C74 SHARE$EXEC_INIT 0000000000014BD0 FFFFFFFF83082BD0 stepped to C_TEST_ROUTINES\test_c_code3\%LINE 147 - PROMPT -error-program-prompt-------------------------------------------------- DBG> go DBG> Step DBG> examine subrtnCount DBG> show calls DBG> cancel break/all DBG> go DBG> |
The STEP/RETURN command, a different type of step command, single steps assembly code until it finds a return instruction. This command is useful if you want to see the return value for the routine, which is done here by examining the R0 register.
For more information about using other STEP command qualifiers, see the HP OpenVMS Debugger Manual.
Example 11-15 Using the Step/Return Command |
---|
- SRC: module C_TEST_ROUTINES -scroll-source------------------------------------ 137: { 138: test_c_code5(&i); 139: } 140: return; 141: } 142: int test_c_code3(int subrtnCount) 143: { 144: subrtnCount = subrtnCount - 1; 145: if (subrtnCount != 0) 146: subrtnCount = test_c_code3(subrtnCount); 147: return subrtnCount; -> 148: } 149: int test_c_code2(int64 in64,int in32, int64 test, int64* pVar) 150: { 151: xdt$fregsav[5] = in64; 152: xdt$fregsav[6] = in32; 153: if (xdt$fregsav[9] > 0) 154: *pVar = (*pVar + xdt$fregsav[17])%xdt$fregsav[9]; 155: else 156: *pVar = (*pVar + xdt$fregsav[17]); 157: xdt$fregsav[7] = test_c_code3(10); 158: xdt$fregsav[3] = test; 159: return xdt$fregsav[23]; - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 break at C_TEST_ROUTINES\test_c_code3\%LINE 146 C_TEST_ROUTINES\test_c_code3\subrtnCount: 8 module name routine name line rel PC abs PC *C_TEST_ROUTINES test_c_code3 146 00000000000000C4 FFFFFFFF83002D64 *C_TEST_ROUTINES test_c_code3 146 00000000000000D4 FFFFFFFF83002D74 *C_TEST_ROUTINES test_c_code2 157 00000000000001A0 FFFFFFFF83002E40 *C_TEST_ROUTINES test_c_code 170 0000000000000260 FFFFFFFF83002F00 *XDELTA XDT$SYSDBG_INIT 9371 0000000000000058 FFFFFFFF83052238 *SYS$DOINIT INI$DOINIT 1488 0000000000000098 FFFFFFFF830520B8 SHARE$EXEC_INIT 0000000000018C74 FFFFFFFF83086C74 SHARE$EXEC_INIT 0000000000014BD0 FFFFFFFF83082BD0 stepped to C_TEST_ROUTINES\test_c_code3\%LINE 147 stepped on return from C_TEST_ROUTINES\test_c_code3\%LINE 147 to C_TEST_ROUTINES\test_c_code3\%LINE 148 C_TEST_ROUTINES\test_c_code3\%R0: 0 - PROMPT -error-program-prompt-------------------------------------------------- DBG> examine subrtnCount DBG> show calls DBG> cancel break/all DBG> go DBG> step/return DBG> examine r0 DBG> |
After you finish the SCD session, enter the GO command to leave this module. You will encounter another INI$BRK breakpoint at the end of EXEC_INIT. An error message indicating there are no source lines for address 80002010 is displayed, because debug information on this image or module is not available.
Also notice that there is no message in the OUT display for this event. That is because INI$BRKs are special breakpoints that are handled as SS$_DEBUG signals. They are a method for the system code to break into the debugger and there is no real breakpoint in the code.
Example 11-16 Source Lines Error Message |
---|
- SRC: module SYSTEM_ROUTINES -scroll-source------------------------------------ 15896: Source line not available 15897: Source line not available . . . 15906: Source line not available ->5907: Source line not available 15908: Source line not available . . . 15917: Source line not available 15918: Source line not available - OUT -output------------------------------------------------------------------- break at C_TEST_ROUTINES\test_c_code3\%LINE 146 break at C_TEST_ROUTINES\test_c_code3\%LINE 146 C_TEST_ROUTINES\test_c_code3\subrtnCount: 8 module name routine name line rel PC abs PC *C_TEST_ROUTINES test_c_code3 146 00000000000000C4 FFFFFFFF83002D64 *C_TEST_ROUTINES test_c_code3 146 00000000000000D4 FFFFFFFF83002D74 *C_TEST_ROUTINES test_c_code2 157 00000000000001A0 FFFFFFFF83002E40 *C_TEST_ROUTINES test_c_code 170 0000000000000260 FFFFFFFF83002F00 *XDELTA XDT$SYSDBG_INIT 9371 0000000000000058 FFFFFFFF83052238 *SYS$DOINIT INI$DOINIT 1488 0000000000000098 FFFFFFFF830520B8 SHARE$EXEC_INIT 0000000000018C74 FFFFFFFF83086C74 SHARE$EXEC_INIT 0000000000014BD0 FFFFFFFF83082BD0 stepped to C_TEST_ROUTINES\test_c_code3\%LINE 147 stepped on return from C_TEST_ROUTINES\test_c_code3\%LINE 147 to C_TEST_ROUTINES\test_c_code3\%LINE 148 C_TEST_ROUTINES\test_c_code3\%R0: 0 - PROMPT -error-program-prompt-------------------------------------------------- DBG> examine r0 DBG> go %DEBUG-I-INIBRK, target system interrupted %DEBUG-I-DYNIMGSET, setting image SYS$BASE_IMAGE %DEBUG-W-SCRUNAOPNSRC, unable to open source file SYS$COMMON:[SYSLIB]SYSTEM_ROUTINES.M64; -RMS-E-FNF, file not found DBG> |
Enter the SHOW IMAGE command. You will see more images displayed as the boot path has progressed further.
Finally, enter GO, allowing the target system to boot completely, because there are no more breakpoints in the boot path. The debugger will wait for another event to occur.
Example 11-17 Using the Show Image Command |
---|
- SRC: module SYSTEM_ROUTINES -scroll-source------------------------------------ 15896: Source line not available 15897: Source line not available . . . 15906: Source line not available ->5907: Source line not available 15908: Source line not available . . . 15917: Source line not available 15918: Source line not available - OUT -output------------------------------------------------------------------- PRO2 FFFFFFFF8329C000 FFFFFFFF832A2DFF SYSLICENSE no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80188000 FFFFFFFF801883FF NPRW1 FFFFFFFF80CCC000 FFFFFFFF80CCC5FF PRO2 FFFFFFFF8321E000 FFFFFFFF832247FF PRW3 FFFFFFFF83226000 FFFFFFFF832265FF SYSTEM_DEBUG yes FFFFFFFF82FFE000 FFFFFFFF83056000 SYSTEM_PRIMITIVES_MIN no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80034000 FFFFFFFF800775FF NPRW1 FFFFFFFF80C31A00 FFFFFFFF80CA11FF SYSTEM_SYNCHRONIZATION_UNI no 0000000000000000 FFFFFFFFFFFFFFFF NPRO0 FFFFFFFF80078000 FFFFFFFF800835FF NPRW1 FFFFFFFF80CA1200 FFFFFFFF80CA35FF total images: 40 bytes allocated: 2803296 - PROMPT -error-program-prompt-------------------------------------------------- %DEBUG-I-INIBRK, target system interrupted %DEBUG-I-DYNIMGSET, setting image SYS$BASE_IMAGE %DEBUG-W-SCRUNAOPNSRC, unable to open source file X6P3_RESD$:[SYSLIB]SYSTEM_ROUTINES.M64; -RMS-E-FNF, file not found DBG> show image DBG> go |
Previous | Next | Contents | Index |