| 104 | |
| 105 | |
| 106 | def check_usable_gdb(): |
| 107 | # Verify that "gdb" was built with the embedded Python support enabled and |
| 108 | # verify that "gdb" can load our custom hooks, as OS security settings may |
| 109 | # disallow this without a customized .gdbinit. |
| 110 | stdout, stderr = run_gdb( |
| 111 | '--eval-command=python import sys; print(sys.version_info)', |
| 112 | '--args', sys.executable, |
| 113 | check=False) |
| 114 | |
| 115 | if "auto-loading has been declined" in stderr: |
| 116 | raise unittest.SkipTest( |
| 117 | f"gdb security settings prevent use of custom hooks; " |
| 118 | f"stderr: {stderr!r}") |
| 119 | |
| 120 | if not stdout: |
| 121 | raise unittest.SkipTest( |
| 122 | f"gdb not built with embedded python support; " |
| 123 | f"stderr: {stderr!r}") |
| 124 | |
| 125 | if "major=2" in stdout: |
| 126 | raise unittest.SkipTest("gdb built with Python 2") |
| 127 | |
| 128 | check_usable_gdb() |
| 129 | |