DebugClients/Python/DebugBase.py

branch
debugger speed
changeset 5012
be693f11da53
parent 5007
e2fa12bb0f53
child 5041
f00a4c8bcbbd
diff -r e2fa12bb0f53 -r be693f11da53 DebugClients/Python/DebugBase.py
--- a/DebugClients/Python/DebugBase.py	Fri Jul 01 21:54:07 2016 +0200
+++ b/DebugClients/Python/DebugBase.py	Sat Jul 02 21:58:09 2016 +0200
@@ -72,8 +72,7 @@
         self.breaks = self._dbgClient.breakpoints
         self.tracePythonLibs(0)
         
-        self.__event = ""
-        self.__isBroken = ""
+        self.__isBroken = False
         self.cFrame = None
         
         # current frame we are at
@@ -232,10 +231,15 @@
         for new events (i.e. new breakpoints) while we are going through
         the code.
         
-        @param frame The current stack frame.
-        @param event The trace event (string)
+        @param frame The current stack frame
+        @type frame object
+        @param event The trace event
+        @type str
         @param arg The arguments
+        @type depends on the previous event parameter
         @return local trace function
+        @rtype trace function or None
+        @exception bdb.BdbQuit
         """
         if self.quitting:
             return  # None
@@ -243,72 +247,56 @@
         # give the client a chance to push through new break points.
         self._dbgClient.eventPoll()
         
-        self.__event == event
-        self.__isBroken = False
+        if event == 'line':
+            if self.stop_here(frame) or self.break_here(frame):
+                self.user_line(frame)
+                if self.quitting:
+                    raise bdb.BdbQuit
+            return
         
-        if event == 'line':
-            return self.dispatch_line(frame)
         if event == 'call':
-            return self.dispatch_call(frame, arg)
-        if event == 'return':
-            return self.dispatch_return(frame, arg)
-        if event == 'exception':
-            return self.dispatch_exception(frame, arg)
-        if event == 'c_call':
-            return self.trace_dispatch
-        if event == 'c_exception':
-            return self.trace_dispatch
-        if event == 'c_return':
-            return self.trace_dispatch
-        print 'DebugBase.trace_dispatch: unknown debugging event:', repr(event)  # __IGNORE_WARNING__
-        return self.trace_dispatch
-
-    def dispatch_line(self, frame):
-        """
-        Public method reimplemented from bdb.py to do some special things.
-        
-        This speciality is to check the connection to the debug server
-        for new events (i.e. new breakpoints) while we are going through
-        the code.
-        
-        @param frame The current stack frame.
-        @return local trace function
-        @exception bdb.BdbQuit raised to indicate the end of the debug session
-        """
-        if self.stop_here(frame) or self.break_here(frame):
-            self.user_line(frame)
+            if self.botframe is None:
+                # First call of dispatch since reset()
+                # (CT) Note that this may also be None!
+                self.botframe = frame.f_back
+                return self.trace_dispatch
+            
+            if not (self.stop_here(frame) or self.break_anywhere(frame)):
+                # No need to trace this function
+                return
             if self.quitting:
                 raise bdb.BdbQuit
-        return self.trace_dispatch
-
-    def dispatch_return(self, frame, arg):
-        """
-        Public method reimplemented from bdb.py to handle passive mode cleanly.
+            return self.trace_dispatch
         
-        @param frame The current stack frame.
-        @param arg The arguments
-        @return local trace function
-        @exception bdb.BdbQuit raised to indicate the end of the debug session
-        """
-        if self.stop_here(frame) or frame == self.returnframe:
-            self.user_return(frame, arg)
-            if self.quitting and not self._dbgClient.passive:
-                raise bdb.BdbQuit
-        return self.trace_dispatch
+        if event == 'return':
+            if self.stop_here(frame) or frame == self.returnframe:
+                # The program has finished if we have just left the first frame
+                if frame == self._dbgClient.mainFrame and \
+                        self._mainThread:
+                    atexit._run_exitfuncs()
+                    self._dbgClient.progTerminated(arg)
+                elif frame is not self.stepFrame:
+                    self.stepFrame = None
+                    self.user_line(frame)
+                    
+                if self.quitting and not self._dbgClient.passive:
+                    raise bdb.BdbQuit
+            return
+        
+        if event == 'exception':
+            if not self.__skipFrame(frame):
+                self.user_exception(frame, arg)
+                if self.quitting:
+                    raise bdb.BdbQuit
+            return
 
-    def dispatch_exception(self, frame, arg):
-        """
-        Public method reimplemented from bdb.py to always call user_exception.
-        
-        @param frame The current stack frame.
-        @param arg The arguments
-        @return local trace function
-        @exception bdb.BdbQuit raised to indicate the end of the debug session
-        """
-        if not self.__skipFrame(frame):
-            self.user_exception(frame, arg)
-            if self.quitting:
-                raise bdb.BdbQuit
+        if event == 'c_call':
+            return
+        if event == 'c_exception':
+            return
+        if event == 'c_return':
+            return
+        print 'DebugBase.trace_dispatch: unknown debugging event:', repr(event)  # __IGNORE_WARNING__
         return self.trace_dispatch
 
     def set_trace(self, frame=None):
@@ -718,6 +706,8 @@
         
         self._dbgClient.write('%s%s\n' % (ResponseLine, unicode(stack)))
         self._dbgClient.eventLoop()
+        
+        self.__isBroken = False
 
     def user_exception(self, frame, (exctype, excval, exctb), unhandled=0):
         """
@@ -832,23 +822,6 @@
         tb = None
         return stack
 
-    def user_return(self, frame, retval):
-        """
-        Public method reimplemented to report program termination to the debug
-        server.
-        
-        @param frame the frame object
-        @param retval the return value of the program
-        """
-        # The program has finished if we have just left the first frame.
-        if frame == self._dbgClient.mainFrame and \
-                self._mainThread:
-            atexit._run_exitfuncs()
-            self._dbgClient.progTerminated(retval)
-        elif frame is not self.stepFrame:
-            self.stepFrame = None
-            self.user_line(frame)
-
     def stop_here(self, frame):
         """
         Public method reimplemented to filter out debugger files.
@@ -909,17 +882,10 @@
         """
         Public method to return the broken state of the debugger.
         
-        @return flag indicating the broken state (boolean)
+        @return flag indicating the broken state
+        @rtype bool
         """
         return self.__isBroken
-    
-    def getEvent(self):
-        """
-        Protected method to return the last debugger event.
-        
-        @return last debugger event (string)
-        """
-        return self.__event
 
 #
 # eflag: FileType = Python2

eric ide

mercurial