|
|
| Updated: 11 December 1998 |
OpenVMS Delta/XDelta Debugger Manual
| Previous | Contents | Index |
This appendix gives an example of using DELTA to debug a program on OpenVMS VAX. The program, LOGINTIM, uses the system service SYS$GETJPI to obtain the login times of each process. Although this is an example of using DELTA, most of the commands in the example could be used in an XDELTA debugging session.
To run this program without error, you need WORLD privilege.
The .LIS file is listed in Example A-1. Only the offsets and source code are shown.
| Example A-1 Program for Getting LOGINTIMs |
|---|
0000 1 ;++ 0000 2 ; This sample program uses the wildcard feature of GETJPI to get the 0000 3 ; LOGINTIM for each active process. It outputs the PID and LOGINTIM 0000 4 ; for each and exits when there are NOMOREPROCs. 0000 5 ;-- 0000 6 0000 7 ; 0000 8 ; Data areas. 0000 9 ; 0000 10 DEVNAM: .ASCID /SYS$OUTPUT/ ;Output device specifier 000E 0012 11 0012 12 CHAN: .LONG 0 ;Assigned output channel 0016 13 0016 14 ITMLST: ;Item list for GETJPI call 0016 15 .WORD 8 ; Byte length of output buffer 0018 16 .WORD JPI$_LOGINTIM ; Specify LOGINTIM item code 001A 17 .ADDRESS TIME ; Address of output buffer 001E 18 .LONG 0 ; Not interested in return length 0022 19 .LONG 0 ;Item list terminator 0026 20 0026 21 TIME: .QUAD 0 ;Buffer to hold LOGINTIM 002E 22 002E 23 OUTLEN: .LONG 0 ;FAO buffer length 0032 24 OUTBUF: .LONG 1024 ;FAO buffer descriptor 0036 25 .ADDRESS BUF 003A 26 BUF: .BLKB 1024 ;FAO buffer 043A 27 043A 28 CTRSTR: .ASCID *!/!_PID= !XW!_LOGINTIME= !%T* ;FAO control string 0448 0454 045E 29 045E 30 PIDADR: .LONG -1 ;Wildcard PID control longword 0462 31 0462 32 ;++ 0462 33 ; Start of program. 0462 34 ;-- 0462 35 S: .WORD 0 ;Entry mask 0464 36 $ASSIGN_S DEVNAM,CHAN ;Assign output channel 0475 37 MOVAB TIME,R2 ;Load pointer to LOGINTIM 047A 38 ; output buffer 047A 39 LOOP: $GETJPI_S ITMLST=ITMLST,-;Get LOGINTIM for a process 047A 40 PIDADR=PIDADR 0490 41 CMPL R0,#SS$_NOMOREPROC ;Are we done? 0497 42 BEQL 5$ ;If EQL yes 0499 43 BSBB GOT_IT ;Process data for this process 049B 44 BRB LOOP ;Look for another process 049D 45 049D 46 5$: MOVZBL #SS$_NORMAL,R0 ;Set successful completion code 04A1 47 RET ;Return, no more processes 04A2 48 04A2 49 GOT_IT: $FAO_S CTRSTR,- ;Format the output data 04A2 50 OUTLEN,- 04A2 51 OUTBUF,- 04A2 52 PIDADR,R2 04B9 53 $QIOW_S CHAN=CHAN,- ;Output to SYS$OUTPUT 04B9 54 FUNC=#IO$_WRITEVBLK,- 04B9 55 P1=BUF,- 04B9 56 P2=OUTLEN 04DC 57 RSB ;Done with this process data 04DD 58 04DD 59 .END S |
The .MAP file is listed in Example A-2. Only the Program Section Synopsis with the PSECT, MODULE, base address, end address, and length are listed.
| Example A-2 LOGINTIM Program .Map File |
|---|
+--------------------------+
! Program Section Synopsis !
+--------------------------+
Psect Name Module Name Base End Length
---------- ----------- ---- --- ------
. BLANK . 00000200 000006E2 000004E3 ( 1251.)
.MAIN. 00000200 000006E2 000004E3 ( 1251.)
|
The DELTA debugging session is listed in Example A-3.
| Example A-3 DELTA Debugging Session Example |
|---|
$ DEFINE LIB$debugging SYS$LIBRARY:DELTA (1) $ RUN/debugging LOGINTIM (2) DELTA Version 6.0 00000664/CLRQ -(SP) 200,1;X (3) 00000200 (4) X1 490!CMPL R0,#000009A8 .;B (5) X1 499!BSBB X1+04A2 .;B (6) ;P (7) 1 BRK AT 00000690 X1+0490/CMPL R0,#000009A8 R0/00000001 ;P (8) 2 BRK AT 00000699 X1+499/BSBB X1+04A2 O (9) PID= 0000 LOGINTIME= 00:00:00.00 (10) X1+049B/BRB X1+047A ;P (11) 1 BRK AT 00000690 X1+0490/CMPL R0,#000009A8 R0/00000001 ;P (12) 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 O (13) PID= 0001 LOGINTIME= 00:00:00.00 X1+049B/BRB X1+047A ;P 1 BRK AT 00000690 X1+0490/CMPL R0,#000009A8 (14) ;B (15) 1 00000690 2 00000699 (16) 0,1;B (17) ;B (18) 2 00000699 (19) ;P (20) 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 O PID= 0004 LOGINTIME= 12:50:20.40 X1+049B/BRB X1+047A ;P (21) 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 ;P PID= 0005 LOGINTIME= 12:50:25.61 (22) 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 X1 4B9!CLRQ -(SP) (23) [Linefeed] (24) X1+04BB/CLRQ -(SP) [Linefeed] X1+04BD/PUSHL X1+002E [Linefeed] X1+04C1/PUSHAL X1+003A [Linefeed] X1+04C5/CLRQ -(SP) [Linefeed] X1+04C7/PUSHL #00 [Linefeed] X1+04C9/MOVZWL #0030;-(SP) [Linefeed] X1+04CE/MOVZWL X1+0012,-(SP) [Linefeed] X1+04D3/PUSHL #00 [Linefeed] X1+04D5/CALLS #0C,@#7FFEDE00 .;B (25) ;B (26) 1 000006D5 2 00000699 ;P (27) 1 BRK AT 000006D5 X1+04D5/CALLS #0C,@#7FFEDE00 ;P (28) PID= 0006 LOGINTIME= 12:50:29.45 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 ;P (29) 1 BRK AT 000006D5 X1+04D5/CALLS #0C,@#7FFEDE00 ;P (30) PID= 0007 LOGINTIME= 12:50:37.08 2 BRK AT 00000699 X1+0499/BSBB X1+04A2 O (31) 1 BRK AT 000006D5 X1+04D5/CALLS #0C,@#7FFEDE00 ;P (32) PID= 0008 LOGINTIME= 12:50:45.64 STEPOVER BRK AT 0000069B (33) X1+049B/BRB X1+047A ;B (34) 1 000006D5 2 00000699 (35) 0,2;B (36) 0,1;B (37) ;B (38) ;P (39) PID= 0009 LOGINTIME= 12:51:22.51 PID= 000A LOGINTIME= 12:51:30.26 PID= 000B LOGINTIME= 12:51:36.21 PID= 000C LOGINTIME= 12:51:58.86 (40) EXIT 00000001 (41) 80187E7E/POPR #03 EXIT (42) |
This appendix gives an example of using DELTA to debug a program on OpenVMS Alpha. The C program named LOG uses the system service SYS$GETJPIW to obtain the PID, process name, and login time of each process. Although this is an example of using DELTA, most of the commands in the example could be used in an XDELTA debugging session.
To run this program without error, you need WORLD privilege.
The listing file for LOG is shown in two parts. The C source code part is shown in Example B-1. The machine code part is shown in Example B-2.
| Example B-1 Listing File for LOG: C Source Code |
|---|
1 #include <descrip.h>
434 #include <jpidef.h>
581 #include <ssdef.h>
1233 #include <starlet.h>
3784 #include <stdio.h>
4117 #include <stdlib.h>
4345
4346 void print_line(unsigned long int pid, char *process_name,
4347 unsigned long int *time_buffer);
4348
4349 typedef struct {
4350 unsigned short int il3_buffer_len;
4351 unsigned short int il3_item_code;
4352 void *il3_buffer_ptr;
4353 unsigned short int *il3_return_len_ptr;
4354 } item_list_3;
4355
4356 #define NUL '\0'
4357
4358 main()
4359 {
4360 static char name_buf[16];
4361 static unsigned long int pid, time_buf[2];
4362 static unsigned short int name_len;
4363
4364 unsigned short int pidadr[2] = {-1, -1};
4365 unsigned long int ss_sts;
4366 item_list_3 jpi_itmlst[] = {
4367 /* Get's login time */
4368 {sizeof(time_buf),
4369 JPI$_LOGINTIM,
4370 (void *) time_buf,
4371 NULL},
4372
4373 /* Get's process name */
4374 {sizeof(name_buf) - 1,
4375 JPI$_PRCNAM,
4376 (void *) name_buf,
4377 &name_len},
4378
4379 /* Get's process ID (PID) */
4380 {sizeof(pid),
4381 JPI$_PID,
4382 (void *) &pid,
4383 NULL},
4384
4385 /* End of list */
4386 {0,
4387 0,
4388 NULL,
4389 NULL}
4390 };
4391
4392 /*
4393 While there's more GETJPI information to process and a catastrophic
4394 error has not occurred then
4395 If GETJPI was successful then
4396 NUL terminate the process name string and
4397 print the information returned by GETJPI
4398 */
4399
4400 while(
4401 (ss_sts = sys$getjpiw(0, &pidadr, 0, &jpi_itmlst, 0, 0, 0)) != SS$_NOMOREPROC &&
4402 ss_sts != SS$_BADPARAM &&
4403 ss_sts != SS$_ACCVIO)
4404 {
4405 if (ss_sts == SS$_NORMAL)
4406 {
4407 *(name_buf + name_len) = NUL;
4408 print_line(pid, name_buf, time_buf);
4409 }
4410 }
4411 exit(EXIT_SUCCESS);
4412 }
4413
4414 void print_line(unsigned long int pid, char *process_name,
4415 unsigned long int *time_buffer)
4416 {
4417 static char ascii_time[12];
4418
4419 struct dsc$descriptor_s time_dsc = {
4420 sizeof(ascii_time) - 1,
4421 DSC$K_DTYPE_T,
4422 DSC$K_CLASS_S,
4423 ascii_time
4424 };
4425 unsigned short int time_len;
4426
4427 /*
4428 Convert the logged in time to ASCII and NUL terminate it
4429 */
4430 sys$asctim(&time_len, &time_dsc, time_buffer, 1);
4431 *(ascii_time + time_len) = NUL;
4432
4433 /*
4434 Output the PID, process name and logged in time
4435 */
4436 printf("\n\tPID= %08.8X\t\tPRCNAM= %s\tLOGINTIM= %s", pid,
4437 process_name, ascii_time);
4438
4439 return;
4440 }
4441 __main(void *p1, void *p2, void *p3, void *p4, void *p5, void *p6)
4442 {
4443 void decc$exit(int);
4444 void decc$main(void *, void *, void *, void *, void *, void *, int *, void **, void **);
4445 int status;
4446 int argc;
4447 void *argv;
4448 void *envp;
4449
4450 decc$main(p1, p2, p3, p4, p5, p6, &argc, &argv, &envp);
4451
4452 status = main
4453 (
4454
4455
4456
4457 );
4458
4459 decc$exit(status);
4460 }
|
| Example B-2 Listing File for LOG: Machine Code |
|---|
.PSECT $CODE, OCTA, PIC, CON, REL, LCL, SHR,-
EXE, NORD, NOWRT
0000 print_line:: ; 004414
0000 LDA SP, -80(SP) ; SP, -80(SP)
0004 MOV 1, R19 ; 1, R19 ; 004430
0008 STQ R27, (SP) ; R27, (SP) ; 004414
000C MOV 4, R25 ; 4, R25 ; 004430
0010 STQ R26, 32(SP) ; R26, 32(SP) ; 004414
0014 STQ R2, 40(SP) ; R2, 40(SP)
0018 STQ R3, 48(SP) ; R3, 48(SP)
001C STQ R4, 56(SP) ; R4, 56(SP)
0020 STQ FP, 64(SP) ; FP, 64(SP)
0024 MOV SP, FP ; SP, FP
0028 MOV R27, R2 ; R27, R2
002C STL R17, process_name ; R17, 16(FP)
0030 LDQ R0, 40(R2) ; R0, 40(R2) ; 004419
0034 MOV R16, pid ; R16, R3 ; 004414
0038 LDQ R26, 48(R2) ; R26, 48(R2) ; 004430
003C LDA R16, time_len ; R16, 8(FP)
0040 LDQ R4, 32(R2) ; R4, 32(R2) ; 004423
0044 LDA R17, time_dsc ; R17, 24(FP) ; 004430
0048 STQ R0, time_dsc ; R0, 24(FP) ; 004419
004C LDQ R27, 56(R2) ; R27, 56(R2) ; 004430
0050 STL R4, 28(FP) ; R4, 28(FP) ; 004419
0054 JSR R26, SYS$ASCTIM ; R26, R26 ; 004430
0058 LDL R0, time_len ; R0, 8(FP) ; 004431
005C MOV pid, R17 ; R3, R17 ; 004436
0060 LDQ R27, 88(R2) ; R27, 88(R2)
0064 MOV R4, R19 ; R4, R19
0068 LDQ R26, 80(R2) ; R26, 80(R2)
006C MOV 4, R25 ; 4, R25
0070 ZEXTW R0, R0 ; R0, R0 ; 004431
0074 ADDQ R4, R0, R0 ; R4, R0, R0
0078 LDQ_U R16, (R0) ; R16, (R0)
007C MSKBL R16, R0, R16 ; R16, R0, R16
0080 STQ_U R16, (R0) ; R16, (R0)
0084 LDQ R16, 64(R2) ; R16, 64(R2) ; 004436
0088 LDL R18, process_name ; R18, 16(FP)
008C JSR R26, DECC$GPRINTF ; R26, R26
0090 MOV FP, SP ; FP, SP ; 004439
0094 LDQ R28, 32(FP) ; R28, 32(FP)
0098 LDQ R2, 40(FP) ; R2, 40(FP)
009C LDQ R3, 48(FP) ; R3, 48(FP)
00A0 LDQ R4, 56(FP) ; R4, 56(FP)
00A4 LDQ FP, 64(FP) ; FP, 64(FP)
00A8 LDA SP, 80(SP) ; SP, 80(SP)
00AC RET R28 ; R28
Routine Size: 176 bytes, Routine Base: $CODE + 0000
00B0 main:: ; 004358
00B0 LDA SP, -144(SP) ; SP, -144(SP)
00B4 MOV 48, R17 ; 48, R17 ; 004366
00B8 STQ R27, (SP) ; R27, (SP) ; 004358
00BC STQ R26, 64(SP) ; R26, 64(SP)
00C0 STQ R2, 72(SP) ; R2, 72(SP)
00C4 STQ R3, 80(SP) ; R3, 80(SP)
00C8 STQ R4, 88(SP) ; R4, 88(SP)
00CC STQ R5, 96(SP) ; R5, 96(SP)
00D0 STQ R6, 104(SP) ; R6, 104(SP)
00D4 STQ R7, 112(SP) ; R7, 112(SP)
00D8 STQ R8, 120(SP) ; R8, 120(SP)
00DC STQ FP, 128(SP) ; FP, 128(SP)
00E0 MOV SP, FP ; SP, FP
00E4 MOV R27, R2 ; R27, R2
00E8 LDA SP, -16(SP) ; SP, -16(SP)
00EC LDQ R26, 40(R2) ; R26, 40(R2) ; 004366
00F0 LDQ R18, 64(R2) ; R18, 64(R2)
00F4 LDA R16, jpi_itmlst ; R16, 16(FP)
00F8 JSR R26, OTS$MOVE ; R26, R26
00FC LDA R6, jpi_itmlst ; R6, 16(FP) ; 004401
0100 LDQ R3, -64(R2) ; R3, -64(R2) ; 004370
0104 LDA R7, pidadr ; R7, 8(FP) ; 004401
0108 LDQ R0, 32(R2) ; R0, 32(R2) ; 004364
010C MOV 2472, R8 ; 2472, R8 ; 004401
0110 STL R0, pidadr ; R0, 8(FP) ; 004364
0114 LDA R3, time_buf ; R3, 16(R3) ; 004370
0118 MOV R3, R5 ; R3, R5
011C STL R5, 20(FP) ; R5, 20(FP) ; 004366
0120 LDA R4, 8(R3) ; R4, 8(R3) ; 004376
0124 STL R4, 32(FP) ; R4, 32(FP) ; 004366
0128 LDA R17, 24(R3) ; R17, 24(R3)
012C STL R17, 36(FP) ; R17, 36(FP)
0130 LDA R19, 28(R3) ; R19, 28(R3)
0134 STL R19, 44(FP) ; R19, 44(FP)
0138 L$6: ; 004400
0138 LDQ R26, 48(R2) ; R26, 48(R2) ; 004401
013C CLR R16 ; R16
0140 LDQ R27, 56(R2) ; R27, 56(R2)
0144 MOV R7, R17 ; R7, R17
0148 STQ R31, (SP) ; R31, (SP)
014C CLR R18 ; R18
0150 MOV R6, R19 ; R6, R19
0154 CLR R20 ; R20
0158 CLR R21 ; R21
015C MOV 7, R25 ; 7, R25
0160 JSR R26, SYS$GETJPIW ; R26, R26
0164 CMPEQ ss_sts, 20, R16 ; R0, 20, R16 ; 004402
0168 CMPEQ ss_sts, R8, R17 ; R0, R8, R17 ; 004401
016C CMPEQ ss_sts, 12, R18 ; R0, 12, R18 ; 004403
0170 BIS R17, R16, R17 ; R17, R16, R17 ; 004401
0174 BIS R17, R18, R18 ; R17, R18, R18
0178 BNE R18, L$10 ; R18, L$10 ; 004400
017C CMPEQ ss_sts, 1, R0 ; R0, 1, R0 ; 004405
0180 BEQ R0, L$6 ; R0, L$6
0184 MOV R4, R17 ; R4, R17 ; 004408
0188 LDQ_U R19, 24(R3) ; R19, 24(R3) ; 004407
018C MOV R5, R18 ; R5, R18 ; 004408
0190 LDA R27, -96(R2) ; R27, -96(R2)
0194 EXTWL R19, R3, R19 ; R19, R3, R19 ; 004407
0198 ADDQ R4, R19, R19 ; R4, R19, R19
019C LDQ_U R22, (R19) ; R22, (R19)
01A0 MSKBL R22, R19, R22 ; R22, R19, R22
01A4 STQ_U R22, (R19) ; R22, (R19)
01A8 LDL R16, 28(R3) ; R16, 28(R3) ; 004408
01AC BSR R26, print_line ; R26, print_line
01B0 BR L$6 ; L$6 ; 004405
01B4 NOP ;
01B8 L$10: ; 004400
01B8 LDQ R26, 80(R2) ; R26, 80(R2) ; 004411
01BC CLR R16 ; R16
01C0 LDQ R27, 88(R2) ; R27, 88(R2)
01C4 MOV 1, R25 ; 1, R25
01C8 JSR R26, DECC$EXIT ; R26, R26
01CC MOV FP, SP ; FP, SP ; 004412
01D0 LDQ R28, 64(FP) ; R28, 64(FP)
01D4 MOV 1, R0 ; 1, R0
01D8 LDQ R2, 72(FP) ; R2, 72(FP)
01DC LDQ R3, 80(FP) ; R3, 80(FP)
01E0 LDQ R4, 88(FP) ; R4, 88(FP)
01E4 LDQ R5, 96(FP) ; R5, 96(FP)
01E8 LDQ R6, 104(FP) ; R6, 104(FP)
01EC LDQ R7, 112(FP) ; R7, 112(FP)
01F0 LDQ R8, 120(FP) ; R8, 120(FP)
01F4 LDQ FP, 128(FP) ; FP, 128(FP)
01F8 LDA SP, 144(SP) ; SP, 144(SP)
01FC RET R28 ; R28
Routine Size: 336 bytes, Routine Base: $CODE + 00B0
0200 __main:: ; 004441
0200 LDA SP, -48(SP) ; SP, -48(SP)
0204 MOV 9, R25 ; 9, R25 ; 004450
0208 STQ R27, (SP) ; R27, (SP) ; 004441
020C STQ R26, 24(SP) ; R26, 24(SP)
0210 STQ R2, 32(SP) ; R2, 32(SP)
0214 STQ FP, 40(SP) ; FP, 40(SP)
0218 MOV SP, FP ; SP, FP
021C LDA SP, -32(SP) ; SP, -32(SP)
0220 MOV R27, R2 ; R27, R2
0224 LDA R0, argc ; R0, 16(FP) ; 004450
0228 LDQ R26, 48(R2) ; R26, 48(R2)
022C LDA R1, argv ; R1, 12(FP)
0230 STQ R0, (SP) ; R0, (SP)
0234 LDA R0, envp ; R0, 8(FP)
0238 STQ R1, 8(SP) ; R1, 8(SP)
023C LDQ R27, 56(R2) ; R27, 56(R2)
0240 STQ R0, 16(SP) ; R0, 16(SP)
0244 JSR R26, DECC$MAIN ; R26, R26
0248 LDA R27, -96(R2) ; R27, -96(R2) ; 004452
024C BSR R26, main ; R26, main
0250 LDQ R27, 40(R2) ; R27, 40(R2) ; 004459
0254 MOV status, R16 ; R0, R16
0258 MOV 1, R25 ; 1, R25
025C LDQ R26, 32(R2) ; R26, 32(R2)
0260 JSR R26, DECC$EXIT ; R26, R26
0264 MOV FP, SP ; FP, SP ; 004460
0268 LDQ R28, 24(FP) ; R28, 24(FP)
026C LDQ R2, 32(FP) ; R2, 32(FP)
0270 LDQ FP, 40(FP) ; FP, 40(FP)
0274 LDA SP, 48(SP) ; SP, 48(SP)
0278 RET R28 ; R28
Routine Size: 124 bytes, Routine Base: $CODE + 0200
|
| Previous | Next | Contents | Index |
|
|
|
Copyright © Compaq Computer Corporation 1998. All rights reserved. Legal |
4540PRO_006.HTML
|