aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-tdep.c
diff options
context:
space:
mode:
authornobody <>2003-04-19 14:43:51 +0000
committernobody <>2003-04-19 14:43:51 +0000
commit291862d73dc6b445dae7638c7490d74473dea27c (patch)
tree9263a76bef13f0ba98af84e9496af9524e617d83 /gdb/i386-tdep.c
parentbad7deeefd1fa35f148ce755f6ee1e00c3c0d05e (diff)
downloadgdb-291862d73dc6b445dae7638c7490d74473dea27c.zip
gdb-291862d73dc6b445dae7638c7490d74473dea27c.tar.gz
gdb-291862d73dc6b445dae7638c7490d74473dea27c.tar.bz2
This commit was manufactured by cvs2svn to create branchkettenis_i386newframe-20030419-branchpoint
'kettenis_i386newframe-20030419-branch'. Sprout from kettenis_i386newframe-20030406-branch 2003-04-06 14:50:16 UTC nobody 'This commit was manufactured by cvs2svn to create branch' Cherrypick from master 2003-04-19 14:43:50 UTC Mark Kettenis <kettenis@gnu.org> '* i386-tdep.c (i386_num_register_names): New variable.': ChangeLog Makefile.in Makefile.tpl bfd/ChangeLog bfd/archures.c bfd/bfd-in2.h bfd/coff-h8300.c bfd/coff-h8500.c bfd/coff-sh.c bfd/cpu-h8300.c bfd/cpu-sh.c bfd/dwarf2.c bfd/elf32-h8300.c bfd/elf32-mips.c bfd/elf32-sh.c bfd/elf32-sh64-com.c bfd/elf32-sh64.c bfd/elf32-xtensa.c bfd/elf64-alpha.c bfd/elf64-sh64.c bfd/elflink.h bfd/elfn32-mips.c bfd/elfxx-ia64.c bfd/elfxx-mips.c bfd/format.c bfd/peicode.h bfd/reloc.c bfd/version.h configure configure.in gdb/ChangeLog gdb/Makefile.in gdb/NEWS gdb/ada-lang.h gdb/alpha-tdep.c gdb/arch-utils.c gdb/arch-utils.h gdb/arm-linux-tdep.c gdb/arm-tdep.c gdb/avr-tdep.c gdb/ax-gdb.h gdb/block.c gdb/block.h gdb/blockframe.c gdb/breakpoint.c gdb/buildsym.c gdb/buildsym.h gdb/builtin-regs.h gdb/c-lang.h gdb/cli-out.h gdb/cli/cli-cmds.c gdb/cli/cli-cmds.h gdb/cli/cli-script.h gdb/cli/cli-setshow.h gdb/config/i386/nm-ptx4.h gdb/config/i386/nm-symmetry.h gdb/config/i386/ptx.mh gdb/config/i386/ptx.mt gdb/config/i386/ptx4.mh gdb/config/i386/ptx4.mt gdb/config/i386/symmetry.mh gdb/config/i386/symmetry.mt gdb/config/i386/tm-ptx.h gdb/config/i386/tm-ptx4.h gdb/config/i386/tm-symmetry.h gdb/config/i386/xm-ptx.h gdb/config/i386/xm-ptx4.h gdb/config/i386/xm-symmetry.h gdb/config/m68k/tm-delta68.h gdb/config/mips/mipsm3.mh gdb/config/mips/mipsm3.mt gdb/config/mips/tm-mipsm3.h gdb/config/mips/xm-mipsm3.h gdb/config/nm-linux.h gdb/config/nm-lynx.h gdb/config/nm-m3.h gdb/config/pa/tm-hppa.h gdb/config/pa/tm-hppah.h gdb/config/rs6000/tm-rs6000.h gdb/config/sparc/sparclet.mt gdb/config/sparc/sparclite.mt gdb/config/sparc/tm-sp64.h gdb/config/sparc/tm-sparc.h gdb/config/sparc/tm-sparclet.h gdb/config/sparc/tm-sparclite.h gdb/configure.host gdb/configure.tgt gdb/core-regset.c gdb/cp-abi.h gdb/cp-namespace.c gdb/cp-support.c gdb/cp-support.h gdb/cp-valprint.c gdb/cris-tdep.c gdb/d10v-tdep.c gdb/defs.h gdb/disasm.c gdb/disasm.h gdb/doc/ChangeLog gdb/doc/gdb.texinfo gdb/doc/gdbint.texinfo gdb/doublest.c gdb/doublest.h gdb/dummy-frame.c gdb/dwarf2cfi.h gdb/dwarf2expr.c gdb/dwarf2expr.h gdb/dwarf2loc.c gdb/dwarf2loc.h gdb/dwarf2read.c gdb/event-top.h gdb/fork-child.c gdb/frame.c gdb/frame.h gdb/frv-tdep.c gdb/gdb.h gdb/gdb_gcore.sh gdb/gdb_indent.sh gdb/gdbarch.c gdb/gdbarch.h gdb/gdbarch.sh gdb/gdbcmd.h gdb/gdbcore.h gdb/gdbthread.h gdb/gdbtypes.h gdb/h8300-tdep.c gdb/hppa-hpux-tdep.c gdb/hppa-tdep.c gdb/i386-cygwin-tdep.c gdb/i386-interix-tdep.c gdb/i386-linux-nat.c gdb/i386-linux-tdep.c gdb/i386-tdep.c gdb/i386-tdep.h gdb/i386ly-tdep.c gdb/i387-tdep.c gdb/i387-tdep.h gdb/ia64-tdep.c gdb/infcmd.c gdb/inferior.h gdb/infrun.c gdb/jv-lang.c gdb/language.h gdb/linespec.h gdb/m3-nat.c gdb/m68hc11-tdep.c gdb/m68k-tdep.c gdb/maint.c gdb/mcore-tdep.c gdb/minsyms.c gdb/mips-tdep.c gdb/mips-tdep.h gdb/mipsm3-nat.c gdb/mn10300-tdep.c gdb/monitor.h gdb/ns32k-tdep.c gdb/ns32knbsd-nat.c gdb/objc-lang.c gdb/ocd.h gdb/ppc-linux-tdep.c gdb/ppc-tdep.h gdb/reggroups.c gdb/remote-utils.h gdb/remote-vx.c gdb/remote.c gdb/rs6000-tdep.c gdb/s390-nat.c gdb/s390-tdep.c gdb/ser-unix.h gdb/serial.h gdb/sh-tdep.c gdb/solib-irix.c gdb/solib-osf.c gdb/solib-sunos.c gdb/solib-svr4.c gdb/solib-svr4.h gdb/source.h gdb/sparc-tdep.c gdb/sparcl-stub.c gdb/sparcl-tdep.c gdb/sparclet-rom.c gdb/sparclet-stub.c gdb/srec.h gdb/stabsread.h gdb/symfile.h gdb/symm-nat.c gdb/symm-tdep.c gdb/symmisc.c gdb/symtab.c gdb/symtab.h gdb/target.h gdb/testsuite/ChangeLog gdb/testsuite/gdb.base/args.exp gdb/testsuite/gdb.base/attach.exp gdb/testsuite/gdb.base/completion.exp gdb/testsuite/gdb.c++/derivation.cc gdb/testsuite/gdb.c++/derivation.exp gdb/testsuite/gdb.c++/maint.exp gdb/testsuite/gdb.c++/overload.cc gdb/testsuite/gdb.c++/overload.exp gdb/testsuite/gdb.c++/userdef.cc gdb/testsuite/gdb.c++/userdef.exp gdb/testsuite/gdb.mi/ChangeLog gdb/testsuite/gdb.mi/gdb792.exp gdb/testsuite/gdb.threads/pthreads.exp gdb/testsuite/gdb.threads/schedlock.c gdb/thread-db.c gdb/thread.c gdb/typeprint.h gdb/utils.c gdb/v850-tdep.c gdb/valprint.h gdb/value.h gdb/values.c gdb/vax-tdep.c gdb/version.in gdb/x86-64-tdep.c gdb/x86-64-tdep.h gdb/xmodem.h gdb/xstormy16-tdep.c include/coff/ChangeLog include/coff/h8300.h include/coff/h8500.h include/coff/sh.h include/elf/ChangeLog include/elf/common.h include/opcode/ChangeLog include/opcode/h8300.h include/opcode/mips.h libiberty/ChangeLog libiberty/Makefile.in libiberty/argv.c libiberty/calloc.c libiberty/config.in libiberty/configure libiberty/configure.in libiberty/copysign.c libiberty/floatformat.c libiberty/functions.texi libiberty/getcwd.c libiberty/getopt.c libiberty/hashtab.c libiberty/maint-tool libiberty/memchr.c libiberty/memcmp.c libiberty/memcpy.c libiberty/memmove.c libiberty/mempcpy.c libiberty/memset.c libiberty/regex.c libiberty/rename.c libiberty/sigsetmask.c libiberty/snprintf.c libiberty/stpcpy.c libiberty/stpncpy.c libiberty/strcasecmp.c libiberty/strdup.c libiberty/strncasecmp.c libiberty/strncmp.c libiberty/strsignal.c libiberty/strstr.c libiberty/vfprintf.c libiberty/vprintf.c libiberty/vsnprintf.c libiberty/vsprintf.c libiberty/xatexit.c libiberty/xmalloc.c libtool.m4 opcodes/ChangeLog opcodes/h8500-opc.h opcodes/ia64-asmtab.c opcodes/ia64-ic.tbl opcodes/mips-dis.c sim/arm/ChangeLog sim/arm/armvirt.c sim/common/ChangeLog sim/common/Make-common.in sim/configure sim/configure.in sim/h8300/ChangeLog sim/h8300/compile.c sim/mips/ChangeLog sim/mips/vr.igen sim/testsuite/sim/h8300/ChangeLog sim/testsuite/sim/h8300/add.b.s sim/testsuite/sim/h8300/add.l.s sim/testsuite/sim/h8300/add.w.s sim/testsuite/sim/h8300/adds.s sim/testsuite/sim/h8300/addx.s sim/testsuite/sim/h8300/allinsn.exp sim/testsuite/sim/h8300/and.b.s sim/testsuite/sim/h8300/and.l.s sim/testsuite/sim/h8300/and.w.s sim/testsuite/sim/h8300/bfld.s sim/testsuite/sim/h8300/bra.s sim/testsuite/sim/h8300/brabc.s sim/testsuite/sim/h8300/bset.s sim/testsuite/sim/h8300/cmp.b.s sim/testsuite/sim/h8300/cmp.l.s sim/testsuite/sim/h8300/cmp.w.s sim/testsuite/sim/h8300/daa.s sim/testsuite/sim/h8300/das.s sim/testsuite/sim/h8300/dec.s sim/testsuite/sim/h8300/ext.l.s sim/testsuite/sim/h8300/ext.w.s sim/testsuite/sim/h8300/inc.s sim/testsuite/sim/h8300/jmp.s sim/testsuite/sim/h8300/ldc.s sim/testsuite/sim/h8300/mac.s sim/testsuite/sim/h8300/mov.b.s sim/testsuite/sim/h8300/mov.l.s sim/testsuite/sim/h8300/mov.w.s sim/testsuite/sim/h8300/movmd.s sim/testsuite/sim/h8300/movsd.s sim/testsuite/sim/h8300/neg.s sim/testsuite/sim/h8300/nop.s sim/testsuite/sim/h8300/not.s sim/testsuite/sim/h8300/or.b.s sim/testsuite/sim/h8300/or.l.s sim/testsuite/sim/h8300/or.w.s sim/testsuite/sim/h8300/rotl.s sim/testsuite/sim/h8300/rotr.s sim/testsuite/sim/h8300/rotxl.s sim/testsuite/sim/h8300/rotxr.s sim/testsuite/sim/h8300/shal.s sim/testsuite/sim/h8300/shar.s sim/testsuite/sim/h8300/shll.s sim/testsuite/sim/h8300/shlr.s sim/testsuite/sim/h8300/stc.s sim/testsuite/sim/h8300/sub.b.s sim/testsuite/sim/h8300/sub.l.s sim/testsuite/sim/h8300/sub.w.s sim/testsuite/sim/h8300/testutils.inc sim/testsuite/sim/h8300/xor.b.s sim/testsuite/sim/h8300/xor.l.s sim/testsuite/sim/h8300/xor.w.s sim/v850/ChangeLog
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r--gdb/i386-tdep.c136
1 files changed, 36 insertions, 100 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 317d726..2406e3f 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -46,6 +46,7 @@
/* Names of the registers. The first 10 registers match the register
numbering scheme used by GCC for stabs and DWARF. */
+
static char *i386_register_names[] =
{
"eax", "ecx", "edx", "ebx",
@@ -61,6 +62,9 @@ static char *i386_register_names[] =
"mxcsr"
};
+static const int i386_num_register_names =
+ (sizeof (i386_register_names) / sizeof (*i386_register_names));
+
/* MMX registers. */
static char *i386_mmx_names[] =
@@ -68,14 +72,17 @@ static char *i386_mmx_names[] =
"mm0", "mm1", "mm2", "mm3",
"mm4", "mm5", "mm6", "mm7"
};
-static const int mmx_num_regs = (sizeof (i386_mmx_names)
- / sizeof (i386_mmx_names[0]));
-#define MM0_REGNUM (NUM_REGS)
+
+static const int i386_num_mmx_regs =
+ (sizeof (i386_mmx_names) / sizeof (i386_mmx_names[0]));
+
+#define MM0_REGNUM NUM_REGS
static int
-i386_mmx_regnum_p (int reg)
+i386_mmx_regnum_p (int regnum)
{
- return (reg >= MM0_REGNUM && reg < MM0_REGNUM + mmx_num_regs);
+ return (regnum >= MM0_REGNUM
+ && regnum < MM0_REGNUM + i386_num_mmx_regs);
}
/* FP register? */
@@ -84,14 +91,14 @@ int
i386_fp_regnum_p (int regnum)
{
return (regnum < NUM_REGS
- && (FP0_REGNUM && FP0_REGNUM <= (regnum) && (regnum) < FPC_REGNUM));
+ && (FP0_REGNUM && FP0_REGNUM <= regnum && regnum < FPC_REGNUM));
}
int
i386_fpc_regnum_p (int regnum)
{
return (regnum < NUM_REGS
- && (FPC_REGNUM <= (regnum) && (regnum) < XMM0_REGNUM));
+ && (FPC_REGNUM <= regnum && regnum < XMM0_REGNUM));
}
/* SSE register? */
@@ -100,14 +107,14 @@ int
i386_sse_regnum_p (int regnum)
{
return (regnum < NUM_REGS
- && (XMM0_REGNUM <= (regnum) && (regnum) < MXCSR_REGNUM));
+ && (XMM0_REGNUM <= regnum && regnum < MXCSR_REGNUM));
}
int
i386_mxcsr_regnum_p (int regnum)
{
return (regnum < NUM_REGS
- && (regnum == MXCSR_REGNUM));
+ && regnum == MXCSR_REGNUM);
}
/* Return the name of register REG. */
@@ -115,14 +122,13 @@ i386_mxcsr_regnum_p (int regnum)
const char *
i386_register_name (int reg)
{
- if (reg < 0)
- return NULL;
+ if (reg >= 0 && reg < i386_num_register_names)
+ return i386_register_names[reg];
+
if (i386_mmx_regnum_p (reg))
return i386_mmx_names[reg - MM0_REGNUM];
- if (reg >= sizeof (i386_register_names) / sizeof (*i386_register_names))
- return NULL;
- return i386_register_names[reg];
+ return NULL;
}
/* Convert stabs register number REG to the appropriate register
@@ -600,80 +606,6 @@ i386_saved_pc_after_call (struct frame_info *frame)
return read_memory_unsigned_integer (read_register (SP_REGNUM), 4);
}
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-
-static int
-i386_frame_num_args (struct frame_info *fi)
-{
-#if 1
- return -1;
-#else
- /* This loses because not only might the compiler not be popping the
- args right after the function call, it might be popping args from
- both this call and a previous one, and we would say there are
- more args than there really are. */
-
- int retpc;
- unsigned char op;
- struct frame_info *pfi;
-
- /* On the i386, the instruction following the call could be:
- popl %ecx - one arg
- addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
- anything else - zero args. */
-
- int frameless;
-
- frameless = FRAMELESS_FUNCTION_INVOCATION (fi);
- if (frameless)
- /* In the absence of a frame pointer, GDB doesn't get correct
- values for nameless arguments. Return -1, so it doesn't print
- any nameless arguments. */
- return -1;
-
- pfi = get_prev_frame (fi);
- if (pfi == 0)
- {
- /* NOTE: This can happen if we are looking at the frame for
- main, because DEPRECATED_FRAME_CHAIN_VALID won't let us go
- into start. If we have debugging symbols, that's not really
- a big deal; it just means it will only show as many arguments
- to main as are declared. */
- return -1;
- }
- else
- {
- retpc = pfi->pc;
- op = read_memory_integer (retpc, 1);
- if (op == 0x59) /* pop %ecx */
- return 1;
- else if (op == 0x83)
- {
- op = read_memory_integer (retpc + 1, 1);
- if (op == 0xc4)
- /* addl $<signed imm 8 bits>, %esp */
- return (read_memory_integer (retpc + 2, 1) & 0xff) / 4;
- else
- return 0;
- }
- else if (op == 0x81) /* `add' with 32 bit immediate. */
- {
- op = read_memory_integer (retpc + 1, 1);
- if (op == 0xc4)
- /* addl $<imm 32>, %esp */
- return read_memory_integer (retpc + 2, 4) / 4;
- else
- return 0;
- }
- else
- {
- return 0;
- }
- }
-#endif
-}
-
/* Parse the first few instructions the function to see what registers
were stored.
@@ -901,7 +833,7 @@ i386_get_longjmp_target (CORE_ADDR *pc)
char buf[8];
CORE_ADDR sp, jb_addr;
int jb_pc_offset = gdbarch_tdep (current_gdbarch)->jb_pc_offset;
- int len = TARGET_PTR_BIT / TARGET_CHAR_BIT;
+ int len = TYPE_LENGTH (builtin_type_void_func_ptr);
/* If JB_PC_OFFSET is -1, we have no way to find out where the
longjmp will land. */
@@ -912,11 +844,11 @@ i386_get_longjmp_target (CORE_ADDR *pc)
if (target_read_memory (sp + len, buf, len))
return 0;
- jb_addr = extract_address (buf, len);
+ jb_addr = extract_typed_address (buf, builtin_type_void_func_ptr);
if (target_read_memory (jb_addr + jb_pc_offset, buf, len))
return 0;
- *pc = extract_address (buf, len);
+ *pc = extract_typed_address (buf, builtin_type_void_func_ptr);
return 1;
}
@@ -966,7 +898,7 @@ i386_extract_return_value (struct type *type, struct regcache *regcache,
if (TYPE_CODE (type) == TYPE_CODE_FLT)
{
- if (FP0_REGNUM == 0)
+ if (FP0_REGNUM < 0)
{
warning ("Cannot find floating-point return value.");
memset (valbuf, 0, len);
@@ -1024,7 +956,7 @@ i386_store_return_value (struct type *type, struct regcache *regcache,
ULONGEST fstat;
char buf[FPU_REG_RAW_SIZE];
- if (FP0_REGNUM == 0)
+ if (FP0_REGNUM < 0)
{
warning ("Cannot set floating-point return value.");
return;
@@ -1141,19 +1073,21 @@ i386_register_type (struct gdbarch *gdbarch, int regnum)
}
/* Map a cooked register onto a raw register or memory. For the i386,
- the MMX registers need to be mapped onto floating point registers. */
+ the MMX registers need to be mapped onto floating-point registers. */
static int
-mmx_regnum_to_fp_regnum (struct regcache *regcache, int regnum)
+i386_mmx_regnum_to_fp_regnum (struct regcache *regcache, int regnum)
{
int mmxi;
ULONGEST fstat;
int tos;
int fpi;
+
mmxi = regnum - MM0_REGNUM;
regcache_raw_read_unsigned (regcache, FSTAT_REGNUM, &fstat);
tos = (fstat >> 11) & 0x7;
fpi = (mmxi + tos) % 8;
+
return (FP0_REGNUM + fpi);
}
@@ -1164,9 +1098,10 @@ i386_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
if (i386_mmx_regnum_p (regnum))
{
char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE);
- int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum);
- regcache_raw_read (regcache, fpnum, mmx_buf);
+ int fpnum = i386_mmx_regnum_to_fp_regnum (regcache, regnum);
+
/* Extract (always little endian). */
+ regcache_raw_read (regcache, fpnum, mmx_buf);
memcpy (buf, mmx_buf, REGISTER_RAW_SIZE (regnum));
}
else
@@ -1180,7 +1115,8 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
if (i386_mmx_regnum_p (regnum))
{
char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE);
- int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum);
+ int fpnum = i386_mmx_regnum_to_fp_regnum (regcache, regnum);
+
/* Read ... */
regcache_raw_read (regcache, fpnum, mmx_buf);
/* ... Modify ... (always little endian). */
@@ -1601,8 +1537,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
i386_frameless_function_invocation);
set_gdbarch_deprecated_frame_chain (gdbarch, i386_frame_chain);
set_gdbarch_deprecated_frame_saved_pc (gdbarch, i386_frame_saved_pc);
- set_gdbarch_saved_pc_after_call (gdbarch, i386_saved_pc_after_call);
- set_gdbarch_frame_num_args (gdbarch, i386_frame_num_args);
+ set_gdbarch_deprecated_saved_pc_after_call (gdbarch, i386_saved_pc_after_call);
+ set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
set_gdbarch_pc_in_sigtramp (gdbarch, i386_pc_in_sigtramp);
/* Wire in the MMX registers. */