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

Appearance settings

Latest commit

 

History

History
History
66 lines (58 loc) · 2.37 KB

File metadata and controls

66 lines (58 loc) · 2.37 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/******************************************************************************
* Remote Debugging Module - Interpreters Functions
*
* This file contains function for iterating interpreters.
******************************************************************************/
#include "_remote_debugging.h"
int
iterate_interpreters(
RuntimeOffsets *offsets,
interpreter_processor_func processor,
void *context
) {
uintptr_t interpreters_head_addr =
offsets->runtime_start_address
+ (uintptr_t)offsets->debug_offsets.runtime_state.interpreters_head;
uintptr_t interpreter_id_offset =
(uintptr_t)offsets->debug_offsets.interpreter_state.id;
uintptr_t interpreter_next_offset =
(uintptr_t)offsets->debug_offsets.interpreter_state.next;
uintptr_t interpreter_state_addr;
if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle,
interpreters_head_addr,
sizeof(void*),
&interpreter_state_addr) < 0) {
set_exception_cause(offsets, PyExc_RuntimeError, "Failed to read interpreter state address");
return -1;
}
if (interpreter_state_addr == 0) {
PyErr_SetString(PyExc_RuntimeError, "No interpreter state found");
return -1;
}
int64_t iid = 0;
static_assert(
sizeof((((PyInterpreterState*)NULL)->id)) == sizeof(iid),
"Sizeof of PyInterpreterState.id mismatch with local iid value");
while (interpreter_state_addr != 0) {
if (_Py_RemoteDebug_ReadRemoteMemory(
&offsets->handle,
interpreter_state_addr + interpreter_id_offset,
sizeof(iid),
&iid) < 0) {
set_exception_cause(offsets, PyExc_RuntimeError, "Failed to read interpreter id");
return -1;
}
if (processor(offsets, interpreter_state_addr, iid, context) < 0) {
return -1;
}
if (_Py_RemoteDebug_ReadRemoteMemory(
&offsets->handle,
interpreter_state_addr + interpreter_next_offset,
sizeof(void*),
&interpreter_state_addr) < 0) {
set_exception_cause(offsets, PyExc_RuntimeError, "Failed to read next interpreter state");
return -1;
}
}
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.