How can I attach a debugger to an NSAPI application?NSAPI applications are run in separate processes on your Zeus WebServer, one process per virtual server.
When you next request a web page that uses this function, the debuggerwill break in this function. You can step through the function,examining local variables and so on. If you want to break in a function that is called at Init,you need to be a bit more clever because the function is called justafter the new zeus.nsapi process is fork'ed andexec'ed. Most debuggers cannot follow forks. You can use a dummy Init function that blocks for long enoughfor you to attach a debugger to the new process. pause() andsleep() are good candidates. /* sleep.c * Use as follows: * Init fn="load-modules" funcs="mysleep" shlib="sleep.so" * Init fn="mysleep" secs="20" */#include <unistd.h> /* for sleep() */#include <stdlib.h> /* for atoi() */char *pblock_findval( const char*, const void* );int mysleep( void *args, void *sn, void *rq ){ const char *secs = pblock_findval( "secs", args ); if( secs ) sleep( atoi( secs ) ); return 0;} Compile this up to a .so file, for example: Using gcc: gcc -g -c -fPIC sleep.cUsing HP cc: cc -Ae -g -c +z sleep.c Put the following in your obj.conf, before any otherInit directives: Init fn="load-modules" funcs="mysleep" shlib="sleep.so" Init fn="mysleep" secs="20" (shlib should include the full path to the sleep.so library) Then when you start your virtual server, you have 20 seconds to figure out the process id and attach a debugger to it!
Content Manager
[Administrator] 19 September 2005
|
Recent Articles
Other Resources
|


