Call the debugger directly, don't re-execute Python to run it. (Laurent Pelecq)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 21 Jul 2003 05:56:00 +0000 (05:56 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 21 Jul 2003 05:56:00 +0000 (05:56 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@740 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Script/__init__.py

index 6e92bb72ba357a90321b7446d02c7da9952cec3e..37e36a84cdc913e0bf425aee6bbac7881c07302e 100644 (file)
@@ -47,6 +47,11 @@ RELEASE 0.XX - XXX
   - Fix the value returned by the Node.prevsiginfo() method to conform
     to a previous change when checking whether a node is current.
 
+  From Laurent Pelecq:
+
+  - When the -debug=pdb option is specified, use pdb.Pdb().runcall() to
+    call pdb directly, don't call Python recursively.
+
   From Christoph Wiedemann
 
   - Have the g++ Tool actually use g++ in preference to c++.
index 2f04d41ca8b604c2165ed5c404edd621c24b326a..6aa45bac4a0ecaf429df0361f303bd793a9beaf3 100644 (file)
@@ -458,23 +458,7 @@ class OptParser(OptionParser):
                              "build all Default() targets.")
 
         def opt_debug(option, opt, value, parser):
-            if value == "pdb":
-                if os.name == 'java':
-                    python = os.path.join(sys.prefix, 'jython')
-                else:
-                    python = sys.executable
-                args = [ python, "pdb.py" ] + \
-                       filter(lambda x: x != "--debug=pdb", sys.argv)
-                if sys.platform == 'win32':
-                    args[1] = os.path.join(sys.prefix, "lib", "pdb.py")
-                    sys.exit(os.spawnve(os.P_WAIT, args[0], args, os.environ))
-                else:
-                    args[1] = os.path.join(sys.prefix,
-                                           "lib",
-                                           "python" + sys.version[0:3],
-                                           "pdb.py")
-                os.execvpe(args[0], args, os.environ)
-            elif value in ["tree", "dtree", "time", "includes"]:
+            if value in ["pdb","tree", "dtree", "time", "includes"]:
                 setattr(parser.values, 'debug', value)
             else:
                 raise OptionValueError("Warning:  %s is not a valid debug type" % value)
@@ -693,7 +677,7 @@ class SConscriptSettableOptions:
         self.settable[name] = value
     
 
-def _main():
+def _main(args):
     targets = []
 
     # Enable deprecated warnings by default.
@@ -701,15 +685,7 @@ def _main():
     SCons.Warnings.enableWarningClass(SCons.Warnings.DeprecatedWarning)
     SCons.Warnings.enableWarningClass(SCons.Warnings.CorruptSConsignWarning)
 
-    all_args = sys.argv[1:]
-    try:
-        all_args = string.split(os.environ['SCONSFLAGS']) + all_args
-    except KeyError:
-            # it's OK if there's no SCONSFLAGS
-            pass
-    parser = OptParser()
-    global options, ssoptions
-    options, args = parser.parse_args(all_args)
+    global ssoptions
     ssoptions = SConscriptSettableOptions(options)
 
     if options.help_msg:
@@ -983,11 +959,27 @@ def _main():
         if not options.noexec:
             SCons.Sig.write()
 
+def _exec_main():
+    all_args = sys.argv[1:]
+    try:
+        all_args = string.split(os.environ['SCONSFLAGS']) + all_args
+    except KeyError:
+            # it's OK if there's no SCONSFLAGS
+            pass
+    parser = OptParser()
+    global options
+    options, args = parser.parse_args(all_args)
+    if options.debug == "pdb":
+        import pdb
+        pdb.Pdb().runcall(_main, args)
+    else:
+        _main(args)
+
 def main():
     global exit_status
     
     try:
-       _main()
+       _exec_main()
     except SystemExit, s:
         if s:
             exit_status = s