This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GDB, x86 floating point registers & Linux



Gdb (up to & including the 28 May snapshot) doesn't do very well with the
floating point registers on x86 Linux - it can't display the registers or
display variables which are held in registers.

The appended patch adds support for listing the floating point registers
(with info all-registers), accessing variables held in floating point
registers and printing the registers themselves.

--- 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   Fri Jun  5 23:02:09 1998
@@ -35,4 +35,43 @@
 /* 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)
+
 #endif  /* #ifndef TM_LINUX_H */