aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-arch.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-arch.c')
-rw-r--r--gdb/python/py-arch.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index c6f5662..2bf6251 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -1,6 +1,6 @@
/* Python interface to architecture
- Copyright (C) 2013-2024 Free Software Foundation, Inc.
+ Copyright (C) 2013-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -199,8 +199,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- gdbpy_convert_exception (except);
- return NULL;
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> pc_obj = gdb_py_object_from_ulongest (pc);
@@ -270,15 +269,16 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw)
{
static const char *keywords[] = { "size", "signed", NULL };
int size;
- PyObject *is_signed_obj = nullptr;
+ PyObject *is_signed_obj = Py_True;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O", keywords,
- &size, &is_signed_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O!", keywords,
+ &size,
+ &PyBool_Type, &is_signed_obj))
return nullptr;
/* Assume signed by default. */
- bool is_signed = (is_signed_obj == nullptr
- || PyObject_IsTrue (is_signed_obj));
+ gdb_assert (PyBool_Check (is_signed_obj));
+ bool is_signed = is_signed_obj == Py_True;
struct gdbarch *gdbarch;
ARCHPY_REQUIRE_VALID (self, gdbarch);
@@ -318,6 +318,16 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw)
return type_to_type_object (type);
}
+/* Implementation of gdb.void_type. */
+static PyObject *
+archpy_void_type (PyObject *self, PyObject *args)
+{
+ struct gdbarch *gdbarch;
+ ARCHPY_REQUIRE_VALID (self, gdbarch);
+
+ return type_to_type_object (builtin_type (gdbarch)->builtin_void);
+}
+
/* __repr__ implementation for gdb.Architecture. */
static PyObject *
@@ -362,11 +372,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_arch (void)
{
arch_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&arch_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Architecture",
- (PyObject *) &arch_object_type);
+ return gdbpy_type_ready (&arch_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_arch);
@@ -387,6 +393,10 @@ END_PC." },
"integer_type (size [, signed]) -> type\n\
Return an integer Type corresponding to the given bitsize and signed-ness.\n\
If not specified, the type defaults to signed." },
+ { "void_type", (PyCFunction) archpy_void_type,
+ METH_NOARGS,
+ "void_type () -> type\n\
+Return a void Type." },
{ "registers", (PyCFunction) archpy_registers,
METH_VARARGS | METH_KEYWORDS,
"registers ([ group-name ]) -> Iterator.\n\