@@ -1612,6 +1612,7 @@ static alias_page_entry_t *
16121612alias_find_entry (proc_handle_t * handle , uintptr_t page_base )
16131613{
16141614 alias_read_cache_t * cache = & handle -> alias ;
1615+
16151616 for (int i = 0 ; i < MAX_ALIAS_PAGES ; i ++ ) {
16161617 alias_page_entry_t * entry = & cache -> pages [i ];
16171618 if (entry -> valid && entry -> remote_page_base == page_base ) {
@@ -1625,6 +1626,7 @@ static void
16251626_Py_RemoteDebug_AliasCacheClear (proc_handle_t * handle )
16261627{
16271628 alias_read_cache_t * cache = & handle -> alias ;
1629+
16281630 for (int i = 0 ; i < MAX_ALIAS_PAGES ; i ++ ) {
16291631 alias_invalidate_entry (& cache -> pages [i ]);
16301632 }
@@ -1652,6 +1654,7 @@ static void
16521654alias_cache_init (proc_handle_t * handle )
16531655{
16541656 alias_read_cache_t * cache = & handle -> alias ;
1657+
16551658 cache -> initialized = 1 ;
16561659 cache -> probe_mask = ALIAS_PROBE_DEFAULT_MASK ;
16571660
@@ -1686,6 +1689,7 @@ static int
16861689alias_maybe_probe_entry (proc_handle_t * handle , alias_page_entry_t * entry )
16871690{
16881691 alias_read_cache_t * cache = & handle -> alias ;
1692+
16891693 if (-- entry -> probe_countdown != 0 ) {
16901694 return 1 ;
16911695 }
@@ -1782,10 +1786,12 @@ alias_remap_page(proc_handle_t *handle,
17821786 alias_read_cache_t * cache = & handle -> alias ;
17831787 alias_page_entry_t * entry = alias_alloc_entry (handle );
17841788 kern_return_t kr = alias_map_readonly_page (handle , page_base , entry );
1789+
17851790 if (kr != KERN_SUCCESS ) {
17861791 alias_invalidate_entry (entry );
17871792 if (kr == MACH_SEND_INVALID_DEST || kr == KERN_TERMINATED
1788- || kr == KERN_NOT_SUPPORTED ) {
1793+ || kr == KERN_NOT_SUPPORTED )
1794+ {
17891795 alias_disable_runtime (handle );
17901796 }
17911797 return -1 ;
@@ -1816,6 +1822,7 @@ alias_lookup_page(proc_handle_t *handle,
18161822 alias_page_entry_t * * entry_out )
18171823{
18181824 alias_read_cache_t * cache = & handle -> alias ;
1825+
18191826 if (!cache -> initialized ) {
18201827 alias_cache_init (handle );
18211828 }
@@ -1846,6 +1853,11 @@ alias_lookup_page(proc_handle_t *handle,
18461853 return 0 ;
18471854}
18481855
1856+ #undef MAX_ALIAS_PAGES
1857+ #undef ALIAS_PROBE_DEFAULT_MASK
1858+ #undef ALIAS_PROBE_MIN_MASK
1859+ #undef ALIAS_PROBE_MAX_MASK
1860+
18491861#endif /* defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX */
18501862
18511863// Optional fast path: serve the read from a mapping of the remote pages when
@@ -1854,10 +1866,13 @@ alias_lookup_page(proc_handle_t *handle,
18541866// recycled under the sample. Only for memory whose mapping is stable for the
18551867// lifetime of the target structure; data stack chunks are not.
18561868UNUSED static int
1857- _Py_RemoteDebug_AliasedReadRemoteMemory (proc_handle_t * handle , uintptr_t remote_address , size_t len , void * dst )
1869+ _Py_RemoteDebug_AliasedReadRemoteMemory (proc_handle_t * handle ,
1870+ uintptr_t remote_address ,
1871+ size_t len , void * dst )
18581872{
18591873#if defined(__APPLE__ ) && defined(TARGET_OS_OSX ) && TARGET_OS_OSX
18601874 size_t page_size = handle -> page_size ;
1875+
18611876 if (len == 0 || len > 2 * page_size ) {
18621877 return 1 ;
18631878 }
@@ -1876,7 +1891,8 @@ _Py_RemoteDebug_AliasedReadRemoteMemory(proc_handle_t *handle, uintptr_t remote_
18761891 if (rc != 0 ) {
18771892 return rc ;
18781893 }
1879- memcpy (out , (const char * )alias -> local_page_base + offset_in_page , span );
1894+ memcpy (out , (const char * )alias -> local_page_base + offset_in_page ,
1895+ span );
18801896 addr += span ;
18811897 out += span ;
18821898 remaining -= span ;
@@ -1903,7 +1919,8 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle,
19031919
19041920 // Aliases copy only the requested bytes, with no page snapshot, so
19051921 // repeated reads of one page within a sample may differ.
1906- int aliased = _Py_RemoteDebug_AliasedReadRemoteMemory (handle , addr , size , out );
1922+ int aliased =
1923+ _Py_RemoteDebug_AliasedReadRemoteMemory (handle , addr , size , out );
19071924 if (aliased <= 0 ) {
19081925 return aliased ;
19091926 }
0 commit comments