From: Jim Kingdon Date: Sat, 20 Apr 1991 03:57:50 +0000 (+0000) Subject: * findvar.c (read_register_gen): Add "target byte-order" comment. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2ebc25fc2b9137c3fa0a3607d8e77c7e372226a;p=binutils-gdb.git * findvar.c (read_register_gen): Add "target byte-order" comment. Wed Apr 17 17:09:48 1991 Jim Kingdon (kingdon at cygint.cygnus.com) * i386-tdep.c (i386_get_frame_setup): Use SWAP_TARGET_AND_HOST before returning locals or slocals. * i386-tdep.c (i386_follow_jump): Do not add data16 to pos in call to codestream_seek; add one to pos if (and only if) we are dealing with a jump with data16 == 1 (i.e. 0x66, 0xe9). Mon Apr 15 12:04:32 1991 Jim Kingdon (kingdon at cygint.cygnus.com) * valops.c (call_function_by_hand): Put dummy1 in target order before FIX_CALL_DUMMY. * tm-i386v.h (FIX_CALL_DUMMY): Don't depend on host byte order. Sun Apr 14 11:55:19 1991 Jim Kingdon (kingdon at cygint.cygnus.com) * valops.c (push_word): Add SWAP_TARGET_AND_HOST. * remote.c (remote_open): Send '+' before calling putpkt(). * tm-i386v.h (REGISTER_VIRTUAL_TYPE): Return pointer to void, not int, for pc, fp, and sp. * remote.c (remote_open): Call start_remote after putpkt("?"); --- diff --git a/gdb/exec.c b/gdb/exec.c index 0861c11703a..730692ae927 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 c674a548961..25ff0baf6d0 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 d621fa3a2e2..98dd25add78 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 3e0acd32348..c5673d287c8 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 6789cd66019..bf0739eb4e9 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 4f35e3a9374..0a146cdde31 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 8031471b360..a3269acc752 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); }