Index: Tools/gdb/libpython.py =================================================================== --- Tools/gdb/libpython.py (revision 80217) +++ Tools/gdb/libpython.py (working copy) @@ -1309,8 +1309,6 @@ def invoke(self, args, from_tty): move_in_stack(move_up=True) -PyUp() - class PyDown(gdb.Command): 'Select and print the python stack frame called by this one (if any)' def __init__(self): @@ -1323,7 +1321,10 @@ def invoke(self, args, from_tty): move_in_stack(move_up=False) -PyDown() +# Not all builds of gdb have gdb.Frame.select +if hasattr(gdb.Frame, 'select'): + PyUp() + PyDown() class PyBacktrace(gdb.Command): 'Display the current python frame and all the frames within its call stack (if any)' Index: Lib/test/test_gdb.py =================================================================== --- Lib/test/test_gdb.py (revision 80217) +++ Lib/test/test_gdb.py (working copy) @@ -31,6 +31,17 @@ if gdbpy_version == '': raise unittest.SkipTest("gdb not built with embedded python support") +def gdb_has_frame_select(): + # Does this build of gdb have gdb.Frame.select ? + cmd = "--eval-command=python print(dir(gdb.Frame))" + p = subprocess.Popen(["gdb", "--batch", cmd], + stdout=subprocess.PIPE) + stdout, _ = p.communicate() + m = re.match(r'.*\[(.*)\].*', stdout) + if not m: + raise unittest.SkipTest("Unable to parse output from gdb.Frame.select test") + gdb_frame_dir = m.group(1).split(', ') + return "'select'" in gdb_frame_dir class DebuggerTests(unittest.TestCase): @@ -660,13 +671,17 @@ r".*\na = 1\nb = 2\nc = 3\n.*") def test_main(): - run_unittest(PrettyPrintTests, - PyListTests, - StackNavigationTests, - PyBtTests, - PyPrintTests, - PyLocalsTests - ) + tests = [PrettyPrintTests, + PyListTests, + PyBtTests, + PyPrintTests, + PyLocalsTests] + # Not all builds of gdb have gdb.Frame.select + if gdb_has_frame_select(): + tests.append(StackNavigationTests) + + run_unittest(*tests) + if __name__ == "__main__": test_main()