Improvements on eric's set_trace and set_continue if not in debugging mode. debugger speed

Sun, 24 Jul 2016 21:34:54 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 24 Jul 2016 21:34:54 +0200
branch
debugger speed
changeset 5064
9f4e3914e50c
parent 5063
0b5dccc8aacb
child 5081
4c896f626bd6

Improvements on eric's set_trace and set_continue if not in debugging mode.

DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugBase.py	Sun Jul 24 21:13:03 2016 +0200
+++ b/DebugClients/Python/DebugBase.py	Sun Jul 24 21:34:54 2016 +0200
@@ -342,12 +342,28 @@
 
     def set_trace(self, frame=None):
         """
-        Public method reimplemented from bdb.py to do some special setup.
+        Public method to start debugging from 'frame'.
+
+        If frame is not specified, debugging starts from caller's frame.
         
         @param frame frame to start debugging from
+        @type frame object
         """
-        bdb.Bdb.set_trace(self, frame)
-        sys.setprofile(self.profile)
+        if frame is None:
+            frame = sys._getframe().f_back
+        
+        # stop at erics debugger frame
+        while frame:
+            if not self.__skipFrame(frame):
+                frame.f_trace = self.trace_dispatch
+            frame = frame.f_back
+            self.botframe = frame
+            if self.__skipFrame(frame):
+                break
+        
+        self.set_step()
+        sys.settrace(self.trace_dispatch)
+        sys.setprofile(self._dbgClient.callTraceEnabled)
     
     def set_continue(self, special):
         """
@@ -359,9 +375,11 @@
         # Modified version of the one found in bdb.py
         # Here we only set a new stop frame if it is a normal continue.
         if not special:
-            self.stopframe = self.botframe
-        self.returnframe = None
-        self.quitting = 0
+            self._set_stopinfo(self.botframe, None)
+        # Disable tracing if not started in debug mode
+        if not self._dbgClient.debugging:
+            sys.settrace(None)
+            sys.setprofile(None)
 
     def set_quit(self):
         """
--- a/DebugClients/Python/DebugClientBase.py	Sun Jul 24 21:13:03 2016 +0200
+++ b/DebugClients/Python/DebugClientBase.py	Sun Jul 24 21:34:54 2016 +0200
@@ -233,7 +233,6 @@
         self.pollingDisabled = False
         
         self.callTraceEnabled = None
-        self.__newCallTraceEnabled = None
         
         self.skipdirs = sys.path[:]
         
@@ -478,7 +477,7 @@
                     sys.setprofile(callTraceEnabled)
                 else:
                     # remember for later
-                    self.__newCallTraceEnabled = callTraceEnabled
+                    self.callTraceEnabled = callTraceEnabled
                     
                 return
             
@@ -535,7 +534,7 @@
                 # as a normal str.
                 self.debugMod.__dict__['__file__'] = self.running
                 sys.modules['__main__'] = self.debugMod
-                sys.setprofile(self.__newCallTraceEnabled)
+                sys.setprofile(self.callTraceEnabled)
                 res = self.mainThread.run(
                     'execfile(' + repr(self.running) + ')',
                     self.debugMod.__dict__)
--- a/DebugClients/Python3/DebugBase.py	Sun Jul 24 21:13:03 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Sun Jul 24 21:34:54 2016 +0200
@@ -362,12 +362,28 @@
 
     def set_trace(self, frame=None):
         """
-        Public method reimplemented from bdb.py to do some special setup.
+        Public method to start debugging from 'frame'.
+
+        If frame is not specified, debugging starts from caller's frame.
         
         @param frame frame to start debugging from
+        @type frame object
         """
-        bdb.Bdb.set_trace(self, frame)
-        sys.setprofile(self.profile)
+        if frame is None:
+            frame = sys._getframe().f_back
+        
+        # stop at erics debugger frame
+        while frame:
+            if not self.__skipFrame(frame):
+                frame.f_trace = self.trace_dispatch
+            frame = frame.f_back
+            self.botframe = frame
+            if self.__skipFrame(frame):
+                break
+        
+        self.set_step()
+        sys.settrace(self.trace_dispatch)
+        sys.setprofile(self._dbgClient.callTraceEnabled)
     
     def set_continue(self, special):
         """
@@ -380,8 +396,10 @@
         # Here we only set a new stop frame if it is a normal continue.
         if not special:
             self._set_stopinfo(self.botframe, None)
-        else:
-            self._set_stopinfo(self.stopframe, None)
+        # Disable tracing if not started in debug mode
+        if not self._dbgClient.debugging:
+            sys.settrace(None)
+            sys.setprofile(None)
 
     def set_quit(self):
         """
--- a/DebugClients/Python3/DebugClientBase.py	Sun Jul 24 21:13:03 2016 +0200
+++ b/DebugClients/Python3/DebugClientBase.py	Sun Jul 24 21:34:54 2016 +0200
@@ -207,7 +207,6 @@
         self.pollingDisabled = False
         
         self.callTraceEnabled = None
-        self.__newCallTraceEnabled = None
         
         self.skipdirs = sys.path[:]
         
@@ -472,7 +471,7 @@
                     sys.setprofile(callTraceEnabled)
                 else:
                     # remember for later
-                    self.__newCallTraceEnabled = callTraceEnabled
+                    self.callTraceEnabled = callTraceEnabled
                     
                 return
             
@@ -530,7 +529,7 @@
                 sys.modules['__main__'] = self.debugMod
                 code = self.__compileFileSource(self.running)
                 if code:
-                    sys.setprofile(self.__newCallTraceEnabled)
+                    sys.setprofile(self.callTraceEnabled)
                     res = self.mainThread.run(code, self.debugMod.__dict__)
                     self.progTerminated(res)
                 return

eric ide

mercurial