More on GDB, x86 floating point registers & Linux
Paul Flinders
paul@dawa.demon.co.uk
Sat Jun 6 05:19:00 GMT 1998
The previous patch didn't address extracting the return value from a
function called by GDB. The attached patch (which includes the changes
made previously for simplicity) corrects this.
diff -r -u orig/gdb-1998-05-28/gdb/config/i386/tm-i386aix.h gdb-1998-05-28/gdb/config/i386/tm-i386aix.h
--- orig/gdb-1998-05-28/gdb/config/i386/tm-i386aix.h Thu Nov 2 15:20:33 1995
+++ gdb-1998-05-28/gdb/config/i386/tm-i386aix.h Sat Jun 6 12:34:03 1998
@@ -31,7 +31,9 @@
#ifndef I386_AIX_TARGET
# define I386_AIX_TARGET 1
#endif
-
+#ifndef I386_FLOAT_RET_IN_FP0
+# define I386_FLOAT_RET_IN_FP0 1
+#endif
/* Nonzero if register N requires conversion
from raw format to virtual format. */
diff -r -u orig/gdb-1998-05-28/gdb/config/i386/tm-linux.h gdb-1998-05-28/gdb/config/i386/tm-linux.h
--- orig/gdb-1998-05-28/gdb/config/i386/tm-linux.h Wed Apr 22 02:44:37 1998
+++ gdb-1998-05-28/gdb/config/i386/tm-linux.h Sat Jun 6 12:34:08 1998
@@ -35,4 +35,48 @@
/* The following works around a problem with /usr/include/sys/procfs.h */
#define sys_quotactl 1
+/* Support reading the floating point registers under linux */
+#undef NUM_FREGS
+#define NUM_FREGS 8 /* Number of FP regs */
+
+/* Nonzero if register N requires conversion
+ from raw format to virtual format. */
+
+#undef REGISTER_CONVERTIBLE
+#define REGISTER_CONVERTIBLE(N) \
+ ((N < FP0_REGNUM) ? 0 : 1)
+
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
+
+#undef REGISTER_CONVERT_TO_VIRTUAL
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
+{ \
+ double val; \
+ i387_to_double ((FROM), (char *)&val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
+}
+extern void
+i387_to_double PARAMS ((char *, char *));
+
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
+
+#undef REGISTER_CONVERT_TO_RAW
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
+{ \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_i387((char *)&val, (TO)); \
+}
+extern void
+double_to_i387 PARAMS ((char *, char *));
+
+#define STAB_REG_TO_REGNUM(VALUE) \
+ ((VALUE) < 11 ? (VALUE) : (VALUE) + 5)
+
+/* Linux normally returns floating point values in FP0 */
+#ifndef I386_FLOAT_RET_IN_FP0
+# define I386_FLOAT_RET_IN_FP0 1
+#endif
+
#endif /* #ifndef TM_LINUX_H */
diff -r -u orig/gdb-1998-05-28/gdb/i386-tdep.c gdb-1998-05-28/gdb/i386-tdep.c
--- orig/gdb-1998-05-28/gdb/i386-tdep.c Sat Apr 11 06:43:22 1998
+++ gdb-1998-05-28/gdb/i386-tdep.c Sat Jun 6 12:34:18 1998
@@ -614,8 +614,9 @@
char regbuf[REGISTER_BYTES];
char *valbuf;
{
-/* On AIX, floating point values are returned in floating point registers. */
-#ifdef I386_AIX_TARGET
+/* On AIX and Linux, floating point values are returned in floating
+ point registers. */
+#ifdef I386_FLOAT_RET_IN_FP0
if (TYPE_CODE_FLT == TYPE_CODE(type))
{
double d;
More information about the Gdb-patches
mailing list