churchyard / rpms / python3

Forked from rpms/python3 3 years ago
Clone

Blame 00156-gdb-autoload-safepath.patch

938d1d
diff -up Python-3.2.3/Lib/test/test_gdb.py.gdb-autoload-safepath Python-3.2.3/Lib/test/test_gdb.py
938d1d
--- Python-3.2.3/Lib/test/test_gdb.py.gdb-autoload-safepath	2012-04-30 17:16:24.092706954 -0400
938d1d
+++ Python-3.2.3/Lib/test/test_gdb.py	2012-04-30 17:17:13.275703592 -0400
938d1d
@@ -46,6 +46,19 @@ def gdb_has_frame_select():
938d1d
 
938d1d
 HAS_PYUP_PYDOWN = gdb_has_frame_select()
938d1d
 
938d1d
+def gdb_has_autoload_safepath():
938d1d
+    # Recent GDBs will only auto-load scripts from certain safe
938d1d
+    # locations, so we will need to turn off this protection.
938d1d
+    # However, if the GDB doesn't have it, then the following
938d1d
+    # command will generate noise on stderr (rhbz#817072):
938d1d
+    cmd = "--eval-command=set auto-load safe-path /"
938d1d
+    p = subprocess.Popen(["gdb", "--batch", cmd],
938d1d
+                         stderr=subprocess.PIPE)
938d1d
+    _, stderr = p.communicate()
938d1d
+    return b'"on" or "off" expected.' not in stderr
938d1d
+    
938d1d
+HAS_AUTOLOAD_SAFEPATH = gdb_has_autoload_safepath()
938d1d
+
938d1d
 BREAKPOINT_FN='builtin_id'
938d1d
 
938d1d
 class DebuggerTests(unittest.TestCase):
938d1d
@@ -106,15 +119,28 @@ class DebuggerTests(unittest.TestCase):
938d1d
                     'set print entry-values no',
938d1d
 
938d1d
                     'run']
938d1d
+
938d1d
+        if HAS_AUTOLOAD_SAFEPATH:
938d1d
+            # Recent GDBs will only auto-load scripts from certain safe
938d1d
+            # locations.
938d1d
+            # Where necessary, turn off this protection to ensure that
938d1d
+            # our -gdb.py script can be loaded - but not on earlier gdb builds
938d1d
+            # as this would generate noise on stderr (rhbz#817072):
938d1d
+            init_commands = ['set auto-load safe-path /']
938d1d
+        else:
938d1d
+            init_commands = []
938d1d
+
938d1d
         if cmds_after_breakpoint:
938d1d
             commands += cmds_after_breakpoint
938d1d
         else:
938d1d
             commands += ['backtrace']
938d1d
 
938d1d
+        # print init_commands
938d1d
         # print commands
938d1d
 
938d1d
         # Use "commands" to generate the arguments with which to invoke "gdb":
938d1d
         args = ["gdb", "--batch"]
938d1d
+        args += ['--init-eval-command=%s' % cmd for cmd in init_commands]
938d1d
         args += ['--eval-command=%s' % cmd for cmd in commands]
938d1d
         args += ["--args",
938d1d
                  sys.executable]