Not much left of bdb, so removed it entirely. debugger speed

Mon, 08 Aug 2016 22:51:36 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 08 Aug 2016 22:51:36 +0200
branch
debugger speed
changeset 5087
59316f14216b
parent 5086
6cb8be573090
child 5088
5b992bcb3c86

Not much left of bdb, so removed it entirely.

DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugBase.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugBase.py	Mon Aug 08 22:50:36 2016 +0200
+++ b/DebugClients/Python/DebugBase.py	Mon Aug 08 22:51:36 2016 +0200
@@ -4,11 +4,10 @@
 #
 
 """
-Module implementing the debug base class.
+Module implementing the debug base class which based originally on bdb.
 """
 
 import sys
-import bdb
 import os
 import types
 import atexit
@@ -44,18 +43,17 @@
     gRecursionLimit = limit
 
 
-class DebugBase(bdb.Bdb):
+class DebugBase(object):
     """
     Class implementing base class of the debugger.
 
-    Provides simple wrapper methods around bdb for the 'owning' client to
-    call to step etc.
+    Provides methods for the 'owning' client to call to step etc.
     """
     # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch
     #  on Windows
-    lib = os.path.dirname(bdb.__file__)
+    lib = os.path.dirname(inspect.__file__)
     # tuple required because it's accessed a lot of times by startswith method
-    pathsToSkip = ('<', os.path.dirname(__file__), bdb.__file__[:-1])
+    pathsToSkip = ('<', os.path.dirname(__file__), inspect.__file__[:-1])
     filesToSkip = {}
 
     # cache for fixed file names
@@ -67,8 +65,6 @@
         
         @param dbgClient the owning client
         """
-        bdb.Bdb.__init__(self)
-
         self._dbgClient = dbgClient
         self._mainThread = 1
         self.quitting = 0
@@ -97,9 +93,6 @@
         # if hasattr(sys, 'breakpoint): sys.breakpoint()
         sys.breakpoint = self.set_trace
         
-        # initialize parent
-        bdb.Bdb.reset(self)
-        
         self.__recursionDepth = -1
         self.setRecursionDepth(inspect.currentframe())
         
@@ -434,15 +427,38 @@
         self._set_stopinfo(None, None)
         self.stop_everywhere = True
 
+    def set_next(self, frame):
+        """
+        Public method to stop on the next line in or below the given frame.
+        
+        @param frame the frame object
+        @type frame object
+        """
+        self._set_stopinfo(frame, frame.f_back)
+        frame.f_back.f_trace = self.trace_dispatch
+        frame.f_trace = self.trace_dispatch
+
+    def set_return(self, frame):
+        """
+        Public method to stop when returning from the given frame.
+        
+        @param frame the frame object
+        @type frame object
+        """
+        self._set_stopinfo(None, frame.f_back)
+
     def set_quit(self):
         """
         Public method to quit.
         
-        It wraps call to bdb to clear the current frame properly.
+        Disables the trace functions and resets all frame pointer.
         """
         self.currentFrame = None
         sys.setprofile(None)
-        bdb.Bdb.set_quit(self)
+        sys.settrace(None)
+        self.stopframe = None
+        self.returnframe = None
+        self.quitting = 1
     
     def fix_frame_filename(self, frame):
         """
@@ -772,8 +788,7 @@
             for fr in frlist[self.skipFrames:]:
                 filename = self._dbgClient.absPath(self.fix_frame_filename(fr))
                 
-                if os.path.basename(filename).startswith("DebugClient") or \
-                   os.path.basename(filename) == "bdb.py":
+                if os.path.basename(filename).startswith("DebugClientBase"):
                     break
                 
                 linenr = fr.f_lineno
--- a/DebugClients/Python3/DebugBase.py	Mon Aug 08 22:50:36 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Mon Aug 08 22:51:36 2016 +0200
@@ -4,11 +4,10 @@
 #
 
 """
-Module implementing the debug base class.
+Module implementing the debug base class which based originally on bdb.
 """
 
 import sys
-import bdb
 import os
 import atexit
 import inspect
@@ -45,18 +44,17 @@
     gRecursionLimit = limit
 
 
-class DebugBase(bdb.Bdb):
+class DebugBase(object):
     """
     Class implementing base class of the debugger.
 
-    Provides simple wrapper methods around bdb for the 'owning' client to
-    call to step etc.
+    Provides methods for the 'owning' client to call to step etc.
     """
     # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch
     #  on Windows
-    lib = os.path.dirname(bdb.__file__)
+    lib = os.path.dirname(inspect.__file__)
     # tuple required because it's accessed a lot of times by startswith method
-    pathsToSkip = ('<', os.path.dirname(__file__), bdb.__file__[:-1])
+    pathsToSkip = ('<', os.path.dirname(__file__), inspect.__file__[:-1])
     filesToSkip = {}
 
     # cache for fixed file names
@@ -68,8 +66,6 @@
         
         @param dbgClient the owning client
         """
-        bdb.Bdb.__init__(self)
-
         self._dbgClient = dbgClient
         self._mainThread = True
         self.quitting = 0
@@ -98,9 +94,6 @@
         # if hasattr(sys, 'breakpoint): sys.breakpoint()
         sys.breakpoint = self.set_trace
         
-        # initialize parent
-        bdb.Bdb.reset(self)
-        
         self.__recursionDepth = -1
         self.setRecursionDepth(inspect.currentframe())
         
@@ -452,15 +445,38 @@
         self._set_stopinfo(None, None)
         self.stop_everywhere = True
 
+    def set_next(self, frame):
+        """
+        Public method to stop on the next line in or below the given frame.
+        
+        @param frame the frame object
+        @type frame object
+        """
+        self._set_stopinfo(frame, frame.f_back)
+        frame.f_back.f_trace = self.trace_dispatch
+        frame.f_trace = self.trace_dispatch
+
+    def set_return(self, frame):
+        """
+        Public method to stop when returning from the given frame.
+        
+        @param frame the frame object
+        @type frame object
+        """
+        self._set_stopinfo(None, frame.f_back)
+
     def set_quit(self):
         """
         Public method to quit.
         
-        It wraps call to bdb to clear the current frame properly.
+        Disables the trace functions and resets all frame pointer.
         """
         self.currentFrame = None
         sys.setprofile(None)
-        bdb.Bdb.set_quit(self)
+        sys.settrace(None)
+        self.stopframe = None
+        self.returnframe = None
+        self.quitting = 1
     
     def fix_frame_filename(self, frame):
         """
@@ -796,8 +812,7 @@
             for fr in frlist[self.skipFrames:]:
                 filename = self._dbgClient.absPath(self.fix_frame_filename(fr))
                 
-                if os.path.basename(filename).startswith("DebugClient") or \
-                   os.path.basename(filename) == "bdb.py":
+                if os.path.basename(filename).startswith("DebugClientBase"):
                     break
                 
                 linenr = fr.f_lineno

eric ide

mercurial