This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[rfc] multiarch TARGET_SINGLE_FORMAT et al
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [rfc] multiarch TARGET_SINGLE_FORMAT et al
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 30 May 2000 16:39:48 +1000
- Organization: Cygnus Solutions
Hello,
The attached patch replaces the defs.h definitions of
TARGET_SINGLE_FORMAT, TARGET_DOUBLE_FORMAT and TARGET_LONG_DOUBLE_FORMAT
with multi-arched versions. I belive I've got bug-for-bug compatible
with the existing code.
As a pre cursor to this change, I checked in:
Tue May 30 11:22:28 2000 Andrew Cagney <cagney@b1.cygnus.com>
* gdbarch.sh: Add field ``postdefault''. Rename fields
``startup'' and ``default'' to ``staticdefault'' and
``predefault''. Fix initialization of valid_p. Create/compare
gdbarch.log.
which makes it possible for gdbarch to initialize a gdbarch member
after, rather than before, the target initialization has occured.
Andrew
(I deleted the patches from gdbarch.sh.)
Tue May 30 13:31:57 2000 Andrew Cagney <cagney@b1.cygnus.com>
* defs.h (TARGET_FLOAT_FORMAT, TARGET_DOUBLE_FORMAT,
TARGET_LONG_DOUBLE_FORMAT): Delete.
* gdbarch.sh: Add support for parameterized expressions.
(TARGET_FLOAT_FORMAT, TARGET_DOUBLE_FORMAT,
TARGET_LONG_DOUBLE_FORMAT): Add. Include "floatformat.h".
* gdbarch.h, gdbarch.c: Regenerate.
* arch-utils.c (default_single_format, default_double_format,
default_long_double_format): New functions. Include
"floatformat.h"
* arch-utils.h: Declare.
* d10v-tdep.c (d10v_gdbarch_init): Set floating point format.
Note that long double is 64 bit, the rest are 32 bit. Include
"floatformat.h".
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.4
diff -p -r1.4 arch-utils.c
*** arch-utils.c 2000/05/15 03:56:30 1.4
--- arch-utils.c 2000/05/30 06:27:41
***************
*** 41,46 ****
--- 41,48 ----
#include "symfile.h" /* for overlay functions */
#endif
+ #include "floatformat.h"
+
/* Convenience macro for allocting typesafe memory. */
#ifndef XMALLOC
*************** core_addr_greaterthan (lhs, rhs)
*** 162,167 ****
--- 164,210 ----
return (lhs > rhs);
}
+
+ /* Helper functions for TARGET_{FLOAT,DOUBLE}_FORMAT */
+
+ const struct floatformat *
+ default_float_format (struct gdbarch *gdbarch)
+ {
+ #if GDB_MULTI_ARCH
+ int byte_order = gdbarch_byte_order (gdbarch);
+ #else
+ int byte_order = TARGET_BYTE_ORDER;
+ #endif
+ switch (byte_order)
+ {
+ case BIG_ENDIAN:
+ return &floatformat_ieee_single_big;
+ case LITTLE_ENDIAN:
+ return &floatformat_ieee_single_little;
+ default:
+ internal_error ("default_float_format: bad byte order");
+ }
+ }
+
+
+ const struct floatformat *
+ default_double_format (struct gdbarch *gdbarch)
+ {
+ #if GDB_MULTI_ARCH
+ int byte_order = gdbarch_byte_order (gdbarch);
+ #else
+ int byte_order = TARGET_BYTE_ORDER;
+ #endif
+ switch (byte_order)
+ {
+ case BIG_ENDIAN:
+ return &floatformat_ieee_double_big;
+ case LITTLE_ENDIAN:
+ return &floatformat_ieee_double_little;
+ default:
+ internal_error ("default_double_format: bad byte order");
+ }
+ }
/* */
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.4
diff -p -r1.4 arch-utils.h
*** arch-utils.h 2000/05/15 03:56:30 1.4
--- arch-utils.h 2000/05/30 06:27:41
*************** extern gdbarch_prologue_frameless_p_ftyp
*** 63,66 ****
--- 63,70 ----
extern int core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs);
extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs);
+ /* Floating point values. */
+ extern const struct floatformat *default_float_format (struct gdbarch *gdbarch);
+ extern const struct floatformat *default_double_format (struct gdbarch *gdbarch);
+
#endif
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.5
diff -p -r1.5 d10v-tdep.c
*** d10v-tdep.c 2000/05/28 01:12:26 1.5
--- d10v-tdep.c 2000/05/30 06:27:43
***************
*** 36,41 ****
--- 36,42 ----
#include "language.h"
#include "arch-utils.h"
+ #include "floatformat.h"
#include "sim-d10v.h"
#undef XMALLOC
*************** d10v_gdbarch_init (info, arches)
*** 1596,1604 ****
--- 1597,1622 ----
set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_long_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+ /* NOTE: The d10v as a 32 bit ``float'' and ``double''. ``long
+ double'' is 64 bits. */
set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
+ switch (info.byte_order)
+ {
+ case BIG_ENDIAN:
+ set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_big);
+ set_gdbarch_double_format (gdbarch, &floatformat_ieee_single_big);
+ set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+ break;
+ case LITTLE_ENDIAN:
+ set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
+ set_gdbarch_double_format (gdbarch, &floatformat_ieee_single_little);
+ set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_little);
+ break;
+ default:
+ internal_error ("d10v_gdbarch_init: bad byte order for float format");
+ }
set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
set_gdbarch_call_dummy_length (gdbarch, 0);
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.21
diff -p -r1.21 defs.h
*** defs.h 2000/05/23 14:48:13 1.21
--- defs.h 2000/05/30 06:27:47
*************** extern const struct floatformat floatfor
*** 1114,1134 ****
#define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown
#endif
- #ifndef TARGET_FLOAT_FORMAT
- #define TARGET_FLOAT_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
- ? &floatformat_ieee_single_big \
- : &floatformat_ieee_single_little)
- #endif
- #ifndef TARGET_DOUBLE_FORMAT
- #define TARGET_DOUBLE_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
- ? &floatformat_ieee_double_big \
- : &floatformat_ieee_double_little)
- #endif
-
- #ifndef TARGET_LONG_DOUBLE_FORMAT
- #define TARGET_LONG_DOUBLE_FORMAT &floatformat_unknown
- #endif
-
/* Use `long double' if the host compiler supports it. (Note that this is not
necessarily any longer than `double'. On SunOS/gcc, it's the same as
double.) This is necessary because GDB internally converts all floating
--- 1114,1119 ----
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.23
diff -p -r1.23 gdbarch.c
*** gdbarch.c 2000/05/15 06:27:16 1.23
--- gdbarch.c 2000/05/30 06:27:52
***************
*** 58,63 ****
--- 58,64 ----
#endif
#include "symcat.h"
+ #include "floatformat.h"
/* Static function declarations */
*************** struct gdbarch
*** 220,225 ****
--- 221,229 ----
gdbarch_stack_align_ftype *stack_align;
gdbarch_reg_struct_has_addr_ftype *reg_struct_has_addr;
gdbarch_save_dummy_frame_tos_ftype *save_dummy_frame_tos;
+ const struct floatformat * float_format;
+ const struct floatformat * double_format;
+ const struct floatformat * long_double_format;
};
*************** struct gdbarch startup_gdbarch = {
*** 331,336 ****
--- 335,343 ----
0,
0,
0,
+ 0,
+ 0,
+ 0,
/* startup_gdbarch() */
};
struct gdbarch *current_gdbarch = &startup_gdbarch;
*************** verify_gdbarch (struct gdbarch *gdbarch)
*** 637,642 ****
--- 644,655 ----
/* Skip verify of stack_align, has predicate */
/* Skip verify of reg_struct_has_addr, has predicate */
/* Skip verify of save_dummy_frame_tos, has predicate */
+ if (gdbarch->float_format == 0)
+ gdbarch->float_format = default_float_format (gdbarch);
+ if (gdbarch->double_format == 0)
+ gdbarch->double_format = default_double_format (gdbarch);
+ if (gdbarch->long_double_format == 0)
+ gdbarch->long_double_format = &floatformat_unknown;
}
*************** gdbarch_dump (void)
*** 1185,1190 ****
--- 1198,1218 ----
(long) current_gdbarch->save_dummy_frame_tos
/*SAVE_DUMMY_FRAME_TOS ()*/);
#endif
+ #ifdef TARGET_FLOAT_FORMAT
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: TARGET_FLOAT_FORMAT = %ld\n",
+ (long) TARGET_FLOAT_FORMAT);
+ #endif
+ #ifdef TARGET_DOUBLE_FORMAT
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: TARGET_DOUBLE_FORMAT = %ld\n",
+ (long) TARGET_DOUBLE_FORMAT);
+ #endif
+ #ifdef TARGET_LONG_DOUBLE_FORMAT
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: TARGET_LONG_DOUBLE_FORMAT = %ld\n",
+ (long) TARGET_LONG_DOUBLE_FORMAT);
+ #endif
fprintf_unfiltered (gdb_stdlog,
"gdbarch_update: GDB_MULTI_ARCH = %d\n",
GDB_MULTI_ARCH);
*************** set_gdbarch_save_dummy_frame_tos (struct
*** 2818,2823 ****
--- 2846,2896 ----
gdbarch_save_dummy_frame_tos_ftype save_dummy_frame_tos)
{
gdbarch->save_dummy_frame_tos = save_dummy_frame_tos;
+ }
+
+ const struct floatformat *
+ gdbarch_float_format (struct gdbarch *gdbarch)
+ {
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_float_format called\n");
+ return gdbarch->float_format;
+ }
+
+ void
+ set_gdbarch_float_format (struct gdbarch *gdbarch,
+ const struct floatformat * float_format)
+ {
+ gdbarch->float_format = float_format;
+ }
+
+ const struct floatformat *
+ gdbarch_double_format (struct gdbarch *gdbarch)
+ {
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_double_format called\n");
+ return gdbarch->double_format;
+ }
+
+ void
+ set_gdbarch_double_format (struct gdbarch *gdbarch,
+ const struct floatformat * double_format)
+ {
+ gdbarch->double_format = double_format;
+ }
+
+ const struct floatformat *
+ gdbarch_long_double_format (struct gdbarch *gdbarch)
+ {
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_long_double_format called\n");
+ return gdbarch->long_double_format;
+ }
+
+ void
+ set_gdbarch_long_double_format (struct gdbarch *gdbarch,
+ const struct floatformat * long_double_format)
+ {
+ gdbarch->long_double_format = long_double_format;
}
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.18
diff -p -r1.18 gdbarch.h
*** gdbarch.h 2000/05/15 06:27:16 1.18
--- gdbarch.h 2000/05/30 06:27:54
*************** extern void set_gdbarch_save_dummy_frame
*** 1091,1096 ****
--- 1091,1135 ----
#endif
#endif
+ /* Default (value) for non- multi-arch platforms. */
+ #if (GDB_MULTI_ARCH == 0) && !defined (TARGET_FLOAT_FORMAT)
+ #define TARGET_FLOAT_FORMAT (default_float_format (current_gdbarch))
+ #endif
+
+ extern const struct floatformat * gdbarch_float_format (struct gdbarch *gdbarch);
+ extern void set_gdbarch_float_format (struct gdbarch *gdbarch, const struct floatformat * float_format);
+ #if GDB_MULTI_ARCH
+ #if (GDB_MULTI_ARCH > 1) || !defined (TARGET_FLOAT_FORMAT)
+ #define TARGET_FLOAT_FORMAT (gdbarch_float_format (current_gdbarch))
+ #endif
+ #endif
+
+ /* Default (value) for non- multi-arch platforms. */
+ #if (GDB_MULTI_ARCH == 0) && !defined (TARGET_DOUBLE_FORMAT)
+ #define TARGET_DOUBLE_FORMAT (default_double_format (current_gdbarch))
+ #endif
+
+ extern const struct floatformat * gdbarch_double_format (struct gdbarch *gdbarch);
+ extern void set_gdbarch_double_format (struct gdbarch *gdbarch, const struct floatformat * double_format);
+ #if GDB_MULTI_ARCH
+ #if (GDB_MULTI_ARCH > 1) || !defined (TARGET_DOUBLE_FORMAT)
+ #define TARGET_DOUBLE_FORMAT (gdbarch_double_format (current_gdbarch))
+ #endif
+ #endif
+
+ /* Default (value) for non- multi-arch platforms. */
+ #if (GDB_MULTI_ARCH == 0) && !defined (TARGET_LONG_DOUBLE_FORMAT)
+ #define TARGET_LONG_DOUBLE_FORMAT (&floatformat_unknown)
+ #endif
+
+ extern const struct floatformat * gdbarch_long_double_format (struct gdbarch *gdbarch);
+ extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struct floatformat * long_double_format);
+ #if GDB_MULTI_ARCH
+ #if (GDB_MULTI_ARCH > 1) || !defined (TARGET_LONG_DOUBLE_FORMAT)
+ #define TARGET_LONG_DOUBLE_FORMAT (gdbarch_long_double_format (current_gdbarch))
+ #endif
+ #endif
+
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);