Debugging CSP
From CacheWiki
Contents |
Some tips about debugging Cache Server Pages
Retaining INT code
When a CSP page compiles it generates a Cache class. That class then compiles via an INT routine and generates the OBJ code which Cache executes to serve the page and implement your server-side methods.
When debugging this server-side logic you need to retain the INT code, which by default is deleted at the end of the compilation sequence.
Set the so-called "k" flag ("Keep generated source code"). To do this for your entire namespace:
SAMPLES>D $system.OBJ.SetFlags("k")
To examine your current settings, and to learn more about the flags:
SAMPLES>D $system.OBJ.ShowFlags()
Once the "k" flag is the default for your namespace, recompile all the pages for your app:
SAMPLES>d $system.CSP.LoadPageDir("/csp/samples")
In fact, you can specify flags as the second argument to the LoadPageDir method. See Documatic for more info.
How To Debug From Studio
Don’t set breakpoints via the Debug>View Breakpoints… dialog, as this seems error prone.
For CSPs you must have the ‘Keep Generated Source Code” option checked.[Tools>Options… Option Dialog go to Compiler>Flags ]
Open your Workspace windows and add your CSPs to the CSP folder if they are not already there.
Compile your CSP and then press the ‘View Other Code’ button in the toolbar (or View>ViewOtherCode menuitem). This will allow you to see the cls and then the int file, i.e., A.CSP generates “CSP.A.CLS” and “CSP.1.INT”.
In the CLS or the INT file right click on the line of code where you want a breakpoint and select ‘Toggle Breakpoint’ (or select the line and hit F9).
Go to menu DEBUG>DEBUG TARGET…
Select ‘ZEN or CSP page’.
If you have dragged your CSPs to the Workspace window, they will appear in the dropdown list. Select the target CSP which the debugger will run.
Press the GO button.
For example, if you have a flow: A -> B That is, display page A and then follow a link to page B.
There is a bug in B.
Check that A.CSP and B.CSP are in the Workspace window. Compile both. Go to the Debug Target dialog, and select target:’ZEN or CSP page’ and select A.CSP from the dropdown. Open B.CSP and hit the View Other Code button to open csp.B.CLS. In csp.B.CLS, right click on the first line in the OnPageBODY() method and select ‘toggle breakpoint’.
Press GO. Page A should appear. Click its link to page B. The debugger should stop on the breakpoint in B.
Buying time
By default the CSP Web Gateway on your web server gives up waiting for a response 60 seconds after it submits the request. When you're debugging, you probably need more time than this (unlss you're an expert speed-dater).
In the CSP Web Gateway Management page, alter the "Server Response Time" parameter.
If you're using an Apache web server you may also need to alter the Timeout parameter in httpd.conf, since Apache by default gives up on a request after 120 seconds.

