#include "frame.h"
#include "inferior.h"
#include "gdbcore.h"
-
-#ifdef USE_PROC_FS /* Target dependent support for /proc */
-#include <sys/procfs.h>
-#endif
+#include "target.h"
static long
i386_get_frame_setup PARAMS ((int));
codestream_next_addr += CODESTREAM_BUFSIZ;
codestream_off = 0;
codestream_cnt = CODESTREAM_BUFSIZ;
- read_memory (codestream_addr,
- (unsigned char *)codestream_buf,
- CODESTREAM_BUFSIZ);
+ read_memory (codestream_addr, (char *) codestream_buf, CODESTREAM_BUFSIZ);
if (peek_flag)
return (codestream_peek());
static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 };
pos = codestream_tell ();
codestream_read (buf, 4);
- if (bcmp (buf, proto1, 3) == 0)
+ if (memcmp (buf, proto1, 3) == 0)
pos += 3;
- else if (bcmp (buf, proto2, 4) == 0)
+ else if (memcmp (buf, proto2, 4) == 0)
pos += 4;
codestream_seek (pos);
}
else if (op == 0x81)
{
- /* subl with 32 bit immed */
- int locals;
+ char buf[4];
+ /* Maybe it is subl with 32 bit immedediate. */
codestream_get();
if (codestream_get () != 0xec)
/* Some instruction starting with 0x81 other than subl. */
codestream_seek (codestream_tell () - 2);
return 0;
}
- /* subl with 32 bit immediate */
- codestream_read ((unsigned char *)&locals, 4);
- SWAP_TARGET_AND_HOST (&locals, 4);
- return (locals);
+ /* It is subl with 32 bit immediate. */
+ codestream_read ((unsigned char *)buf, 4);
+ return extract_signed_integer (buf, 4);
}
else
{
}
else if (op == 0xc8)
{
+ char buf[2];
/* enter instruction: arg is 16 bit unsigned immed */
- unsigned short slocals;
- codestream_read ((unsigned char *)&slocals, 2);
- SWAP_TARGET_AND_HOST (&slocals, 2);
+ codestream_read ((unsigned char *)buf, 2);
codestream_get (); /* flush final byte of enter instruction */
- return (slocals);
+ return extract_unsigned_integer (buf, 2);
}
return (-1);
}
/* Return number of args passed to a frame.
Can return -1, meaning no way to tell. */
-/* on the 386, 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
i386_frame_num_args (fi)
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 386, 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_FUNCTION_INVOCATION (fi, frameless);
return 0;
}
}
+#endif
}
/*
struct frame_saved_regs *fsrp;
{
long locals;
- unsigned char *p;
unsigned char op;
CORE_ADDR dummy_bottom;
CORE_ADDR adr;
int i;
- bzero (fsrp, sizeof *fsrp);
+ memset (fsrp, 0, sizeof *fsrp);
/* if frame is the end of a dummy, compute where the
* beginning would be
read_pc ()));
}
-#ifdef USE_PROC_FS /* Target dependent support for /proc */
-
-/* The /proc interface divides the target machine's register set up into
- two different sets, the general register set (gregset) and the floating
- point register set (fpregset). For each set, there is an ioctl to get
- the current register set and another ioctl to set the current values.
-
- The actual structure passed through the ioctl interface is, of course,
- naturally machine dependent, and is different for each set of registers.
- For the i386 for example, the general register set is typically defined
- by:
-
- typedef int gregset_t[19]; (in <sys/regset.h>)
+#ifdef GET_LONGJMP_TARGET
- #define GS 0 (in <sys/reg.h>)
- #define FS 1
- ...
- #define UESP 17
- #define SS 18
+/* Figure out where the longjmp will land. Slurp the args out of the stack.
+ We expect the first arg to be a pointer to the jmp_buf structure from which
+ we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
+ This routine returns true on success. */
- and the floating point set by:
+int
+get_longjmp_target(pc)
+ CORE_ADDR *pc;
+{
+ char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
+ CORE_ADDR sp, jb_addr;
- typedef struct fpregset
- {
- union
- {
- struct fpchip_state // fp extension state //
- {
- int state[27]; // 287/387 saved state //
- int status; // status word saved at exception //
- } fpchip_state;
- struct fp_emul_space // for emulators //
- {
- char fp_emul[246];
- char fp_epad[2];
- } fp_emul_space;
- int f_fpregs[62]; // union of the above //
- } fp_reg_set;
- long f_wregs[33]; // saved weitek state //
- } fpregset_t;
-
- These routines provide the packing and unpacking of gregset_t and
- fpregset_t formatted data.
+ sp = read_register (SP_REGNUM);
- */
+ if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */
+ buf,
+ TARGET_PTR_BIT / TARGET_CHAR_BIT))
+ return 0;
-/* This is a duplicate of the table in i386-xdep.c. */
+ jb_addr = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-static int regmap[] =
-{
- EAX, ECX, EDX, EBX,
- UESP, EBP, ESI, EDI,
- EIP, EFL, CS, SS,
- DS, ES, FS, GS,
-};
+ if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
+ TARGET_PTR_BIT / TARGET_CHAR_BIT))
+ return 0;
+ *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-/* Given a pointer to a general register set in /proc format (gregset_t *),
- unpack the register contents and supply them as gdb's idea of the current
- register values. */
+ return 1;
+}
-void
-supply_gregset (gregsetp)
- gregset_t *gregsetp;
-{
- register int regno;
- register greg_t *regp = (greg_t *) gregsetp;
- extern int regmap[];
+#endif /* GET_LONGJMP_TARGET */
- for (regno = 0 ; regno < NUM_REGS ; regno++)
- {
- supply_register (regno, (char *) (regp + regmap[regno]));
- }
-}
+#ifdef I386_AIX_TARGET
+/* On AIX, floating point values are returned in floating point registers. */
void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
+i386_extract_return_value(type, regbuf, valbuf)
+ struct type *type;
+ char regbuf[REGISTER_BYTES];
+ char *valbuf;
{
- int regi;
- register greg_t *regp = (greg_t *) gregsetp;
- extern char registers[];
- extern int regmap[];
-
- for (regi = 0 ; regi < NUM_REGS ; regi++)
+ if (TYPE_CODE_FLT == TYPE_CODE(type))
{
- if ((regno == -1) || (regno == regi))
+ extern struct ext_format ext_format_i387;
+ double d;
+ /* 387 %st(0), gcc uses this */
+ ieee_extended_to_double (&ext_format_i387,
+ ®buf[REGISTER_BYTE(FP0_REGNUM)],
+ &d);
+ switch (TYPE_LENGTH(type))
{
- *(regp + regmap[regno]) = *(int *) ®isters[REGISTER_BYTE (regi)];
+ case 4: /* float */
+ {
+ float f = (float) d;
+ memcpy (valbuf, &f, 4);
+ break;
+ }
+ case 8: /* double */
+ memcpy (valbuf, &d, 8);
+ break;
+ default:
+ error("Unknown floating point size");
+ break;
}
}
+ else
+ {
+ memcpy (valbuf, regbuf, TYPE_LENGTH (type));
+ }
}
-
-#if defined (FP0_REGNUM)
-
-/* Given a pointer to a floating point register set in /proc format
- (fpregset_t *), unpack the register contents and supply them as gdb's
- idea of the current floating point register values. */
-
-void
-supply_fpregset (fpregsetp)
- fpregset_t *fpregsetp;
-{
- register int regno;
-
- /* FIXME: see m68k-tdep.c for an example, for the m68k. */
-}
-
-/* Given a pointer to a floating point register set in /proc format
- (fpregset_t *), update the register specified by REGNO from gdb's idea
- of the current floating point register set. If REGNO is -1, update
- them all. */
-
-void
-fill_fpregset (fpregsetp, regno)
- fpregset_t *fpregsetp;
- int regno;
-{
- int regi;
- char *to;
- char *from;
- extern char registers[];
-
- /* FIXME: see m68k-tdep.c for an example, for the m68k. */
-}
-
-#endif /* defined (FP0_REGNUM) */
-
-#endif /* USE_PROC_FS */
+#endif /* I386_AIX_TARGET */