From 67470e9d8be180344494635dcef34e054938bfb8 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 25 Jun 2021 08:01:15 -0600 Subject: Decode Ada types in Python layer GNAT emits encoded type names, but these aren't usually of interest to users. The Ada language code in gdb hides this oddity -- but the Python layer does not. This patch changes the Python code to use the decoded Ada type name, when appropriate. I looked at decoding Ada type names during construction, as that would be cleaner. However, the Ada support in gdb relies on the encodings at various points, so this isn't really doable right now. 2021-06-25 Tom Tromey * python/py-type.c (typy_get_name): Decode an Ada type name. gdb/testsuite/ChangeLog 2021-06-25 Tom Tromey * gdb.ada/py_range.exp: Add type name test cases. --- gdb/python/py-type.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gdb/python') diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 4f5f425..04d1c7a 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -27,6 +27,7 @@ #include "objfiles.h" #include "language.h" #include "typeprint.h" +#include "ada-lang.h" struct type_object { @@ -393,6 +394,14 @@ typy_get_name (PyObject *self, void *closure) if (type->name () == NULL) Py_RETURN_NONE; + /* Ada type names are encoded, but it is better for users to see the + decoded form. */ + if (ADA_TYPE_P (type)) + { + std::string name = ada_decode (type->name (), false); + if (!name.empty ()) + return PyString_FromString (name.c_str ()); + } return PyString_FromString (type->name ()); } -- cgit v1.1