Published on System iNetwork (http://systeminetwork.com)
The System i5 Debugger and Service Entry Points
By linda.harty@penton.com
Created Dec 11 2008 - 05:39

By:
Scott Klement [1]

In my opinion, one of the most exciting developments in debugger technologies is Service Entry Points (SEPs). SEPs make it easy to debug a program without regard to where it runs. With SEPs, debugging a batch job, server job, or trigger is just as easy as debugging an interactive application.

My favorite debugging tool is the System i5 Debugger. I prefer it over both the green-screen (STRDBG) debugger and the one included with WDSC/RDi. I recently learned that the System i5 Debugger supports SEPs! In this article, I show you how to use them.

The System i5 debugger is a GUI tool for debugging programs that run on the IBM i platform. It supports debugging OPM RPG, OPM CL, OPM Cobol, ILE RPG, ILE CL, ILE Cobol, ILE C, ILE C++, Java, and PASE C/C++.

The System i5 Debugger is included as part of the Toolbox for Java (57xx-JC1) licensed program, which is included with the IBM i operating system, so you won't have to shell out any extra money for it. Contrast this with the Interactive Source Debugger (STRISDB)—which supports relatively few languages and requires you to purchase ATDS—or the RDi debugger, which requires you to pay for RDi.

Since RDi's debugger has a GUI, as does the System i5 debugger, it's similar to the System i5 Debugger in many ways. Both support most of the same features and are written in Java. However, the System i5 debugger is cross-platform, unlike the RDi one, which runs only under Windows. The System i5 Debugger also requires less memory and is simpler to use than the RDi debugger. Even with these advantages, I still used RDi's tool until recently because I didn't realize that the System i5 debugger could use SEPs!

Getting Started with the System i5 Debugger

In "STRDBG Can Be GUI!" [2] (February 24, 2005, article ID 20545), I discussed how to get started with the System i5 Debugger. As that article is nearly four years old, some parts of it might be out of date. IBM documents the System i5 Debugger in the Information Center under Programming|Development Tools|System i5 Debugger. [3]

Furthermore, I recently discovered that the System i5 Debugger can be launched from within IBM i Navigator. To start it from Navigator, click your computer's name, then Databases. Select the database you use on your system, then click Run an SQL Script. From the Run SQL Scripts window, click Run|Debugger.

Getting Started with SEPs

SEPs provide a way of setting a breakpoint in debug so that any time your user ID(or another user ID that you designate) runs a given program, it triggers the breakpoint and opens the program in the debugger. Regardless of whether the program is run interactively or in a batch job or a server job, anytime the program is run by that user, it opens in debug automatically.

To learn more about SEPs, and how to use them with STRDBG or the RDi debugger, please see "An Easier Way to Debug Batch Jobs" [4] (January 25, 2007, article ID 53910).

Using SEPs in the green-screen debugger is very awkward, as it does not start the debugger for you, but instead just sends you the job name, user ID, and job number. You still have to run the Start Service Job (STRSRVJOB) command manually to debug the job.

By contrast, in the RDi debugger, you simply tell the system which program to debug with a SEP. That's all you have to do, and as soon as the program is run, it automatically pops up in the RDi debug perspective and gives you a chance to set breakpoints or step through the code or do whatever the circumstance dictates. This functionality makes SEP very easy to use from the RDi debugger.

SEP in the System i5 Debugger

The System i5 Debugger's support for SEPs is somewhere in between the green-screen method and the RDi method. It's not quite as easy or elegant as RDi, yet it's nowhere near as awkward as the green-screen tool.

To try SEPs from the System i5 Debugger, do the following:

  1. Start debug from the System i5 Debugger.
  2. Select Submit and debug program in batch job. (It doesn't matter if this will be a batch or interactive program; you just need a way to get your program's source to display in the debugger.)
  3. Click to the left of the statement number on any line in your source. A red arrow should appear to mark it as a break point.
  4. Right-click the arrow and choose Breakpoint properties.
  5. Change the Breakpoint style to Service Entry Point.
  6. Click OK to return to the display of the source code. The SEP breakpoint is set!
  7. The next time the user ID you selected runs the program you selected, a dialog box will appear on your PC to tell you that the service entry point was encountered and ask you if you want to debug the job. Click Yes.
  8. A new System i5 Debugger window will open with the program stopped at the line on which you inserted the SEP breakpoint. From that point, you can step through the code, display variables, set more breakpoints, and so forth, just as you would in a normal debug session.
  9. The original window with the SEP breakpoint will remain open. Keep it open as long as you want that SEP breakpoint to stay active. Ending debug, or closing that window will stop the SEP breakpoint from firing.

Here's a screenshot that shows what it looks like when you change a breakpoint's properties to use SEPs:
SEP Properties

Here's a screenshot that shows what it looks like when the SEP breakpoint has fired in the System i5 Debugger:
SEP Notification

© 2010 Penton Media, Inc.

Source URL: http://systeminetwork.com/article/system-i5-debugger-and-service-entry-points

Links:
[1] http://systeminetwork.com/author/scott-klement
[2] http://systeminetwork.com/node/61011
[3] http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/topic/rzamq/rzamqmain.htm?tocNode=int_98900
[4] http://systeminetwork.com/article/easier-way-debug-batch-jobs