/* Python interface to types.
- Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Copyright (C) 2008-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "demangle.h"
#include "objfiles.h"
#include "language.h"
-#include "common/vec.h"
#include "typeprint.h"
typedef struct pyty_type_object
{
checked_type = check_typedef (checked_type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
return PyString_FromString (tagname);
}
+/* Return the type's objfile, or None. */
+static PyObject *
+typy_get_objfile (PyObject *self, void *closure)
+{
+ struct type *type = ((type_object *) self)->type;
+ struct objfile *objfile = TYPE_OBJFILE (type);
+
+ if (objfile == nullptr)
+ Py_RETURN_NONE;
+ return objfile_to_objfile_object (objfile).release ();
+}
+
/* Return the type, stripped of typedefs. */
static PyObject *
typy_strip_typedefs (PyObject *self, PyObject *args)
{
type = check_typedef (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = check_typedef (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
if (is_vector)
make_vector_type (array);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = lookup_pointer_type (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = lookup_lvalue_reference_type (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = make_cv_type (1, 0, type, NULL);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = make_cv_type (0, 1, type, NULL);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
type = make_cv_type (0, 0, type, NULL);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
check_typedef (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
}
{
align = type_align (type);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
align = 0;
}
else if (startswith (type_name, "enum "))
type = lookup_enum (type_name + 5, NULL);
else
- type = lookup_typename (python_language, python_gdbarch,
+ type = lookup_typename (python_language,
type_name, block, 0);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
break;
}
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
/* Note -- this is not thread-safe. */
info = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
if (TYPE_IS_REFERENCE (type))
type = check_typedef (TYPE_TARGET_TYPE (type));
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
val = value_of_variable (sym, block);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
LA_PRINT_TYPE (type_object_to_type (self), "", &thetype, -1, 0,
&type_print_raw_options);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
{
result = types_deeply_equal (type1, type2);
}
- catch (const gdb_exception_RETURN_MASK_ALL &except)
+ catch (const gdb_exception &except)
{
/* If there is a GDB exception, a comparison is not capable
(or trusted), so exit. */
typy_iterator_object *iter_obj = (typy_iterator_object *) obj;
Py_DECREF (iter_obj->source);
+ Py_TYPE (obj)->tp_free (obj);
}
/* Create a new Type referring to TYPE. */
{
type_object *type_obj;
+ try
+ {
+ /* Try not to let stub types leak out to Python. */
+ if (TYPE_STUB (type))
+ type = check_typedef (type);
+ }
+ catch (...)
+ {
+ /* Just ignore failures in check_typedef. */
+ }
+
type_obj = PyObject_New (type_object, &type_object_type);
if (type_obj)
set_type (type_obj, type);
"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 },
{ NULL }
};