@@ -77,10 +77,14 @@ def _managed_dict_offset():
77
77
else :
78
78
return - 3 * _sizeof_void_p ()
79
79
80
- def _interp_frame_has_tlbc_index ():
81
- interp_frame = gdb .lookup_type ("_PyInterpreterFrame" )
82
- return any (field .name == "tlbc_index" for field in interp_frame .fields ())
83
-
80
+ _INTERP_FRAME_HAS_TLBC_INDEX = None
81
+ def interp_frame_has_tlbc_index ():
82
+ global _INTERP_FRAME_HAS_TLBC_INDEX
83
+ if _INTERP_FRAME_HAS_TLBC_INDEX is None :
84
+ interp_frame = gdb .lookup_type ("_PyInterpreterFrame" )
85
+ _INTERP_FRAME_HAS_TLBC_INDEX = any (field .name == "tlbc_index"
86
+ for field in interp_frame .fields ())
87
+ return _INTERP_FRAME_HAS_TLBC_INDEX
84
88
85
89
Py_TPFLAGS_INLINE_VALUES = (1 << 2 )
86
90
Py_TPFLAGS_MANAGED_DICT = (1 << 4 )
@@ -109,7 +113,6 @@ def _interp_frame_has_tlbc_index():
109
113
UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
110
114
EVALFRAME = '_PyEval_EvalFrameDefault'
111
115
112
- INTERP_FRAME_HAS_TLBC_INDEX = _interp_frame_has_tlbc_index ()
113
116
114
117
class NullPyObjectPtr (RuntimeError ):
115
118
pass
@@ -1101,7 +1104,7 @@ def _f_nlocalsplus(self):
1101
1104
def _f_lasti (self ):
1102
1105
codeunit_p = gdb .lookup_type ("_Py_CODEUNIT" ).pointer ()
1103
1106
instr_ptr = self ._gdbval ["instr_ptr" ]
1104
- if INTERP_FRAME_HAS_TLBC_INDEX :
1107
+ if interp_frame_has_tlbc_index () :
1105
1108
tlbc_index = self ._gdbval ["tlbc_index" ]
1106
1109
code_arr = PyCodeArrayPtr (self ._f_code ().field ("co_tlbc" ))
1107
1110
first_instr = code_arr .get_entry (tlbc_index ).cast (codeunit_p )
0 commit comments