OLD | NEW |
1 # Verify that gdb can pretty-print the various PyObject* types | 1 # Verify that gdb can pretty-print the various PyObject* types |
2 # | 2 # |
3 # The code for testing gdb was adapted from similar work in Unladen Swallow's | 3 # The code for testing gdb was adapted from similar work in Unladen Swallow's |
4 # Lib/test/test_jit_gdb.py | 4 # Lib/test/test_jit_gdb.py |
5 | 5 |
6 import os | 6 import os |
7 import re | 7 import re |
8 import pprint | 8 import pprint |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 14 matching lines...) Expand all Loading... |
25 try: | 25 try: |
26 proc = subprocess.Popen(["gdb", "-nx", "--version"], | 26 proc = subprocess.Popen(["gdb", "-nx", "--version"], |
27 stdout=subprocess.PIPE, | 27 stdout=subprocess.PIPE, |
28 universal_newlines=True) | 28 universal_newlines=True) |
29 with proc: | 29 with proc: |
30 version = proc.communicate()[0] | 30 version = proc.communicate()[0] |
31 except OSError: | 31 except OSError: |
32 # This is what "no gdb" looks like. There may, however, be other | 32 # This is what "no gdb" looks like. There may, however, be other |
33 # errors that manifest this way too. | 33 # errors that manifest this way too. |
34 raise unittest.SkipTest("Couldn't find gdb on the path") | 34 raise unittest.SkipTest("Couldn't find gdb on the path") |
| 35 except AttributeError: |
| 36 raise unittest.SkipTest("subprocess module doesn't provide Popen()") |
35 | 37 |
36 # Regex to parse: | 38 # Regex to parse: |
37 # 'GNU gdb (GDB; SUSE Linux Enterprise 12) 7.7\n' -> 7.7 | 39 # 'GNU gdb (GDB; SUSE Linux Enterprise 12) 7.7\n' -> 7.7 |
38 # 'GNU gdb (GDB) Fedora 7.9.1-17.fc22\n' -> 7.9 | 40 # 'GNU gdb (GDB) Fedora 7.9.1-17.fc22\n' -> 7.9 |
39 # 'GNU gdb 6.1.1 [FreeBSD]\n' -> 6.1 | 41 # 'GNU gdb 6.1.1 [FreeBSD]\n' -> 6.1 |
40 # 'GNU gdb (GDB) Fedora (7.5.1-37.fc18)\n' -> 7.5 | 42 # 'GNU gdb (GDB) Fedora (7.5.1-37.fc18)\n' -> 7.5 |
41 match = re.search(r"^GNU gdb.*?\b(\d+)\.(\d+)", version) | 43 match = re.search(r"^GNU gdb.*?\b(\d+)\.(\d+)", version) |
42 if match is None: | 44 if match is None: |
43 raise Exception("unable to parse GDB version: %r" % version) | 45 raise Exception("unable to parse GDB version: %r" % version) |
44 return (version, int(match.group(1)), int(match.group(2))) | 46 return (version, int(match.group(1)), int(match.group(2))) |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 run_unittest(PrettyPrintTests, | 920 run_unittest(PrettyPrintTests, |
919 PyListTests, | 921 PyListTests, |
920 StackNavigationTests, | 922 StackNavigationTests, |
921 PyBtTests, | 923 PyBtTests, |
922 PyPrintTests, | 924 PyPrintTests, |
923 PyLocalsTests | 925 PyLocalsTests |
924 ) | 926 ) |
925 | 927 |
926 if __name__ == "__main__": | 928 if __name__ == "__main__": |
927 test_main() | 929 test_main() |
OLD | NEW |