commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src GBaseApp.py GDebug.py


From: James Thompson
Subject: gnue/common/src GBaseApp.py GDebug.py
Date: Fri, 12 Apr 2002 21:18:25 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     James Thompson <address@hidden> 02/04/12 21:18:24

Modified files:
        common/src     : GBaseApp.py GDebug.py 

Log message:
        Start of integration of python's internal debugger

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GBaseApp.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GDebug.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/common/src/GBaseApp.py
diff -c gnue/common/src/GBaseApp.py:1.9 gnue/common/src/GBaseApp.py:1.10
*** gnue/common/src/GBaseApp.py:1.9     Tue Apr  9 11:27:04 2002
--- gnue/common/src/GBaseApp.py Fri Apr 12 21:18:24 2002
***************
*** 92,97 ****
--- 92,99 ----
           [ 'profile', None, 'profile', 0, None, None,
             "Run Python's built-in profiler and display the resulting " + \
             "run statistics." ],
+          [ 'debugger', None, 'interactive-debugger', 0, None, None,
+            "Run the app inside Python's built-in debugger "],
      ]
  
      #
***************
*** 131,148 ****
        self.printVersion()
        sys.exit()
  
-     # Should we profile?
      self._run = self.run
      if self.OPTIONS['profile']:
        self.run = self._profile
  
      # Setup debugging
      try:
        GDebug.setDebug(int("%s" % self.OPTIONS['debug_level']),
            self.OPTIONS['debug_file'])
      except ValueError:
        self.handleStartupError('The debug_level option ("-d") expects a 
numerical value.')
! 
      GDebug.printMesg(1,"Python %s" % sys.version)
      GDebug.printMesg(1,"Run Options: %s" % opt)
      GDebug.printMesg(1,"Run Arguments: %s" % self.ARGUMENTS)
--- 133,157 ----
        self.printVersion()
        sys.exit()
  
      self._run = self.run
+     
+     # Should we profile?
      if self.OPTIONS['profile']:
        self.run = self._profile
  
      # Setup debugging
+     # Should we run in debugger?
+     if self.OPTIONS['debugger']:
+       self.run = self._debugger
+       
      try:
        GDebug.setDebug(int("%s" % self.OPTIONS['debug_level']),
            self.OPTIONS['debug_file'])
      except ValueError:
        self.handleStartupError('The debug_level option ("-d") expects a 
numerical value.')
!       
!         
!     
      GDebug.printMesg(1,"Python %s" % sys.version)
      GDebug.printMesg(1,"Run Options: %s" % opt)
      GDebug.printMesg(1,"Run Arguments: %s" % self.ARGUMENTS)
***************
*** 267,272 ****
--- 276,291 ----
          print '-' * 60
        print "\nFor help, type:\n   %s --help\n" % (self.COMMAND)
        sys.exit()
+ 
+   #
+   # Used when interactive debugger in use
+   # 
+   def _debugger(self):
+ 
+     import pdb
+     debugger = pdb.Pdb()
+     GDebug.setDebugger(debugger)
+     debugger.runctx( 'self._run()', globals(), locals() )
  
    #
    #  Used when profiling
Index: gnue/common/src/GDebug.py
diff -c gnue/common/src/GDebug.py:1.4 gnue/common/src/GDebug.py:1.5
*** gnue/common/src/GDebug.py:1.4       Tue May 29 21:07:42 2001
--- gnue/common/src/GDebug.py   Fri Apr 12 21:18:24 2002
***************
*** 36,45 ****
  _fh = sys.__stderr__
  _conttest = 0
  _DEBUG_LEVEL = 0
  
  class _stderrcatcher:
      def write(self, str):
!         global _fh, _conttest
          for ch in str:
              if (_conttest == 0):
                  _fh.write("DB000: ")
--- 36,46 ----
  _fh = sys.__stderr__
  _conttest = 0
  _DEBUG_LEVEL = 0
+ _DEBUGGER = None
  
  class _stderrcatcher:
      def write(self, str):
!         global _fh, _conttest, _DEBUGGER
          for ch in str:
              if (_conttest == 0):
                  _fh.write("DB000: ")
***************
*** 49,60 ****
              else:
                  _fh.write('\n')
                  _conttest = 0
  
      def writelines(self, list):
          for line in list:
              self.write(str)
  
! 
  def setDebug (level, file=None): 
    global _DEBUG_LEVEL
    _DEBUG_LEVEL = level
--- 50,66 ----
              else:
                  _fh.write('\n')
                  _conttest = 0
+         if _DEBUGGER:
+             _DEBUGGER.set_trace()
  
      def writelines(self, list):
          for line in list:
              self.write(str)
  
! def setDebugger(debugger):
!     global _DEBUGGER
!     _DEBUGGER = debugger
!     
  def setDebug (level, file=None): 
    global _DEBUG_LEVEL
    _DEBUG_LEVEL = level
***************
*** 109,112 ****
--- 115,119 ----
          Exception.__init__(self)
          self.level = level
          self.message = message
+ 
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]