diff options
author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2017-10-24 18:01:39 +0200 |
---|---|---|
committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2017-10-24 18:01:39 +0200 |
commit | 8ba0dd515c1ba23318f28c6bb04c9da573855b50 (patch) | |
tree | af57478382ceb88d7d664f38efcfbd72994d0e71 /gdb/mips-tdep.c | |
parent | 16e812b29e68c4a6fcad73b033716c4f385ce94f (diff) | |
download | gdb-8ba0dd515c1ba23318f28c6bb04c9da573855b50.zip gdb-8ba0dd515c1ba23318f28c6bb04c9da573855b50.tar.gz gdb-8ba0dd515c1ba23318f28c6bb04c9da573855b50.tar.bz2 |
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 <uweigand@de.ibm.com>
* 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.
Diffstat (limited to 'gdb/mips-tdep.c')
-rw-r--r-- | gdb/mips-tdep.c | 45 |
1 files changed, 14 insertions, 31 deletions
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, " <invalid float> "); - 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, "<invalid double>"); - 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, "<invalid float>"); - else - fprintf_filtered (file, "%-17.9g", flt1); - - fprintf_filtered (file, " dbl: "); - if (inv2) - fprintf_filtered (file, "<invalid double>"); - 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 ()); } } |