@@ -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-
35763485static 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