Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite13c5a6

Browse files
committed
gh-91048: Refactor _testexternalinspection and add Windows support
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent1007aab commite13c5a6

11 files changed

+494
-645
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndefPy_INTERNAL_REMOTE_DEBUG_H
2+
#definePy_INTERNAL_REMOTE_DEBUG_H
3+
#ifdef__cplusplus
4+
extern"C" {
5+
#endif
6+
7+
#ifndefPy_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
#include<stdio.h>
12+
13+
#ifndefMS_WINDOWS
14+
#include<unistd.h>
15+
#endif
16+
17+
// Define a platform-independent process handle structure
18+
typedefstruct {
19+
pid_tpid;
20+
#ifdefMS_WINDOWS
21+
HANDLEhProcess;
22+
#endif
23+
}proc_handle_t;
24+
25+
// Initialize a process handle
26+
PyAPI_FUNC(int)_Py_RemoteDebug_InitProcHandle(proc_handle_t*handle,pid_tpid);
27+
28+
// Cleanup a process handle
29+
PyAPI_FUNC(void)_Py_RemoteDebug_CleanupProcHandle(proc_handle_t*handle);
30+
31+
// Get the PyRuntime section address from a process
32+
PyAPI_FUNC(uintptr_t)_Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t*handle);
33+
34+
// Get the PyAsyncioDebug section address from a process
35+
PyAPI_FUNC(uintptr_t)_Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t*handle);
36+
37+
// Read memory from a remote process
38+
PyAPI_FUNC(int)_Py_RemoteDebug_ReadRemoteMemory(proc_handle_t*handle,uintptr_tremote_address,size_tlen,void*dst);
39+
40+
// Write memory to a remote process
41+
PyAPI_FUNC(int)_Py_RemoteDebug_WriteRemoteMemory(proc_handle_t*handle,uintptr_tremote_address,size_tlen,constvoid*src);
42+
43+
// Read debug offsets from a remote process
44+
PyAPI_FUNC(int)_Py_RemoteDebug_ReadDebugOffsets(proc_handle_t*handle,uintptr_t*runtime_start_address,_Py_DebugOffsets*debug_offsets);
45+
46+
#ifdef__cplusplus
47+
}
48+
#endif
49+
#endif/* !Py_INTERNAL_DEBUG_OFFSETS_H */

‎Lib/test/test_external_inspection.py‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ def _make_test_script(script_dir, script_basename, source):
2424
importlib.invalidate_caches()
2525
returnto_return
2626

27+
skip_if_not_supported=unittest.skipIf((sys.platform!="darwin"
28+
andsys.platform!="linux"
29+
andsys.platform!="win32"),
30+
"Test only runs on Linux, Windows and MacOS")
2731
classTestGetStackTrace(unittest.TestCase):
2832

29-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
30-
"Test only runs on Linux and MacOS")
33+
@skip_if_not_supported
3134
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
3235
"Test only runs on Linux with process_vm_readv support")
3336
deftest_remote_stack_trace(self):
@@ -79,8 +82,7 @@ def foo():
7982
]
8083
self.assertEqual(stack_trace,expected_stack_trace)
8184

82-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
83-
"Test only runs on Linux and MacOS")
85+
@skip_if_not_supported
8486
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
8587
"Test only runs on Linux with process_vm_readv support")
8688
deftest_async_remote_stack_trace(self):
@@ -169,8 +171,7 @@ def new_eager_loop():
169171
]
170172
self.assertEqual(stack_trace,expected_stack_trace)
171173

172-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
173-
"Test only runs on Linux and MacOS")
174+
@skip_if_not_supported
174175
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
175176
"Test only runs on Linux with process_vm_readv support")
176177
deftest_asyncgen_remote_stack_trace(self):
@@ -227,8 +228,7 @@ async def main():
227228
]
228229
self.assertEqual(stack_trace,expected_stack_trace)
229230

230-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
231-
"Test only runs on Linux and MacOS")
231+
@skip_if_not_supported
232232
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
233233
"Test only runs on Linux with process_vm_readv support")
234234
deftest_async_gather_remote_stack_trace(self):
@@ -287,8 +287,7 @@ async def main():
287287
]
288288
self.assertEqual(stack_trace,expected_stack_trace)
289289

290-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
291-
"Test only runs on Linux and MacOS")
290+
@skip_if_not_supported
292291
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
293292
"Test only runs on Linux with process_vm_readv support")
294293
deftest_async_staggered_race_remote_stack_trace(self):
@@ -350,8 +349,7 @@ async def main():
350349
]
351350
self.assertEqual(stack_trace,expected_stack_trace)
352351

353-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
354-
"Test only runs on Linux and MacOS")
352+
@skip_if_not_supported
355353
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
356354
"Test only runs on Linux with process_vm_readv support")
357355
deftest_async_global_awaited_by(self):
@@ -470,8 +468,7 @@ async def main():
470468
p.terminate()
471469
p.wait(timeout=SHORT_TIMEOUT)
472470

473-
@unittest.skipIf(sys.platform!="darwin"andsys.platform!="linux",
474-
"Test only runs on Linux and MacOS")
471+
@skip_if_not_supported
475472
@unittest.skipIf(sys.platform=="linux"andnotPROCESS_VM_READV_SUPPORTED,
476473
"Test only runs on Linux with process_vm_readv support")
477474
deftest_self_trace(self):

‎Makefile.pre.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,7 @@ PYTHON_HEADERS= \
12901290
$(srcdir)/Include/internal/pycore_crossinterp.h \
12911291
$(srcdir)/Include/internal/pycore_crossinterp_data_registry.h \
12921292
$(srcdir)/Include/internal/pycore_debug_offsets.h \
1293+
$(srcdir)/Include/internal/pycore_remote_debug.h \
12931294
$(srcdir)/Include/internal/pycore_descrobject.h \
12941295
$(srcdir)/Include/internal/pycore_dict.h \
12951296
$(srcdir)/Include/internal/pycore_dict_state.h \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp