W3Kit applications run in a somewhat unusual environment. To simulate that environment with a conventional debugger like GDB, a few extra steps are required:
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.)
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); }
(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 1234The number after the CONTENT_LENGTH in this example should be replaced by the size in bytes of the /tmp/post file.
(gdb) run < /tmp/post
Author: Paul Burchard
Comments to:
webmaster@geom.umn.edu
Created: Apr 18 1994 ---
Last modified: Tue Jun 18 10:26:18 1996