diff options
author | David Carlton <carlton@bactrian.org> | 2003-09-17 21:29:05 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-09-17 21:29:05 +0000 |
commit | 5993e46956fada1bbe5ad7b95b63c22a5c858746 (patch) | |
tree | 94451834539b4a3459fcd3b18f22ea6cdd838f0f /gdb/i387-tdep.c | |
parent | 6ac3a292f75ffbdc018a333c89e23809dc90bc56 (diff) | |
download | gdb-5993e46956fada1bbe5ad7b95b63c22a5c858746.tar.gz |
2003-09-17 David Carlton <carlton@kealia.com>
* Merge with mainline; tag is carlton_dictionary-20030917-merge.
Diffstat (limited to 'gdb/i387-tdep.c')
-rw-r--r-- | gdb/i387-tdep.c | 206 |
1 files changed, 96 insertions, 110 deletions
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index f7800af6415..6feb39285f5 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -217,22 +217,14 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, int fpreg; int top; - frame_register_read (frame, FCTRL_REGNUM, buf); - fctrl = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FSTAT_REGNUM, buf); - fstat = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FTAG_REGNUM, buf); - ftag = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FISEG_REGNUM, buf); - fiseg = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FIOFF_REGNUM, buf); - fioff = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FOSEG_REGNUM, buf); - foseg = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FOOFF_REGNUM, buf); - fooff = extract_unsigned_integer (buf, 4); - frame_register_read (frame, FOP_REGNUM, buf); - fop = extract_unsigned_integer (buf, 4); + fctrl = get_frame_register_unsigned (frame, FCTRL_REGNUM); + fstat = get_frame_register_unsigned (frame, FSTAT_REGNUM); + ftag = get_frame_register_unsigned (frame, FTAG_REGNUM); + fiseg = get_frame_register_unsigned (frame, FISEG_REGNUM); + fioff = get_frame_register_unsigned (frame, FIOFF_REGNUM); + foseg = get_frame_register_unsigned (frame, FOSEG_REGNUM); + fooff = get_frame_register_unsigned (frame, FOOFF_REGNUM); + fop = get_frame_register_unsigned (frame, FOP_REGNUM); top = ((fstat >> 11) & 7); @@ -260,7 +252,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, break; } - frame_register_read (frame, (fpreg + 8 - top) % 8 + FP0_REGNUM, raw); + get_frame_register (frame, (fpreg + 8 - top) % 8 + FP0_REGNUM, raw); fputs_filtered ("0x", file); for (i = 9; i >= 0; i--) @@ -310,7 +302,7 @@ i387_register_to_value (struct frame_info *frame, int regnum, /* Convert to TYPE. This should be a no-op if TYPE is equivalent to the extended floating-point format used by the FPU. */ - frame_read_register (frame, regnum, from); + get_frame_register (frame, regnum, from); convert_typed_floating (from, builtin_type_i387_ext, to, type); } @@ -369,51 +361,44 @@ static int fsave_offset[] = #define FSAVE_ADDR(fsave, regnum) (fsave + fsave_offset[regnum - FP0_REGNUM]) -/* Fill register REGNUM in GDB's register array with the appropriate +/* Fill register REGNUM in GDB's register cache with the appropriate value from *FSAVE. This function masks off any of the reserved bits in *FSAVE. */ void -i387_supply_register (int regnum, char *fsave) -{ - if (fsave == NULL) - { - supply_register (regnum, NULL); - return; - } - - /* Most of the FPU control registers occupy only 16 bits in - the fsave area. Give those a special treatment. */ - if (regnum >= FPC_REGNUM - && regnum != FIOFF_REGNUM && regnum != FOOFF_REGNUM) - { - unsigned char val[4]; - - memcpy (val, FSAVE_ADDR (fsave, regnum), 2); - val[2] = val[3] = 0; - if (regnum == FOP_REGNUM) - val[1] &= ((1 << 3) - 1); - supply_register (regnum, val); - } - else - supply_register (regnum, FSAVE_ADDR (fsave, regnum)); -} - -/* Fill GDB's register array with the floating-point register values - in *FSAVE. This function masks off any of the reserved - bits in *FSAVE. */ - -void -i387_supply_fsave (char *fsave) +i387_supply_fsave (const char *fsave, int regnum) { int i; for (i = FP0_REGNUM; i < XMM0_REGNUM; i++) - i387_supply_register (i, fsave); + if (regnum == -1 || regnum == i) + { + if (fsave == NULL) + { + supply_register (i, NULL); + return; + } + + /* Most of the FPU control registers occupy only 16 bits in the + fsave area. Give those a special treatment. */ + if (i >= FPC_REGNUM + && i != FIOFF_REGNUM && i != FOOFF_REGNUM) + { + unsigned char val[4]; + + memcpy (val, FSAVE_ADDR (fsave, i), 2); + val[2] = val[3] = 0; + if (i == FOP_REGNUM) + val[1] &= ((1 << 3) - 1); + supply_register (i, val); + } + else + supply_register (i, FSAVE_ADDR (fsave, i)); + } } /* Fill register REGNUM (if it is a floating-point register) in *FSAVE - with the value in GDB's register array. If REGNUM is -1, do this + with the value in GDB's register cache. If REGNUM is -1, do this for all registers. This function doesn't touch any of the reserved bits in *FSAVE. */ @@ -500,15 +485,15 @@ static int fxsave_offset[] = ((regnum == MXCSR_REGNUM) ? (fxsave + 24) : \ (fxsave + fxsave_offset[regnum - FP0_REGNUM])) -static int i387_tag (unsigned char *raw); +static int i387_tag (const unsigned char *raw); -/* Fill GDB's register array with the floating-point and SSE register - values in *FXSAVE. This function masks off any of the reserved - bits in *FXSAVE. */ +/* Fill register REGNUM in GDB's register cache with the appropriate + floating-point or SSE register value from *FXSAVE. This function + masks off any of the reserved bits in *FXSAVE. */ void -i387_supply_fxsave (char *fxsave) +i387_supply_fxsave (const char *fxsave, int regnum) { int i, last_regnum = MXCSR_REGNUM; @@ -516,62 +501,63 @@ i387_supply_fxsave (char *fxsave) last_regnum = FOP_REGNUM; for (i = FP0_REGNUM; i <= last_regnum; i++) - { - if (fxsave == NULL) - { - supply_register (i, NULL); - continue; - } + if (regnum == -1 || regnum == i) + { + if (fxsave == NULL) + { + supply_register (i, NULL); + continue; + } - /* Most of the FPU control registers occupy only 16 bits in - the fxsave area. Give those a special treatment. */ - if (i >= FPC_REGNUM && i < XMM0_REGNUM - && i != FIOFF_REGNUM && i != FOOFF_REGNUM) - { - unsigned char val[4]; - - memcpy (val, FXSAVE_ADDR (fxsave, i), 2); - val[2] = val[3] = 0; - if (i == FOP_REGNUM) - val[1] &= ((1 << 3) - 1); - else if (i== FTAG_REGNUM) - { - /* The fxsave area contains a simplified version of the - tag word. We have to look at the actual 80-bit FP - data to recreate the traditional i387 tag word. */ - - unsigned long ftag = 0; - int fpreg; - int top; - - top = (((FXSAVE_ADDR (fxsave, FSTAT_REGNUM))[1] >> 3) & 0x7); - - for (fpreg = 7; fpreg >= 0; fpreg--) - { - int tag; - - if (val[0] & (1 << fpreg)) - { - int regnum = (fpreg + 8 - top) % 8 + FP0_REGNUM; - tag = i387_tag (FXSAVE_ADDR (fxsave, regnum)); - } - else - tag = 3; /* Empty */ - - ftag |= tag << (2 * fpreg); - } - val[0] = ftag & 0xff; - val[1] = (ftag >> 8) & 0xff; - } - supply_register (i, val); - } - else - supply_register (i, FXSAVE_ADDR (fxsave, i)); - } + /* Most of the FPU control registers occupy only 16 bits in + the fxsave area. Give those a special treatment. */ + if (i >= FPC_REGNUM && i < XMM0_REGNUM + && i != FIOFF_REGNUM && i != FOOFF_REGNUM) + { + unsigned char val[4]; + + memcpy (val, FXSAVE_ADDR (fxsave, i), 2); + val[2] = val[3] = 0; + if (i == FOP_REGNUM) + val[1] &= ((1 << 3) - 1); + else if (i== FTAG_REGNUM) + { + /* The fxsave area contains a simplified version of + the tag word. We have to look at the actual 80-bit + FP data to recreate the traditional i387 tag word. */ + + unsigned long ftag = 0; + int fpreg; + int top; + + top = (((FXSAVE_ADDR (fxsave, FSTAT_REGNUM))[1] >> 3) & 0x7); + + for (fpreg = 7; fpreg >= 0; fpreg--) + { + int tag; + + if (val[0] & (1 << fpreg)) + { + int regnum = (fpreg + 8 - top) % 8 + FP0_REGNUM; + tag = i387_tag (FXSAVE_ADDR (fxsave, regnum)); + } + else + tag = 3; /* Empty */ + + ftag |= tag << (2 * fpreg); + } + val[0] = ftag & 0xff; + val[1] = (ftag >> 8) & 0xff; + } + supply_register (i, val); + } + else + supply_register (i, FXSAVE_ADDR (fxsave, i)); + } } /* Fill register REGNUM (if it is a floating-point or SSE register) in - *FXSAVE with the value in GDB's register array. If REGNUM is -1, do + *FXSAVE with the value in GDB's register cache. If REGNUM is -1, do this for all registers. This function doesn't touch any of the reserved bits in *FXSAVE. */ @@ -632,7 +618,7 @@ i387_fill_fxsave (char *fxsave, int regnum) *RAW. */ static int -i387_tag (unsigned char *raw) +i387_tag (const unsigned char *raw) { int integer; unsigned int exponent; |