DebugClients/Python3/DebugBase.py

branch
debugger speed
changeset 5045
50862a6a2c63
parent 5044
630b9f290a77
child 5046
d57f18f15f1a
--- a/DebugClients/Python3/DebugBase.py	Mon Jul 18 22:12:12 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Tue Jul 19 22:20:51 2016 +0200
@@ -279,7 +279,7 @@
                 return self.trace_dispatch
             
             if not (self.stop_here(frame) or
-                    self.break_anywhere(frame) or
+                    self.__checkBreakInFrame(frame) or
                     Watch.watches != []):
                 # No need to trace this function
                 return
@@ -409,6 +409,43 @@
             self._fnCache[fn] = fixedName
             return fixedName
 
+    def __checkBreakInFrame(self, frame):
+        """
+        Private method to check if the function / method has a line number
+        which is a breakpoint.
+        @param frame the frame object
+        @type frame object
+        @return Flag indicating a function / method with breakpoint
+        @rtype bool
+        """
+        try:
+            return Breakpoint.breakInFrameCache[
+                frame.f_globals.get('__file__'),
+                frame.f_code.co_firstlineno]
+        except KeyError:
+            filename = self.fix_frame_filename(frame)
+            if filename not in Breakpoint.breakInFile:
+                Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
+                    frame.f_code.co_firstlineno] = False
+                return False
+            lineNo = frame.f_code.co_firstlineno
+            lineNumbers = [lineNo]
+            # No need to handle special case if a lot of lines between
+            # (e.g. closure), because the additional lines won't cause a bp
+            for co_lno in frame.f_code.co_lnotab[1::2]:
+                lineNo += co_lno
+                lineNumbers.append(lineNo)
+            
+            for bp in Breakpoint.breakInFile[filename]:
+                if bp in lineNumbers:
+                    Breakpoint.breakInFrameCache[
+                        frame.f_globals.get('__file__'),
+                        frame.f_code.co_firstlineno] = True
+                    return True
+            Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
+                frame.f_code.co_firstlineno] = False
+            return False
+    
     def break_here(self, frame):
         """
         Public method reimplemented from bdb.py to fix the filename from the
@@ -441,20 +478,6 @@
         
         return False
 
-    def break_anywhere(self, frame):
-        """
-        Public method reimplemented from bdb.py to do some special things.
-        
-        These speciality is to fix the filename from the frame
-        (see fix_frame_filename for more info).
-        
-        @param frame the frame object
-        @param frame object
-        @return flag indicating the break status
-        @rtype bool
-        """
-        return self.fix_frame_filename(frame) in Breakpoint.breakInFile
-
     def __do_clearBreak(self, filename, lineno):
         """
         Private method called to clear a temporary breakpoint.

eric ide

mercurial