3.12. Debugging CGI programs

[<<<] [>>>]

To debug a CGI program you have to execute it in the Eszter SB Application Engine. The Eszter SB Application Engine is a single process, multi-thread httpd daemon that runs ScriptBasic programs inside the process as separate threads. Yoi can install the engine as Windows NT Service, UNIX daemon or start just as a command line tool.

More information how to start the Eszter SB Application Engine read the manual of the program.

When the engine is started from the command line it acts like a normal command line program. Although the BASIC command PRINT is redirected to send HTML output to the browser, and the input functions read the http POST data, the debugger, if started still prints to the console screen and reads the keyboard.

To invoke the debugger, however you can not use the command line option `-i dbg' because in this case the command line is for the Eszter SB Application Engine and not for the individual BASIC program thread. Instead you have to modify the code of your BASIC program to have the first line (or the second line following @code{#! /usr/bin/scriba) to be

use dbg

This will invoke the debugger as soon as the file is read y the application engine.

To make sure that the engine is reading the source instead of the cache file, in which case the preprocessors defined by the statement use are ignored configure the ScriptBasic interpreter with a fake cache directory that does not exist.

Start the engine from the command line

sbhttpd -start

and open a browser with the URL that refers to the program you want to debug. Do not forget to specify `-start' under Windows NT! The engine will stop and wait on the console with the debugger cursor.

At this point you can go and debug your program.

[<<<] [>>>]