--- ./gdb-7.2/gdb/i387-tdep.c 2010-05-05 21:30:36.000000000 +0200 +++ ./gdb-7.2.2/gdb/i387-tdep.c 2011-04-19 20:42:56.691027998 +0200 @@ -36,6 +36,106 @@ #include "i387-tdep.h" #include "i386-xstate.h" +struct +{ + const char *tag; + const char *description; +} + +static const npx_exception_flags[6] = + +{ + {"IE", "invalid operation"}, + {"DE", "denormalized operand"}, + {"ZE", "zero divide"}, + {"OE", "overflow"}, + {"UE", "underflow"}, + {"PE", "precision"} +}; + +struct +{ + const char *tag; + const char *description; +} + +static const npx_exception_mask[6] = + +{ + {"IM", "invalid operation"}, + {"DM", "denormalized operand"}, + {"ZM", "zero divide"}, + {"OM", "overflow"}, + {"UM", "underflow"}, + {"PM", "precision"} +}; + +static const char *npx_precision_control[4] = +{ + "24-bits (single precision)", + "(reserved)", + "53-bits (double precision)", + "64-bits (extended precision)" +}; + +static const char *npx_rounding_control[4] = +{ + "round to nearest or even", + "round down (towards -inf)", + "round up (toward +inf)", + "chop (truncate toward zero)" +}; + +/* print the numeric coprocessor extension (npx) status word */ +void print_npx_status_word(uint16_t npx_status_word, struct ui_file *file) +{ + fprintf_filtered(file, "status word : 0x%04X\n", npx_status_word); + + fprintf_filtered(file, " exception flags : "); + + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0005) & 0x0001) ? npx_exception_flags[5].tag : " "); // precision + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0004) & 0x0001) ? npx_exception_flags[4].tag : " "); // underflow + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0003) & 0x0001) ? npx_exception_flags[3].tag : " "); // overflow + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0002) & 0x0001) ? npx_exception_flags[2].tag : " "); // zero divide + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0001) & 0x0001) ? npx_exception_flags[1].tag : " "); // denormalized operand + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0000) & 0x0001) ? npx_exception_flags[0].tag : " "); // invalid operation + fprintf_filtered(file, "\n"); + + fprintf_filtered(file, " stack fault : %u\n", ((npx_status_word >> 0x0006) & 0x0001)); + fprintf_filtered(file, " error summary status : %u\n", ((npx_status_word >> 0x0007) & 0x0001)); + fprintf_filtered(file, " busy : %u\n", ((npx_status_word >> 0x000F) & 0x0001)); + fprintf_filtered(file, " top of stack pointer : %u\n", ((npx_status_word >> 0x000B) & 0x0007)); + + fprintf_filtered(file, " condition code : "); + + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x000E) & 0x0001) ? "C3" : " "); + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x000A) & 0x0001) ? "C2" : " "); + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0009) & 0x0001) ? "C1" : " "); + fprintf_filtered(file, "%s ", ((npx_status_word >> 0x0008) & 0x0001) ? "C0" : " "); + fprintf_filtered(file, "\n"); +} + +/* print the numeric coprocessor extension (npx) control word */ +void print_npx_control_word(uint16_t npx_control_word, struct ui_file *file) +{ + fprintf_filtered(file, "control word : 0x%04X\n", npx_control_word); + + fprintf_filtered(file, " exception mask : "); + + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0005) & 0x0001) ? npx_exception_mask[5].tag : " "); // precision + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0004) & 0x0001) ? npx_exception_mask[4].tag : " "); // underflow + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0003) & 0x0001) ? npx_exception_mask[3].tag : " "); // overflow + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0002) & 0x0001) ? npx_exception_mask[2].tag : " "); // zero divide + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0001) & 0x0001) ? npx_exception_mask[1].tag : " "); // denormalized operand + fprintf_filtered(file, "%s ", ((npx_control_word >> 0x0000) & 0x0001) ? npx_exception_mask[0].tag : " "); // invalid operation + fprintf_filtered(file, "\n"); + + fprintf_filtered(file, " precision control (PC) : %s\n", npx_precision_control[((npx_control_word >> 0x0008) & 0x0003)]); + fprintf_filtered(file, " rounding control (RC) : %s\n", npx_rounding_control[((npx_control_word >> 0x000A) & 0x0003)]); + + fprintf_filtered(file, " infinity control : %u\n", ((npx_control_word >> 0x000C) & 0x0001)); +} + /* Print the floating point number specified by RAW. */ static void @@ -114,88 +214,6 @@ print_i387_ext (struct gdbarch *gdbarch, fputs_filtered (" Unsupported", file); } -/* Print the status word STATUS. */ - -static void -print_i387_status_word (unsigned int status, struct ui_file *file) -{ - fprintf_filtered (file, "Status Word: %s", - hex_string_custom (status, 4)); - fputs_filtered (" ", file); - fprintf_filtered (file, " %s", (status & 0x0001) ? "IE" : " "); - fprintf_filtered (file, " %s", (status & 0x0002) ? "DE" : " "); - fprintf_filtered (file, " %s", (status & 0x0004) ? "ZE" : " "); - fprintf_filtered (file, " %s", (status & 0x0008) ? "OE" : " "); - fprintf_filtered (file, " %s", (status & 0x0010) ? "UE" : " "); - fprintf_filtered (file, " %s", (status & 0x0020) ? "PE" : " "); - fputs_filtered (" ", file); - fprintf_filtered (file, " %s", (status & 0x0080) ? "ES" : " "); - fputs_filtered (" ", file); - fprintf_filtered (file, " %s", (status & 0x0040) ? "SF" : " "); - fputs_filtered (" ", file); - fprintf_filtered (file, " %s", (status & 0x0100) ? "C0" : " "); - fprintf_filtered (file, " %s", (status & 0x0200) ? "C1" : " "); - fprintf_filtered (file, " %s", (status & 0x0400) ? "C2" : " "); - fprintf_filtered (file, " %s", (status & 0x4000) ? "C3" : " "); - - fputs_filtered ("\n", file); - - fprintf_filtered (file, - " TOP: %d\n", ((status >> 11) & 7)); -} - -/* Print the control word CONTROL. */ - -static void -print_i387_control_word (unsigned int control, struct ui_file *file) -{ - fprintf_filtered (file, "Control Word: %s", - hex_string_custom (control, 4)); - fputs_filtered (" ", file); - fprintf_filtered (file, " %s", (control & 0x0001) ? "IM" : " "); - fprintf_filtered (file, " %s", (control & 0x0002) ? "DM" : " "); - fprintf_filtered (file, " %s", (control & 0x0004) ? "ZM" : " "); - fprintf_filtered (file, " %s", (control & 0x0008) ? "OM" : " "); - fprintf_filtered (file, " %s", (control & 0x0010) ? "UM" : " "); - fprintf_filtered (file, " %s", (control & 0x0020) ? "PM" : " "); - - fputs_filtered ("\n", file); - - fputs_filtered (" PC: ", file); - switch ((control >> 8) & 3) - { - case 0: - fputs_filtered ("Single Precision (24-bits)\n", file); - break; - case 1: - fputs_filtered ("Reserved\n", file); - break; - case 2: - fputs_filtered ("Double Precision (53-bits)\n", file); - break; - case 3: - fputs_filtered ("Extended Precision (64-bits)\n", file); - break; - } - - fputs_filtered (" RC: ", file); - switch ((control >> 10) & 3) - { - case 0: - fputs_filtered ("Round to nearest\n", file); - break; - case 1: - fputs_filtered ("Round down\n", file); - break; - case 2: - fputs_filtered ("Round up\n", file); - break; - case 3: - fputs_filtered ("Round toward zero\n", file); - break; - } -} - /* Print out the i387 floating point state. Note that we ignore FRAME in the code below. That's OK since floating-point registers are never saved on the stack. */ @@ -268,8 +286,12 @@ i387_print_float_info (struct gdbarch *g fputs_filtered ("\n", file); - print_i387_status_word (fstat, file); - print_i387_control_word (fctrl, file); + print_npx_status_word(fstat, file); + fprintf_filtered(file, "\n"); + + print_npx_control_word(fctrl, file); + fprintf_filtered(file, "\n"); + fprintf_filtered (file, "Tag Word: %s\n", hex_string_custom (ftag, 4)); fprintf_filtered (file, "Instruction Pointer: %s:",