aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-08-08 19:49:43 +0000
committerAndrew Cagney <cagney@redhat.com>2004-08-08 19:49:43 +0000
commit456fcf94f7f9a4f275739b19f16a0a24c06bf31d (patch)
treeb6aba6182d1be5d242c6176d522ee6c2512ce38b
parent69e9e646da0e5602742734053eb60f7082368210 (diff)
downloadgdb-456fcf94f7f9a4f275739b19f16a0a24c06bf31d.zip
gdb-456fcf94f7f9a4f275739b19f16a0a24c06bf31d.tar.gz
gdb-456fcf94f7f9a4f275739b19f16a0a24c06bf31d.tar.bz2
2004-08-08 Andrew Cagney <cagney@gnu.org>
* gdbarch.sh (pformat): New function. (float_format, double_format, long_double_format): List with bit members. Use pformat when printing. * gdbarch.c, gdbarch.h: Re-generate.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/gdbarch.c135
-rw-r--r--gdb/gdbarch.h58
-rwxr-xr-xgdb/gdbarch.sh24
4 files changed, 125 insertions, 99 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 37a5ec3..a125a22 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2004-08-08 Andrew Cagney <cagney@gnu.org>
+
+ * gdbarch.sh (pformat): New function.
+ (float_format, double_format, long_double_format): List with bit
+ members. Use pformat when printing.
+ * gdbarch.c, gdbarch.h: Re-generate.
+
2004-08-08 Nathan J. Williams <nathanw@wasabisystems.com>
* ppcnbsd-nat.c: Include <machine/frame.h>, <machine/pcb.h>,
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index c77a70e..185447b 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -62,6 +62,15 @@ static void alloc_gdbarch_data (struct gdbarch *);
#endif
int gdbarch_debug = GDBARCH_DEBUG;
+static const char *
+pformat (const struct floatformat *format)
+{
+ if (format == NULL)
+ return "(null)";
+ else
+ return format->name;
+}
+
/* Maintain the struct gdbarch object */
@@ -120,8 +129,11 @@ struct gdbarch
int long_bit;
int long_long_bit;
int float_bit;
+ const struct floatformat * float_format;
int double_bit;
+ const struct floatformat * double_format;
int long_double_bit;
+ const struct floatformat * long_double_format;
int ptr_bit;
int addr_bit;
int bfd_vma_bit;
@@ -195,9 +207,6 @@ struct gdbarch
gdbarch_deprecated_reg_struct_has_addr_ftype *deprecated_reg_struct_has_addr;
gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr;
int frame_red_zone_size;
- const struct floatformat * float_format;
- const struct floatformat * double_format;
- const struct floatformat * long_double_format;
gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr;
gdbarch_addr_bits_remove_ftype *addr_bits_remove;
gdbarch_smash_text_address_ftype *smash_text_address;
@@ -246,8 +255,11 @@ struct gdbarch startup_gdbarch =
8 * sizeof (long), /* long_bit */
8 * sizeof (LONGEST), /* long_long_bit */
8 * sizeof (float), /* float_bit */
+ 0, /* float_format */
8 * sizeof (double), /* double_bit */
+ 0, /* double_format */
8 * sizeof (long double), /* long_double_bit */
+ 0, /* long_double_format */
8 * sizeof (void*), /* ptr_bit */
8 * sizeof (void*), /* addr_bit */
8 * sizeof (void*), /* bfd_vma_bit */
@@ -321,9 +333,6 @@ struct gdbarch startup_gdbarch =
0, /* deprecated_reg_struct_has_addr */
default_stabs_argument_has_addr, /* stabs_argument_has_addr */
0, /* frame_red_zone_size */
- 0, /* float_format */
- 0, /* double_format */
- 0, /* long_double_format */
convert_from_func_ptr_addr_identity, /* convert_from_func_ptr_addr */
0, /* addr_bits_remove */
0, /* smash_text_address */
@@ -499,8 +508,14 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of long_bit, invalid_p == 0 */
/* Skip verify of long_long_bit, invalid_p == 0 */
/* Skip verify of float_bit, invalid_p == 0 */
+ if (current_gdbarch->float_format == 0)
+ current_gdbarch->float_format = default_float_format (current_gdbarch);
/* Skip verify of double_bit, invalid_p == 0 */
+ if (current_gdbarch->double_format == 0)
+ current_gdbarch->double_format = default_double_format (current_gdbarch);
/* Skip verify of long_double_bit, invalid_p == 0 */
+ if (current_gdbarch->long_double_format == 0)
+ current_gdbarch->long_double_format = default_double_format (current_gdbarch);
/* Skip verify of ptr_bit, invalid_p == 0 */
if (current_gdbarch->addr_bit == 0)
current_gdbarch->addr_bit = TARGET_PTR_BIT;
@@ -576,12 +591,6 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of frame_align, has predicate */
/* Skip verify of deprecated_reg_struct_has_addr, has predicate */
/* Skip verify of stabs_argument_has_addr, invalid_p == 0 */
- if (current_gdbarch->float_format == 0)
- current_gdbarch->float_format = default_float_format (current_gdbarch);
- if (current_gdbarch->double_format == 0)
- current_gdbarch->double_format = default_double_format (current_gdbarch);
- if (current_gdbarch->long_double_format == 0)
- current_gdbarch->long_double_format = default_double_format (current_gdbarch);
/* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */
/* Skip verify of addr_bits_remove, invalid_p == 0 */
/* Skip verify of smash_text_address, invalid_p == 0 */
@@ -999,7 +1008,7 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
#endif
fprintf_unfiltered (file,
"gdbarch_dump: double_format = %s\n",
- (TARGET_DOUBLE_FORMAT)->name);
+ pformat (current_gdbarch->double_format));
#ifdef DWARF2_REG_TO_REGNUM
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -1078,7 +1087,7 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
#endif
fprintf_unfiltered (file,
"gdbarch_dump: float_format = %s\n",
- (TARGET_FLOAT_FORMAT)->name);
+ pformat (current_gdbarch->float_format));
#ifdef FP0_REGNUM
fprintf_unfiltered (file,
"gdbarch_dump: FP0_REGNUM # %s\n",
@@ -1232,7 +1241,7 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
#endif
fprintf_unfiltered (file,
"gdbarch_dump: long_double_format = %s\n",
- (TARGET_LONG_DOUBLE_FORMAT)->name);
+ pformat (current_gdbarch->long_double_format));
#ifdef TARGET_LONG_LONG_BIT
fprintf_unfiltered (file,
"gdbarch_dump: TARGET_LONG_LONG_BIT # %s\n",
@@ -1741,6 +1750,22 @@ set_gdbarch_float_bit (struct gdbarch *gdbarch,
gdbarch->float_bit = float_bit;
}
+const struct floatformat *
+gdbarch_float_format (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ 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;
+}
+
int
gdbarch_double_bit (struct gdbarch *gdbarch)
{
@@ -1758,6 +1783,22 @@ set_gdbarch_double_bit (struct gdbarch *gdbarch,
gdbarch->double_bit = double_bit;
}
+const struct floatformat *
+gdbarch_double_format (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ 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;
+}
+
int
gdbarch_long_double_bit (struct gdbarch *gdbarch)
{
@@ -1775,6 +1816,22 @@ set_gdbarch_long_double_bit (struct gdbarch *gdbarch,
gdbarch->long_double_bit = long_double_bit;
}
+const struct floatformat *
+gdbarch_long_double_format (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ 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;
+}
+
int
gdbarch_ptr_bit (struct gdbarch *gdbarch)
{
@@ -3200,54 +3257,6 @@ set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch,
gdbarch->frame_red_zone_size = frame_red_zone_size;
}
-const struct floatformat *
-gdbarch_float_format (struct gdbarch *gdbarch)
-{
- gdb_assert (gdbarch != NULL);
- 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)
-{
- gdb_assert (gdbarch != NULL);
- 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)
-{
- gdb_assert (gdbarch != NULL);
- 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;
-}
-
CORE_ADDR
gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index fc0fe50..f7af9f0 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -141,7 +141,9 @@ extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bi
#define TARGET_LONG_LONG_BIT (gdbarch_long_long_bit (current_gdbarch))
#endif
-/* Number of bits in a float for the target machine. */
+/* The ABI default bit-size and format for "float", "double", and "long
+ double". These bit/format pairs should eventually be combined into
+ a single object. */
extern int gdbarch_float_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_float_bit (struct gdbarch *gdbarch, int float_bit);
@@ -152,7 +154,14 @@ extern void set_gdbarch_float_bit (struct gdbarch *gdbarch, int float_bit);
#define TARGET_FLOAT_BIT (gdbarch_float_bit (current_gdbarch))
#endif
-/* Number of bits in a double for the target machine. */
+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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_FLOAT_FORMAT)
+#error "Non multi-arch definition of TARGET_FLOAT_FORMAT"
+#endif
+#if !defined (TARGET_FLOAT_FORMAT)
+#define TARGET_FLOAT_FORMAT (gdbarch_float_format (current_gdbarch))
+#endif
extern int gdbarch_double_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_double_bit (struct gdbarch *gdbarch, int double_bit);
@@ -163,7 +172,14 @@ extern void set_gdbarch_double_bit (struct gdbarch *gdbarch, int double_bit);
#define TARGET_DOUBLE_BIT (gdbarch_double_bit (current_gdbarch))
#endif
-/* Number of bits in a long double for the target machine. */
+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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_DOUBLE_FORMAT)
+#error "Non multi-arch definition of TARGET_DOUBLE_FORMAT"
+#endif
+#if !defined (TARGET_DOUBLE_FORMAT)
+#define TARGET_DOUBLE_FORMAT (gdbarch_double_format (current_gdbarch))
+#endif
extern int gdbarch_long_double_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_long_double_bit (struct gdbarch *gdbarch, int long_double_bit);
@@ -174,6 +190,15 @@ extern void set_gdbarch_long_double_bit (struct gdbarch *gdbarch, int long_doubl
#define TARGET_LONG_DOUBLE_BIT (gdbarch_long_double_bit (current_gdbarch))
#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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_LONG_DOUBLE_FORMAT)
+#error "Non multi-arch definition of TARGET_LONG_DOUBLE_FORMAT"
+#endif
+#if !defined (TARGET_LONG_DOUBLE_FORMAT)
+#define TARGET_LONG_DOUBLE_FORMAT (gdbarch_long_double_format (current_gdbarch))
+#endif
+
/* For most targets, a pointer on the target and its representation as an
address in GDB have the same size and "look the same". For such a
target, you need only set TARGET_PTR_BIT / ptr_bit and TARGET_ADDR_BIT
@@ -1129,33 +1154,6 @@ extern void set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch, int frame_
#define FRAME_RED_ZONE_SIZE (gdbarch_frame_red_zone_size (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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_FLOAT_FORMAT)
-#error "Non multi-arch definition of TARGET_FLOAT_FORMAT"
-#endif
-#if !defined (TARGET_FLOAT_FORMAT)
-#define TARGET_FLOAT_FORMAT (gdbarch_float_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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_DOUBLE_FORMAT)
-#error "Non multi-arch definition of TARGET_DOUBLE_FORMAT"
-#endif
-#if !defined (TARGET_DOUBLE_FORMAT)
-#define TARGET_DOUBLE_FORMAT (gdbarch_double_format (current_gdbarch))
-#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 > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_LONG_DOUBLE_FORMAT)
-#error "Non multi-arch definition of TARGET_LONG_DOUBLE_FORMAT"
-#endif
-#if !defined (TARGET_LONG_DOUBLE_FORMAT)
-#define TARGET_LONG_DOUBLE_FORMAT (gdbarch_long_double_format (current_gdbarch))
-#endif
-
typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern void set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 7278783..bde13b9 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -397,12 +397,18 @@ v:TARGET_LONG_BIT:int:long_bit::::8 * sizeof (long):4*TARGET_CHAR_BIT::0
# Number of bits in a long long or unsigned long long for the target
# machine.
v:TARGET_LONG_LONG_BIT:int:long_long_bit::::8 * sizeof (LONGEST):2*TARGET_LONG_BIT::0
-# Number of bits in a float for the target machine.
+
+# The ABI default bit-size and format for "float", "double", and "long
+# double". These bit/format pairs should eventually be combined into
+# a single object. For the moment, just initialize them as a pair.
+
v:TARGET_FLOAT_BIT:int:float_bit::::8 * sizeof (float):4*TARGET_CHAR_BIT::0
-# Number of bits in a double for the target machine.
+v:TARGET_FLOAT_FORMAT:const struct floatformat *:float_format::::::default_float_format (current_gdbarch)::%s:pformat (current_gdbarch->float_format)
v:TARGET_DOUBLE_BIT:int:double_bit::::8 * sizeof (double):8*TARGET_CHAR_BIT::0
-# Number of bits in a long double for the target machine.
+v:TARGET_DOUBLE_FORMAT:const struct floatformat *:double_format::::::default_double_format (current_gdbarch)::%s:pformat (current_gdbarch->double_format)
v:TARGET_LONG_DOUBLE_BIT:int:long_double_bit::::8 * sizeof (long double):8*TARGET_CHAR_BIT::0
+v:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat *:long_double_format::::::default_double_format (current_gdbarch)::%s:pformat (current_gdbarch->long_double_format)
+
# For most targets, a pointer on the target and its representation as an
# address in GDB have the same size and "look the same". For such a
# target, you need only set TARGET_PTR_BIT / ptr_bit and TARGET_ADDR_BIT
@@ -594,9 +600,6 @@ F:=:int:deprecated_reg_struct_has_addr:int gcc_p, struct type *type:gcc_p, type
m::int:stabs_argument_has_addr:struct type *type:type:::default_stabs_argument_has_addr::0
v:=:int:frame_red_zone_size
#
-v:TARGET_FLOAT_FORMAT:const struct floatformat *:float_format::::::default_float_format (current_gdbarch)::%s:(TARGET_FLOAT_FORMAT)->name
-v:TARGET_DOUBLE_FORMAT:const struct floatformat *:double_format::::::default_double_format (current_gdbarch)::%s:(TARGET_DOUBLE_FORMAT)->name
-v:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat *:long_double_format::::::default_double_format (current_gdbarch)::%s:(TARGET_LONG_DOUBLE_FORMAT)->name
m::CORE_ADDR:convert_from_func_ptr_addr:CORE_ADDR addr, struct target_ops *targ:addr, targ:::convert_from_func_ptr_addr_identity::0
# On some machines there are bits in addresses which are not really
# part of the address, but are used by the kernel, the hardware, etc.
@@ -1196,6 +1199,15 @@ static void alloc_gdbarch_data (struct gdbarch *);
#endif
int gdbarch_debug = GDBARCH_DEBUG;
+static const char *
+pformat (const struct floatformat *format)
+{
+ if (format == NULL)
+ return "(null)";
+ else
+ return format->name;
+}
+
EOF
# gdbarch open the gdbarch object