summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedora Python maintainers <python-devel@lists.fedoraproject.org>2020-07-15 15:39:42 +0200
committerPetr Viktorin <pviktori@redhat.com>2020-09-29 15:59:05 +0200
commite20a3150622d5b2b632b45c8704f43dda25e9810 (patch)
tree9f706115ce7bf50c125dde0e433c08a804e02445
parent37f6fef219c7c3d8d4b3eb9d57c93a43c14f64c1 (diff)
downloadcpython-git-e20a3150622d5b2b632b45c8704f43dda25e9810.tar.gz
00156-gdb-autoload-safepath.patch
00156 # Recent builds of gdb will only auto-load scripts from certain safe locations. Turn off this protection when running test_gdb in the selftest suite to ensure that it can load our -gdb.py script (rhbz#817072): Not yet sent upstream
-rw-r--r--Lib/test/test_gdb.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index b96acc0988..360bad1846 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -132,6 +132,19 @@ def gdb_has_frame_select():
HAS_PYUP_PYDOWN = gdb_has_frame_select()
+def gdb_has_autoload_safepath():
+ # Recent GDBs will only auto-load scripts from certain safe
+ # locations, so we will need to turn off this protection.
+ # However, if the GDB doesn't have it, then the following
+ # command will generate noise on stderr (rhbz#817072):
+ cmd = "--eval-command=set auto-load safe-path /"
+ p = subprocess.Popen(["gdb", "--batch", cmd],
+ stderr=subprocess.PIPE)
+ _, stderr = p.communicate()
+ return '"on" or "off" expected.' not in stderr
+
+HAS_AUTOLOAD_SAFEPATH = gdb_has_autoload_safepath()
+
class DebuggerTests(unittest.TestCase):
"""Test that the debugger can debug Python."""
@@ -178,6 +191,17 @@ class DebuggerTests(unittest.TestCase):
'run']
+ if HAS_AUTOLOAD_SAFEPATH:
+ # Recent GDBs will only auto-load scripts from certain safe
+ # locations.
+ # Where necessary, turn off this protection to ensure that
+ # our -gdb.py script can be loaded - but not on earlier gdb builds
+ # as this would generate noise on stderr (rhbz#817072):
+ init_commands = ['set auto-load safe-path /']
+ else:
+ init_commands = []
+
+
# GDB as of 7.4 onwards can distinguish between the
# value of a variable at entry vs current value:
# http://sourceware.org/gdb/onlinedocs/gdb/Variables.html
@@ -198,10 +222,11 @@ class DebuggerTests(unittest.TestCase):
else:
commands += ['backtrace']
- # print commands
+ # print init_commands
# Use "commands" to generate the arguments with which to invoke "gdb":
args = ["gdb", "--batch", "-nx"]
+ args += ['--init-eval-command=%s' % cmd for cmd in init_commands]
args += ['--eval-command=%s' % cmd for cmd in commands]
args += ["--args",
sys.executable]