fhg
Volume 12, Number 24 -- October 3, 2012

Debugging Server Jobs In Green Screen

Revised: October 3, 2012

by Susan Gantner

A few years ago, I wrote a tip about my favorite way to debug programs using the Service Entry Point (SEP) feature of WDSC, which I have now replaced with RDP Rational Developer for Power Systems. If you're a WDSC or RDP user and have somehow missed out on using SEPs for debugging, take a look at my tip.

If you don't use WDSC or RDP, you probably didn't pay any attention to that tip. As it turns out, SEPs aren't just for the graphical toolset. You can use SEPs with the traditional STRDBG "green screen" debugger as well.

You may be wondering why you should care? STRDBG works just fine as is, right? For interactive jobs, yes. Even for batch jobs when you're in control of the submission and can hold the job or the queue to do a STRSRVJOB, it works. But most shops are finding they have many other types of jobs that don't fit into those categories. What about web server jobs, such as those servicing CGI requests or database server jobs servicing stored procedure calls, from other platforms or exit programs? There are often multiple jobs servicing those requests, so just finding which job to service can be a challenge.

What if you could just specify the program you wanted to debug and the system would notify you when that program started to run in any of the available server job, or any other kind of job, for that matter? That's what SEPs do for you. And you can use them from the STRDBG green screen debugger.

An SEP is a breakpoint that will cause the program to stop when it is run in any job anywhere on the system by a specific user profile when the breakpoint is encountered.

Here's how. First, begin your debug session using STRDBG as you normally would, specifying the program you want to debug and any other options you may need. As usual, the source for the program appears. Find the statement number of a statement in the program, preferably near the beginning. This is where the program will stop once the SEP is triggered, giving you the chance to step or set other breakpoints.

Add a Service Breakpoint on that statement. There is no function key for setting a Service Breakpoint, so to do this, go to the debug command line and use the sbreak command. For example:

sbreak 105

In addition to the statement number, you also have the option of putting a user profile name in.

sbreak 62 user QUSER

If you don't specify a user, it will assume your user profile. Once you have entered the sbreak command, press F12 to exit the module source view.

Next, do whatever action it takes to cause that program to run with the specified (or assumed) user profile. What should happen next is that a message comes back to the job where you started the debug session. The message will look something like this:

Service Entry Point has stopped at line 3 in program LIBNAME/PGMNAME

You may notice that the line number where the message says it stopped is not the same as the statement number you specified for the Service Breakpoint. Don't worry about it. This number is a different type of line number to your source statements.

Position on that message and press F1 to get the full details for the message. In the details, you will see something like this:

Recovery  . . . :   This program must be debugged from a servicing job. Do a
Start Service Job (STRSRVJOB JOB(961729/GANTNER/QPADEV0003)). Then do
Start Debug (STRDBG) on the spawned job from where the STRSRVJOB was done.
Set a local breakpoint at or after the Service Entry Point. Return to the
original job and press enter to release the spawned job.

Leave this message there for the moment; do not press Enter yet. This is an unusually helpful message. Note that you can actually copy and paste that STRSRVJOB command with the job parameter on a command line. One detail that may not be clear from the message is that you must run the STRSRVJOB and STRDBG commands from another job, not the one where the message is displayed (hence the reference to a "servicing job").

Start another emulation session and paste the STRSRVJOB command onto a command line. Then issue (another) STRDBG command for the program in that job. As before, this will cause the source to appear. This time, you'll see that the source shows that the program has stopped on the statement where you put the Service Breakpoint (sbreak) earlier.

Set an ordinary breakpoint, using F6 or the Break command, on either that same statement or a later one. Go back to the original job where you did the first STRDBG (it should still be stopped at the message) and press Enter to reply to the message. At that point, or any time later, you can ENDDBG on the job where the message was.

Now you're in a debug session in the second emulation job. You can set any other breakpoints you like or use Step or whatever else you want or need to do to debug the program. You may notice that if you use Step, it will momentarily jump back to the service breakpoint before stepping to the next line of code. It seems a little strange, but otherwise, the debug session works much like an ordinary interactive debug session, albeit perhaps a bit more sluggish.

Don't forget that after you ENDDBG, you should also ENDSRVJOB before going on with the rest of your day.

If the process seems a bit cumbersome, you're right. The debugger with RSE that I described in the earlier tip does a lot of these steps for you, significantly simplifying the process. Still, compared to what actions would be required to debug these server or batch jobs, it is a very useful tool if you're stuck using the green screen debugger.

There are a few limitations I should mention related to Service Entry Points. SEPs came in at V5R2, so only programs that have been compiled since V5R2 can take advantage of them. Furthermore, the program that you use to get control of the job (the one where you use the sbreak command) must be a source member type that ends in LE, e.g., RPGLE, CLLE, CBLLE, etc. You can still debug non-LE programs once the debug process begins, but you can't put a service breakpoint into a program unless it is an "LE" type program.

I won't be using this process much in the future myself, because I much prefer doing my debugging with the RSE tool in RDP, as I covered in my previous tip. But if you don't have that option, SEPs are a big help for debugging in these situations.


Susan Gantner is half of Partner400, a consulting company focused on education on modern programming and database techniques and tools on the IBM i platform. She is also a founding partner in System i Developer, a consortium of System i educators and hosts of the RPG & DB2 Summit conferences. Susan was a programmer for corporations in Atlanta, Georgia, before joining IBM. During her IBM career, she worked in both the Rochester and Toronto labs, providing technical support and education for application developers. Susan left IBM in 1999 to devote more time to teaching and consulting. Together with Jon Paris, she now runs Partner400, and appears regularly at many technical conferences, including System i Developer's RPG & DB2 Summit. Send your questions or comments for Susan to Ted Holt via the IT Jungle Contact page.


RELATED STORY

Three Little Words That Simplify Debugging



                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
BUG BUSTERS SOFTWARE ENGINEERING

RSF-HA Keeps You Going While it Saves You a Bundle

 

                                          · Replicate your entire system for High Availability.
                                          · Easy to set up. Easy to monitor.
                                          · Full role swap support.
                                          · Mirror libraries, IFS directories, user profiles, configuration
                                              changes, spooled files and more!

 

                                          · All this, at a price that will make you smile.

 

Bug Busters has been providing quality software solutions
for the iSeries and AS/400 since 1988.

 

Download a Free Thirty-Day Trial:
www.bugbusters.net


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

Sirius Computer Solutions:  A comprehensive, cost-effective cloud solution for IBM i users
Tributary Systems:  Storage Director® makes your tape work better. FREE Webinar and PDF
System i Developer:  RPG & DB2 Summit, Oct 23-25 in Minneapolis. Register by Oct 12 to save $100!


 

IT Jungle Store Top Book Picks

BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

The iSeries Express Web Implementer's Guide: List Price, $49.95
The iSeries Pocket Database Guide: List Price, $59
The iSeries Pocket SQL Guide: List Price, $59
The iSeries Pocket WebFacing Primer: List Price, $39
Migrating to WebSphere Express for iSeries: List Price, $49
Getting Started with WebSphere Express for iSeries: List Price, $49
The All-Everything Operating System: List Price, $35
The Best Joomla! Tutorial Ever!: List Price, $19.95


 
The Four Hundred
Some Things To Ponder On The Impending Power7+ Era

iBelieve NY: If You Don't Like Change. . .

Arming The IBM i Nation

Mad Dog 21/21: Shamoon And Six Trends

IBM's Rometty Takes Over As Chairman Of The Board

Four Hundred Stuff
Coglin Mill Reaches Out to Salesforce.com with ETL Connector

Infor Rolls Out Cloud for Heavy Equipment Biz

Android or iOS: Which Mobile OS Fits Best with IBM i?

Remain Software Adds to Multi-Platform Choices

Joomla Now Optimized for Mobile Devices

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
September 29, 2012: Volume 14, Number 39

September 22, 2012: Volume 14, Number 38

September 15, 2012: Volume 14, Number 37

September 8, 2012: Volume 14, Number 36

September 1, 2012: Volume 14, Number 35

August 25, 2012: Volume 14, Number 34

TPM at The Register
Fujitsu, Oracle pair up on future 'Athena' Sparc64 chips

Oracle customers DEMANDED infrastructure cloud

Big mainframe shops embiggen, says BMC survey

Big Blue: 'New PureSystem? Madness? No, THIS IS SPARTA!'

Oracle cranks up the flash with Exadata X3 systems

AMD, Oracle tag-team on GPU acceleration for Java apps

Oracle fudges touts Sparc SuperCluster prowess

OpenStack gets "Folsom" release out on time

Quantcast gives the boot to Hadoop's HDFS

'Double Stuf' Power7+ sockets: Yummy, but so is overclocking

HP pitches four-socketeer Xeon E5 borg boxes

Chambers says Cisco is mulling succession plans

THIS ISSUE SPONSORED BY:

Bug Busters Software Engineering
WorksRight Software
Connectria Hosting


Printer Friendly Version


TABLE OF CONTENTS
Debugging Server Jobs In Green Screen

Alternatives To SQL Literals

Admin Alert: Seven Things You Should Be Monitoring On Your System

Four Hundred Guru

BACK ISSUES




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2012 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement