diff --git a/gdb/exec.c b/gdb/exec.c index 0861c11703..730692ae92 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -39,6 +39,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #endif +#include #include extern char *getenv(); diff --git a/gdb/findvar.c b/gdb/findvar.c index c674a54896..25ff0baf6d 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -267,8 +267,9 @@ read_register_bytes (regbyte, myaddr, len) } /* 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; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d621fa3a2e..98dd25add7 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1,5 +1,5 @@ -/* 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. @@ -46,15 +46,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include -/* 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 -#else -#include -#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; @@ -133,7 +125,9 @@ i386_follow_jump () 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 { @@ -147,7 +141,7 @@ i386_follow_jump () pos += byte_delta + 2; break; } - codestream_seek (pos + data16); + codestream_seek (pos); } /* @@ -252,6 +246,7 @@ i386_get_frame_setup (pc) } /* subl with 32 bit immediate */ codestream_read ((unsigned char *)&locals, 4); + SWAP_TARGET_AND_HOST (&locals, 4); return (locals); } else @@ -264,6 +259,7 @@ i386_get_frame_setup (pc) /* 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); } diff --git a/gdb/remote.c b/gdb/remote.c index 3e0acd3234..c5673d287c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -187,7 +187,6 @@ device is attached to the remote system (e.g. /dev/ttya)."); 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 @@ -201,7 +200,11 @@ device is attached to the remote system (e.g. /dev/ttya)."); 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() diff --git a/gdb/sun3-xdep.c b/gdb/sun3-xdep.c index 6789cd6601..bf0739eb4e 100644 --- a/gdb/sun3-xdep.c +++ b/gdb/sun3-xdep.c @@ -119,6 +119,7 @@ fetch_core_registers (core_reg_sect, core_reg_size, which) 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); @@ -126,6 +127,7 @@ fetch_core_registers (core_reg_sect, core_reg_size, which) ®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"); diff --git a/gdb/tm-i386v.h b/gdb/tm-i386v.h index 4f35e3a937..0a146cdde3 100644 --- a/gdb/tm-i386v.h +++ b/gdb/tm-i386v.h @@ -191,8 +191,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 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. */ @@ -308,5 +311,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 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); \ } diff --git a/gdb/valops.c b/gdb/valops.c index 8031471b36..a3269acc75 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -511,6 +511,7 @@ push_word (sp, buffer) { 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); @@ -671,6 +672,9 @@ call_function_by_hand (function, nargs, args) 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; @@ -717,6 +721,8 @@ call_function_by_hand (function, nargs, args) /* 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); @@ -1104,7 +1110,9 @@ value_struct_elt (argp, args, name, static_memfuncp, err) { 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); }