diff options
Diffstat (limited to 'gdb/i387-tdep.c')
-rw-r--r-- | gdb/i387-tdep.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index ff369f9..1552565 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -734,3 +734,31 @@ i387_tag (const unsigned char *raw) } } } + +/* Prepare the FPU stack in REGCACHE for a function return. */ + +void +i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ULONGEST fstat; + + /* Define I387_ST0_REGNUM such that we use the proper + definitions for the architecture. */ +#define I387_ST0_REGNUM tdep->st0_regnum + + /* Set the top of the floating-point register stack to 7. The + actual value doesn't really matter, but 7 is what a normal + function return would end up with if the program started out with + a freshly initialized FPU. */ + regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM, &fstat); + fstat |= (7 << 11); + regcache_raw_write_unsigned (regcache, I387_FSTAT_REGNUM, fstat); + + /* Mark %st(1) through %st(7) as empty. Since we set the top of the + floating-point register stack to 7, the appropriate value for the + tag word is 0x3fff. */ + regcache_raw_write_unsigned (regcache, I387_FTAG_REGNUM, 0x3fff); + +#undef I387_ST0_REGNUM +} |