You can debug a job that is already running if you know what statements
the job will run.
For example, you may want to debug a running program if the
job is looping or the job has not yet run a program that is to be debugged.
The following steps allow you to debug a running job:
- Use the Work with Active Jobs (WRKACTJOB) command to
find the job that is running. When the display appears, enter option 5 next
to the job to obtain the qualified job name.
- Enter the Start Service Job (STRSRVJOB) command as
follows:
STRSRVJOB JOB(qualified-job-name)
- Enter the Start Debug (STRDBG) command. (Entering the
command does not stop the job from running.)
Note: You can use the Display
Debug (DSPDBG) command to show the call stack. However, unless the
program is stopped for some reason, the stack is correct only for an instant,
and the program continues to run.
- If you know a statement to be run, enter the Add Breakpoint (ADDBKP) command
to stop the job at the statement.
If you do not know what statements are
being run, do the following:
- Enter the Add Trace (ADDTRC) command.
- After a short time, enter the Remove Trace (RMVTRC) command
to stop tracing the program.
- Enter the Display Trace Data (DSPTRCDTA) command to
show what statements have processed. Use the trace data to determine which
data statements to process next (for example, statements inside a program
loop).
- Enter the Add Breakpoint (ADDBKP) command to stop the
job at the statement.
- Enter the desired debug commands when the program is stopped at a breakpoint.