This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfc] Add TYPE_FLOATFORMAT() to `struct type'
- To: gdb-patches at sources dot redhat dot com
- Subject: [rfc] Add TYPE_FLOATFORMAT() to `struct type'
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 20 Aug 2001 23:42:32 -0400
Hello,
Continuing with this floating-point overhall, the attatched adds
TYPE_FLOATFORMAT() to the floating-point (TYPE_CODE_FLT) `struct type'
objects. All the existing builtin FP types are updated. I even
discovered and updated ``(gdb) maint print type double''.
Assuming no one says anything about this, I'll check this patch in in a
few days.
The next steps are:
o add builtin types for all those floatformats
o update the store_floating() and extract_floating()
functions make use of TYPE_FLOATFORMAT().
Andrew
2001-08-20 Andrew Cagney <ac131313@redhat.com>
* gdbtypes.c (build_gdbtypes): Initialize TYPE_FLOATFORMAT field
of builtin_type_float, builtin_type_double and
builtin_type_long_double.
(recursive_dump_type): Print the floatformat name.
* gdbtypes.h (struct type): Add type_specific field floatformat.
(TYPE_FLOATFORMAT): Define
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.23
diff -p -r1.23 gdbtypes.c
*** gdbtypes.c 2001/07/08 20:42:15 1.23
--- gdbtypes.c 2001/08/21 03:23:07
*************** recursive_dump_type (struct type *type,
*** 2769,2774 ****
--- 2769,2784 ----
print_cplus_stuff (type, spaces);
break;
+ case TYPE_CODE_FLT:
+ printfi_filtered (spaces, "floatformat ");
+ if (TYPE_FLOATFORMAT (type) == NULL
+ || TYPE_FLOATFORMAT (type)->name == NULL)
+ puts_filtered ("(null)");
+ else
+ puts_filtered (TYPE_FLOATFORMAT (type)->name);
+ puts_filtered ("\n");
+ break;
+
default:
/* We have to pick one of the union types to be able print and test
the value. Pick cplus_struct_type, even though we know it isn't
*************** build_gdbtypes (void)
*** 2848,2861 ****
--- 2858,2874 ----
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
0,
"float", (struct objfile *) NULL);
+ TYPE_FLOATFORMAT (builtin_type_float) = TARGET_FLOAT_FORMAT;
builtin_type_double =
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
0,
"double", (struct objfile *) NULL);
+ TYPE_FLOATFORMAT (builtin_type_double) = TARGET_DOUBLE_FORMAT;
builtin_type_long_double =
init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
0,
"long double", (struct objfile *) NULL);
+ TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
builtin_type_complex =
init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
0,
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.12
diff -p -r1.12 gdbtypes.h
*** gdbtypes.h 2001/08/21 00:24:58 1.12
--- gdbtypes.h 2001/08/21 03:23:13
*************** struct type
*** 413,418 ****
--- 413,423 ----
struct cplus_struct_type *cplus_stuff;
+ /* FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to the
+ floatformat object that describes the floating-point value
+ that resides within the type. */
+
+ const struct floatformat *floatformat;
}
type_specific;
};
*************** extern void allocate_cplus_struct_type (
*** 722,727 ****
--- 727,733 ----
#define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific
#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types
#define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff
+ #define TYPE_FLOATFORMAT(thistype) (thistype)->type_specific.floatformat
#define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
#define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name