Using the interactive debugger

From Try-AS/400
Jump to navigation Jump to search

With no prior experience, getting into using the interactive debugger can be quite frustrating. This article should provide a quick start to the uninitiated.

Compile program with debugging information

The debugger is more helpful, the more source information is imbedded into the final program object. For an ILE RPG application, simply

  • call up wrkmbrpdm with the source file containing the member of the program to be debugged,
  • type 14 into the line with the application you wish to debug — and do not press enter yet,
  • add dbgview(*all) into the command line at the screen bottom,
  • and finally press enter to compile the source to the eventual *pgm object.

Switching on debug mode

This is done by issuing the command

strdebug[1]

with appropriate options. Prompt with F4.

  • The pgm option is very helpful to limit the debugging scope to the desired application(s).
  • The updprod(*yes) is necessary if your program relies on using files from a normal[2] *prod type library.

After pressing enter, you'll be presented with the Display Module Source screen. From here you can scroll through the imbedded code to set or delete so called breakpoints. These are tags in code lines, where the normal program handling is suspended, and the debugger screen (Display Module Source) is called up again.

Running the program in debug mode

If you've set one or more appropriate breakpoints, exit the Display Module Source screen with F3, and run your program object as intended. Most often you'll call it from the command line:

call mypgm

The program will now run as usual until the first breakpoint is hit. Then, the Display Module Source screen is displayed again, showing the current line the program's execution was suspended due to the breakpoint. From here, you can

  • single-step through the program with F10,
  • inspect variable contents by placing the cursor appropriately, and pressing F11,
  • set watches to variables by placing the cursor appropriately, and pressing F17.

If you're done, press F3 to end your program.

Ending debug mode

Issue the following command:

enddbg

Weblinks

Footnotes

  1. This is a restricted command. It can be used only by user profiles
    • being member of the qpgmr group profile,
    • having *allobj authority.
  2. The crtlib command has a parameter type(*prod|*test)
  3. The presenter has a very strong accent, possibly making it very hard to understand what he's saying.