From 8ba0dd515c1ba23318f28c6bb04c9da573855b50 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 24 Oct 2017 18:01:39 +0200 Subject: Target FP printing: Use floatformat_to_string in tdep code A few tdep files use target-specific printing routines to output values in the floating-point registers. To get rid of host floating-point code, this patch changes them to use floatformat_to_string instead. No functional change intended, the resulting output should look the same. ChangeLog: 2017-10-24 Ulrich Weigand * i387-tdep.c (print_i387_value): Use floatformat_to_string. * sh64-tdep.c (sh64_do_fp_register): Likewise. * mips-tdep.c (mips_print_fp_register): Likewise. --- gdb/mips-tdep.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'gdb/mips-tdep.c') diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 4eafe3e..61e7295 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -6256,8 +6256,12 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame, { /* Do values for FP (float) regs. */ struct gdbarch *gdbarch = get_frame_arch (frame); gdb_byte *raw_buffer; - double doub, flt1; /* Doubles extracted from raw hex data. */ - int inv1, inv2; + std::string flt_str, dbl_str; + + const struct floatformat *flt_fmt + = floatformat_from_type (builtin_type (gdbarch)->builtin_float); + const struct floatformat *dbl_fmt + = floatformat_from_type (builtin_type (gdbarch)->builtin_double); raw_buffer = ((gdb_byte *) @@ -6275,31 +6279,21 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame, /* 4-byte registers: Print hex and floating. Also print even numbered registers as doubles. */ mips_read_fp_register_single (frame, regnum, raw_buffer); - flt1 = unpack_double (builtin_type (gdbarch)->builtin_float, - raw_buffer, &inv1); + flt_str = floatformat_to_string (flt_fmt, raw_buffer, "%-17.9g"); get_formatted_print_options (&opts, 'x'); print_scalar_formatted (raw_buffer, builtin_type (gdbarch)->builtin_uint32, &opts, 'w', file); - fprintf_filtered (file, " flt: "); - if (inv1) - fprintf_filtered (file, " "); - else - fprintf_filtered (file, "%-17.9g", flt1); + fprintf_filtered (file, " flt: %s", flt_str.c_str ()); if ((regnum - gdbarch_num_regs (gdbarch)) % 2 == 0) { mips_read_fp_register_double (frame, regnum, raw_buffer); - doub = unpack_double (builtin_type (gdbarch)->builtin_double, - raw_buffer, &inv2); + dbl_str = floatformat_to_string (dbl_fmt, raw_buffer, "%-24.17g"); - fprintf_filtered (file, " dbl: "); - if (inv2) - fprintf_filtered (file, ""); - else - fprintf_filtered (file, "%-24.17g", doub); + fprintf_filtered (file, " dbl: %s", dbl_str.c_str ()); } } else @@ -6308,29 +6302,18 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame, /* Eight byte registers: print each one as hex, float and double. */ mips_read_fp_register_single (frame, regnum, raw_buffer); - flt1 = unpack_double (builtin_type (gdbarch)->builtin_float, - raw_buffer, &inv1); + flt_str = floatformat_to_string (flt_fmt, raw_buffer, "%-17.9g"); mips_read_fp_register_double (frame, regnum, raw_buffer); - doub = unpack_double (builtin_type (gdbarch)->builtin_double, - raw_buffer, &inv2); + dbl_str = floatformat_to_string (dbl_fmt, raw_buffer, "%-24.17g"); get_formatted_print_options (&opts, 'x'); print_scalar_formatted (raw_buffer, builtin_type (gdbarch)->builtin_uint64, &opts, 'g', file); - fprintf_filtered (file, " flt: "); - if (inv1) - fprintf_filtered (file, ""); - else - fprintf_filtered (file, "%-17.9g", flt1); - - fprintf_filtered (file, " dbl: "); - if (inv2) - fprintf_filtered (file, ""); - else - fprintf_filtered (file, "%-24.17g", doub); + fprintf_filtered (file, " flt: %s", flt_str.c_str ()); + fprintf_filtered (file, " dbl: %s", dbl_str.c_str ()); } } -- cgit v1.1