Next: Known Problems and Bugs Related to W3Kit
Up: W3Kit 2.2, An Object-Oriented Toolkit for Interactive WWW Applications
Prev: CGI Environment Extensions for W3Kit

Debugging W3Kit Applications

W3Kit applications run in a somewhat unusual environment. To simulate that environment with a conventional debugger like GDB, a few extra steps are required:

  1. Make a copy of the installed $W3APPNAME-app script inside your application's source directory. Replace the exec line
    	exec "$W3APPBINDIR/$W3APPNAME"
    
    with the debugging command
    	gdb O.arch/"$W3APPNAME"
    
    Here you should substitute arch with actual the platform you are running on, e.g. "sgi" or "sun4". (Note: you need to debug the uninstalled executable because the Makefile automatically strips the executable during installation.)

  2. Create simulated POST input. The easiest way is to save a copy of the input form document, edit it to have its ACTION point to the following CGI script, reload the form, and submit it. This will produce a file /tmp/post on the server containing the exact standard input that would have been fed to the W3Kit application (you can ignore the 500 Server Error message that appears on the client end).
    	void main()
    	{
    		int fd, n = atoi(getenv("CONTENT_LENGTH"));
    		char *buf = malloc(n);
    		read(0, buf, n);
    		fd = open("/tmp/post", O_WRONLY|O_CREAT|O_TRUNC, 0644);
    		write(fd, buf, n);
    	}
    

  3. Run the modified $W3APPNAME-app script to enter the debugger. Immediately after you enter GDB, set the CGI environment variables on which W3Kit depends (of which there are currently four). For example:
    	(gdb) set env REQUEST_METHOD POST
    	(gdb) set env GATEWAY_INTERFACE CGI/1.1
    	(gdb) set env HTTP_USER_AGENT NCSA Mosaic/2.4 libwww/2.12
    	(gdb) set env CONTENT_LENGTH 1234
    
    The number after the CONTENT_LENGTH in this example should be replaced by the size in bytes of the /tmp/post file.

  4. You are now in a position to debug your application using the GDB command
    	(gdb) run < /tmp/post
    


Next: Known Problems and Bugs Related to W3Kit
Up: W3Kit 2.2, An Object-Oriented Toolkit for Interactive WWW Applications
Prev: CGI Environment Extensions for W3Kit

[HOME] The Geometry Center Home Page

Author: Paul Burchard
Comments to: webmaster@geom.umn.edu
Created: Apr 18 1994 --- Last modified: Tue Jun 18 10:26:18 1996