Skip to content

Commit c179848

Browse files
committed
Fix test for raspian, macOS x86_64 and wasi
1 parent 5d53a15 commit c179848

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

Lib/test/test_frame_pointer_unwind.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,27 @@ def _frame_pointers_expected(machine):
2727
)
2828
if "no-omit-frame-pointer" in cflags:
2929
return True
30-
if machine in {"aarch64", "arm64"}:
31-
return "-fomit-frame-pointer" not in cflags
32-
if machine == "x86_64":
30+
if "omit-frame-pointer" in cflags:
3331
return False
34-
# MSVC ignores /Oy and /Oy- on x64/ARM64.
35-
if sys.platform == "win32" and machine == "arm64":
36-
# Windows ARM64 guidelines recommend frame pointers (x29) for stack walking.
32+
if sys.platform == "darwin":
33+
# macOS x86_64/ARM64 always have frame pointer by default.
3734
return True
38-
if sys.platform == "win32" and machine == "x86_64":
39-
# Windows x64 uses unwind metadata; frame pointers are not required.
40-
return None
35+
if sys.platform == "linux":
36+
if machine in {"aarch64", "arm64"}:
37+
# 32-bit Linux is not supported
38+
if sys.maxsize < 2**32:
39+
return None
40+
return True
41+
if machine == "x86_64":
42+
return False
43+
if sys.platform == "win32":
44+
# MSVC ignores /Oy and /Oy- on x64/ARM64.
45+
if machine == "arm64":
46+
# Windows ARM64 guidelines recommend frame pointers (x29) for stack walking.
47+
return True
48+
elif machine == "x86_64":
49+
# Windows x64 uses unwind metadata; frame pointers are not required.
50+
return None
4151
return None
4252

4353

@@ -139,6 +149,7 @@ def _manual_unwind_length(**env):
139149
) from exc
140150

141151

152+
@unittest.skipIf(support.is_wasi, "test not supported on WASI")
142153
class FramePointerUnwindTests(unittest.TestCase):
143154

144155
def setUp(self):

Modules/_testinternalcapi.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
// Include test definitions from _testinternalcapi/
4545
#include "_testinternalcapi/parts.h"
4646

47-
#ifdef HAVE_DLFCN_H
47+
#if defined(HAVE_DLADDR) && !defined(__wasi__)
4848
# include <dlfcn.h>
4949
#endif
5050
#ifdef MS_WINDOWS
@@ -178,7 +178,18 @@ classify_address(uintptr_t addr, int jit_enabled, PyInterpreterState *interp)
178178
#endif
179179
return "other";
180180
}
181-
#elif defined(HAVE_DLFCN_H)
181+
#elif defined(__wasi__)
182+
static const char *
183+
classify_address(uintptr_t addr, int jit_enabled, PyInterpreterState *interp)
184+
{
185+
#ifdef _Py_JIT
186+
if (jit_enabled && _PyJIT_AddressInJitCode(interp, addr)) {
187+
return "jit";
188+
}
189+
#endif
190+
return "other";
191+
}
192+
#elif defined(HAVE_DLADDR) && !defined(__wasi__)
182193
static const char *
183194
classify_address(uintptr_t addr, int jit_enabled, PyInterpreterState *interp)
184195
{

0 commit comments

Comments
 (0)