From 54e75f291ef10f2ccb0549b25e0d9d207b325c79 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 1 Dec 2020 11:07:12 +0000 Subject: [PATCH] gdbsupport/tdesc: print enum fields using 'evalue' syntax Currently when printing an XML description GDB prints enum values like this: This is incorrect, and is most likely a copy and paste error with the struct and flags printing code. The correct syntax is: A test is included to cover this functionality. gdb/testsuite/ChangeLog: * gdb.xml/maint-xml-dump-03.xml: New file. gdbsupport/ChangeLog: * tdesc.cc (print_xml_feature::visit): Print enum fields using 'evalue' syntax. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.xml/maint-xml-dump-03.xml | 13 +++++++++++++ gdbsupport/ChangeLog | 5 +++++ gdbsupport/tdesc.cc | 4 +++- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.xml/maint-xml-dump-03.xml diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 882d02f5ef1..5966355266a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-12-01 Andrew Burgess + + * gdb.xml/maint-xml-dump-03.xml: New file. + 2020-11-30 Tom de Vries PR symtab/26905 diff --git a/gdb/testsuite/gdb.xml/maint-xml-dump-03.xml b/gdb/testsuite/gdb.xml/maint-xml-dump-03.xml new file mode 100644 index 00000000000..89741e65577 --- /dev/null +++ b/gdb/testsuite/gdb.xml/maint-xml-dump-03.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index a77f1c9fd86..88a0413e8b9 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,3 +1,8 @@ +2020-12-01 Andrew Burgess + + * tdesc.cc (print_xml_feature::visit): Print enum fields using + 'evalue' syntax. + 2020-12-01 Chungyi Chi * tdesc.cc (print_xml_feature::visit): Print enum size attribute. diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc index 2bc0247907d..c062a771b58 100644 --- a/gdbsupport/tdesc.cc +++ b/gdbsupport/tdesc.cc @@ -355,8 +355,10 @@ void print_xml_feature::visit (const tdesc_type_with_fields *t) string_appendf (tmp, " size=\"%d\"", t->size); string_appendf (tmp, ">"); add_line (tmp); + /* The 'start' of the field is reused as the enum value. The 'end' + of the field is always set to -1 for enum values. */ for (const tdesc_type_field &f : t->fields) - add_line (" ", + add_line (" ", f.name.c_str (), f.start); break; -- 2.30.2