[PATCH] Rename field in gdb-gdb.py

Tom Tromey tromey@adacore.com
Fri Sep 24 17:41:33 GMT 2021


I noticed that, when printing a type, gdb's own pretty-printer shows
the name of field::m_type as "type".  I'd forgotten about the renaming
and referenced the member using "->type" -- which of course was
invalid.

This patch changes the pretty-printer to reflect reality, so that the
names it supplies can be used to access the underlying member.
---
 gdb/gdb-gdb.py.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in
index 15dbf385654..e27e56b55d0 100644
--- a/gdb/gdb-gdb.py.in
+++ b/gdb/gdb-gdb.py.in
@@ -176,7 +176,7 @@ class StructMainTypePrettyPrinter:
             label += " (artificial)"
         fields = []
         fields.append("name = %s" % f["name"])
-        fields.append("type = %s" % f["m_type"])
+        fields.append("m_type = %s" % f["m_type"])
         fields.append("loc_kind = %s" % f["loc_kind"])
         fields.append("bitsize = %d" % f["bitsize"])
         fields.append(self.struct_field_location_img(f))
-- 
2.31.1



More information about the Gdb-patches mailing list