Skip to content

Commit 760914c

Browse files
committed
Limit the platform rewrite to the profiler implementation
1 parent 4b2bdb1 commit 760914c

3 files changed

Lines changed: 0 additions & 254 deletions

File tree

‎Lib/test/test_capi/test_remote_debug_macho.py‎

Lines changed: 0 additions & 118 deletions
This file was deleted.

‎Lib/test/test_external_inspection.py‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,46 +3501,6 @@ def test_finally_no_exception_no_flag(self):
35013501
self._check_exception_status(p, thread_tid, expect_exception=False)
35023502

35033503

3504-
@skip_if_not_supported
3505-
class TestThreadStatusInProcess(RemoteInspectionTestBase):
3506-
def test_new_threads_with_reused_unwinder(self):
3507-
from test.support import threading_helper
3508-
3509-
try:
3510-
unwinder = RemoteUnwinder(
3511-
os.getpid(), all_threads=True, mode=PROFILING_MODE_CPU,
3512-
skip_non_matching_threads=False,
3513-
)
3514-
except PermissionError as exc:
3515-
self.skipTest(f"self-inspection is unavailable: {exc}")
3516-
3517-
# Reuse one unwinder across thread exits and new native thread IDs.
3518-
for iteration in range(5):
3519-
with self.subTest(iteration=iteration):
3520-
ready = threading.Event()
3521-
stop = threading.Event()
3522-
3523-
def sleeper():
3524-
ready.set()
3525-
stop.wait()
3526-
3527-
thread = threading.Thread(target=sleeper)
3528-
with threading_helper.start_threads([thread], stop.set):
3529-
self.assertTrue(ready.wait(SHORT_TIMEOUT))
3530-
statuses = {}
3531-
for _ in busy_retry(SHORT_TIMEOUT):
3532-
with contextlib.suppress(*TRANSIENT_ERRORS):
3533-
statuses = self._get_thread_statuses(unwinder.get_stack_trace())
3534-
status = statuses.get(thread.native_id)
3535-
if status is not None and not status & (
3536-
THREAD_STATUS_UNKNOWN | THREAD_STATUS_ON_CPU
3537-
):
3538-
break
3539-
self.assertIn(thread.native_id, statuses)
3540-
self.assertFalse(statuses[thread.native_id] & THREAD_STATUS_UNKNOWN)
3541-
self.assertFalse(statuses[thread.native_id] & THREAD_STATUS_ON_CPU)
3542-
3543-
35443504
@skip_if_not_supported
35453505
class TestExceptionDetectionInProcess(RemoteInspectionTestBase):
35463506
"""gh-158539: HAS_EXCEPTION for handlers running in generators/coroutines.

‎Modules/_testinternalcapi.c‎

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,103 +3482,7 @@ static PyTypeObject SelfInterruptingContextManager_Type = {
34823482
};
34833483

34843484

3485-
#ifdef __APPLE__
3486-
# include <TargetConditionals.h>
3487-
# if TARGET_OS_OSX
3488-
# include "pycore_debug_offsets.h"
3489-
# include "../Python/remote_debug.h"
3490-
3491-
static PyObject *
3492-
get_macho_section_address(PyObject *self, PyObject *args)
3493-
{
3494-
const char *image, *section;
3495-
Py_ssize_t size;
3496-
unsigned long long base;
3497-
if (!PyArg_ParseTuple(args, "y#Ks", &image, &size, &base, &section)) {
3498-
return NULL;
3499-
}
3500-
if (base > UINTPTR_MAX) {
3501-
return PyErr_Format(PyExc_OverflowError, "base does not fit uintptr_t");
3502-
}
3503-
uintptr_t address = macho_section_address(image, size, base, section);
3504-
if (PyErr_Occurred()) {
3505-
return NULL;
3506-
}
3507-
return PyLong_FromUnsignedLongLong(address);
3508-
}
3509-
3510-
static PyObject *
3511-
check_macho_runtime_address(PyObject *self, PyObject *Py_UNUSED(ignored))
3512-
{
3513-
proc_handle_t *handle = PyMem_Calloc(1, sizeof(*handle));
3514-
if (handle == NULL) {
3515-
return PyErr_NoMemory();
3516-
}
3517-
if (_Py_RemoteDebug_InitProcHandle(handle, getpid()) == 0) {
3518-
uintptr_t address = search_memory_regions_for_section(
3519-
handle, "PyRuntime", _Py_RemoteDebug_ValidatePyRuntimeCookie);
3520-
if (!PyErr_Occurred() && address != (uintptr_t)&_PyRuntime) {
3521-
PyErr_SetString(PyExc_AssertionError, "Memory-region lookup returned the wrong runtime");
3522-
}
3523-
}
3524-
_Py_RemoteDebug_CleanupProcHandle(handle);
3525-
PyMem_Free(handle);
3526-
if (PyErr_Occurred()) {
3527-
return NULL;
3528-
}
3529-
Py_RETURN_NONE;
3530-
}
3531-
3532-
static PyObject *
3533-
get_dyld_image_addresses(PyObject *self, PyObject *Py_UNUSED(ignored))
3534-
{
3535-
proc_handle_t *handle = PyMem_Calloc(1, sizeof(*handle));
3536-
if (handle == NULL) {
3537-
return PyErr_NoMemory();
3538-
}
3539-
PyObject *result = NULL;
3540-
unsigned char *images = NULL;
3541-
if (_Py_RemoteDebug_InitProcHandle(handle, getpid()) < 0) {
3542-
goto done;
3543-
}
3544-
DyldImageList list;
3545-
images = copy_dyld_images(handle, &list);
3546-
if (images == NULL) {
3547-
if (!PyErr_Occurred()) {
3548-
result = PyList_New(0);
3549-
}
3550-
goto done;
3551-
}
3552-
result = PyList_New(list.count);
3553-
if (result == NULL) {
3554-
goto done;
3555-
}
3556-
for (uint32_t index = 0; index < list.count; index++) {
3557-
uint64_t address = read_dyld_pointer(
3558-
images + index * (3 * list.pointer_size), list.pointer_size);
3559-
PyObject *item = PyLong_FromUnsignedLongLong(address);
3560-
if (item == NULL) {
3561-
Py_CLEAR(result);
3562-
goto done;
3563-
}
3564-
PyList_SET_ITEM(result, index, item);
3565-
}
3566-
done:
3567-
PyMem_Free(images);
3568-
_Py_RemoteDebug_CleanupProcHandle(handle);
3569-
PyMem_Free(handle);
3570-
return result;
3571-
}
3572-
3573-
# endif
3574-
#endif
3575-
35763485
static PyMethodDef module_functions[] = {
3577-
#if defined(__APPLE__) && TARGET_OS_OSX
3578-
{"get_macho_section_address", get_macho_section_address, METH_VARARGS},
3579-
{"get_dyld_image_addresses", get_dyld_image_addresses, METH_NOARGS},
3580-
{"check_macho_runtime_address", check_macho_runtime_address, METH_NOARGS},
3581-
#endif
35823486
{"get_configs", get_configs, METH_NOARGS},
35833487
{"get_eval_frame_stats", get_eval_frame_stats, METH_NOARGS, NULL},
35843488
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},

0 commit comments

Comments
 (0)