This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfc] A type for the i386 mxcsr
- From: Andrew Cagney <ac131313 at ges dot redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 28 Aug 2002 19:43:32 -0400
- Subject: [rfc] A type for the i386 mxcsr
(found another one)
This adds bit type for the mxcsr vis:
(gdb) info registers mxcsr
mxcsr {mxcsr = 0x1f80, bits = {FZ = 0x0, RC = 0x0, PM = 0x1, UM
= 0x1, OM = 0x1, ZM = 0x1,
DM = 0x1, IM = 0x1, PE = 0x0, UE = 0x0, OE = 0x0, ZE = 0x0, DE =
0x0, IE = 0x0}} {mxcsr = 8064,
bits = {FZ = 0, RC = 0, PM = 1, UM = 1, OM = 1, ZM = 1, DM = 1, IM =
1, PE = 0, UE = 0, OE = 0, ZE = 0,
DE = 0, IE = 0}}
(no the duplicate isn't a typo, looks like a bit more supression in the
print registers function is needed).
I guess the thing to do is decide on eflags first.
Andrew
2002-08-28 Andrew Cagney <cagney@redhat.com>
* i386-tdep.c (i386_register_virtual_type): When MXCSR, return
builtin_type_i386_mxcsr.
(builtin_type_i386_mxcsr): New function. From Fernando Nasser.
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.85
diff -u -r1.85 i386-tdep.c
--- i386-tdep.c 26 Aug 2002 18:35:25 -0000 1.85
+++ i386-tdep.c 28 Aug 2002 23:38:14 -0000
@@ -1092,6 +1092,152 @@
}
+static struct type *
+builtin_type_i386_mxcsr (void)
+{
+ /* Construct a type for the MXCSR register. The type we're building
+ is this: */
+#if 0
+ union builtin_type_i386_mxcsr
+ {
+ uint32 mxcsr;
+ struct builtin_i386_mxcsr_bits
+ {
+ /* We skip the 16 reserved bits here. */
+ unsigned FZ:1;
+ unsigned RC:2;
+ unsigned PM:1;
+ unsigned UM:1;
+ unsigned OM:1;
+ unsigned ZM:1;
+ unsigned DM:1;
+ unsigned IM:1;
+ /* We skip one reserved bit here. */
+ unsigned PE:1;
+ unsigned UE:1;
+ unsigned OE:1;
+ unsigned ZE:1;
+ unsigned DE:1;
+ unsigned IE:1;
+ } bits;
+ };
+#endif
+ /* Note that we cannot create a structure like that in C because we
+ could not skip the reserved bits and the order would be the
+ reverse of what we want (we want to see bit names from left to
+ right, as in a manual figure). */
+
+ static struct type *t; /* The type we are creating. */
+ struct type *tp; /* The type of the pointer part. */
+ struct type *tb; /* The type of the bitfields part. */
+ struct field *fu; /* Fields of the union. */
+ struct field *fs; /* Fields of the struct. */
+
+ if (t != NULL)
+ return t;
+
+ /* Create fields for each group of bits. */
+ fs = (struct field *) xmalloc (sizeof (*fs) * 14);
+ memset (fs, 0, sizeof (*fs) * 14);
+
+ /* Note that we reverse the order of the fields so they are printed
+ as we would see then in a manual figure, left to right. */
+
+ FIELD_TYPE (fs[13]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[13]) = "IE";
+ FIELD_BITPOS (fs[13]) = 0;
+ FIELD_BITSIZE (fs[13]) = 1;
+
+ FIELD_TYPE (fs[12]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[12]) = "DE";
+ FIELD_BITPOS (fs[12]) = 1;
+ FIELD_BITSIZE (fs[12]) = 1;
+
+ FIELD_TYPE (fs[11]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[11]) = "ZE";
+ FIELD_BITPOS (fs[11]) = 2;
+ FIELD_BITSIZE (fs[11]) = 1;
+
+ FIELD_TYPE (fs[10]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[10]) = "OE";
+ FIELD_BITPOS (fs[10]) = 3;
+ FIELD_BITSIZE (fs[10]) = 1;
+
+ FIELD_TYPE (fs[9]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[9]) = "UE";
+ FIELD_BITPOS (fs[9]) = 4;
+ FIELD_BITSIZE (fs[9]) = 1;
+
+ FIELD_TYPE (fs[8]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[8]) = "PE";
+ FIELD_BITPOS (fs[8]) = 5;
+ FIELD_BITSIZE (fs[8]) = 1;
+
+ FIELD_TYPE (fs[7]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[7]) = "IM";
+ FIELD_BITPOS (fs[7]) = 7;
+ FIELD_BITSIZE (fs[7]) = 1;
+
+ FIELD_TYPE (fs[6]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[6]) = "DM";
+ FIELD_BITPOS (fs[6]) = 8;
+ FIELD_BITSIZE (fs[6]) = 1;
+
+ FIELD_TYPE (fs[5]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[5]) = "ZM";
+ FIELD_BITPOS (fs[5]) = 9;
+ FIELD_BITSIZE (fs[5]) = 1;
+
+ FIELD_TYPE (fs[4]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[4]) = "OM";
+ FIELD_BITPOS (fs[4]) = 10;
+ FIELD_BITSIZE (fs[4]) = 1;
+
+ FIELD_TYPE (fs[3]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[3]) = "UM";
+ FIELD_BITPOS (fs[3]) = 11;
+ FIELD_BITSIZE (fs[3]) = 1;
+
+ FIELD_TYPE (fs[2]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[2]) = "PM";
+ FIELD_BITPOS (fs[2]) = 12;
+ FIELD_BITSIZE (fs[2]) = 1;
+
+ FIELD_TYPE (fs[1]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[1]) = "RC";
+ FIELD_BITPOS (fs[1]) = 13;
+ FIELD_BITSIZE (fs[1]) = 2;
+
+ FIELD_TYPE (fs[0]) = builtin_type_unsigned_int;
+ FIELD_NAME (fs[0]) = "FZ";
+ FIELD_BITPOS (fs[0]) = 15;
+ FIELD_BITSIZE (fs[0]) = 1;
+
+ /* Build a struct type with these bitfields. */
+ tb = init_type (TYPE_CODE_STRUCT, 4, 0, 0, 0);
+ TYPE_NFIELDS (tb) = 14;
+ TYPE_FIELDS (tb) = fs;
+ TYPE_TAG_NAME (tb) = "builtin_type_i386_mxcsr_bits";
+
+ /* Now make our type as the union of the pointer and the bitfield parts. */
+ fu = (struct field *) xmalloc (sizeof (*fu) * 2);
+ memset (fu, 0, sizeof (*fu) * 2);
+
+ FIELD_TYPE (fu[0]) = builtin_type_uint32;
+ FIELD_NAME (fu[0]) = "mxcsr";
+
+ FIELD_TYPE (fu[1]) = tb;
+ FIELD_NAME (fu[1]) = "bits";
+
+ /* Build a union type with those fields. */
+ t = init_type (TYPE_CODE_UNION, 4, 0, 0, 0);
+ TYPE_NFIELDS (t) = 2;
+ TYPE_FIELDS (t) = fu;
+ TYPE_TAG_NAME (t) = "builtin_type_i386_mxcsr";
+
+ return t;
+}
+
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. Perhaps %esi and %edi should go here, but
potentially they could be used for things other than address. */
@@ -1110,6 +1256,9 @@
if (mmx_regnum_p (regnum))
return builtin_type_vec64i;
+
+ if (regnum == MXCSR_REGNUM)
+ return builtin_type_i386_mxcsr ();
return builtin_type_int;
}