This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to fix cross-debugging of x86 targets on 64-bit hosts


The FRAME_CHAIN and FRAME_SAVED_PC macros for various x86 targets use
"read_memory_integer()" to fetch frame pointers and PCs from stack
frames; in a Digital UNIX/Alpha-hosted GDB debugging an x86 target, this
causes the 32-bit frame pointer and PC values to be sign-extended, which
causes errors of various sorts.

Changing those macros (well, actually, changing the macro in the header
file for our target, which I modeled after other x86 targets, but...)
fixes this problem.

There may well be other places where addresses are sign-extended
inappropriately, either as a result of fetching them with
"read_memory_integer()" or perhaps as a result of other problems.

Whilst investigating this, I noticed that the "val" argument to
"store_address()" is a LONGEST rather than a ULONGEST; is there a reason
why it's signed?

I've attached a ChangeLog and a patch.
2000-04-21  Guy Harris  <guy@netapp.com>

	* config/i386/tm-i386.h, gdb/config/i386/tm-i386v.h,
	gdb/config/i386/tm-sun386.h: use read_memory_unsigned_integer,
	rather than read_memory_integer, to fetch addresses from the
	target, so that the addresses don't get sign-extended.
Index: gdb/config/i386/tm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-i386.h,v
retrieving revision 1.5
diff -c -3 -p -r1.5 tm-i386.h
*** tm-i386.h	2000/04/14 19:13:07	1.5
--- tm-i386.h	2000/04/22 00:45:18
*************** extern int i386_skip_prologue PARAMS ((i
*** 68,74 ****
     through the frames for this because on some machines the new frame is not
     set up until the new function executes some instructions.  */
  
! #define SAVED_PC_AFTER_CALL(frame) (read_memory_integer (read_register (SP_REGNUM), 4))
  
  /* Stack grows downward.  */
  
--- 68,74 ----
     through the frames for this because on some machines the new frame is not
     set up until the new function executes some instructions.  */
  
! #define SAVED_PC_AFTER_CALL(frame) (read_memory_unsigned_integer (read_register (SP_REGNUM), 4))
  
  /* Stack grows downward.  */
  
*************** extern void i386_extract_return_value (s
*** 326,332 ****
    ((thisframe)->signal_handler_caller \
     ? (thisframe)->frame \
     : (!inside_entry_file ((thisframe)->pc) \
!       ? read_memory_integer ((thisframe)->frame, 4) \
        : 0))
  
  /* A macro that tells us whether the function invocation represented
--- 326,332 ----
    ((thisframe)->signal_handler_caller \
     ? (thisframe)->frame \
     : (!inside_entry_file ((thisframe)->pc) \
!       ? read_memory_unsigned_integer ((thisframe)->frame, 4) \
        : 0))
  
  /* A macro that tells us whether the function invocation represented
*************** extern void i386_extract_return_value (s
*** 341,347 ****
  #define FRAME_SAVED_PC(FRAME) \
    (((FRAME)->signal_handler_caller \
      ? sigtramp_saved_pc (FRAME) \
!     : read_memory_integer ((FRAME)->frame + 4, 4)) \
     )
  
  extern CORE_ADDR sigtramp_saved_pc PARAMS ((struct frame_info *));
--- 341,347 ----
  #define FRAME_SAVED_PC(FRAME) \
    (((FRAME)->signal_handler_caller \
      ? sigtramp_saved_pc (FRAME) \
!     : read_memory_unsigned_integer ((FRAME)->frame + 4, 4)) \
     )
  
  extern CORE_ADDR sigtramp_saved_pc PARAMS ((struct frame_info *));
Index: gdb/config/i386/tm-i386v.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-i386v.h,v
retrieving revision 1.1.1.5
diff -c -3 -p -r1.1.1.5 tm-i386v.h
*** tm-i386v.h	1999/12/07 03:56:10	1.1.1.5
--- tm-i386v.h	2000/04/22 00:45:18
***************
*** 64,70 ****
  #undef  FRAME_CHAIN
  #define FRAME_CHAIN(thisframe) \
    (!inside_entry_file ((thisframe)->pc) ? \
!    read_memory_integer ((thisframe)->frame, 4) :\
     0)
  
  /* Define other aspects of the stack frame.  */
--- 64,70 ----
  #undef  FRAME_CHAIN
  #define FRAME_CHAIN(thisframe) \
    (!inside_entry_file ((thisframe)->pc) ? \
!    read_memory_unsigned_integer ((thisframe)->frame, 4) :\
     0)
  
  /* Define other aspects of the stack frame.  */
***************
*** 78,84 ****
    (frameless_look_for_prologue (FI))
  
  #undef  FRAME_SAVED_PC
! #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
  
  /* Return number of args passed to a frame.
     Can return -1, meaning no way to tell.  */
--- 78,84 ----
    (frameless_look_for_prologue (FI))
  
  #undef  FRAME_SAVED_PC
! #define FRAME_SAVED_PC(FRAME) (read_memory_unsigned_integer ((FRAME)->frame + 4, 4))
  
  /* Return number of args passed to a frame.
     Can return -1, meaning no way to tell.  */
Index: gdb/config/i386/tm-sun386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-sun386.h,v
retrieving revision 1.1.1.4
diff -c -3 -p -r1.1.1.4 tm-sun386.h
*** tm-sun386.h	1999/08/31 01:07:11	1.1.1.4
--- tm-sun386.h	2000/04/22 00:45:18
*************** double_to_i387 PARAMS ((char *, char *))
*** 176,182 ****
  #undef  FRAME_CHAIN
  #define FRAME_CHAIN(thisframe) \
    (!inside_entry_file ((thisframe)->pc) ? \
!    read_memory_integer ((thisframe)->frame, 4) :\
     0)
  
  /* Define other aspects of the stack frame.  */
--- 176,182 ----
  #undef  FRAME_CHAIN
  #define FRAME_CHAIN(thisframe) \
    (!inside_entry_file ((thisframe)->pc) ? \
!    read_memory_unsigned_integer ((thisframe)->frame, 4) :\
     0)
  
  /* Define other aspects of the stack frame.  */
*************** double_to_i387 PARAMS ((char *, char *))
*** 190,196 ****
       (frameless_look_for_prologue (FI))
  
  #undef  FRAME_SAVED_PC
! #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
  
  /* Insert the specified number of args and function address
     into a call sequence of the above form stored at DUMMYNAME.  */
--- 190,196 ----
       (frameless_look_for_prologue (FI))
  
  #undef  FRAME_SAVED_PC
! #define FRAME_SAVED_PC(FRAME) (read_memory_unsigned_integer ((FRAME)->frame + 4, 4))
  
  /* Insert the specified number of args and function address
     into a call sequence of the above form stored at DUMMYNAME.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]