MCPcopy Index your code
hub / github.com/python/cpython / field

Method field

Tools/gdb/libpython.py:184–208  ·  view source on GitHub ↗

Get the gdb.Value for the given field within the PyObject. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python, this is defined as an embedded PyVarObject type thus: PyVarObject ob_base; so that

(self, name)

Source from the content-addressed store, hash-verified

182 self._gdbval = gdbval
183
184 def field(self, name):
185 '''
186 Get the gdb.Value for the given field within the PyObject.
187
188 Various libpython types are defined using the "PyObject_HEAD" and
189 "PyObject_VAR_HEAD" macros.
190
191 In Python, this is defined as an embedded PyVarObject type thus:
192 PyVarObject ob_base;
193 so that the "ob_size" field is located insize the "ob_base" field, and
194 the "ob_type" is most easily accessed by casting back to a (PyObject*).
195 '''
196 if self.is_null():
197 raise NullPyObjectPtr(self)
198
199 if name == 'ob_type':
200 pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
201 return pyo_ptr.dereference()[name]
202
203 if name == 'ob_size':
204 pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type())
205 return pyo_ptr.dereference()[name]
206
207 # General case: look it up inside the object:
208 return self._gdbval.dereference()[name]
209
210 def pyop_field(self, name):
211 '''

Callers 15

pyop_fieldMethod · 0.95
typeMethod · 0.95
RefCountEntryClass · 0.80
dataclass1Class · 0.80
DummyDataclassClass · 0.80
MyClass · 0.80
_TargetClass · 0.80
HoleClass · 0.80
StencilClass · 0.80
StencilGroupClass · 0.80
_BlockClass · 0.80
OptimizerClass · 0.80

Calls 4

is_nullMethod · 0.95
NullPyObjectPtrClass · 0.85
castMethod · 0.80
get_gdb_typeMethod · 0.80

Tested by

no test coverage detected