04
Mon, Nov
5 New Articles

From RPG to Java: A New Era in AS/400 Debugging

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

Most AS/400 programmers would agree that writing new code is a far more interesting task than finding problems in existing programs. Figuring out problems in your own code is not too bad because you usually have a relatively clear idea about what is going on. It is a much more difficult task to fix bugs in someone else’s program. Without a good set of debugging tools, even very simple bugs may take days or weeks to find.

For years, AS/400 programmers have been using System Debugger and the Interactive Source Debugger (ISDB). Both tools are fairly powerful and provide solid debugging capabilities. Yet both have a green-screen interface. This may be sufficient for some debugging tasks, but it is not as elegant or effective as a GUI. Most of the current debugging tools on PC and UNIX provide point-and-click features because debugging is one of those tasks that truly benefits from a GUI. To further complicate matters, with Java becoming a major language on the AS/400, we may see a large number of workstation programmers developing client/server applications on the AS/400. More and more developers will no longer feel comfortable with the green-screen tools.

Foreseeing these difficulties, IBM has developed a number of client/server tools that give developers the full advantage of a GUI while still targeting the AS/400 platform. You may already be familiar with products like CODE/400 and VisualAge for RPG. Currently, both of these products are being marketed as an ADTS Client Server for AS/400 solution. The client part of these products runs on Windows 95 and Windows NT
4.0 platforms, while the server supports all RISC releases of OS/400 and V3R2. ADTS Client Server for AS/400 integrates a set of tools including a Live Parsing Extendable (LPEX) editor, program verifiers, an AS/400 graphical screen designer, and both the Cooperative Debugger and RPG workstation debugger. The ADTS product allows programmers to develop AS/400 applications from their PC desktops. One of the latest

client/server products released by IBM is VisualAge for Java. It incorporates a set of Java development tools for the AS/400, the workstation, and 390 platforms.

The Cooperative Debugger

The client/server tool that I will be describing in detail is the Cooperative Debugger. Following the footsteps of the AS/400 System Debugger, the Cooperative Debugger allows the debugging of applications written in most available languages, while bringing to the developer’s disposal the power of a GUI. This debugger supports Original Program Model (OPM) and ILE languages, including CL, RPG, COBOL, C, C++, and Java. Moreover, it allows the debugging of programs that consist of modules written in various languages. This will become more and more important as a large number of the legacy applications written in RPG or COBOL will be enhanced using Java or C++. It is no surprise that IBM packages Cooperative Debugger as a part of ADTS Client Server for AS/400 as well as the VisualAge for Java AS/400 feature.

What makes Cooperative Debugger attractive to AS/400 programmers? For those who come from a workstation background, the debugger offers the familiar look and feel of a workstation debugger. The GUI is very similar to that of the VisualAge family of debuggers. For green-screen developers, Cooperative Debugger gives an all-new point- and-click appearance while still preserving the feel of the AS/400 System Debugger. It makes debugging batch jobs easier than ever. As a matter of fact, the programmer does not even need to specify whether the debugged job runs interactively or in batch, or whether the program is OPM or ILE—the debugger takes care of all these details.

Another advantage of the GUI is that all the required screens of information can be displayed at the same time. There’s no need to press some function key or Enter to switch from a Source Code view to the Call Stack or Variable Monitor views. All windows are in front of the user, easily sizable to one’s liking, and kept in synch during program execution.

Debugger Windows

The name of the Debugger - Session Control (DSC) window says it all. Shown in Figure 1, it is the main window for the current debug session. It serves the purpose of the main control panel, where you can add new programs, service programs, modules, and classes to the debug environment. Also, the DSC window lists those modules, classes, procedures, and methods that constitute a program.

From this list, you can select the source to be displayed for an ILE module or C++ class. All these actions are initiated by clicking on the entries in the right portion of the DSC container.

This window roughly corresponds to the Add Module Source panel of the System Debugger. However, it offers a richer set of attributes than its green-screen counterpart. From the DSC, the user can do the following:

• Issue program execution commands such as Run and Restart
• Search for a particular procedure or current execution point
• Bring up stack and local variable monitors
• Display the Line and Watch Breakpoint dialogs From the DSC window, the user can tailor the global debugger settings, such as default data representations for various language groups, program profiles, monitor properties, and window presentation properties. The user can also terminate the debug session from the DSC window by pressing F3.

Each debug session can have only one control panel and hence only one DSC window. The Debug Source window (see Figure 2) is a different story. While the user debugs an AS/400 program, only one module can contain the current execution line. But

the user may choose to display the source for a few different modules simultaneously. So at any given time, more than one Debug Source window may be displayed.

This allows better navigation through the program. It is particularly convenient to display the source of the caller and the callee at the same time, even if both procedures belong to different modules. For most languages, Cooperative Debugger supports the *Text, *Listing, and *Statement views if the program was compiled with one of these three debug options. You use the View menu to switch between available views. The left margin of the Debug Source window, which contains line numbers, is called prefix area. The rest of the window contains actual source of your program. For visual convenience, all executable lines are colored in blue, while comments and other nonexecutable statements are shown in gray (these colors are not customizable).

The vast majority of debug actions can be performed from the Source window (for example: stepping, running, setting various kinds of breakpoints, displaying variables, and bringing up the Call Stack and Breakpoint List windows). There is usually a very intuitive (point-and-click) way of performing these operations. However, those familiar with the green-screen tools can take the alternative route of typing the appropriate debugging command in a corresponding entry field that resembles the System Debugger interface.

Step and Run Before Reaching the Breakpoint

Cooperative Debugger supports two stepping modes: step over and step debug. Both actions are accessible from the toolbar or the Run menu in the Debug Source window. The step debug action should be used when execution is stopped at the call to some routine that we would like to debug. In any other situation, step over is a preferable action. The corresponding accelerator keys are O and D. (In this case, accelerator keys are invoked by simply pressing a letter that corresponds to the action—O for step over and D for step debug.)

Run and Run to Location commands are also available from the Run menu (with corresponding accelerator keys R and L). The latter command could be accessed through a pop-up menu. The pop-up menu can be invoked by pressing the right mouse button in the prefix area of any executable line.

Breakpoints can be set by double-clicking in the prefix area of any executable line. Alternatively, you can use the Line Breakpoint dialog (see Figure 3) invoked from the Breakpoints menu. From this dialog, the user can set a conditional breakpoint by entering any valid Boolean expression in the Expression field. Once a breakpoint has been set, the prefix area of that line turns red (as shown in Figure 2).

Watches are set through the Watch Breakpoint dialog (see Figure 4), which is also invoked from the Breakpoints menu in the Source window. Using watches can be handy when you want to monitor changes for the same variable or variables as you step through the code. Watches can be set for any valid variable. If the content of a watched variable changes during the execution of your program, execution stops, and the user gets control and is notified about the variable being changed. Currently, watches are not supported for Java.

All line breakpoints and watches that are set successfully will show up in the Breakpoints List window (see Figure 5). From that window, the user can modify breakpoint properties and enablement. Cooperative Debugger currently supports line breakpoints and watches. However, there are plans to add advanced breakpoint features.

Displaying Variables

One of the major advantages of Cooperative Debugger over its green-screen counterparts is the availability of various monitors to display variables. There are four types of monitors: program monitors, private monitors, pop-up monitors, and local variable

monitors. Each one has certain advantages. However, two of the more commonly used ones are the program and local variable monitors.

Adding a variable to the program monitor is as easy as highlighting the appropriate variable in the Source window and double-clicking on it. Alternatively, the Monitor Expression dialog can be used to add a variable to a program, private, or pop-up monitor.

Bringing up a local variable monitor is a matter of choosing the Local Variables option from the Monitors menu in the Source window. This option is also available from the DSC window.

Just like the local variables monitor, the Call Stack window (see Figure 6) could be invoked from the Monitors menu in the Source window or from the DSC window. The Call Stack window contains an entry for every procedure or method that is on the stack at the current execution point. Double-clicking on the call stack entry brings up a source view of the corresponding routine. Each call stack entry contains complete qualification information, such as program, module name, procedure name, statement number, and call level number. This window becomes very handy while debugging deeply nested procedure calls.

It is the existence of the Program Monitor window (see Figure 7) that makes Cooperative Debugger such an invaluable tool. Variables can be added to the Program Monitor by double-clicking in the Source window or using a Monitor Expression dialog. Changing a variable’s value is just a matter of another double-click and typing a new value in the editable part of the window’s container. Data structures can be expanded by double- clicking on the data structure name. Displaying and changing array elements can also be done with ease.

In the Program Monitor window, the user has the capability of removing a particular expression, clearing the entire monitor, changing the expression’s representation, or toggling the expression’s enablement. Full expression qualification can be displayed, although I rarely find it useful.

The Breakpoints List window (see Figure 5) contains every line and watch breakpoint that is set for the current debug session. This is a very convenient place to tamper with breakpoint entries. Double-clicking on the breakpoint entry in the Breakpoints List window brings up the module source view where the breakpoint is set. From this window, the user can delete a particular breakpoint or even all breakpoints, toggle breakpoint enablement, and modify existing breakpoints.

Another handy feature offered by Cooperative Debugger is the availability of the program profile. Breakpoints and monitor information can be preserved from one debug session to another. Simply mark the Use program profile checkbox in the Startup dialog in order to take advantage of this feature.

Give It a Try

I had used the System Debugger for a few years before I came across Cooperative Debugger. After a year and a half of successful experience with this tool, I would definitely not go back to the green-screen. I believe that Cooperative Debugger has saved me many hours of typing and showed me the full power of a GUI. It certainly deserves a try from any developer who regularly debugs AS/400 programs.

Vadim Berestetsky would like to express special thanks to Inge Weiss for her contributions in assuring technical accuracy of this article as well as providing invaluable comments and suggestions.




Figure 1: Debugger-Session Control window


 Figure 2: Debug Source window



From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging05-00.png 854x610





From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging05-01.png 899x579




Figure 3: Line Breakpoint window


 Figure 4: Watch Breakpoint window



From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging06-00.png 900x460





From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging06-01.png 900x504




Figure 5: Breakpoints List window


 Figure 6: Call Stack window



From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging07-00.png 900x404





From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging07-01.png 900x450




Figure 7: Program Monitor window



From_RPG_to_Java-_A_New_Era_in_AS-_400_Debugging08-00.png 854x858
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

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: