mirror of
https://github.com/python/cpython.git
synced 2026-05-08 19:41:06 +00:00
[3.14] gh-148037: remove critical section from PyCode_Addr2Line (GH… (#148353)
[3.14] gh-148037: remove critical section from `PyCode_Addr2Line` (GH-148103)
(cherry picked from commit d3b7b93cbb)
This commit is contained in:
parent
288cbacfb9
commit
f36da66c71
5 changed files with 33 additions and 42 deletions
|
|
@ -1013,14 +1013,18 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
|||
* source location tracking (co_lines/co_positions)
|
||||
******************/
|
||||
|
||||
static int
|
||||
_PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
||||
int
|
||||
PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
||||
{
|
||||
if (addrq < 0) {
|
||||
return co->co_firstlineno;
|
||||
}
|
||||
if (co->_co_monitoring && co->_co_monitoring->lines) {
|
||||
return _Py_Instrumentation_GetLine(co, addrq/sizeof(_Py_CODEUNIT));
|
||||
_PyCoMonitoringData *data = _Py_atomic_load_ptr_acquire(&co->_co_monitoring);
|
||||
if (data) {
|
||||
_PyCoLineInstrumentationData *lines = _Py_atomic_load_ptr_acquire(&data->lines);
|
||||
if (lines) {
|
||||
return _Py_Instrumentation_GetLine(co, lines, addrq/sizeof(_Py_CODEUNIT));
|
||||
}
|
||||
}
|
||||
assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
|
||||
PyCodeAddressRange bounds;
|
||||
|
|
@ -1035,7 +1039,7 @@ _PyCode_SafeAddr2Line(PyCodeObject *co, int addrq)
|
|||
return co->co_firstlineno;
|
||||
}
|
||||
if (co->_co_monitoring && co->_co_monitoring->lines) {
|
||||
return _Py_Instrumentation_GetLine(co, addrq/sizeof(_Py_CODEUNIT));
|
||||
return _Py_Instrumentation_GetLine(co, co->_co_monitoring->lines, addrq/sizeof(_Py_CODEUNIT));
|
||||
}
|
||||
if (!(addrq >= 0 && addrq < _PyCode_NBYTES(co))) {
|
||||
return -1;
|
||||
|
|
@ -1045,16 +1049,6 @@ _PyCode_SafeAddr2Line(PyCodeObject *co, int addrq)
|
|||
return _PyCode_CheckLineNumber(addrq, &bounds);
|
||||
}
|
||||
|
||||
int
|
||||
PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
||||
{
|
||||
int lineno;
|
||||
Py_BEGIN_CRITICAL_SECTION(co);
|
||||
lineno = _PyCode_Addr2Line(co, addrq);
|
||||
Py_END_CRITICAL_SECTION();
|
||||
return lineno;
|
||||
}
|
||||
|
||||
void
|
||||
_PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue