#include <sys/file.h>
#endif
+#include <ctype.h>
#include <sys/stat.h>
extern char *getenv();
}
/* Read register REGNO into memory at MYADDR, which must be large enough
- for REGISTER_RAW_BYTES (REGNO). If the register is known to be the
- size of a CORE_ADDR or smaller, read_register can be used instead. */
+ for REGISTER_RAW_BYTES (REGNO). Target byte-order.
+ If the register is known to be the size of a CORE_ADDR or smaller,
+ read_register can be used instead. */
void
read_register_gen (regno, myaddr)
int regno;
-/* Intel 386 stuff.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
+/* Intel 386 target-dependent stuff.
+ Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <sys/file.h>
#include <sys/stat.h>
-/* I don't know whether this is right for cross-debugging even if you
- do somehow manage to get the right include file. */
-#if defined (USE_MACHINE_REG_H)
-#include <machine/reg.h>
-#else
-#include <sys/reg.h>
-#endif
-
-/* helper functions for m-i386.h */
+/* helper functions for tm-i386.h */
/* stdio style buffering to minimize calls to ptrace */
static CORE_ADDR codestream_next_addr;
if (data16)
{
codestream_read ((unsigned char *)&short_delta, 2);
- pos += short_delta + 3; /* include size of jmp inst */
+
+ /* include size of jmp inst (including the 0x66 prefix). */
+ pos += short_delta + 4;
}
else
{
pos += byte_delta + 2;
break;
}
- codestream_seek (pos + data16);
+ codestream_seek (pos);
}
/*
}
/* subl with 32 bit immediate */
codestream_read ((unsigned char *)&locals, 4);
+ SWAP_TARGET_AND_HOST (&locals, 4);
return (locals);
}
else
/* enter instruction: arg is 16 bit unsigned immed */
unsigned short slocals;
codestream_read ((unsigned char *)&slocals, 2);
+ SWAP_TARGET_AND_HOST (&slocals, 2);
codestream_get (); /* flush final byte of enter instruction */
return (slocals);
}
if (from_tty)
printf ("Remote debugging using %s\n", name);
push_target (&remote_ops); /* Switch to using remote target now */
- start_remote (); /* Initialize gdb process mechanisms */
#ifndef HAVE_TERMIO
#ifndef NO_SIGINTERRUPT
perror ("remote_open: error in signal");
#endif
+ /* Ack any packet which the remote side has already sent. */
+ write (remote_desc, "+", 1);
putpkt ("?"); /* initiate a query from remote machine */
+
+ start_remote (); /* Initialize gdb process mechanisms */
}
/* remote_detach()
if (core_reg_size >= sizeof (struct fpu))
{
+#ifdef FP0_REGNUM
bcopy (fpustruct->f_fpstatus.fps_regs,
®isters[REGISTER_BYTE (FP0_REGNUM)],
sizeof fpustruct->f_fpstatus.fps_regs);
®isters[REGISTER_BYTE (FPC_REGNUM)],
sizeof fpustruct->f_fpstatus -
sizeof fpustruct->f_fpstatus.fps_regs);
+#endif
}
else
fprintf (stderr, "Couldn't read float regs from core file\n");
/* Return the GDB type object for the "standard" data type
of data in register N. */
-
-#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
+/* Perhaps si and di should go here, but potentially they could be
+ used for things other than address. */
+#define REGISTER_VIRTUAL_TYPE(N) \
+ ((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM ? \
+ lookup_pointer_type (builtin_type_void) : builtin_type_int)
/* Store the address of the place in which to copy the structure the
subroutine will return. This is called from call_function. */
from = loc + 5; \
to = (int)(fun); \
delta = to - from; \
- *(int *)((char *)(dummyname) + 1) = delta; \
+ *((char *)(dummyname) + 1) = (delta & 0xff); \
+ *((char *)(dummyname) + 2) = ((delta >> 8) & 0xff); \
+ *((char *)(dummyname) + 3) = ((delta >> 16) & 0xff); \
+ *((char *)(dummyname) + 4) = ((delta >> 24) & 0xff); \
}
{
register int len = sizeof (REGISTER_TYPE);
+ SWAP_TARGET_AND_HOST (&buffer, len);
#if 1 INNER_THAN 2
sp -= len;
write_memory (sp, (char *)&buffer, len);
register CORE_ADDR sp;
register int i;
CORE_ADDR start_sp;
+ /* CALL_DUMMY is an array of words (REGISTER_TYPE), but each word
+ in in host byte order. It is switched to target byte order before calling
+ FIX_CALL_DUMMY. */
static REGISTER_TYPE dummy[] = CALL_DUMMY;
REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)];
CORE_ADDR old_sp;
/* Create a call sequence customized for this function
and the number of arguments for it. */
bcopy (dummy, dummy1, sizeof dummy);
+ for (i = 0; i < sizeof dummy / sizeof (REGISTER_TYPE); i++)
+ SWAP_TARGET_AND_HOST (&dummy1[i], sizeof (REGISTER_TYPE));
FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
value_type, using_gcc);
{
arg1_as_ptr = *argp;
*argp = value_ind (*argp);
- COERCE_ARRAY (*argp);
+ /* Don't coerce fn pointer to fn and then back again! */
+ if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
+ COERCE_ARRAY (*argp);
t = VALUE_TYPE (*argp);
}