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)
| 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 | ''' |
no test coverage detected