If you've ever had to debug CGI programs, you know how difficult it can be. To make things a little easier, here is a list of steps to follow when debugging a CGI program.
1. Compile the CGI program with DBGVIEW(*SOURCE or *LIST or *COPY).
You already know how to do this. Use the CRTBNDRPG or CRTRPGMOD commands and specify the DBGVIEW keyword.
2. End the HTTP server.
This is the most dangerous step. Be sure to use the ENDTCPSVR command with the SERVER(*HTTP) parameter. If you enter just the ENDTCPSVR command, you will have an upsetting learning experience.
3. Restart the HTTP server with one activation.
To debug effectively, you need to know which HTTP server job your browser session will attach to. Normally, this is a crap shoot. However, by ending the server and restarting it with one activation, you can pretty much guarantee that you'll get the right server job.
4. Determine the HTTP job for single-thread CGI programs.
Using the WRKACTJOB command, display the jobs that are active and roll up to the subsystem running the HTTP server. Typically, this is QHTTPSVR. Then, use option 5 (Work with Job) to display the jobs in that subsystem.
Next, use option 10 (DSPJOBLOG) on each of the jobs running in the subsystem. The job with the HTP2001 message logged in it is the job you need to place in service. Record the job number, name, and user ID.
5. Start a service job on the HTTP server job.
Run the STRSRVJOB command, specifying the job whose number, name, and user ID you just recorded.
6. Start debug on the CGI program.
After starting the service job, start debug on the CGI program using STRDBG as usual. Set the breakpoints you want, and then press F12 to return.
7. Call the CGI program using the browser.
After starting debug, switch over to a Web browser and evoke the CGI program through the browser by pressing the Submit button on the HTML form that will call your CGI program.
Now, switch over to the 5250 session that has the program in debug; a breakpoint should have been detected, and the ILE debugger should be stopped in your session. Debug as usual.
When finished debugging, make sure you end the service job using ENDSRVJOB and then end and restart the HTTP server with the normal number of activations.
Bob Cozzi has been programming in RPG since 1978. Since then, he has written many articles and several books, including The Modern RPG Language--the most widely used RPG reference manual in the world. Bob is also a very popular speaker at industry events such as RPG World and is the author of his own Web site and of the RPG ToolKit, an add-on library for RPG IV programmers.
LATEST COMMENTS
MC Press Online