To debug a CGI, which is processing an Anchor Activator, you basically need to get the query string. The first way to get this is to look at the HTML source for the Calling Anchor and get the part of the HREF after the character, ?. For example if the anchor looks like this:
<A HREF=
"http://cezanne/cgibin/table//table.cgi?FNC=tcreate__Atdemo_ html">
Create Table</A>then the QUERY_STRING is:
FNC=tcreate__Atdemo_htmlA second technique is to set the Project Option, "Print Environment" to True. Rebuild your CGI. Click on the Calling Anchor. In the resulting HTML source get the value of the QUERY_STRING environment. Now to use the QUERY_STRING value do the following. Start the debugger with your CGI.
xxgdb table.cgiwhere table.CGI is the name of your CGI. Then break points are set. Start the CGI in the debugger using the QUERY_STRING as:
run table.cgi FNC=tcreate__Atdemo_htmlwhere the last parameter is the QUERY_STRING. You may need to perform shell escaping depending on content. If you also want to set up the environment to try to match what the CGI will see when launched from http, you will need to capture the environment. If you already set "Print Environment" as described previously, then you can grab the entire environment from the returned HTML source, then paste it into a file, e.g. ENV. To use that file, start the CGI in the debugger with
run table.cgi FNC=tcreate__Atdemo_html -env ENVThe order of arguments is important.
Of course there are still several differences with the debug run and the real CGI. First, the user for the real CGI is usually, "nobody". In the debugger it's you. You may be fooled by permissions on files and directories. Second, the debugger CGI has other environment variables that the real CGI does not. Third, unless the HTML and CGI bin directories are mounted, the debug CGI will run in the starting directory.
To debug form-activated CGIs you need to do the following. Set the Project Option, Print Form Args to True. Rebuild your CGI. Fill in and activate the Calling Form. In the resulting HTML source get the form arguments. Paste these into a file, e.g. ARGS. To use that file to start the CGI in the debugger with:
run table.cgi -debug ARGSYou can also use the environment, getting it as described above, with:
run table.cgi -debug ARGS -env ENVor
run table.cgi -env ENV -debug ARGS