22
Unit 6. Using the ILE Source Debugger Copyright IBM Corp. 1996, 2000 6-1

IBM AS400 RPG IV Training Course(Course Code OL86)--7

Embed Size (px)

DESCRIPTION

J

Citation preview

Page 1: IBM AS400 RPG IV Training Course(Course Code OL86)--7

Unit 6. Using the ILE Source Debugger

Copyright IBM Corp. 1996, 2000 6-1

Page 2: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-2

Unit Objectives - Debugging

After completing this unit, you should be able to:

• Describe the benefits of source view and listing view debugging

• Use compile options to specify desired level of debugging

• Use the source debugger to use:

− breakpoints− display and change values of program variables− step through the execution of an RPG IV program

• Use the “watch” feature of the ILE DebuggerOL866000

Page 3: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-3

Source View Debugger

• OS/400 debugger for ILE programs

• View source on display in debug mode:

− Set breakpoints by cursor position− Step through source statements− Display / change values of program variables− “Watch” the value of a variable change as program executes

• Includes debug commands :

− Display or change values of variables, structures and expressions− Set a “watch” for a variable− Search for strings in source code− Set up “shorthand” notation to reduce keying− Navigate through the source code

OL866105

Page 4: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-4

OL866110

Page 5: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-5

Using the ILE Debugger

1. STRDBG PGM(RPG4PGM) .... UPDPROD(*NO/*YES)

• View source• Set breakpoints

2. CALL PGM(RPG4PGM)

• View source, set/clear breakpoints, display/change variables, etc.

3. ENDDBG

4. Correct source, recompile

5. Test

6. Repeat process until satisfiedOL866115

Page 6: IBM AS400 RPG IV Training Course(Course Code OL86)--7

Example of Source Debugging

�Display Module Source

Program: ITEMLIST Library: OL86V3LIB Module: ITEMLIST12 FItem_PF IF E K Disk3 FItemList O E Printer Oflind(*In88)45 C If NOT *In996 ** Headings on first page7 C Write Heading8 C Eval *In99 = *ON9 C Endif1011 C Read Item_PF1213 C If *In8814 ** Page overflow15 C Write Heading16 C Eval *In88 = *Off17 C Endif181920 C If *InLR21 ** End of file reached22 C Write Footing2324 C Else25 C Eval TotQtyAvl = ItmQtyOH + ItmQt26 C Eval *In43 = (TotQtyAvl < 15)27 C Write Detail2829 C Endif

Debug . . . ________________________________________________________________________________________________________________________________ F3=End program F6=Add/Clear breakpoint F10=Step F11=Display variable F12=Resume F17=Watch variable F18=Work with watch F24=More keys

OL866120

Copyright IBM Corp. 1996, 2000 6-6

Page 7: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-7

OL866125

Page 8: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-8

OL866130

Page 9: IBM AS400 RPG IV Training Course(Course Code OL86)--7

Watching a Variable

�Display Module Source

Program: DEBUGDEMO Library: OL86V3LIB Module: DEBUGDEMO1 ** Declare variables2 D Count S 3P 0 Inz(1)3 D Sum S 5P 045 ** Loop 5 times and accumulate6 C Dow Count <= 57 C Eval Sum = Sum + Count8 C Eval Count = Count + 19 C Enddo1011 ** End program - what are the values of Sum and Count ?12 C Eval *InLR = *ON13 C Return

Bottom

Debug . . . watch sum_____________________________________________________________________________________________________________________ F3=End program F6=Add/Clear breakpoint F10=Step F11=Display variable F12=Resume F17=Watch variable F18=Work with watch F24=More keys

OL866132

Copyright IBM Corp. 1996, 2000 6-9

Page 10: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-10

OL866135

Page 11: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-11

OL866140

Page 12: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-12

OL866145

Page 13: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-13

Changing Debugger View

�Display Module Source

:...........................................................................: Select View :: :: Current View . . . : ILE RPG Source View :: :: Type option, press Enter. :: 1=Select :: :: Opt View :: 1 ILE RPG Listing View :: ILE RPG Source View :: ILE RPG Copy View :: :: Bottom:: F12=Cancel :: ::..........................................................................: Debug . . . __________________________________________________________________________________________________________________________________

F3=End program F6=Add/Clear breakpoint F10=Step F11=Display variable F12=Resume F13=Work with module breakpoints F24=More keys

OL866150

Page 14: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-14

Source Debugger Summary

• Source View debugging

• Simple setting of breakpoints

• Simple display of variable values

• Navigation commands

• Step option

• Evaluation of Expressions

• BIFs can be used with DebuggerOL866155

Page 15: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-15

Tools

• DEBUG on H-spec

• DUMP opcode

• STRSRVJOB

• JoblogOL866200

Page 16: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-16

Debug and Dump

H�DEBUG(*YES)�D DaMoYr S 6 INZ(′120697′)

D Date S 6 0 INZ D Field1 S 8 INZ D Field2 S 8 INZ D Amount S 6 2 INZ(-123.58) D Amount2 S 7 3 INZ(9457.323)D Name S 15 INZ(′ RPG IV Workshop′ )D Class S 6

C MOVE DaMoYr DateC MOVEL (P) Date Field1C MOVEL Name ClassC MOVEL Amount Field2C MOVE Amount Amount2

C Eval *InLR = *ONC �Dump�:

OL866205

Page 17: IBM AS400 RPG IV Training Course(Course Code OL86)--7

Sample DUMP Listing (1/2)

�ILE RPG/400 FORMATTED DUMP

Module Name. . . . . . . . . . . . . . : MOVEXOptimization Level . . . . . . . . . . : *NONE

Halt Indicators:H1 ′ 0 ′ H2 ′ 0 ′ H3 ′ 0 ′ H4 ′ 0 ′ H5 ′ 0 ′ H6 ′ 0 ′ H7 ′ 0 ′ H8Command/Function Key Indicators:KA ′ 0 ′ KB ′ 0 ′ KC ′ 0 ′ KD ′ 0 ′ KE ′ 0 ′ KF ′ 0 ′ KG ′ 0 ′ KHKK ′ 0 ′ KL ′ 0 ′ KM ′ 0 ′ KN ′ 0 ′ KP ′ 0 ′ KQ ′ 0 ′ KR ′ 0 ′ KSKV ′ 0 ′ KW ′ 0 ′ KX ′ 0 ′ KY ′ 0 ′Control Level Indicators:L1 ′ 0 ′ L2 ′ 0 ′ L3 ′ 0 ′ L4 ′ 0 ′ L5 ′ 0 ′ L6 ′ 0 ′ L7 ′ 0 ′ L8Overflow Indicators:OA ′ 0 ′ OB ′ 0 ′ OC ′ 0 ′ OD ′ 0 ′ OE ′ 0 ′ OF ′ 0 ′ OG ′ 0 ′ OVExternal Indicators:U1 ′ 0 ′ U2 ′ 0 ′ U3 ′ 0 ′ U4 ′ 0 ′ U5 ′ 0 ′ U6 ′ 0 ′ U7 ′ 0 ′ U8General Indicators:01 ′ 0 ′ 02 ′ 0 ′ 03 ′ 0 ′ 04 ′ 0 ′ 05 ′ 0 ′ 06 ′ 0 ′ 07 ′ 0 ′ 0811 ′ 0 ′ 12 ′ 0 ′ 13 ′ 0 ′ 14 ′ 0 ′ 15 ′ 0 ′ 16 ′ 0 ′ 17 ′ 0 ′ 1821 ′ 0 ′ 22 ′ 0 ′ 23 ′ 0 ′ 24 ′ 0 ′ 25 ′ 0 ′ 26 ′ 0 ′ 27 ′ 0 ′ 28::Internal Indicators:LR ′ 1 ′ MR ′ 0 ′ RT ′ 0 ′ 1P ′ 0 ′

NAME ATTRIBUTES VALUEAMOUNT PACKED(6,2) -0123.58 ′0012358D′ XAMOUNT2 PACKED(7,3) -9012.358 ′9012358D′ XCLASS CHAR(6) ′ RPG IV′ ′ D9D7C740C9E5′ XDAMOYR CHAR(6) ′120697′ ′F1F2F0F6F9F7′ XDATE PACKED(6,0) 120697. ′0120697F′ XFIELD1 CHAR(8) ′120697 ′ ′F1F2F0F6F9F74040′ XFIELD2 CHAR(8) ′01235Q ′ ′ F0F1F2F3F5D84040′ XNAME CHAR(15) ′ RPG IV Workshop′

VALUE IN HEX ′ D9D7C740C9E540E6969992A2889697′ X

OL866210

Copyright IBM Corp. 1996, 2000 6-17

Page 18: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-18

STRSRVJOB

• STRSRVJOB

• TRCJOB *ON/*OFF/*ENDOL866215

Page 19: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-19

Using the Joblog as a Debugging Tool (1/2)

�1.� Display Program Messages

Job 025627/RJSLANEY/QPADEV0005 started on 05/03/00 at 14:37:26 in subsystemError message CPF4101 appeared during OPEN for file BFDSUBST (C S D F).

�2.� Additional Message Information

Message ID . . . . . . : RNQ1216 Severity . . . . . . . : 99Message type . . . . . : InquiryDate sent . . . . . . : 07/28/97 Time sent . . . . . . : 14:

Message . . . . : Error message CPF4101 appeared during OPEN for fileBFDSUBST (C S D F).

Cause . . . . . : RPG procedure BFRSUBST in program OL86V3LIB/BFRSUBSTreceived the message CPF4101 while performing an implicit OPEN operationfile BFDSUBST.

Recovery . . . : Check the job log for a complete description of messageCPF4101, and contact the person responsible for program maintenance.file has a device type of SPECIAL, there may be no message in the joblog

Possible choices for replying to message . . . . . . . . . . . . . . .D -- Obtain RPG formatted printout of system storage.S -- Obtain printout of system storage.F -- Obtain full formatted printout of system storage.

OL866220

Page 20: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-20

Using the Joblog as a Debugging Tool (2/2)

�3.�Joblog

4>> CALL OL86V3LIB/BFRSUBSTFile BFDSUBST in library *LIBL not found or inline data file missing.Error message CPF4101 appeared during OPEN for file BFDSUBST.Function check. RNX1216 unmonitored by BFRSUBST at statement 0001000001,

instruction X′ 0000 ′ .Error message CPF4101 appeared during OPEN for file BFDSUBST (C S D F).Error message CPF4101 appeared during OPEN for file BFDSUBST (C S D F).

OL866225

Page 21: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-21

OL86610L

Page 22: IBM AS400 RPG IV Training Course(Course Code OL86)--7

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

06

-22

Unit Summary

Having completed this unit, you should be able to:

• Describe the benefits of source view and listing view debugging

• Use compile options to specify desired level of debugging

• Use the source debugger to use:

− breakpoints− display and change values of program variables− step through the execution of an RPG IV program

• Use the “watch” feature of the ILE DebuggerOL866999