diff options
Diffstat (limited to 'python/helpers/pydev/pydevd_additional_thread_info.py')
-rw-r--r-- | python/helpers/pydev/pydevd_additional_thread_info.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/python/helpers/pydev/pydevd_additional_thread_info.py b/python/helpers/pydev/pydevd_additional_thread_info.py index 1b0fc2cdd633..fa906adf385e 100644 --- a/python/helpers/pydev/pydevd_additional_thread_info.py +++ b/python/helpers/pydev/pydevd_additional_thread_info.py @@ -12,7 +12,7 @@ import weakref #======================================================================================================================= class AbstractPyDBAdditionalThreadInfo: def __init__(self): - self.pydev_state = STATE_RUN + self.pydev_state = STATE_RUN self.pydev_step_stop = None self.pydev_step_cmd = None self.pydev_notify_kill = False @@ -20,51 +20,52 @@ class AbstractPyDBAdditionalThreadInfo: self.pydev_smart_step_stop = None self.pydev_django_resolve_frame = None self.is_tracing = False + self.conditional_breakpoint_exception = None + - def IterFrames(self): raise NotImplementedError() - + def CreateDbFrame(self, args): #args = mainDebugger, filename, base, additionalInfo, t, frame raise NotImplementedError() - + def __str__(self): return 'State:%s Stop:%s Cmd: %s Kill:%s' % (self.pydev_state, self.pydev_step_stop, self.pydev_step_cmd, self.pydev_notify_kill) - + #======================================================================================================================= # PyDBAdditionalThreadInfoWithCurrentFramesSupport #======================================================================================================================= class PyDBAdditionalThreadInfoWithCurrentFramesSupport(AbstractPyDBAdditionalThreadInfo): - + def IterFrames(self): #sys._current_frames(): dictionary with thread id -> topmost frame return sys._current_frames().values() #return a copy... don't know if it's changed if we did get an iterator #just create the db frame directly CreateDbFrame = PyDBFrame - + #======================================================================================================================= # PyDBAdditionalThreadInfoWithoutCurrentFramesSupport #======================================================================================================================= class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditionalThreadInfo): - + def __init__(self): AbstractPyDBAdditionalThreadInfo.__init__(self) - #That's where the last frame entered is kept. That's needed so that we're able to + #That's where the last frame entered is kept. That's needed so that we're able to #trace contexts that were previously untraced and are currently active. So, the bad thing #is that the frame may be kept alive longer than it would if we go up on the frame stack, #and is only disposed when some other frame is removed. - #A better way would be if we could get the topmost frame for each thread, but that's + #A better way would be if we could get the topmost frame for each thread, but that's #not possible (until python 2.5 -- which is the PyDBAdditionalThreadInfoWithCurrentFramesSupport version) #Or if the user compiled threadframe (from http://www.majid.info/mylos/stories/2004/06/10/threadframe.html) - + #NOT RLock!! (could deadlock if it was) self.lock = threading.Lock() self._acquire_lock = self.lock.acquire self._release_lock = self.lock.release - + #collection with the refs d = {} self.pydev_existing_frames = d @@ -72,8 +73,8 @@ class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditional self._iter_frames = d.iterkeys except AttributeError: self._iter_frames = d.keys - - + + def _OnDbFrameCollected(self, ref): ''' Callback to be called when a given reference is garbage-collected. @@ -83,8 +84,8 @@ class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditional del self.pydev_existing_frames[ref] finally: self._release_lock() - - + + def _AddDbFrame(self, db_frame): self._acquire_lock() try: @@ -94,8 +95,8 @@ class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditional self.pydev_existing_frames[r] = r finally: self._release_lock() - - + + def CreateDbFrame(self, args): #the frame must be cached as a weak-ref (we return the actual db frame -- which will be kept #alive until its trace_dispatch method is not referenced anymore). @@ -106,14 +107,14 @@ class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditional db_frame.frame = args[-1] self._AddDbFrame(db_frame) return db_frame - - + + def IterFrames(self): #We cannot use yield (because of the lock) self._acquire_lock() try: ret = [] - + for weak_db_frame in self._iter_frames(): try: ret.append(weak_db_frame().frame) |