gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r209576 - in /gump/branches/Gump3: gump pygump/python/gump/engine/__init__.py pygump/python/gump/engine/algorithm.py pygump/python/gump/engine/walker.py pygump/python/main.py
Date Thu, 07 Jul 2005 09:21:31 GMT
Author: leosimons
Date: Thu Jul  7 02:21:29 2005
New Revision: 209576

URL: http://svn.apache.org/viewcvs?rev=209576&view=rev
Log:
Make it drop-dead-easy to attach a debugger to gump3.

 * gump,
   pygump/python/main.py: implement two new commandline options for debugging, --attach-pdb
and --attach-wingdb.

 * pygump/python/gump/engine/__init__.py: add in debugger hooks that print some very basic
help and pointers, the attach either pdb or wing.

 * pygump/python/gump/engine/walker.py,
   pygump/python/gump/engine/algorithm.py: comment on some interesting places to attach debuggers.

Modified:
    gump/branches/Gump3/gump
    gump/branches/Gump3/pygump/python/gump/engine/__init__.py
    gump/branches/Gump3/pygump/python/gump/engine/algorithm.py
    gump/branches/Gump3/pygump/python/gump/engine/walker.py
    gump/branches/Gump3/pygump/python/main.py

Modified: gump/branches/Gump3/gump
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/gump?rev=209576&r1=209575&r2=209576&view=diff
==============================================================================
--- gump/branches/Gump3/gump (original)
+++ gump/branches/Gump3/gump Thu Jul  7 02:21:29 2005
@@ -99,6 +99,25 @@
       parameter. Using this command will actually start the command line
       debugger pdb to run gump in, whereas the '--debug' option customizes
       the log verbosity gump will use.
+      
+      This command otherwise accepts the same arguments as the 'run'
+      command.
+"
+      ;;
+    debug-with-wing)
+      echo "
+      Run pygump in debug mode.
+      
+      Usage:
+        $0 debug [gump.py-args ...]
+    
+      This is not the same as executing the 'run' command with a '--debug'
+      parameter. Using this command will actually start the debug connector
+      for the Wing IDE and attach it to the gump process, whereas the
+      '--debug' option customizes the log verbosity gump will use.
+
+      This command otherwise accepts the same arguments as the 'run'
+      command.
 "
       ;;
     test)
@@ -199,7 +218,8 @@
       Available commands are:
      
         run             -- run pygump
-        debug           -- run pygump in debug mode
+        debug           -- run pygump in debug mode, attaching pdb
+        debug-with-wing -- run pygump in debug mode, attaching the Wing IDE
         test            -- run the pygump unit tests
         dynagump        -- run the dynagump web application server
         webgump         -- run the webgump application server
@@ -622,7 +642,13 @@
 # Run pygump in the debugger
 function debug
 {
-  do_run "from main import main; import pdb; pdb.run('main()')" $@
+  run --attach-pdb $@
+}
+
+# Run pygump in the Wing IDE debugger
+function debug_with_wing
+{
+  run --attach-wingdb $@
 }
 
 # Prematurely shut down pygump
@@ -802,6 +828,9 @@
       ;;
     debug)
       debug $@
+      ;;
+    debug-with-wing)
+      debug_with_wing $@
       ;;
     kill)
       kill $@

Modified: gump/branches/Gump3/pygump/python/gump/engine/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/__init__.py?rev=209576&r1=209575&r2=209576&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/__init__.py Thu Jul  7 02:21:29 2005
@@ -112,7 +112,77 @@
                      dom_implementation,
                      pre_process_visitor, visitor, post_process_visitor,
                      config.paths_workspace, mergefile, dropfile)
-    
+
+    # Debugging sessions start right here
+    if settings.attach_wing:
+        print "=" * 78
+        print """
+!!!ENABLING WING IDE DEBUGGER!!!
+
+You are entering a WING IDE debug session. If you set up Wing correctly and
+specified the WINGHOME environment variable, wing should attach to gump in
+a moment.
+
+An overview of debugging external processes with Wing is at
+
+  http://wingware.com/doc/debug/debugging-externally-launched-code
+
+With the complete documentation for the Wing debugger at
+
+  http://wingware.com/doc/debug/index
+
+Note that you can get a free copy of the Wing IDE for open source development.
+Details are at
+
+  http://wingware.com/store/prices#discounts
+        """
+        print "=" * 78
+        import wingdbstub
+        wingdbstub.debugger.StartDebug(1)
+
+    if settings.attach_pdb:
+        print "=" * 78
+        print """
+!!!ENABLING COMMANDLINE DEBUGGER!!!
+
+You are entering a PDB debug session. If you didn't want this, simply type
+'continue' at the prompt that follows, then enter, then 'quit' when the
+prompt returns.
+
+Python's debugger is completely commmand-line based. An overview of
+the available commands is at
+
+  http://www.python.org/doc/current/lib/debugger-commands.html
+
+You get basic information on these commands by typing 'help'. It's a good
+idea to set some breakpoints within the run() method of the Engine class and
+some breakpoints within for example the Walker class and/or the Algorithm
+classes. Throughout the code, some useful spots to start debugging have been
+marked with "# DEBUG TIP". For example, the following sequence of commands may
+be useful for getting your feed wet (though note the line numbers are probably
+out-of-sync with the current layout of the sourcefiles):
+
+(Pdb) break gump/engine/__init__.py:235
+(Pdb) break gump/engine/__init__.py:259
+(Pdb) break gump/engine/algorithm.py:203
+(Pdb) break gump/engine/algorithm.py:230
+(Pdb) break gump/engine/walker.py:52
+(Pdb) break
+(Pdb) where
+(Pdb) continue
+(Pdb) where
+(Pdb) continue
+(Pdb) where
+(Pdb) continue
+(Pdb) where
+       ... (until you're bored)
+(Pdb) clear 1 2 3 4 5
+(Pdb) continue
+        """
+        print "=" * 78
+        import pdb
+        pdb.set_trace()
+
     # run it
     engine.run()
     
@@ -209,6 +279,7 @@
     def run(self):
         """Perform a gump run. What actually goes on during a gump run is
         largely determined by the components we're using."""
+        # DEBUG TIP: good place to start debugging :-)
         try:
             # * merge workspace into big DOM tree
             (domtree, dropped_nodes) = self.workspace_loader.get_workspace_tree(self.workspace)
@@ -231,6 +302,7 @@
             #   no circular dependencies)
             self.workspace_verifier.verify(workspace)
             
+            # DEBUG TIP: good place to look at the plugin flow control
             # * Pfew! All done. Now actually start *doing* stuff.
             self.walker.walk(workspace, self.pre_process_visitor, 'pre_process')
             # (visited_repositories, visited_modules, visited_projects) = \

Modified: gump/branches/Gump3/pygump/python/gump/engine/algorithm.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/algorithm.py?rev=209576&r1=209575&r2=209576&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/algorithm.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/algorithm.py Thu Jul  7 02:21:29 2005
@@ -116,6 +116,8 @@
                         "{{{initialization stage}}}", type, value, traceback)
 
     def _visit_workspace(self, workspace):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         for visitor in self.list:
             try: visitor._visit_workspace(workspace)
             except:
@@ -123,6 +125,8 @@
                 self.error_handler.handle(visitor, workspace, type, value, traceback)
 
     def _visit_repository(self, repository):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         for visitor in self.list:
             try: visitor._visit_repository(repository)
             except:
@@ -130,6 +134,8 @@
                 self.error_handler.handle(visitor, repository, type, value, traceback)
 
     def _visit_module(self, module):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         for visitor in self.list:
             try: visitor._visit_module(module)
             except:
@@ -137,6 +143,8 @@
                 self.error_handler.handle(visitor, module, type, value, traceback)
 
     def _visit_project(self, project):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         for visitor in self.list:
             try: visitor._visit_project(project)
             except:
@@ -144,6 +152,8 @@
                 self.error_handler.handle(visitor, project, type, value, traceback)
 
     def _finalize(self, workspace):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         for visitor in self.list:
             try:
                 visitor._finalize(workspace)
@@ -187,6 +197,8 @@
           self.persistence_helper = persistence_helper
         
     def _visit_module(self, module):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         # run the delegates
         try:
             for visitor in self.list:
@@ -212,6 +224,8 @@
         #        mark_skip(project)
             
     def _visit_project(self, project):
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         # check for dependencies that failed to build
         for relationship in project.dependencies:
             if check_failure(relationship.dependency):

Modified: gump/branches/Gump3/pygump/python/gump/engine/walker.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/walker.py?rev=209576&r1=209575&r2=209576&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/walker.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/walker.py Thu Jul  7 02:21:29 2005
@@ -47,6 +47,8 @@
         Returns a tuple containing the repositories visited, the modules
         visited, and the projects visited, in the order they were visited.
         """
+        # DEBUG TIP: This is a good function to monitor if you want to figure
+        #   out flow control
         visited_repositories = []
         visited_modules = []
         visited_projects = []

Modified: gump/branches/Gump3/pygump/python/main.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/main.py?rev=209576&r1=209575&r2=209576&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/main.py (original)
+++ gump/branches/Gump3/pygump/python/main.py Thu Jul  7 02:21:29 2005
@@ -150,6 +150,16 @@
                       dest="irc",
                       default=False,
                       help="enable an IRCbot during this run using nickname@irc.freenode.net/channel")
+    parser.add_option("--attach-pdb",
+                      action="store_true",
+                      dest="attach_pdb",
+                      default=False,
+                      help="Run within the Python Debugger (PDB)")
+    parser.add_option("--attach-wingdb",
+                      action="store_true",
+                      dest="attach_wing",
+                      default=False,
+                      help="Run within the Wing IDE Debugger")
                       
     return parser
 
@@ -424,8 +434,19 @@
     
     options.version = GUMP_VERSION
     
+    # check for debug info
+    if options.attach_wing:
+        try:
+            winghome = os.environ["WINGHOME"]
+        except:
+            print "ERROR: debug environment not set up properly. Please set WINGHOME to the"
+            print "       directory containing your Wing IDE installation."  
+            sys.exit(2)
+
     # create logger
     log = _Logger(options.logdir)
+    
+    # fire it up!
     exitcode = 0
     try:
         if options.debug:



Mime
View raw message