summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2001-07-28 17:03:38 +0000
committerMark Kettenis <kettenis@gnu.org>2001-07-28 17:03:38 +0000
commit9de859fdeca6efad29858294c21ad83da059de0b (patch)
tree28e4fcad162c8dd9a350bad92b59476693fb48ee
parent2840dd75f40c618328df95359c30921c103e8a2b (diff)
downloadgdb-9de859fdeca6efad29858294c21ad83da059de0b.tar.gz
* config/i386/tm-i386.h (STAB_REG_TO_REGNUM, SDB_REG_TO_REGNUM,
DWARF_REG_TO_REGNUM, DWARF2_REG_TO_REGNUM): New defines. (i386_stab_reg_to_regnum, i386_dwarf_reg_to_regnum): New prototypes. * config/i386/tm-fbsd.h, config/i386/tm-i386gnu.h, config/i386/tm-linux.h (STAB_REG_TO_REGNUM): Redefine to call i386_dwarf_reg_to_regnum. * i386-tdep.c (i386_stab_reg_to_regnum, i386_dwarf_reg_to_regnum): New functions.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/config/i386/tm-fbsd.h8
-rw-r--r--gdb/config/i386/tm-i386gnu.h5
-rw-r--r--gdb/i386-tdep.c62
4 files changed, 85 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 51c77275fdf..0fe00f315fc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2001-07-28 Mark Kettenis <kettenis@gnu.org>
+ * config/i386/tm-i386.h (STAB_REG_TO_REGNUM, SDB_REG_TO_REGNUM,
+ DWARF_REG_TO_REGNUM, DWARF2_REG_TO_REGNUM): New defines.
+ (i386_stab_reg_to_regnum, i386_dwarf_reg_to_regnum): New
+ prototypes.
+ * config/i386/tm-fbsd.h, config/i386/tm-i386gnu.h,
+ config/i386/tm-linux.h (STAB_REG_TO_REGNUM): Redefine to call
+ i386_dwarf_reg_to_regnum.
+ * i386-tdep.c (i386_stab_reg_to_regnum, i386_dwarf_reg_to_regnum):
+ New functions.
+
* i386-tdep.c: Include "gdb_assert.h"
(i386_register_convert_to_virtual): Fix such that it can handle
conversion to any floating-point type. Assert that we are dealing
diff --git a/gdb/config/i386/tm-fbsd.h b/gdb/config/i386/tm-fbsd.h
index f8f4889c2f3..61f5de57f4a 100644
--- a/gdb/config/i386/tm-fbsd.h
+++ b/gdb/config/i386/tm-fbsd.h
@@ -24,6 +24,14 @@
#define HAVE_I387_REGS
#include "i386/tm-i386.h"
+/* FreeBSD/ELF uses stabs-in-ELF with the DWARF register numbering
+ scheme by default, so we must redefine STAB_REG_TO_REGNUM. This
+ messes up the floating-point registers for a.out, but there is not
+ much we can do about that. */
+
+#undef STAB_REG_TO_REGNUM
+#define STAB_REG_TO_REGNUM(reg) i386_dwarf_reg_to_regnum ((reg))
+
/* FreeBSD uses the old gcc convention for struct returns. */
#define USE_STRUCT_CONVENTION(gcc_p, type) \
diff --git a/gdb/config/i386/tm-i386gnu.h b/gdb/config/i386/tm-i386gnu.h
index 6f6d245379a..00cb5a9f100 100644
--- a/gdb/config/i386/tm-i386gnu.h
+++ b/gdb/config/i386/tm-i386gnu.h
@@ -42,6 +42,11 @@
#define HAVE_I387_REGS
#include "i386/tm-i386.h"
+/* We use stabs-in-ELF with the DWARF register numbering scheme. */
+
+#undef STAB_REG_TO_REGNUM
+#define STAB_REG_TO_REGNUM(reg) i386_dwarf_reg_to_regnum ((reg))
+
/* Offset to saved PC in sigcontext. */
#define SIGCONTEXT_PC_OFFSET 68
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 60ca84ed998..3aa8cb54344 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -59,6 +59,68 @@ int i386_register_raw_size[MAX_NUM_REGS] = {
/* i386_register_virtual_size[i] is the size in bytes of the virtual
type of register i. */
int i386_register_virtual_size[MAX_NUM_REGS];
+
+/* Convert stabs register number REG to the appropriate register
+ number used by GDB. */
+
+int
+i386_stab_reg_to_regnum (int reg)
+{
+ /* This implements what GCC calls the "default" register map. */
+ if (reg >= 0 && reg <= 7)
+ {
+ /* General registers. */
+ return reg;
+ }
+ else if (reg >= 12 && reg <= 19)
+ {
+ /* Floating-point registers. */
+ return reg - 12 + FP0_REGNUM;
+ }
+ else if (reg >= 21 && reg <= 28)
+ {
+ /* SSE registers. */
+ return reg - 21 + XMM0_REGNUM;
+ }
+ else if (reg >= 29 && reg <= 36)
+ {
+ /* MMX registers. */
+ /* FIXME: kettenis/2001-07-28: Should we have the MMX registers
+ as pseudo-registers? */
+ return reg - 29 + FP0_REGNUM;
+ }
+
+ /* This will hopefully provoke a warning. */
+ return NUM_REGS + NUM_PSEUDO_REGS;
+}
+
+/* Convert Dwarf register number REG to the appropriate register
+ number used by GDB. */
+
+int
+i386_dwarf_reg_to_regnum (int reg)
+{
+ /* The DWARF register numbering includes %eip and %eflags, and
+ numbers the floating point registers differently. */
+ if (reg >= 0 && reg <= 9)
+ {
+ /* General registers. */
+ return reg;
+ }
+ else if (reg >= 11 && reg <= 18)
+ {
+ /* Floating-point registers. */
+ return reg - 11 + FP0_REGNUM;
+ }
+ else if (reg >= 21)
+ {
+ /* The SSE and MMX registers have identical numbers as in stabs. */
+ return i386_stab_reg_to_regnum (reg);
+ }
+
+ /* This will hopefully provoke a warning. */
+ return NUM_REGS + NUM_PSEUDO_REGS;
+}
/* This is the variable that is set with "set disassembly-flavor", and