This would be worth putting into the Webware Wiki.
> -----Original Message-----
> From: Deepak Giridharagopal [mailto:deepak@...]
> Sent: Friday, February 21, 2003 4:21 PM
> To: Stuart Donaldson
> Cc: 'webware-discuss@...'
> Subject: Re: [Webware-discuss] Debuggers?
> Stuart Donaldson (stuartd@...) wrote:
> > So what are people using to debug the application server and the
> > servlets within?
> This is an old thread, but I just found it :). My approach uses pdb,
> which is not a GUI debugger, but rather a debugging console like gdb.
> Pdb is included with python, and you can find pdb.py in
> (or wherever your installation is).
> The first thing I tried was getting Webware to run through pdb's run
> function. A modified Launch.py did the trick, and ThreadedAppServer
> loaded and ran just fine.
> The problem was that pdb wasn't stopping when it hit breakpoints in my
> servlet code. After much swearing, I learned that when pdb launches a
> function, it only attaches to the main thread. I suspect this
> has to do
> with the way the bdb module invokes sys.settrace... But even if you
> could get around that, the pdb module provides no way to switch from
> thread to thread, like gdb does, for example.
> What I ended up doing was inserting the following code into an
> entrypoint for the thread I'm trying to debug (say, inside writeHTML,
> for example):
> import pdb
> This will immediately drop the thread that called the
> set_trace function
> straight into a pdb debugging session on the same console you launched
> Webware from. And since I called set_trace inside the servlet
> I want to
> debug, pdb gets attached to the right thread. And from that point you
> can do anything pdb will let you do.
> It's worked great for me so far. Though it's not as flexible as a
> multi-threaded debugger, it sure beats print statements.
> A caveat, though, is that other threads will keep running while you're
> debugging the one that called set_trace. But that's true on every
> multi-threaded debugger I can think of...gdb, jdb, etc.
> I thought a neat improvement would be to define a
> debug_handler function
> that just calls pdb.set_trace() and connect that to a signal handler,
> say USR1, so then I could just send Webware a 'kill -USR1
> pid' and have
> it drop into a debug console. Unfortunately, the docs for the python
> signal module state that signal handlers can only be invoked
> by the main
> program thread, so I never tried.
> As an aside, WingIDE, a commercial product, seems to do
> remote debugging
> and reportedly supports Webware. Anyone used it?
> This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> The most comprehensive and flexible code editor you can use.
> Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
> Webware-discuss mailing list