GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
py-type.c File Reference
#include "defs.h"
#include "value.h"
#include "python-internal.h"
#include "charset.h"
#include "gdbtypes.h"
#include "cp-support.h"
#include "demangle.h"
#include "objfiles.h"
#include "language.h"
#include "typeprint.h"
#include "ada-lang.h"
#include "type-codes.def"

Go to the source code of this file.

Classes

struct  type_object
 
struct  field_object
 
struct  typy_iterator_object
 
struct  pyty_code
 
struct  typy_deleter
 

Macros

#define OP(X)   { X, #X },
 

Functions

PyTypeObject type_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object")
 
PyTypeObject field_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object")
 
PyTypeObject type_iterator_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object")
 
static PyObjecttypy_make_iter (PyObject *self, enum gdbpy_iter_kind kind)
 
static void field_dealloc (PyObject *obj)
 
static PyObjectfield_new (void)
 
int gdbpy_is_field (PyObject *obj)
 
static PyObjecttypy_get_code (PyObject *self, void *closure)
 
static gdbpy_ref convert_field (struct type *type, int field)
 
static gdbpy_ref field_name (struct type *type, int field)
 
static gdbpy_ref make_fielditem (struct type *type, int i, enum gdbpy_iter_kind kind)
 
static PyObjecttypy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
 
static PyObjecttypy_values (PyObject *self, PyObject *args)
 
static PyObjecttypy_fields (PyObject *self, PyObject *args)
 
static PyObjecttypy_field_names (PyObject *self, PyObject *args)
 
static PyObjecttypy_items (PyObject *self, PyObject *args)
 
static PyObjecttypy_get_name (PyObject *self, void *closure)
 
static PyObjecttypy_get_tag (PyObject *self, void *closure)
 
static PyObjecttypy_get_objfile (PyObject *self, void *closure)
 
static PyObjecttypy_is_scalar (PyObject *self, void *closure)
 
static PyObjecttypy_is_signed (PyObject *self, void *closure)
 
static PyObjecttypy_is_array_like (PyObject *self, void *closure)
 
static PyObjecttypy_is_string_like (PyObject *self, void *closure)
 
static PyObjecttypy_strip_typedefs (PyObject *self, PyObject *args)
 
static struct typetypy_get_composite (struct type *type)
 
static PyObjecttypy_array_1 (PyObject *self, PyObject *args, int is_vector)
 
static PyObjecttypy_array (PyObject *self, PyObject *args)
 
static PyObjecttypy_vector (PyObject *self, PyObject *args)
 
static PyObjecttypy_pointer (PyObject *self, PyObject *args)
 
static PyObjecttypy_range (PyObject *self, PyObject *args)
 
static PyObjecttypy_reference (PyObject *self, PyObject *args)
 
static PyObjecttypy_target (PyObject *self, PyObject *args)
 
static PyObjecttypy_const (PyObject *self, PyObject *args)
 
static PyObjecttypy_volatile (PyObject *self, PyObject *args)
 
static PyObjecttypy_unqualified (PyObject *self, PyObject *args)
 
static PyObjecttypy_get_sizeof (PyObject *self, void *closure)
 
static PyObjecttypy_get_alignof (PyObject *self, void *closure)
 
static PyObjecttypy_get_dynamic (PyObject *self, void *closure)
 
static struct typetypy_lookup_typename (const char *type_name, const struct block *block)
 
static struct typetypy_lookup_type (struct demangle_component *demangled, const struct block *block)
 
static PyObjecttypy_legacy_template_argument (struct type *type, const struct block *block, int argno)
 
static PyObjecttypy_template_argument (PyObject *self, PyObject *args)
 
static PyObjecttypy_repr (PyObject *self)
 
static PyObjecttypy_str (PyObject *self)
 
static PyObjecttypy_richcompare (PyObject *self, PyObject *other, int op)
 
static void set_type (type_object *obj, struct type *type)
 
static void typy_dealloc (PyObject *obj)
 
static Py_ssize_t typy_length (PyObject *self)
 
static int typy_nonzero (PyObject *self)
 
static PyObjecttypy_optimized_out (PyObject *self, PyObject *args)
 
static PyObjecttypy_getitem (PyObject *self, PyObject *key)
 
static PyObjecttypy_get (PyObject *self, PyObject *args)
 
static PyObjecttypy_has_key (PyObject *self, PyObject *args)
 
static PyObjecttypy_iteritems (PyObject *self, PyObject *args)
 
static PyObjecttypy_iterkeys (PyObject *self, PyObject *args)
 
static PyObjecttypy_iter (PyObject *self)
 
static PyObjecttypy_itervalues (PyObject *self, PyObject *args)
 
static PyObjecttypy_iterator_iter (PyObject *self)
 
static PyObjecttypy_iterator_iternext (PyObject *self)
 
static void typy_iterator_dealloc (PyObject *obj)
 
PyObjecttype_to_type_object (struct type *type)
 
struct typetype_object_to_type (PyObject *obj)
 
PyObjectgdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
 
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_types (void)
 
 GDBPY_INITIALIZE_FILE (gdbpy_initialize_types)
 

Variables

static struct pyty_code pyty_codes []
 
static const registry< objfile >::key< type_object, typy_deletertypy_objfile_data_key
 
static gdb_PyGetSetDef type_object_getset []
 
static PyMethodDef type_object_methods []
 
static PyNumberMethods type_object_as_number
 
static PyMappingMethods typy_mapping
 
PyTypeObject type_object_type
 
static gdb_PyGetSetDef field_object_getset []
 
PyTypeObject field_object_type
 
PyTypeObject type_iterator_object_type
 

Macro Definition Documentation

◆ OP

#define OP ( X)    { X, #X },

Function Documentation

◆ convert_field()

static gdbpy_ref convert_field ( struct type * type,
int field )
static

◆ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF() [1/3]

PyTypeObject field_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ( "field_object" )
extern

◆ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF() [2/3]

PyTypeObject type_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ( "type_object" )
extern

◆ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF() [3/3]

PyTypeObject type_iterator_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ( "typy_iterator_object" )
extern

◆ field_dealloc()

static void field_dealloc ( PyObject * obj)
static

Definition at line 98 of file py-type.c.

References f().

◆ field_name()

static gdbpy_ref field_name ( struct type * type,
int field )
static

◆ field_new()

static PyObject * field_new ( void )
static

Definition at line 107 of file py-type.c.

References field_object_type.

Referenced by convert_field().

◆ GDBPY_INITIALIZE_FILE()

GDBPY_INITIALIZE_FILE ( gdbpy_initialize_types )

◆ gdbpy_initialize_types()

static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_types ( void )
static

◆ gdbpy_is_field()

int gdbpy_is_field ( PyObject * obj)

Definition at line 126 of file py-type.c.

References field_object_type.

Referenced by valpy_getitem().

◆ gdbpy_lookup_type()

PyObject * gdbpy_lookup_type ( PyObject * self,
PyObject * args,
PyObject * kw )

◆ make_fielditem()

static gdbpy_ref make_fielditem ( struct type * type,
int i,
enum gdbpy_iter_kind kind )
static

Definition at line 253 of file py-type.c.

References convert_field(), field_name(), iter_items, iter_keys, and iter_values.

Referenced by typy_iterator_iternext().

◆ set_type()

static void set_type ( type_object * obj,
struct type * type )
static

◆ type_object_to_type()

struct type * type_object_to_type ( PyObject * obj)

◆ type_to_type_object()

PyObject * type_to_type_object ( struct type * type)

◆ typy_array()

static PyObject * typy_array ( PyObject * self,
PyObject * args )
static

Definition at line 605 of file py-type.c.

References typy_array_1().

◆ typy_array_1()

static PyObject * typy_array_1 ( PyObject * self,
PyObject * args,
int is_vector )
static

◆ typy_const()

static PyObject * typy_const ( PyObject * self,
PyObject * args )
static

Definition at line 726 of file py-type.c.

References GDB_PY_HANDLE_EXCEPTION, make_cv_type(), and type_to_type_object().

◆ typy_dealloc()

static void typy_dealloc ( PyObject * obj)
static

Definition at line 1219 of file py-type.c.

References type::objfile_owner(), registry< T >::set(), and typy_objfile_data_key.

◆ typy_field_names()

static PyObject * typy_field_names ( PyObject * self,
PyObject * args )
static

Definition at line 348 of file py-type.c.

References iter_keys, and typy_fields_items().

◆ typy_fields()

static PyObject * typy_fields ( PyObject * self,
PyObject * args )
static

Definition at line 328 of file py-type.c.

References type::code(), convert_field(), iter_values, and typy_fields_items().

◆ typy_fields_items()

static PyObject * typy_fields_items ( PyObject * self,
enum gdbpy_iter_kind kind )
static

◆ typy_get()

static PyObject * typy_get ( PyObject * self,
PyObject * args )
static

Definition at line 1310 of file py-type.c.

References typy_getitem().

◆ typy_get_alignof()

static PyObject * typy_get_alignof ( PyObject * self,
void * closure )
static

Definition at line 804 of file py-type.c.

References gdb_py_object_from_ulongest(), and type_align().

◆ typy_get_code()

static PyObject * typy_get_code ( PyObject * self,
void * closure )
static

Definition at line 133 of file py-type.c.

References type::code(), and gdb_py_object_from_longest().

◆ typy_get_composite()

static struct type * typy_get_composite ( struct type * type)
static

◆ typy_get_dynamic()

static PyObject * typy_get_dynamic ( PyObject * self,
void * closure )
static

Definition at line 825 of file py-type.c.

References is_dynamic_type().

◆ typy_get_name()

static PyObject * typy_get_name ( PyObject * self,
void * closure )
static

Definition at line 365 of file py-type.c.

References ada_decode(), ADA_TYPE_P, name, and type::name().

◆ typy_get_objfile()

static PyObject * typy_get_objfile ( PyObject * self,
void * closure )
static

Definition at line 401 of file py-type.c.

References type::objfile_owner(), and objfile_to_objfile_object().

◆ typy_get_sizeof()

static PyObject * typy_get_sizeof ( PyObject * self,
void * closure )
static

◆ typy_get_tag()

static PyObject * typy_get_tag ( PyObject * self,
void * closure )
static

Definition at line 384 of file py-type.c.

References type::code(), and type::name().

◆ typy_getitem()

static PyObject * typy_getitem ( PyObject * self,
PyObject * key )
static

◆ typy_has_key()

static PyObject * typy_has_key ( PyObject * self,
PyObject * args )
static

◆ typy_is_array_like()

static PyObject * typy_is_array_like ( PyObject * self,
void * closure )
static

Definition at line 448 of file py-type.c.

References check_typedef(), GDB_PY_HANDLE_EXCEPTION, and type::is_array_like().

◆ typy_is_scalar()

static PyObject * typy_is_scalar ( PyObject * self,
void * closure )
static

Definition at line 414 of file py-type.c.

References is_scalar_type().

◆ typy_is_signed()

static PyObject * typy_is_signed ( PyObject * self,
void * closure )
static

Definition at line 428 of file py-type.c.

References is_scalar_type(), and type::is_unsigned().

◆ typy_is_string_like()

static PyObject * typy_is_string_like ( PyObject * self,
void * closure )
static

Definition at line 472 of file py-type.c.

References check_typedef(), GDB_PY_HANDLE_EXCEPTION, and type::is_string_like().

◆ typy_items()

static PyObject * typy_items ( PyObject * self,
PyObject * args )
static

Definition at line 357 of file py-type.c.

References iter_items, and typy_fields_items().

◆ typy_iter()

static PyObject * typy_iter ( PyObject * self)
static

Definition at line 1406 of file py-type.c.

References iter_keys, and typy_make_iter().

◆ typy_iterator_dealloc()

static void typy_iterator_dealloc ( PyObject * obj)
static

Definition at line 1450 of file py-type.c.

References typy_iterator_object::source.

◆ typy_iterator_iter()

static PyObject * typy_iterator_iter ( PyObject * self)
static

Definition at line 1422 of file py-type.c.

◆ typy_iterator_iternext()

static PyObject * typy_iterator_iternext ( PyObject * self)
static

◆ typy_iteritems()

static PyObject * typy_iteritems ( PyObject * self,
PyObject * args )
static

Definition at line 1389 of file py-type.c.

References iter_items, and typy_make_iter().

◆ typy_iterkeys()

static PyObject * typy_iterkeys ( PyObject * self,
PyObject * args )
static

Definition at line 1397 of file py-type.c.

References iter_keys, and typy_make_iter().

◆ typy_itervalues()

static PyObject * typy_itervalues ( PyObject * self,
PyObject * args )
static

Definition at line 1414 of file py-type.c.

References iter_values, and typy_make_iter().

◆ typy_legacy_template_argument()

static PyObject * typy_legacy_template_argument ( struct type * type,
const struct block * block,
int argno )
static

◆ typy_length()

static Py_ssize_t typy_length ( PyObject * self)
static

Definition at line 1242 of file py-type.c.

References type::num_fields(), and typy_get_composite().

◆ typy_lookup_type()

static struct type * typy_lookup_type ( struct demangle_component * demangled,
const struct block * block )
static

◆ typy_lookup_typename()

static struct type * typy_lookup_typename ( const char * type_name,
const struct block * block )
static

◆ typy_make_iter()

static PyObject * typy_make_iter ( PyObject * self,
enum gdbpy_iter_kind kind )
static

◆ typy_nonzero()

static int typy_nonzero ( PyObject * self)
static

Definition at line 1258 of file py-type.c.

◆ typy_optimized_out()

static PyObject * typy_optimized_out ( PyObject * self,
PyObject * args )
static

Definition at line 1266 of file py-type.c.

References value::allocate_optimized_out(), and value_to_value_object().

◆ typy_pointer()

static PyObject * typy_pointer ( PyObject * self,
PyObject * args )
static

Definition at line 620 of file py-type.c.

References GDB_PY_HANDLE_EXCEPTION, lookup_pointer_type(), and type_to_type_object().

◆ typy_range()

static PyObject * typy_range ( PyObject * self,
PyObject * args )
static

◆ typy_reference()

static PyObject * typy_reference ( PyObject * self,
PyObject * args )
static

◆ typy_repr()

static PyObject * typy_repr ( PyObject * self)
static

◆ typy_richcompare()

static PyObject * typy_richcompare ( PyObject * self,
PyObject * other,
int op )
static

Definition at line 1130 of file py-type.c.

References GDB_PY_HANDLE_EXCEPTION, type_object_to_type(), and types_deeply_equal().

◆ typy_str()

static PyObject * typy_str ( PyObject * self)
static

◆ typy_strip_typedefs()

static PyObject * typy_strip_typedefs ( PyObject * self,
PyObject * args )
static

Definition at line 495 of file py-type.c.

References check_typedef(), GDB_PY_HANDLE_EXCEPTION, and type_to_type_object().

◆ typy_target()

static PyObject * typy_target ( PyObject * self,
PyObject * args )
static

Definition at line 710 of file py-type.c.

References type::target_type(), and type_to_type_object().

◆ typy_template_argument()

static PyObject * typy_template_argument ( PyObject * self,
PyObject * args )
static

◆ typy_unqualified()

static PyObject * typy_unqualified ( PyObject * self,
PyObject * args )
static

Definition at line 762 of file py-type.c.

References GDB_PY_HANDLE_EXCEPTION, make_cv_type(), and type_to_type_object().

◆ typy_values()

static PyObject * typy_values ( PyObject * self,
PyObject * args )
static

Definition at line 317 of file py-type.c.

References iter_values, and typy_fields_items().

◆ typy_vector()

static PyObject * typy_vector ( PyObject * self,
PyObject * args )
static

Definition at line 613 of file py-type.c.

References typy_array_1().

◆ typy_volatile()

static PyObject * typy_volatile ( PyObject * self,
PyObject * args )
static

Definition at line 744 of file py-type.c.

References GDB_PY_HANDLE_EXCEPTION, make_cv_type(), and type_to_type_object().

Variable Documentation

◆ field_object_getset

gdb_PyGetSetDef field_object_getset[]
static
Initial value:
=
{
{ "__dict__", gdb_py_generic_dict, NULL,
"The __dict__ for this field.", &field_object_type },
{ NULL }
}
PyTypeObject field_object_type
Definition py-type.c:1738
PyObject * gdb_py_generic_dict(PyObject *self, void *closure)
Definition py-utils.c:317

Definition at line 1731 of file py-type.c.

◆ field_object_type

PyTypeObject field_object_type

Definition at line 1738 of file py-type.c.

Referenced by field_new(), gdbpy_initialize_types(), and gdbpy_is_field().

◆ pyty_codes

struct pyty_code pyty_codes[]
static
Initial value:
=
{
{ -1, "TYPE_CODE_BITSTRING" },
#define OP(X)
}

Definition at line 85 of file py-type.c.

Referenced by gdbpy_initialize_types(), and typy_repr().

◆ type_iterator_object_type

PyTypeObject type_iterator_object_type
Initial value:
= {
PyVarObject_HEAD_INIT (NULL, 0)
"gdb.TypeIterator",
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT,
"GDB type iterator object",
0,
0,
0,
0,
0
}
static void typy_iterator_dealloc(PyObject *obj)
Definition py-type.c:1450
static PyObject * typy_iterator_iter(PyObject *self)
Definition py-type.c:1422
static PyObject * typy_iterator_iternext(PyObject *self)
Definition py-type.c:1432

Definition at line 1780 of file py-type.c.

Referenced by gdbpy_initialize_types(), and typy_make_iter().

◆ type_object_as_number

PyNumberMethods type_object_as_number
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
static int typy_nonzero(PyObject *self)
Definition py-type.c:1258

Definition at line 1661 of file py-type.c.

◆ type_object_getset

gdb_PyGetSetDef type_object_getset[]
static
Initial value:
=
{
{ "alignof", typy_get_alignof, NULL,
"The alignment of this type, in bytes.", NULL },
{ "code", typy_get_code, NULL,
"The code for this type.", NULL },
{ "dynamic", typy_get_dynamic, NULL,
"Whether this type is dynamic.", NULL },
{ "name", typy_get_name, NULL,
"The name for this type, or None.", NULL },
{ "sizeof", typy_get_sizeof, NULL,
"The size of this type, in bytes.", NULL },
{ "tag", typy_get_tag, NULL,
"The tag name for this type, or None.", NULL },
{ "objfile", typy_get_objfile, NULL,
"The objfile this type was defined in, or None.", NULL },
{ "is_scalar", typy_is_scalar, nullptr,
"Is this a scalar type?", nullptr },
{ "is_signed", typy_is_signed, nullptr,
"Is this a signed type?", nullptr },
{ "is_array_like", typy_is_array_like, nullptr,
"Is this an array-like type?", nullptr },
{ "is_string_like", typy_is_string_like, nullptr,
"Is this a string-like type?", nullptr },
{ NULL }
}
static PyObject * typy_get_code(PyObject *self, void *closure)
Definition py-type.c:133
static PyObject * typy_get_tag(PyObject *self, void *closure)
Definition py-type.c:384
static PyObject * typy_get_sizeof(PyObject *self, void *closure)
Definition py-type.c:780
static PyObject * typy_is_array_like(PyObject *self, void *closure)
Definition py-type.c:448
static PyObject * typy_get_name(PyObject *self, void *closure)
Definition py-type.c:365
static PyObject * typy_get_objfile(PyObject *self, void *closure)
Definition py-type.c:401
static PyObject * typy_get_dynamic(PyObject *self, void *closure)
Definition py-type.c:825
static PyObject * typy_is_signed(PyObject *self, void *closure)
Definition py-type.c:428
static PyObject * typy_is_scalar(PyObject *self, void *closure)
Definition py-type.c:414
static PyObject * typy_is_string_like(PyObject *self, void *closure)
Definition py-type.c:472
static PyObject * typy_get_alignof(PyObject *self, void *closure)
Definition py-type.c:804

Definition at line 1556 of file py-type.c.

◆ type_object_methods

PyMethodDef type_object_methods[]
static

Definition at line 1583 of file py-type.c.

◆ type_object_type

PyTypeObject type_object_type

Definition at line 1689 of file py-type.c.

Referenced by gdbpy_initialize_types(), type_object_to_type(), and type_to_type_object().

◆ typy_mapping

PyMappingMethods typy_mapping
static
Initial value:
= {
NULL
}
static PyObject * typy_getitem(PyObject *self, PyObject *key)
Definition py-type.c:1277
static Py_ssize_t typy_length(PyObject *self)
Definition py-type.c:1242

Definition at line 1683 of file py-type.c.

◆ typy_objfile_data_key

const registry<objfile>::key<type_object, typy_deleter> typy_objfile_data_key
static

Definition at line 1198 of file py-type.c.

Referenced by set_type(), and typy_dealloc().