Developer's Guide to the ILE Debugger

18
2 EXECUTIVE DRIVE, SUITE 430, SOMERSET, NJ 08873 RxClaim Development Developer’s Guide to the ILE Debugger Version <1.0> Version Date: <04/17/12> STRICTLY PRIVATE, PROPRIETARY AND CONFIDENTIAL FOR INTERNAL DISTRIBUTION ONLY

Transcript of Developer's Guide to the ILE Debugger

Page 1: Developer's Guide to the ILE Debugger

2 EXECUTIVE DRIVE, SUITE 430, SOMERSET, NJ 08873

RxClaim Development

Developer’s Guide to the ILE Debugger

Version <1.0>

Version Date: <04/17/12>

Written ByCandy Slackman

CONTENTS

STRICTLY PRIVATE, PROPRIETARY AND CONFIDENTIAL

FOR INTERNAL DISTRIBUTION ONLY

Page 2: Developer's Guide to the ILE Debugger

Overview....................................................................................................................................1

Debug a Batch Job.....................................................................................................................2

the Interactive Debugger............................................................................................................5

Index.........................................................................................................................................11

Table of Figures.......................................................................................................................12

Glossary....................................................................................................................................13

STRICTLY PRIVATE, PROPRIETARY AND CONFIDENTIAL

FOR INTERNAL DISTRIBUTION ONLY

Page 3: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

OVERVIEW

Debugging a batch job is easy with the source debugger available with ILE. The source debugger can be used with any ILE program, in any ILE language. It works with Cobol, CL, and RPG. It works with interactive jobs as well as batch jobs. It can go seamlessly from one program to the next.

Most of the programs in RxClaim will tell you you’re not authorized to debug, but that’s easy to get around if you recompile them in one of the dev libraries, or your own if you’re lucky enough to have one.

There’s also a utility called ASTRDBG that RxClaim supplies to deal with the authority issues, but it’s pretty much useless.

Figure 1 – ASTRDBG

Most of the RxClaim programs were not compiled with debug in mind, so displaying the source code (DSPMODSRC) usually brings up a blank screen like the one below.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 3 of 15

Page 4: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

Figure 2 – DSPMODSRC

You’re generally better of just recompiling in a test library. Follow the steps below to debug any batch job.*

DEBUG A BATCH JOB

1. Compile your ILE source using DBGVIEW (*SOURCE) OPTION(*SRCSTMT:*NODEBUGIO)

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 4 of 15

Page 5: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

Figure 3 - Options *SRCSTMT & *NODEBUGIO

Figure 4 - DBGVIEW(*SOURCE)

2. Submit the job with the HOLD (*YES) parameter: SBMJOB HOLD(*YES) or Hold the job queue that before submitting the job by using the HLDJOBQ command.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 5 of 15

Page 6: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

3. Determine the job name, user, and number of the submitted job by using the WRKSBMJOB command.

Figure 5 - Find Job Attributes

4. Start servicing the submitted job using STRSRVJOB JOB(number/user/name) (Start Service job), where "number", "user' and "name" are attributes retrieved from the submitted job.

5. Start the debugger using STRDBG PGM(library/program) UPDPROD(*YES) (Start Debug)

6. You are now in the display module source (DSPMODSRC) screen. Don't try to debug or add breakpoints. It's too early. The job must be active first. Leave this screen using F12.

7. Release the job in the jobq. Type WRKSBMJOB and then put a 6 beside the job to be released and press enter, or, if the job queue was put on hold, release the job queue with the RLSJOBQ command.

8. When the job is activated, the start service job window comes. Use F10 to enter debug command.

9. Use DSPMODSRC (Display module source) command to go back to the source and add breakpoint wherever you want, using F6, or just enter the ADDBKP command on the command line.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 6 of 15

Page 7: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

10. Use F12 to resume the job, and F12 once again to go back to the start service job window.

11. Use Enter to launch the job.

12. The process breaks at the first breakpoint installed and gives you the control. (Now it works as the interactive debugger. You can do anything here that you would normally do interactively).

13. Debug....my friend (see the section below for details on the interactive debugger).

14. When the job is finished, you receive a 'Job being serviced ended' message.

15. Use ENDDBG command to end debug.

16. Use ENDSRVJOB to end servicing

*Note: These steps were copied from 2 Articles: ‘How to debug a batch ILE RPG’ written by Thierry Schmitz and published: 1 Jun 2004, and Debugging batch jobs by Russell Rollins published in October 2001. I combined the best of both articles. They were displayed on website: http://search400.techtarget.com/news/968098/How-to-debug-a-batch-ILE-RPG

THE INTERACTIVE DEBUGGER

From the DSPMODSRC screen you can set up your breakpoints, add more programs, check or change variables, etc. This is a really powerful tool that allows you to run your program line by line modifying and trying different outcomes.

You can either step thru the program line by line, or you can stop it at selected lines in the code. Once the program is stopped at the DSPMODSRC screen you can end the program, view any variable that you want, change the value of any variable, set a watch on a variable, run a command from the command line, pretty much anything you want to do.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 7 of 15

Page 8: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

Figure 6 - DSPMODSRC Screen

F3 from this screen will always end the program when it’s stopped on this screen. F6 allows you to set breakpoints. Position the cursor on the line where you want the program to stop. It will always stop right before it executes that line. The DSPMODSRC screen will be displayed at each breakpoint and you will have access to all of this functionality.

In addition, F13 will allow you to work with breakpoints. You can add and clear breakpoints on this screen, and more importantly you can set conditional breakpoints.

Figure 7 - Conditional Breakpoints

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 8 of 15

Page 9: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

To add a conditional breakpoint, place a 1 in the option field, enter the line number, and then specify the condition. For example, the condition FDPOPR = ‘U’ will cause the program to break at line 77.00 only when field FDPOPR is ‘U’. This is a great timesaver in a big program!

If you want to see each line of the program, you can set a breakpoint on the first line, then press F10 each time you want to execute a line. At any point in the debugging process you can opt to execute just the next line by pressing F10. You don’t have to use just steps, or just breakpoints, you can use a combination of both. When you want the program to continue running normally until it hits the next breakpoint, press F12 to resume processing.

Anytime you want to view the value of a variable, position the cursor anywhere in the program where the field name appears and press F11. The value of the field will be displayed in the lower left hand corner. If the field is a subfield of a data structure, or an array element, it will be displayed on a separate screen along with the rest of the data structure.

Figure 8 - Display Variable

You can also set a watch on a variable. If you want to know whenever the variable changes, but you don’t want to step thru the program line by line, you can position the cursor to the variable anywhere on the screen and press F17. This has the effect of adding a break point anytime that variable is changed.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 9 of 15

Page 10: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

Figure 9 - Watch Variable

Pressing F18 will allow you to view and work with all watches that you have active. You can clear or display each watch on this screen.

Figure 10 - Work with Watch

When the program is stopped on the DSPMODSRC screen you can press F21 to get a command line. This allows you to enter commands to work with files, etc.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 10 of 15

Page 11: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

Figure 11 - Command Line

Another important function key is F14. This screen allows you to add other programs to the debug process. ILE programs can all be run in this debugger, regardless of language. Cobol and CL programs will run right along with RPG as long as they’re compiled as ILE. When another program is called, the debugger will allow you to continue stepping thru that program the same way if it’s been added to the debugger. From this screen you can manage all of your programs and modules and set breakpoints. The debugger flows seamlessly from program to program.

Figure 12 - Work with Module List

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 11 of 15

Page 12: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

There are a few other function keys specified, but these are the ones that you’ll use most. As always you can press F1 or F4 for help on all of these screens, or go to the IBM library for the user guides. But overall this debugger is much easier to use than the old one, and fairly quick to learn. It involves a lot less setup and typing, as long as your modules and programs are compiled correctly. You can specify these options on the H specs in your RPG programs so you don’t have to worry about having someone else compile them with the proper values. These keywords are all available for the H specs now.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 12 of 15

Page 13: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

INDEX

*

*NODEBUGIO..........................................2, 3*SRCSTMT................................................2, 3

A

add programs...................................................9ADDBKP........................................................4ASTRDBG......................................................1

B

breakpoint......................................................4breakpoints................................................4, 6

C

clear a watch....................................................8clear breakpoints.............................................6command line..................................................8Compile OPTION..........................................2compile options.............................................10Compile Options............................................2conditional breakpoint.....................................7conditional breakpoints...................................6Conditional Breakpoints..................................6

D

DBGVIEW......................................................3DBGVIEW (*SOURCE)...............................2DBGVIEW(*SOURCE)..................................3display variable...............................................7DSPMODSRC.........................................1, 4, 5

E

ENDDBG........................................................5ENDSRVJOB..................................................5

F

F1...................................................................10F10..................................................................7

F11..................................................................7F12...................................................................7F13..................................................................6F14..................................................................9F17..................................................................7F18..................................................................8F21..................................................................8F4...................................................................10F6....................................................................6Find Job Attributes..........................................4

G

Glossary.........................................................13

H

H specs..........................................................10

R

recompiling in a test library............................2resume processing...........................................7

S

set breakpoints.................................................6STRDBG........................................................4STRSRVJOB.................................................4

T

Table of Figures............................................12

U

UPDPROD(*YES).........................................4

W

watch a variable...............................................7work with breakpoints.....................................6Work with Module List...................................9work with watches...........................................8WRKSBMJOB..............................................4

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 13 of 15

Page 14: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

TABLE OF FIGURES

Figure 1 – ASTRDBG.............................................................................................................................1Figure 2 – DSPMODSRC........................................................................................................................2Figure 3 - Options *SRCSTMT & *NODEBUGIO................................................................................3Figure 4 - DBGVIEW(*SOURCE).........................................................................................................3Figure 5 - Find Job Attributes..................................................................................................................4Figure 6 - DSPMODSRC Screen.............................................................................................................6Figure 7 - Conditional Breakpoints.........................................................................................................6Figure 8 - Display Variable.....................................................................................................................7Figure 9 - Watch Variable.......................................................................................................................8Figure 10 - Work with Watch..................................................................................................................8Figure 11 - Command Line......................................................................................................................9Figure 12 - Work with Module List.........................................................................................................9

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 14 of 15

Page 15: Developer's Guide to the ILE Debugger

Debugging ILE Jobs

GLOSSARY

batch program: Any program that’s submitted to run in a subsystem. Non-interactive jobs.

breakpoint: Any line of code where you want the program to halt. You can check and change variables while the program is paused, then continue on.

Step through: You can step through any program by setting a breakpoint at the beginning, then pressing F10 to execute just the next line of code. By pressing F10 at each line you can ‘step through’ the program. Alternately you can set breakpoints to force the program to stop only at selected points throughout the program.

How To – Debugging ILE Jobs 03-23-2012

GalaxE.Solutions® Confidential Proprietary Information, All Rights ReservedPage 15 of 15