10 import bdb |
10 import bdb |
11 import sys |
11 import sys |
12 |
12 |
13 from DebugBase import * |
13 from DebugBase import * |
14 |
14 |
|
15 |
15 class DebugThread(DebugBase): |
16 class DebugThread(DebugBase): |
16 """ |
17 """ |
17 Class implementing a debug thread. |
18 Class implementing a debug thread. |
18 |
19 |
19 It represents a thread in the python interpreter that we are tracing. |
20 It represents a thread in the python interpreter that we are tracing. |
20 |
21 |
21 Provides simple wrapper methods around bdb for the 'owning' client to |
22 Provides simple wrapper methods around bdb for the 'owning' client to |
22 call to step etc. |
23 call to step etc. |
23 """ |
24 """ |
24 def __init__(self, dbgClient, targ = None, args = None, kwargs = None, |
25 def __init__(self, dbgClient, targ=None, args=None, kwargs=None, |
25 mainThread = 0): |
26 mainThread=0): |
26 """ |
27 """ |
27 Constructor |
28 Constructor |
28 |
29 |
29 @param dbgClient the owning client |
30 @param dbgClient the owning client |
30 @param targ the target method in the run thread |
31 @param targ the target method in the run thread |
32 @param kwargs arguments to be passed to the thread |
33 @param kwargs arguments to be passed to the thread |
33 @param mainThread 0 if this thread is not the mainscripts thread |
34 @param mainThread 0 if this thread is not the mainscripts thread |
34 """ |
35 """ |
35 DebugBase.__init__(self, dbgClient) |
36 DebugBase.__init__(self, dbgClient) |
36 |
37 |
37 self._target = targ |
38 self._target = targ |
38 self._args = args |
39 self._args = args |
39 self._kwargs = kwargs |
40 self._kwargs = kwargs |
40 self._mainThread = mainThread |
41 self._mainThread = mainThread |
41 # thread running tracks execution state of client code |
42 # thread running tracks execution state of client code |
42 # it will always be 0 for main thread as that is tracked |
43 # it will always be 0 for main thread as that is tracked |
43 # by DebugClientThreads and Bdb... |
44 # by DebugClientThreads and Bdb... |
44 self._threadRunning = 0 |
45 self._threadRunning = 0 |
45 |
46 |
46 self.__ident = None # id of this thread. |
47 self.__ident = None # id of this thread. |
47 self.__name = "" |
48 self.__name = "" |
48 |
49 |
49 def set_ident(self, id): |
50 def set_ident(self, id): |
50 """ |
51 """ |
51 Public method to set the id for this thread. |
52 Public method to set the id for this thread. |
112 @param arg The arguments |
113 @param arg The arguments |
113 @return local trace function |
114 @return local trace function |
114 """ |
115 """ |
115 try: |
116 try: |
116 self._dbgClient.lockClient() |
117 self._dbgClient.lockClient() |
117 # if this thread came out of a lock, and we are quitting |
118 # if this thread came out of a lock, and we are quitting |
118 # and we are still running, then get rid of tracing for this thread |
119 # and we are still running, then get rid of tracing for this thread |
119 if self.quitting and self._threadRunning: |
120 if self.quitting and self._threadRunning: |
120 sys.settrace(None) |
121 sys.settrace(None) |
121 sys.setprofile(None) |
122 sys.setprofile(None) |
122 import threading |
123 import threading |
123 self.__name = threading.currentThread().getName() |
124 self.__name = threading.currentThread().getName() |