From: Kevin Buettner Date: Mon, 7 Apr 2003 18:38:04 +0000 (+0000) Subject: * mips-tdep.c (mips_print_fp_register): New function, created from X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f0ef6b29bde589566edef28c0a8267eff2ca8127;p=binutils-gdb.git * mips-tdep.c (mips_print_fp_register): New function, created from do_fp_register_row(). Registers are now (also) printed as hex. Only one register is printed per row. (mips_print_register, do_fp_register_row): Print floating point registers with mips_print_fp_register(). --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1bb029c4efc..587505702d0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2003-04-07 Kevin Buettner + + * mips-tdep.c (mips_print_fp_register): New function, created from + do_fp_register_row(). Registers are now (also) printed as hex. + Only one register is printed per row. + (mips_print_register, do_fp_register_row): Print floating point + registers with mips_print_fp_register(). + 2003-04-06 Andrew Cagney * valprint.h (inspect_it): Add extern declaration. diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index f9424d76946..59121f3c1aa 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4049,154 +4049,126 @@ mips_read_fp_register_double (int regno, char *rare_buffer) } static void -mips_print_register (int regnum, int all) -{ - char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE); - - /* Get the data in raw format. */ - if (!frame_register_read (deprecated_selected_frame, regnum, raw_buffer)) - { - printf_filtered ("%s: [Invalid]", REGISTER_NAME (regnum)); - return; - } - - /* If we have a actual 32-bit floating point register (or we are in - 32-bit compatibility mode), and the register is even-numbered, - also print it as a double (spanning two registers). */ - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT - && (REGISTER_RAW_SIZE (regnum) == 4 - || mips2_fp_compat ()) - && !((regnum - FP0_REGNUM) & 1)) - { - char *dbuffer = alloca (2 * MAX_REGISTER_RAW_SIZE); - - mips_read_fp_register_double (regnum, dbuffer); - - printf_filtered ("(d%d: ", regnum - FP0_REGNUM); - val_print (mips_double_register_type (), dbuffer, 0, 0, - gdb_stdout, 0, 1, 0, Val_pretty_default); - printf_filtered ("); "); - } - fputs_filtered (REGISTER_NAME (regnum), gdb_stdout); - - /* The problem with printing numeric register names (r26, etc.) is that - the user can't use them on input. Probably the best solution is to - fix it so that either the numeric or the funky (a2, etc.) names - are accepted on input. */ - if (regnum < MIPS_NUMREGS) - printf_filtered ("(r%d): ", regnum); - else - printf_filtered (": "); - - /* If virtual format is floating, print it that way. */ - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT) - if (REGISTER_RAW_SIZE (regnum) == 8 && !mips2_fp_compat ()) - { - /* We have a meaningful 64-bit value in this register. Show - it as a 32-bit float and a 64-bit double. */ - int offset = 4 * (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG); - - printf_filtered (" (float) "); - val_print (mips_float_register_type (), raw_buffer + offset, 0, 0, - gdb_stdout, 0, 1, 0, Val_pretty_default); - printf_filtered (", (double) "); - val_print (mips_double_register_type (), raw_buffer, 0, 0, - gdb_stdout, 0, 1, 0, Val_pretty_default); - } - else - val_print (REGISTER_VIRTUAL_TYPE (regnum), raw_buffer, 0, 0, - gdb_stdout, 0, 1, 0, Val_pretty_default); - /* Else print as integer in hex. */ - else - { - int offset; - - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) - offset = REGISTER_RAW_SIZE (regnum) - REGISTER_VIRTUAL_SIZE (regnum); - else - offset = 0; - - print_scalar_formatted (raw_buffer + offset, - REGISTER_VIRTUAL_TYPE (regnum), - 'x', 0, gdb_stdout); - } -} - -/* Replacement for generic do_registers_info. - Print regs in pretty columns. */ - -static int -do_fp_register_row (int regnum) +mips_print_fp_register (int regnum) { /* do values for FP (float) regs */ char *raw_buffer; double doub, flt1, flt2; /* doubles extracted from raw hex data */ - int inv1, inv2, inv3; + int inv1, inv2, namelen; raw_buffer = (char *) alloca (2 * REGISTER_RAW_SIZE (FP0_REGNUM)); + printf_filtered ("%s:", REGISTER_NAME (regnum)); + printf_filtered ("%*s", 4 - (int) strlen (REGISTER_NAME (regnum)), ""); + if (REGISTER_RAW_SIZE (regnum) == 4 || mips2_fp_compat ()) { - /* 4-byte registers: we can fit two registers per row. */ - /* Also print every pair of 4-byte regs as an 8-byte double. */ + /* 4-byte registers: Print hex and floating. Also print even + numbered registers as doubles. */ mips_read_fp_register_single (regnum, raw_buffer); flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1); - mips_read_fp_register_single (regnum + 1, raw_buffer); - flt2 = unpack_double (mips_float_register_type (), raw_buffer, &inv2); - - mips_read_fp_register_double (regnum, raw_buffer); - doub = unpack_double (mips_double_register_type (), raw_buffer, &inv3); + print_scalar_formatted (raw_buffer, builtin_type_uint32, 'x', 'w', + gdb_stdout); - printf_filtered (" %-5s", REGISTER_NAME (regnum)); + printf_filtered (" flt: "); if (inv1) - printf_filtered (": "); + printf_filtered (" "); else printf_filtered ("%-17.9g", flt1); - printf_filtered (" %-5s", REGISTER_NAME (regnum + 1)); - if (inv2) - printf_filtered (": "); - else - printf_filtered ("%-17.9g", flt2); - - printf_filtered (" dbl: "); - if (inv3) - printf_filtered (""); - else - printf_filtered ("%-24.17g", doub); - printf_filtered ("\n"); + if (regnum % 2 == 0) + { + mips_read_fp_register_double (regnum, raw_buffer); + doub = unpack_double (mips_double_register_type (), raw_buffer, + &inv2); - /* may want to do hex display here (future enhancement) */ - regnum += 2; + printf_filtered (" dbl: "); + if (inv2) + printf_filtered (""); + else + printf_filtered ("%-24.17g", doub); + } } else { - /* Eight byte registers: print each one as float AND as double. */ + /* Eight byte registers: print each one as hex, float and double. */ mips_read_fp_register_single (regnum, raw_buffer); flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1); mips_read_fp_register_double (regnum, raw_buffer); - doub = unpack_double (mips_double_register_type (), raw_buffer, &inv3); + doub = unpack_double (mips_double_register_type (), raw_buffer, &inv2); + + + print_scalar_formatted (raw_buffer, builtin_type_uint64, 'x', 'g', + gdb_stdout); - printf_filtered (" %-5s: ", REGISTER_NAME (regnum)); + printf_filtered (" flt: "); if (inv1) printf_filtered (""); else - printf_filtered ("flt: %-17.9g", flt1); + printf_filtered ("%-17.9g", flt1); printf_filtered (" dbl: "); - if (inv3) + if (inv2) printf_filtered (""); else printf_filtered ("%-24.17g", doub); + } +} - printf_filtered ("\n"); - /* may want to do hex display here (future enhancement) */ - regnum++; +static void +mips_print_register (int regnum, int all) +{ + char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE); + int offset; + + if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT) + { + mips_print_fp_register (regnum); + return; } - return regnum; + + /* Get the data in raw format. */ + if (!frame_register_read (deprecated_selected_frame, regnum, raw_buffer)) + { + printf_filtered ("%s: [Invalid]", REGISTER_NAME (regnum)); + return; + } + + fputs_filtered (REGISTER_NAME (regnum), gdb_stdout); + + /* The problem with printing numeric register names (r26, etc.) is that + the user can't use them on input. Probably the best solution is to + fix it so that either the numeric or the funky (a2, etc.) names + are accepted on input. */ + if (regnum < MIPS_NUMREGS) + printf_filtered ("(r%d): ", regnum); + else + printf_filtered (": "); + + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + offset = REGISTER_RAW_SIZE (regnum) - REGISTER_VIRTUAL_SIZE (regnum); + else + offset = 0; + + print_scalar_formatted (raw_buffer + offset, + REGISTER_VIRTUAL_TYPE (regnum), + 'x', 0, gdb_stdout); } +/* Replacement for generic do_registers_info. + Print regs in pretty columns. */ + +static int +do_fp_register_row (int regnum) +{ + printf_filtered (" "); + mips_print_fp_register (regnum); + printf_filtered ("\n"); + return regnum + 1; +} + + /* Print a row's worth of GP (int) registers, with name labels above */ static int