Pro tips

Debugging and Troubleshooting Techniques in IBM i Development

Publication date

No matter how you’re coding, adept debugging and troubleshooting skills are indispensable for maintaining robust and efficient systems. IBM i programmers can use the built-in tools provided by IBM or integrated development environments (IDEs) connected to the IBM i to diagnose and resolve issues effectively.

Debugging with IBM i debugger commands

The first key step to having a successful debugging session is to include the source code when you compile your program. Without that, debugging options are very limited (a good business practice would be (to remove the source code from the program once it is debugged and prior to porting to production,making it smaller, faster, and more secure).

These are the debugging commands on the IBM i.

  1.  STRDBG (Start Debug): This command initiates interactive debugging for a specified program or service program. It allows developers to set breakpoints, step through code, and examine variables and memory locations interactively.
  2.  ENDDBG (End Debug): Used to terminate interactive debugging sessions initiated by STRDBG, this command exits the debug mode gracefully, allowing the program to resume normal execution.

 

Debugging batch programs in IBM i

To debug batch programs back in the days, you had to find a way to make the program crash so you could have a handle on it and start the debug. Now, there are many more elegant ways to debug your batch programs.

  1.  Use a service job: The STRSRVJOB command facilitates servicing the batch job, enabling your current session to invoke the debugger (STRDBG) on the batch job being serviced.
  2.  Use the Rational Developer for i (RDi): RDI is an IDE where developers can develop, debug, compile, and test. It allows you to use the service job technique but within the IDE itself, even if the batch job has not started yet. It will wake itself up once the serviced batch job gets running.
  3.  Use Visual Studio (VS) Code: With VS Code, you can debug your programs through the IBM i Debug extension found on the Marketplace. It uses the same debug server than RDi uses.

 

Debugging for testing

These debugging techniques can be used for unit testing as well. When the code reaches a breakpoint, you can change a value and see how the program behaves. This is especially useful when testing batch programs, since it lets you control values that you otherwise can’t access directly.

 

IBM i supports success

By leveraging IBM i’s debugging tools, you can streamline your processes, improve software quality, and ensure that your IBM i applications run smoothly.

Looking for help with your IBM i development? Contact the R2i experts now and we’ll be happy to support you.

IBM i development and application services

TRUST R2I FOR ALL YOUR IBM i DEVELOPMENT NEEDS
Learn more

GET THE LATEST FROM R2I!

Subscribe to newsletter
Share on your social media