|
4 | 4 | import sys |
5 | 5 | import unittest |
6 | 6 |
|
| 7 | +from test.support import import_helper |
| 8 | + |
7 | 9 | from .util import setup_module, DebuggerTests |
8 | 10 |
|
9 | 11 |
|
| 12 | +_testinternalcapi = import_helper.import_module("_testinternalcapi") |
| 13 | +NATIVE_JIT_ENABLED = ( |
| 14 | + hasattr(sys, "_jit") |
| 15 | + and sys._jit.is_enabled() |
| 16 | + and _testinternalcapi.get_jit_backend() == "jit" |
| 17 | +) |
| 18 | + |
10 | 19 | JIT_SAMPLE_SCRIPT = os.path.join(os.path.dirname(__file__), "gdb_jit_sample.py") |
11 | 20 | # In batch GDB, break in builtin_id() while it is running under JIT, |
12 | 21 | # then repeatedly "finish" until the selected frame is the JIT executor. |
@@ -62,14 +71,14 @@ def setUpModule(): |
62 | 71 | # Python/jit_unwind.c, and the synthetic EH-frame is only implemented for |
63 | 72 | # x86_64 and AArch64 (a #error fires otherwise). Skip cleanly on other |
64 | 73 | # platforms or architectures instead of producing timeouts / empty backtraces. |
65 | | -# is_enabled() implies is_available() and also implies that the runtime has |
66 | | -# JIT execution active; interpreter-only tier 2 builds don't hit this path. |
| 74 | +# sys._jit.is_enabled() is true for --enable-experimental-jit=interpreter, |
| 75 | +# but these tests need native JIT code and a py::jit:executor frame. |
67 | 76 | @unittest.skipUnless(sys.platform == "linux", |
68 | 77 | "GDB JIT interface is only implemented for Linux + ELF") |
69 | 78 | @unittest.skipUnless(platform.machine() in ("x86_64", "aarch64"), |
70 | 79 | "GDB JIT CFI emitter only supports x86_64 and AArch64") |
71 | | -@unittest.skipUnless(hasattr(sys, "_jit") and sys._jit.is_enabled(), |
72 | | - "requires a JIT-enabled build with JIT execution active") |
| 80 | +@unittest.skipUnless(NATIVE_JIT_ENABLED, |
| 81 | + "requires native JIT execution active") |
73 | 82 | class JitBacktraceTests(DebuggerTests): |
74 | 83 | def get_stack_trace(self, **kwargs): |
75 | 84 | # These tests validate the JIT-relevant part of the backtrace via |
|
0 commit comments