aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/target-descriptions.c33
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.xml/maint_print_struct.exp35
-rw-r--r--gdb/testsuite/gdb.xml/maint_print_struct.xml26
5 files changed, 104 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6a127cf..3e450e3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-27 Walfred Tedeschi <walfred.tedeschi@intel.com>
+
+ * target-descriptions.c (maint_print_c_tdesc_cmd):
+ Add case to parse structures as register types and
+ bitfields.
+
2013-04-30 Walfred Tedeschi <walfred.tedeschi@intel.com>
* MAINTAINERS (Write After Approval): Add myself to the list.
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 95980c5..44ad401 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1675,7 +1675,8 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
printed_field_type = 1;
}
- if (type->kind == TDESC_TYPE_UNION
+ if ((type->kind == TDESC_TYPE_UNION
+ || type->kind == TDESC_TYPE_STRUCT)
&& VEC_length (tdesc_type_field, type->u.u.fields) > 0)
{
printf_unfiltered (" struct tdesc_type *type;\n");
@@ -1746,6 +1747,36 @@ feature = tdesc_create_feature (result, \"%s\");\n",
(" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
type->name, type->u.v.count);
break;
+ case TDESC_TYPE_STRUCT:
+ printf_unfiltered
+ (" type = tdesc_create_struct (feature, \"%s\");\n",
+ type->name);
+ if (type->u.u.size != 0)
+ printf_unfiltered
+ (" tdesc_set_struct_size (type, %s);\n",
+ plongest (type->u.u.size));
+ for (ix3 = 0;
+ VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
+ ix3++)
+ {
+ /* Going first for implicitly sized types, else part handles
+ bitfields. As reported on xml-tdesc.c implicitly sized types
+ cannot contain a bitfield. */
+ if (f->start == 0 && f->end == 0)
+ {
+ printf_unfiltered
+ (" field_type = tdesc_named_type (feature, \"%s\");\n",
+ f->type->name);
+ printf_unfiltered
+ (" tdesc_add_field (type, \"%s\", field_type);\n",
+ f->name);
+ }
+ else
+ printf_unfiltered
+ (" tdesc_add_bitfield (type, \"%s\", %d, %d);\n",
+ f->name, f->start, f->end);
+ }
+ break;
case TDESC_TYPE_UNION:
printf_unfiltered
(" type = tdesc_create_union (feature, \"%s\");\n",
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b278717..bfd7b68 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-27 Walfred Tedeschi <walfred.tedeschi@intel.com>
+
+ * gdb.xml/maint_print_struct.exp: New file.
+ * gdb.xml/maint_print_struct.xml: New file.
+
2013-04-25 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/nostaticblock.exp: New file.
diff --git a/gdb/testsuite/gdb.xml/maint_print_struct.exp b/gdb/testsuite/gdb.xml/maint_print_struct.exp
new file mode 100644
index 0000000..568d174
--- /dev/null
+++ b/gdb/testsuite/gdb.xml/maint_print_struct.exp
@@ -0,0 +1,35 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <walfred.tedeschi@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if {[gdb_skip_xml_test]} {
+ unsupported "maint_print_struct.exp"
+ return -1
+}
+
+gdb_start
+
+# Required registers are not present so it is expected a warning.
+#
+gdb_test "set tdesc filename $srcdir/$subdir/maint_print_struct.xml" "
+warning:.*" "setting a new tdesc having only a structure"
+
+gdb_test "maint print c-tdesc" "
+.*tdesc_create_reg \\(feature, \"bad_reg1\", \[0-9\]+, 1, NULL, 128, \"two_fielded\"\\);\r
+.*tdesc_create_reg \\(feature, \"bad_reg2\", \[0-9\]+, 1, NULL, 64, \"bitfield\"\\);\r
+.*" "printing tdesc with a structure and a bitfield"
diff --git a/gdb/testsuite/gdb.xml/maint_print_struct.xml b/gdb/testsuite/gdb.xml/maint_print_struct.xml
new file mode 100644
index 0000000..5ef0683
--- /dev/null
+++ b/gdb/testsuite/gdb.xml/maint_print_struct.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2013 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<target>
+<feature name="test">
+
+ <struct id="two_fielded">
+ <field name="field1" type="data_ptr"/>
+ <field name="field2" type="data_ptr"/>
+ </struct>
+
+ <struct id="bitfield" size="8">
+ <field name="field1" start="24" end="63"/>
+ <field name="field2" start="16" end="24"/>
+ </struct>
+
+ <reg name="bad_reg1" bitsize="128" type="two_fielded"/>
+ <reg name="bad_reg2" bitsize="64" type="bitfield"/>
+</feature>
+</target>
+