| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1007aab commit ba2f5cf
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -373,6 +373,10 @@ PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyS | |||
| 373 | 373 | #endif | |
| 374 | 374 | #endif | |
| 375 | 375 | ||
| 376 | + #if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG) | ||
| 377 | + extern int _PyRunRemoteDebugger(PyThreadState *tstate); | ||
| 378 | + #endif | ||
| 379 | + | ||
| 376 | 380 | #ifdef __cplusplus | |
| 377 | 381 | } | |
| 378 | 382 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1777,6 +1777,10 @@ PyErr_CheckSignals(void) | |||
| 1777 | 1777 | _Py_RunGC(tstate); | |
| 1778 | 1778 | } | |
| 1779 | 1779 | ||
| 1780 | + #if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG) | ||
| 1781 | + _PyRunRemoteDebugger(tstate); | ||
| 1782 | + #endif | ||
| 1783 | + | ||
| 1780 | 1784 | if (!_Py_ThreadCanHandleSignals(tstate->interp)) { | |
| 1781 | 1785 | return 0; | |
| 1782 | 1786 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1242,6 +1242,37 @@ static inline void run_remote_debugger_script(const char *path) | |||
| 1242 | 1242 | PyErr_FormatUnraisable("Error executing debugger script %s", path); | |
| 1243 | 1243 | } | |
| 1244 | 1244 | } | |
| 1245 | + | ||
| 1246 | + int _PyRunRemoteDebugger(PyThreadState *tstate) | ||
| 1247 | + { | ||
| 1248 | + const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); | ||
| 1249 | + if (config->remote_debug == 1 | ||
| 1250 | + && tstate->remote_debugger_support.debugger_pending_call == 1) | ||
| 1251 | + { | ||
| 1252 | + tstate->remote_debugger_support.debugger_pending_call = 0; | ||
| 1253 | + | ||
| 1254 | + // Immediately make a copy in case of a race with another debugger | ||
| 1255 | + // process that's trying to write to the buffer. At least this way | ||
| 1256 | + // we'll be internally consistent: what we audit is what we run. | ||
| 1257 | + const size_t pathsz | ||
| 1258 | + = sizeof(tstate->remote_debugger_support.debugger_script_path); | ||
| 1259 | + | ||
| 1260 | + char *path = PyMem_Malloc(pathsz); | ||
| 1261 | + if (path) { | ||
| 1262 | + // And don't assume the debugger correctly null terminated it. | ||
| 1263 | + memcpy( | ||
| 1264 | + path, | ||
| 1265 | + tstate->remote_debugger_support.debugger_script_path, | ||
| 1266 | + pathsz); | ||
| 1267 | + path[pathsz - 1] = '\0'; | ||
| 1268 | + if (*path) { | ||
| 1269 | + run_remote_debugger_script(path); | ||
| 1270 | + } | ||
| 1271 | + PyMem_Free(path); | ||
| 1272 | + } | ||
| 1273 | + } | ||
| 1274 | + } | ||
| 1275 | + | ||
| 1245 | 1276 | #endif | |
| 1246 | 1277 | ||
| 1247 | 1278 | /* Do periodic things, like check for signals and async I/0. | |
@@ -1372,32 +1403,7 @@ _Py_HandlePending(PyThreadState *tstate) | |||
| 1372 | 1403 | } | |
| 1373 | 1404 | ||
| 1374 | 1405 | #if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG) | |
| 1375 | - const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); | ||
| 1376 | - if (config->remote_debug == 1 | ||
| 1377 | - && tstate->remote_debugger_support.debugger_pending_call == 1) | ||
| 1378 | - { | ||
| 1379 | - tstate->remote_debugger_support.debugger_pending_call = 0; | ||
| 1380 | - | ||
| 1381 | - // Immediately make a copy in case of a race with another debugger | ||
| 1382 | - // process that's trying to write to the buffer. At least this way | ||
| 1383 | - // we'll be internally consistent: what we audit is what we run. | ||
| 1384 | - const size_t pathsz | ||
| 1385 | - = sizeof(tstate->remote_debugger_support.debugger_script_path); | ||
| 1386 | - | ||
| 1387 | - char *path = PyMem_Malloc(pathsz); | ||
| 1388 | - if (path) { | ||
| 1389 | - // And don't assume the debugger correctly null terminated it. | ||
| 1390 | - memcpy( | ||
| 1391 | - path, | ||
| 1392 | - tstate->remote_debugger_support.debugger_script_path, | ||
| 1393 | - pathsz); | ||
| 1394 | - path[pathsz - 1] = '\0'; | ||
| 1395 | - if (*path) { | ||
| 1396 | - run_remote_debugger_script(path); | ||
| 1397 | - } | ||
| 1398 | - PyMem_Free(path); | ||
| 1399 | - } | ||
| 1400 | - } | ||
| 1406 | + _PyRunRemoteDebugger(tstate); | ||
| 1401 | 1407 | #endif | |
| 1402 | 1408 | ||
| 1403 | 1409 | return 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments