Using Natural Debugger in Batch ?

Hi All,

Can we use Natural Debugger for Batch programs?

I guess we can not take the control of the program from batch by setting up spies but if we will be able to get the logs of “call statstics” and “statement execution summary” then that would be sufficient.

Is their any way to do this?

Many Thanks,
Deeps

It is possible, by setting the debugging environment from an online session then saving it. You can then load that debug environment in batch before running your program. However it would be much easier and better to use the RDC facility instead. Look at the examples in library SYSRDC for more information.

Hi Darrell,

Thanks for replying. I have never used SYSRDC before, could you just brief me about this? Is this a utility?

Also for setting up debugging environment for batch.Do you mean to say load that environment and then run the job. If this is the case I’m not sure how the control will go from a job to natural debugger. Could you add a little more words to your explanation?

Thanks a lot, Deeps

Deeps, Sorry for taking so long to reply. I don’t logon to this forum as often as I should. For the RDC information, you can look in library SYSRDC. It contains example programs. It is all very simple stuff. You can execute the modules there without worry. Be sure your session has RDCBUFF set greater than 2, or RDC cannot work. Estimate about 1K buffer for every 10 or 12 traced activities. More information on RDC is in the Utilities manual. For batch Debugger, set up the traces you want while you are in an online session, then save the settings with a unique name (use the "E Debug environment maintenance " option on the top-level menu). If my memory is working… When running the batch environment, put the following into your CMSYNIN stream before you EXECUTE your program:

TEST ON
TEST E
L your-debug-environment-name

Then run your program. When it is done you can invoke TEST (similar to the above method) to print the call statistics. But I would still recommend the SYSRDC method, because it is sometimes difficult to feed the debugger screens in batch.

This was great !!
Thanks a lot Darrell :smiley:

Darrell or Deeps,

Are you still around?

I have tried using your technique for batch debugging but I can’t seem to get it to work. I am trying to get the Statement execution statistics from a batch program. So far no luck:

DATA FWH,FWH,FWH
Logon accepted to library FWH.
NEXT TEST ON
Test mode started.
NEXT TEST E
NEXT L FWHDB
Source FWHDB not found in current library.
NEXT EX CALLBITS
Page 1 06-10-24 14:01:42
0START CALLBITS CALLING BITSUB 14:01:42
RESULTS: d 7 N
NEXT FIN
0NAT9995 NATURAL SESSION TERMINATED NORMALLY

Ok, I have gotten this far:

DATA FWH,FWH,FWH
Logon accepted to library FWH.
NEXT TEST ON
Test mode started.
NEXT TEST E
NEXT TEST LOAD ENVIRONMENT FWHDB
Debug environment FWHDB loaded.
NEXT EX CALLBITS
Page 1 06-10-25 12:46:54
0START CALLBITS CALLING BITSUB 12:46:54
END CALLBITS : 12:48:49 FOR 9000001 TIMES
NEXT FIN
0NAT9995 NATURAL SESSION TERMINATED NORMALLY

Now, can I print the results in batch?

The RDC buffer is allocated with the RDCSIZE parameter.

Well, I threw out the idea of loading a debug environment. I got a bit further with this:

DATA FWH,FWH,FWH
Logon accepted to library FWH.
NEXT TEST ON
Test mode started.
NEXT TEST SE XSTAT COUNT FWH,CALLBITS
Statement execution counting started for library/object FWH/CALLBITS.
NEXT EX CALLBITS
Page 1 06-10-26 18:37:28
0START CALLBITS CALLING BITSUB 18:37:28
RESULTS: A 1 Y
END CALLBITS : 18:37:28 FOR 2 TIMES
NEXT TEST PR XSTAT FWH,CALLBITS
PRINT file HARDCOPY not available.

  •     ************* NATURAL Debug Utility Error **************
        * NATURAL error 1520 occurred in NATURAL TEST utility. *
        * PRINT file HARDCOPY not available.                   *
        *                                                      *
        * Error occurred on level 2 in line 1590 in            *
        * subprogram DBGXSL in library SYSLIB.                 *
        * DBGXSL has been loaded from FNAT=(1,303).            *
        * DBGXSL has been cataloged on 1999-04-21 16:55:21.    *
        ********************************************************
    

NEXT FIN
0NAT9995 NATURAL SESSION TERMINATED NORMALLY

Anyone know how to set the debug profile output device in batch? It seems to default to HARDCOPY. When I change my output device online to something other than HARDCOPY, save it then log off, log back on and the output device has been set back to HARDCOPY. ARRRGGGG!!!

The standard debug environment is named “Noname”. It is loaded if you don’t specify any other debug environment. If you change this it is valid only for the current Natural session.
All options that can be set with the direct command PROFILE (except the file for loading or saving debug environments) are part of a debug environment. So I think you have to create your own debug environment for to store your output device and proceed as Darrel suggests.

Hi Darrell,

Could you please tell me how can I use the SYSRDC. In fact in my Natural system I do not have a SYSRDC library and also I tried if this is a system command. But there is no system command with SYSRDC.

How can I explore the batch debugging with out the SYSRDC?

Thanks,
Mishra

Hi,

Well i have tried to use the debugger in Batch, but I always get the error: “Reinput can not be executed in batch”, what is true.
Why this feature can not be use in our system?

Thank you
Hezi

Hezi;

Is this message regarding a REINPUT statement in your code? If so, please see my comment to your other posting (other thread); namely, why do you have a REINPUT in batch? What are you trying to do?

Or, is the message coming from the debugger? That is, is the REINPUT something the debugger is trying to do?

steve

HI,

I want to run debugger in batch as shown above.
I follow the instructions but, I get an error regarding “reinput”.
How can I run debugger in batch?

Hezi - the reinput message likely the debugger trying to give you an error regarding your input - something in your input to the test/debugger is incorrect.

Try putting similar commands into a program that STACKs the input and run it online to see the error. Once you have the STACKing program working, you can just run it in batch.

Hi Douglas,

I did not fully undersatnd your suggestion.
Is there a problem running debbuger in batch and also passing parameters to the program calling?
How should my jcl look like (with data input)?

Thanks
Hezi

Hi,

Is it interactive? should I put debbuger command in my jcl or save it in my terst env?

Hezi

The debugger is intended for interactive use. I’m guessing that there is something wrong with the batch input to the debugger, causing it to execute a REINPUT.

If your batch job has something like:
TEST ON
TEST SE XSTAT COUNT FWH,CALLBITS
EX CALLBITS

you can put these strings into STACK COMMAND statements in a small Natural program and run this program online (which will execute the online REINPUT and hopefully tell you what is missing or wrong). Once you have the program with the STACK COMMANDs in it working, you can then just run the program in batch to invoke the program and debugger.

HI Douglas,

Well it works fine.
Actually, I need to debug in batch the variables in a program without involving the objects only the jcl.
So, I need to set tp a watchpoints & to load it under jcl.
Can I do it (without sending commands to debugger) only display the variables data?

ex: jcl
logon slik
test on
test load enviroment prog
prog

Thanks
Hezi

Hi Hezi;

There is a VERY important sentence in Douglas’s last post:

“The debugger is intended for interactive use.”

The idea behind watchpoints and breakpoints is to STOP the execution of an object, look at variable values, think about what is happening and why it happened. Reading a series of printouts doesn’t come close to being as useful for debugging.

Many long time Natural programmers, myself included, debug batch programs by running them online. How? Easy.

If there is only one workfile involved, I typically STACK a bunch of records. Then, instead of a READ WORK FILE, I use an INPUT. If there are more work files involved, I use a subprogram. Instead of a READ WORK FILE, I use a CALLNAT which returns the next “record”. Instead of a WRITE WORK FILE, write to an array, and at the end of what would be a job step, write out the array.

This gives you the benefits of working with the debugger as it was designed to work, interactively. It also gives you the ability to reliably simulate the operation of work files.

Try it. You will never want to go back to using the debugger in batch.

steve