Monday, June 19, 2006

TAO thread debugging

For the past few days I've been sifting through Python's thread handling code trying to figure out how I'm going to facilitate the debugging of threads in mpdb. Now, the Python interpreter provides no way for Python code to switch between threads, nor does it provide a way to suspend, stop, resume, interrupt any thread. So how, you may ask, are we going to enable thread debugging in mpdb? The answer is simply, 'I haven't decided yet'. I'm still running through some possible solutions, which I'll discuss now.

1] This is the least desirable solution. Code a Python module in C to look at the state of each of the threads and try to get some more control over it.

2] Have a main MPdb object that creates, initially sets the settrace method for all threads that are created from the threading module to some helper function inside mpdb that creates a new tracer object and then, from within the thread reassigns the settrace method to that objects trace method. Sound confusing? It kinda is. The main is that, because these tracer objects are under our control (i.e. the debugger's) we can handle all the synchronisation of how the main MPdb object wants to receive data from the tracer object.

3] Similar as above except using tracer threads instead of objects. This is how it's done in rpdb2 (Nir Aides debugger) with positive results.

4] Make calls to mpdb.settrace() inside thread code which sets the tracer function to one defined in the mpdb module. Whilst this would work for both threads created with thread.start_new_thread() and the threading module, it's not all happy-days because the programmer has to modify their buggy code in order to monitor the threads.

At the moment I'm leaning in the direction of #2, but we should be have confirmation by the end of the week as to exactly which design is going to appear in mpdb.

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]