aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-09-05 12:29:23 -0600
committerTom Tromey <tromey@adacore.com>2023-09-19 13:28:42 -0600
commit76fc0f62138e0fa1ec1feeefed7e603d52e83af7 (patch)
treeb423516f220f355dc08b7a7c6a802addae61efc5 /gdb/python
parent26733fc7477ac675df9215b46bf3f3af1dd80186 (diff)
downloadgdb-76fc0f62138e0fa1ec1feeefed7e603d52e83af7.zip
gdb-76fc0f62138e0fa1ec1feeefed7e603d52e83af7.tar.gz
gdb-76fc0f62138e0fa1ec1feeefed7e603d52e83af7.tar.bz2
Give a language to a type
This changes main_type to hold a language, and updates the debug readers to set this field. This is done by adding the language to the type-allocator object. Note that the non-DWARF readers are changed on a "best effort" basis. This patch also reimplements type::is_array_like to use the type's language, and it adds a new type::is_string_like as well. This in turn lets us change the Python implementation of these methods to simply defer to the type.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-type.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 5e5f175..bfaa6d2 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -448,17 +448,19 @@ static PyObject *
typy_is_array_like (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
+ bool result = false;
try
{
type = check_typedef (type);
+ result = type->is_array_like ();
}
catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
- if (type->is_array_like ())
+ if (result)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
@@ -475,14 +477,7 @@ typy_is_string_like (PyObject *self, void *closure)
try
{
type = check_typedef (type);
-
- const language_defn *lang = nullptr;
- if (HAVE_GNAT_AUX_INFO (type))
- lang = language_def (language_ada);
- else if (HAVE_RUST_SPECIFIC (type))
- lang = language_def (language_rust);
- if (lang != nullptr)
- result = lang->is_string_type_p (type);
+ result = type->is_string_like ();
}
catch (const gdb_exception &except)
{