diff options
Diffstat (limited to 'gdb/python')
| -rw-r--r-- | gdb/python/py-symbol.c | 4 | ||||
| -rw-r--r-- | gdb/python/py-symtab.c | 8 | ||||
| -rw-r--r-- | gdb/python/py-type.c | 3 | ||||
| -rw-r--r-- | gdb/python/python-internal.h | 5 |
4 files changed, 11 insertions, 9 deletions
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index bd4023fa31a..736774bd94f 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -25,8 +25,8 @@ #include "objfiles.h" #include "symfile.h" -struct symbol_object { - PyObject_HEAD +struct symbol_object : public PyObject +{ /* The GDB symbol structure this object is wrapping. */ struct symbol *symbol; }; diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 9c093e70fc8..2dca0083277 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -24,8 +24,8 @@ #include "objfiles.h" #include "block.h" -struct symtab_object { - PyObject_HEAD +struct symtab_object : public PyObject +{ /* The GDB Symbol table structure. */ struct symtab *symtab; }; @@ -47,8 +47,8 @@ static const gdbpy_registry<gdbpy_memoizing_registry_storage<symtab_object, } \ } while (0) -struct sal_object { - PyObject_HEAD +struct sal_object : public PyObject +{ /* The GDB Symbol table and line structure. */ struct symtab_and_line *sal; /* A Symtab and line object is associated with an objfile, so keep diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 46004b93acd..f39cb0240c8 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -28,9 +28,8 @@ #include "typeprint.h" #include "ada-lang.h" -struct type_object +struct type_object : public PyObject { - PyObject_HEAD struct type *type; }; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 65d2eee38ed..95619bf775e 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -1157,6 +1157,9 @@ public: using obj_type = typename Storage::obj_type; using val_type = typename Storage::val_type; + static_assert(std::is_base_of<PyObject, obj_type>::value, + "obj_type must be a subclass of PyObject"); + /* Register Python object OBJ as being "owned" by OWNER. When OWNER is about to be freed, OBJ will be invalidated. */ template <typename O> @@ -1180,7 +1183,7 @@ public: obj_type *lookup (O *owner, val_type *val) const { obj_type *obj = get_storage (owner)->lookup (val); - Py_XINCREF (obj); + Py_XINCREF (static_cast<PyObject *> (obj)); return obj; } |
