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

gh-91048: Refactor _testexternalinspection and add Windows support#132852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 10 commits intopython:mainfrompablogsal:gh-91048-2
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
gh-91048: Refactor _testexternalinspection and add Windows support
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
@pablogsal
pablogsal committedApr 25, 2025
commit4b40cb2a2fd07984b7d18dc32a18a688d1aa9e84
49 changes: 49 additions & 0 deletionsInclude/internal/pycore_remote_debug.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
#ifndef Py_INTERNAL_REMOTE_DEBUG_H
#define Py_INTERNAL_REMOTE_DEBUG_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

#include <stdio.h>

#ifndef MS_WINDOWS
#include <unistd.h>
#endif

// Define a platform-independent process handle structure
typedef struct {
pid_t pid;
#ifdef MS_WINDOWS
HANDLE hProcess;
#endif
} proc_handle_t;

// Initialize a process handle
PyAPI_FUNC(int) _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t pid);

// Cleanup a process handle
PyAPI_FUNC(void) _Py_RemoteDebug_CleanupProcHandle(proc_handle_t *handle);

// Get the PyRuntime section address from a process
PyAPI_FUNC(uintptr_t) _Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t *handle);

// Get the PyAsyncioDebug section address from a process
PyAPI_FUNC(uintptr_t) _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t *handle);

// Read memory from a remote process
PyAPI_FUNC(int) _Py_RemoteDebug_ReadRemoteMemory(proc_handle_t *handle, uintptr_t remote_address, size_t len, void* dst);

// Write memory to a remote process
PyAPI_FUNC(int) _Py_RemoteDebug_WriteRemoteMemory(proc_handle_t *handle, uintptr_t remote_address, size_t len, const void* src);

// Read debug offsets from a remote process
PyAPI_FUNC(int) _Py_RemoteDebug_ReadDebugOffsets(proc_handle_t *handle, uintptr_t *runtime_start_address, _Py_DebugOffsets* debug_offsets);

#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_DEBUG_OFFSETS_H */
25 changes: 11 additions & 14 deletionsLib/test/test_external_inspection.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,10 +24,13 @@ def _make_test_script(script_dir, script_basename, source):
importlib.invalidate_caches()
return to_return

skip_if_not_supported = unittest.skipIf((sys.platform != "darwin"
and sys.platform != "linux"
and sys.platform != "win32"),
"Test only runs on Linux, Windows and MacOS")
class TestGetStackTrace(unittest.TestCase):

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_remote_stack_trace(self):
Expand DownExpand Up@@ -79,8 +82,7 @@ def foo():
]
self.assertEqual(stack_trace, expected_stack_trace)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_async_remote_stack_trace(self):
Expand DownExpand Up@@ -169,8 +171,7 @@ def new_eager_loop():
]
self.assertEqual(stack_trace, expected_stack_trace)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_asyncgen_remote_stack_trace(self):
Expand DownExpand Up@@ -227,8 +228,7 @@ async def main():
]
self.assertEqual(stack_trace, expected_stack_trace)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_async_gather_remote_stack_trace(self):
Expand DownExpand Up@@ -287,8 +287,7 @@ async def main():
]
self.assertEqual(stack_trace, expected_stack_trace)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_async_staggered_race_remote_stack_trace(self):
Expand DownExpand Up@@ -350,8 +349,7 @@ async def main():
]
self.assertEqual(stack_trace, expected_stack_trace)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_async_global_awaited_by(self):
Expand DownExpand Up@@ -470,8 +468,7 @@ async def main():
p.terminate()
p.wait(timeout=SHORT_TIMEOUT)

@unittest.skipIf(sys.platform != "darwin" and sys.platform != "linux",
"Test only runs on Linux and MacOS")
@skip_if_not_supported
@unittest.skipIf(sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
"Test only runs on Linux with process_vm_readv support")
def test_self_trace(self):
Expand Down
1 change: 1 addition & 0 deletionsMakefile.pre.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1290,6 +1290,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_crossinterp.h \
$(srcdir)/Include/internal/pycore_crossinterp_data_registry.h \
$(srcdir)/Include/internal/pycore_debug_offsets.h \
$(srcdir)/Include/internal/pycore_remote_debug.h \
$(srcdir)/Include/internal/pycore_descrobject.h \
$(srcdir)/Include/internal/pycore_dict.h \
$(srcdir)/Include/internal/pycore_dict_state.h \
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp