Skip to content

Commit 36abc8d

Browse files
committed
pep[78]
1 parent a3a6dcd commit 36abc8d

4 files changed

Lines changed: 40 additions & 17 deletions

File tree

‎Lib/test/test_external_inspection.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,13 @@ def test_inherited_unwinder(self):
503503
assert unwinder.get_stack_trace()
504504
else:
505505
check = unittest.TestCase()
506-
for name in ("get_stats", "get_stack_trace", "get_async_stack_trace",
507-
"get_all_awaited_by", "pause_threads", "resume_threads"):
508-
with check.assertRaisesRegex(RuntimeError, "after fork", msg=name):
506+
for name in (
507+
"get_stats", "get_stack_trace", "get_async_stack_trace",
508+
"get_all_awaited_by", "pause_threads", "resume_threads",
509+
):
510+
with check.assertRaisesRegex(
511+
RuntimeError, "after fork", msg=name
512+
):
509513
getattr(unwinder, name)()
510514
with check.assertRaisesRegex(RuntimeError, "after fork"):
511515
unwinder.__init__(os.getpid())

‎Modules/_remote_debugging/frame_cache.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,17 @@ read_last_profiled_anchor(RemoteUnwinderObject *unwinder,
167167
// remote-memory read.
168168
if (seq_offset == frame_offset + sizeof(uintptr_t)) {
169169
uintptr_t live_anchor[2];
170-
int rc = _Py_RemoteDebug_AliasedReadRemoteMemory(&unwinder->handle,
171-
thread_state_addr + frame_offset,
172-
sizeof(live_anchor),
173-
live_anchor);
170+
int rc = _Py_RemoteDebug_AliasedReadRemoteMemory(
171+
&unwinder->handle, thread_state_addr + frame_offset,
172+
sizeof(live_anchor), live_anchor);
174173
if (rc < 0) {
175174
return -1;
176175
}
177176
if (rc > 0
178-
&& _Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle,
179-
thread_state_addr + frame_offset,
180-
sizeof(live_anchor),
181-
live_anchor) < 0) {
177+
&& _Py_RemoteDebug_ReadRemoteMemory(
178+
&unwinder->handle, thread_state_addr + frame_offset,
179+
sizeof(live_anchor), live_anchor) < 0)
180+
{
182181
return -1;
183182
}
184183
anchor->frame = live_anchor[0];

‎Modules/_remote_debugging/module.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ read_interp_state_and_maybe_thread_frame(
607607
}
608608
if (aliased == 0) {
609609
if (prefetch->tstate_addr != 0) {
610-
size_t tstate_size = (size_t)unwinder->debug_offsets.thread_state.size;
610+
size_t tstate_size =
611+
(size_t)unwinder->debug_offsets.thread_state.size;
611612
int rc = _Py_RemoteDebug_AliasedReadRemoteMemory(
612613
&unwinder->handle, prefetch->tstate_addr, tstate_size,
613614
tstate_buffer);
@@ -1372,7 +1373,9 @@ RemoteUnwinder_dealloc(PyObject *op)
13721373
PyTypeObject *tp = Py_TYPE(self);
13731374

13741375
#ifdef Py_REMOTE_DEBUG_SUPPORTS_BLOCKING
1375-
if (self->threads_stopped && !_Py_RemoteDebug_HandleIsInherited(&self->handle)) {
1376+
if (self->threads_stopped
1377+
&& !_Py_RemoteDebug_HandleIsInherited(&self->handle))
1378+
{
13761379
_Py_RemoteDebug_ResumeAllThreads(self, &self->threads_state);
13771380
self->threads_stopped = 0;
13781381
}

‎Python/remote_debug.h‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@ static alias_page_entry_t *
16121612
alias_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
16521654
alias_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
16861689
alias_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.
18561868
UNUSED 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

Comments
 (0)