HOT TIPS: Debugging (5 Tips)

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

Debugging

Is My Program Caught in a Loop?

The other day I was testing a piece of code which I suspected of being stuck in a loop. I was about to take the time to stop the program and set up a debug when I realized I could get this information from the DSPJOB command. When you run DSPJOB (from WRKUSRJOB, WRK-SBSJOB or other means) you are provided with a list of options which includes "Display program stack, if active." This display includes a column which shows the line of code the program is on. This display can be updated with the F5 key. While the program executes too fast to let F5 give you a step by step display, repeated F5's will show you approximately where the program is. It definitely showed me where my loop was happening.

After I knew the code was looping, I could use the "Display open files, if active" option to find out which records were up at the time of the loop. Just this information let me look at my code and figure out what the problem was.

- Kathreen Kruse

Breaking an Active Program Out of a Loop

If a program is caught in an infinite loop and observability has not been removed, it may be possible to break the loop without canceling the program.

Use DSPJOB OPTION(*PGMSTK) to determine where the program is looping. Use STRSRVJOB, then STRDBG and ADDBKP to set a breakpoint within the loop. When the breakpoint is displayed, use CHGPGMVAR to set the conditions necessary for the loop to end.

- Douglas Handy

Easy Program Testing

I always have the library QTEMP as the first library in the library list. When testing an interactive program, I copy the test files to QTEMP. Then, I execute the command STRDBG UPDPROD(*NO) (*NO is the default) before testing the program. This way, I can be sure that I will not update the production files accidentally. I do not need to remember to delete the test files when I'm done since the files in QTEMP will be removed when I sign off.

- Ryoichi Morita

Use SEU to Check Compiler Errors

Use the following technique to find errors in an RPG compile listing. Start SEU, press F15, select option 2 to display the spooled file on a split screen, key in FIND *ERR on the SEU command line of the bottom screen and press Enter. Each error message will be displayed on the bottom of the screen. You can press help for second-level text on each message.

- Christopher Andrle

Protecting Files From Update

There are times when you may wish to run a program that writes records to a file, but for test purposes, you wish to prevent this from happening. You could recompile your test program, commenting out the write or update operations, and changing the file specs so the compiler doesn't give you an error message. However, a much better and easier approach is to use the INHWRT(*YES) parameter on the OVRDBF command. You should execute this command for each file you wish to inhibit at the beginning of your jobstream. Be careful not to misspell the file name. You will not get an error message if you do, but the file will not be overridden. (To check that the override has occurred, use the DSPOVR command.) After the override command is executed successfully, the program will act just as before, but no data will be written.

- Jon Vote

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • 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.

  • 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

  • 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: