[Pydev-cvs] org.python.pydev.debug/pysrc pydevd_file_utils.py, 1.5, 1.6 pydevd_additional_thread_in
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-08-06 16:21:33
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25849/pysrc Modified Files: pydevd_file_utils.py pydevd_additional_thread_info.py pydevd_vars.py Log Message: - threadframe can be used (when sys._current_frames is not available) - set/frozenset can be correctly seen - minor refactorings Index: pydevd_file_utils.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_file_utils.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pydevd_file_utils.py 10 May 2008 17:55:33 -0000 1.5 --- pydevd_file_utils.py 6 Aug 2008 16:21:41 -0000 1.6 *************** *** 42,46 **** --- 42,54 ---- import sys normcase = os.path.normcase + basename = os.path.basename + try: + rPath = os.path.realpath #@UndefinedVariable + except: + # jython does not support os.path.realpath + # realpath is a no-op on systems without islink support + rPath = os.path.abspath + #defined as a list of tuples where the 1st element of the tuple is the path in the client machine #and the 2nd element is the path in the server machine. *************** *** 66,76 **** return NORM_FILENAME_CONTAINER[filename] except KeyError: ! try: ! rPath = os.path.realpath #@UndefinedVariable ! except: ! # jython does not support os.path.realpath ! # realpath is a no-op on systems without islink support ! rPath = os.path.abspath ! r = os.path.normcase(rPath(filename)) #cache it for fast access later NORM_FILENAME_CONTAINER[filename] = r --- 74,78 ---- return NORM_FILENAME_CONTAINER[filename] except KeyError: ! r = normcase(rPath(filename)) #cache it for fast access later NORM_FILENAME_CONTAINER[filename] = r *************** *** 140,144 **** except KeyError: filename = _NormFile(f) ! base = os.path.basename(filename) NORM_FILENAME_AND_BASE_CONTAINER[f] = filename, base return filename, base --- 142,146 ---- except KeyError: filename = _NormFile(f) ! base = basename(filename) NORM_FILENAME_AND_BASE_CONTAINER[f] = filename, base return filename, base Index: pydevd_vars.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_vars.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** pydevd_vars.py 5 Jul 2008 19:42:13 -0000 1.46 --- pydevd_vars.py 6 Aug 2008 16:21:41 -0000 1.47 *************** *** 45,50 **** try: ! typeMap.append(set, pydevd_resolver.setResolver) ! typeMap.append(frozenset, pydevd_resolver.setResolver) except: pass #not available on all python versions --- 45,50 ---- try: ! typeMap.append((set, pydevd_resolver.setResolver)) ! typeMap.append((frozenset, pydevd_resolver.setResolver)) except: pass #not available on all python versions Index: pydevd_additional_thread_info.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_additional_thread_info.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pydevd_additional_thread_info.py 16 Feb 2008 12:15:59 -0000 1.6 --- pydevd_additional_thread_info.py 6 Aug 2008 16:21:41 -0000 1.7 *************** *** 51,60 **** #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) #NOT RLock!! (could deadlock if it was) self.lock = threading.Lock() #collection with the refs ! self.pydev_existing_frames = {} def _OnDbFrameCollected(self, ref): --- 51,69 ---- #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 ! try: ! self._iter_frames = d.iterkeys ! except AttributeError: ! self._iter_frames = d.keys ! def _OnDbFrameCollected(self, ref): *************** *** 62,74 **** Callback to be called when a given reference is garbage-collected. ''' ! self.lock.acquire() try: del self.pydev_existing_frames[ref] finally: ! self.lock.release() def _AddDbFrame(self, db_frame): ! self.lock.acquire() try: #create the db frame with a callback to remove it from the dict when it's garbage-collected --- 71,83 ---- Callback to be called when a given reference is garbage-collected. ''' ! self._acquire_lock() try: del self.pydev_existing_frames[ref] finally: ! self._release_lock() def _AddDbFrame(self, db_frame): ! self._acquire_lock() try: #create the db frame with a callback to remove it from the dict when it's garbage-collected *************** *** 77,81 **** self.pydev_existing_frames[r] = r finally: ! self.lock.release() --- 86,90 ---- self.pydev_existing_frames[r] = r finally: ! self._release_lock() *************** *** 91,103 **** return db_frame def IterFrames(self): ! #we may not have yield, so, lets create a list for the iteration ! self.lock.acquire() try: ret = [] ! weak_db_frames = self.pydev_existing_frames.keys() ! ! for weak_db_frame in weak_db_frames: try: ret.append(weak_db_frame().frame) --- 100,111 ---- 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) *************** *** 106,110 **** return ret finally: ! self.lock.release() def __str__(self): --- 114,118 ---- return ret finally: ! self._release_lock() def __str__(self): *************** *** 117,124 **** # and frames, but to support other versions, we can't rely on that. #======================================================================================================================= ! try: ! sys._current_frames #@UndefinedVariable PyDBAdditionalThreadInfo = PyDBAdditionalThreadInfoWithCurrentFramesSupport ! except AttributeError: ! PyDBAdditionalThreadInfo = PyDBAdditionalThreadInfoWithoutCurrentFramesSupport --- 125,138 ---- # and frames, but to support other versions, we can't rely on that. #======================================================================================================================= ! if hasattr(sys, '_current_frames'): PyDBAdditionalThreadInfo = PyDBAdditionalThreadInfoWithCurrentFramesSupport ! else: ! try: ! import threadframe ! sys._current_frames = threadframe.dict ! assert sys._current_frames is threadframe.dict #Just check if it was correctly set ! PyDBAdditionalThreadInfo = PyDBAdditionalThreadInfoWithCurrentFramesSupport ! except: ! #If all fails, let's use the support without frames ! PyDBAdditionalThreadInfo = PyDBAdditionalThreadInfoWithoutCurrentFramesSupport |