09
Thu, May
2 New Articles

The Evolution of De Bug

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Over the past few years, the programming languages available on the AS/400 have evolved into more than simple report-generating programming tools. RPG itself has progressed, with the introduction of ILE, into a means to produce code that is reusable throughout entire application systems.

Putting to use the creation of modules and service programs in your applications makes previously used CALLs and subroutines copied from program to program no longer necessary. This makes code easier to write and maintain because programmers are able to encapsulate smaller functions into external pieces of code, usable from the major pieces of application software. In turn, this also makes code easier to debug because, if one of these modules is performing wrong in one program, it will also be performing wrong in every other instance that it is used.

Finally, making use of ILE in applications makes fixing bugs easier. This is because, if the bug is contained within a service program, fixing it is as simple as correcting the module code, re-creating or updating the service program, and applying the fixed code to the live environment. In the past, some of these fixes required going through every program containing the subroutine with the error, recompiling, and moving these updated programs into production—something most programmers didn’t enjoy.

Enter the ILE Debugger

The movement to ILE, or even simply to RPG IV, forced programmers once again to learn something new. It seems to always work this way. As soon as you master one thing, something newer comes along. Usually this new piece of technology is vaguely similar to its predecessor. What I am referring to is the move from the Interactive Source Debugger (ISDB) to what is called the ILE Debugger.

This is a necessary change because ISDB doesn’t work on ILE objects. This includes program attribute types RPGLE and CLLE, as well as modules and service programs. So, you have two choices: Stick with Original Program Model (OPM) RPG and ISDB or make the move to ILE and learn a few new tricks to debugging. I hope you choose the latter, which is a much more rewarding move. In the following sections, I will compare and contrast the two debuggers to help make the transition a little easier and maybe give a nudge to those of you still on the fence.


Old Faithful vs. the New Kid on the Block

It’s hard to compare two tools that work on totally different object types. If you’re using an OPM programming language, such as RPG III, you really don’t have much of a choice but to use ISDB. By the same token, if you’re programming with RPG IV or any other ILE programming language, then the ILE Debugger is your tool of choice. But if you’re planning on making the switch from RPG III to RPG IV, or you want to brush up on your debugging knowledge after making the switch, this information should help.

Figure 1 (page 122) shows a list of common commands for both debuggers. Viewing the help available for either debugger is a great starting place to get familiar with all the commands. Both debuggers have help screens that are interactive. They start by listing available commands, as well as any shortcut commands, you can use. Moving your cursor over one of the commands and pressing Enter will bring up an extended description of that command. I find this type of help screen intuitive and easy to navigate.

The biggest difference between these two debugging tools is how they display a variable. Both debuggers still allow you to move your cursor to the variable you wish to see and press F11. But, on the command line, you use the Display (DSP) command with ISDB and the EVAL command with the ILE Debugger.

The DSP command doesn’t exist in the ILE Debugger, but a similar command, DISPLAY, does. This command, however, is used to display expressions set up with the EQUATE command or to display a different module’s source code.

The EVAL command can also be used to change the contents of a variable; ISDB uses the Change (CHG) command. Finally, if you like putting “watches” on variables, ISDB uses the WATCH and UNWATCH commands to place and remove watches, respectively, on fields. With the ILE Debugger, the WATCH command is still used to place a watch, but to remove one, you specify the WATCH command with no arguments, displaying a list of the current watches assigned. You then use the Clear option (option 4) to remove a watch.

You’ll also notice that ISDB offers a couple of commands not available in the ILE debugger. These are mainly the Print (PRTxx) commands. I had never used these commands in ISDB before, and, when I tried them out, I was pleasantly surprised to find out what they did, even though it wasn’t really anything more than a print screen of the DSP command.

Although some of the niceties of ISDB were not implemented in the ILE Debugger, such as color-coding the source, some of the annoyances are also missing. For example, when using ISDB to display or print a variable’s contents, the display was limited to the first 200 characters of the field. If you’re like me, you build large query select statements in a CL; this could cause a problem. The ILE Debugger seems to have no limit in the size of a variable it can display.

Figure 2 shows a list of common function keys used in each debugger. It seems again that ISDB wins hands down for functionality and ease of use. Of course, the only commands extant in ISDB that are absent from the ILE Debugger are the aforementioned print commands.

The biggest change in command keys is the STEP command key, which allows you to step, line by line, through the source code. ISDB uses F5, and the ILE Debugger uses F10. How to tell the debugger to run until the next breakpoint or variable being watched differs as well. For IDSB, you use the F17 key. The ILE Debugger uses F12. One great improvement with the ILE Debugger is the addition of the Step Into (F22) function key. This allows you to step into a call to another program or a subprocedure (more on the F22 function key later in this article).

ILE Debugger Views

Before you can begin to debug your ILE programs, you need to know that there are some defaults on the CRTxxx commands that allow you to control the level of debug. This


option on the Create Bound RPG Program (CRTBNDRPG) and Create RPG Module (CRTRPGMOD) commands, is the Debug View (DBGVIEW) option. The values available for this option are *NONE, *STMT, *SOURCE, *LIST, *COPY, and *ALL. Figure 3 contains a reference to these options, as well as a short description of each.

*NONE is fairly self-explanatory. It will not allow debugging on the program at all. *STMT is reminiscent of the days when you had to debug without a view of the source. It allows you to debug your programs, but it lets you step through the source so you can see where you are. *SOURCE gives you a listing to view when debugging, to keep track of your place in the program. This option shows the source exactly as it is displayed in the source file; for example, the /COPY data is not copied into the listing, or files are not expanded. *LIST creates a view similar to a compile listing. Files are expanded, and /COPY members are displayed in the view. *COPY will copy the /COPY members into the view, but, other than that, it’s the same as using *SOURCE. *ALL creates all of the views I just mentioned.

Some ILE Debugger Tricks

Since I haven’t really programmed an RPG III program for quite some time, I have grown unfamiliar with the ISDB. But researching this article brought back a few memories. It also made me appreciate one command in the ILE Debugger that makes viewing programs or subprocedures called by a program much easier. This is the Step Into (F22) function key I mentioned before. If you program using “real” ILE, then you no doubt use a bunch of service programs and modules. When you are on a command that calls one of your subprocedures, using the Step Into function key brings you right into that subprocedure. This is, of course, if you used one of the compile options that allows you to see the source while debugging.

This may seem pretty straightforward on commands such as CALL or CALLP, but what about those subprocedures that return a value? Assume you have a subprocedure that is passed a string of text and returns it centered. The call would look something like this:

Eval Result = Center(Text)

In this case, Center() is the function that returns centered text. To step into this call and debug the subprocedure behind it, simply use the F22 key. The same goes if the function is used on a SELECT or IF statement.

One problem with the ILE Debugger up until V4R4 (or by applying the appropriate service pack for versions down to V3R2 as shown in Figure 4) is that, if you are debugging and come to an I/O statement, such as READ or CHAIN, you have to use the Step function key a few times until it goes past that statement. Well, IBM heard your cries and now allows you to specify a compile option (or H-spec), telling the debugger to skip over these commands. Specifying OPTION(*NODEBUGIO) on the CRTxxx command will determine if breakpoints are specified for I/O operations.

We All Get Bugs

As perfect as most of you are at turning out great code, it is inevitable that, at one point or another, you’ll end up with a bug in your code. IBM has supplied a couple of debuggers that help programmers help themselves find these bugs. It never fails. Sure, neither is perfect, but whether you’re using OPM RPG or diving into the wonderful world of ILE, there is something there to help.

REFERENCES AND RELATED MATERIALS

• AS/400 ILE Concepts V4R1 (SC41-5606-00, CD-ROM QB3AQ700)
• ILE RPG for AS/400 Programmer’s Guide (SC09-2507-01, CD-ROM QB3AGY01)
• Interactive Source Debugger (SC09-1897-00, CD-ROM QBKASS00)


Debugger Command ISDB ILE

Display variable contents DSP var or F11 on variable Eval var or F11 on variable Display variable contents in hex DSPHEX var Eval var:x Print variable contents PRT var N/A Print variable contents in hex PRTHEX var N/A
Watch a variable WATCH var WATCH var Watch a variable in hex WATCHHEX N/A Stop Watching a variable UNWATCH Clear watch in Work with

Watches display (WATCH command with no parameters). Change a variable Value CHG var value Eval var=value

Figure 1: This is a list of common commands for both the ISDB and the ILE Debugger.

Debugger Function Key ISDB ILE

Step F5 F10 Run F17 F12 Add/Remove Breakpoint F6 F6 Print variable contents in hex PRTHEX var N/A Watch a variable WATCH var WATCH var Watch a variable in hex WATCHHEX N/A Stop Watching a variable UNWATCH “WATCH, then select remove from list” Step into N/A F22

Figure 2: Here are common function keys for the ISDB and the ILE Debugger.


Debug Compile Option Meaning

*NONE No debugging is available *STMT Allows debugging using the line numbers or statement numbers of the compile listing.
*SOURCE Provides a source view for debugging the compiled object.
*LIST Provides a listing view for debugging the compiled object.
*COPY Provides a source and copy view for debugging the compiled object. *ALL Provides source, listing, and copy views for debugging the compiled object.

Figure 3: This list shows debug options used when compiling ILE programs.

Release PTF

V3R2 SF46001 V3R6 SF45749 V3R7 SF46327, SF47056 V4R1 SF46327, SF47056 V4R2 SF45191, SF46944, SF47055 V4R3 SF45191, SF46944, SF47055

Figure 4: These are the PTFs needed to enable the *NODEBUGIO options.


BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: