This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines


This fixes a problem on Powerpc 64 machines while running gdb on 64 bit 
programs. The problem is with the alignment of the function arguments
when they are pushed to the stack in the ppc64_sysv_abi_push_dummy_call.
GCC expects the values to be right aligned.


gdb:
2006-10-02  Janani Janakiraman <janani@us.ibm.com>
	* ppc-sysv-tdep.c: Remove the hack for GCC. Right align 
	  the values on the stack.

Index: gdb/ppc-sysv-tdep.c
===================================================================
*** ppc-sysv-tdep.c.orig	2006-09-29 15:52:35.000000000 -0500
--- ppc-sysv-tdep.c	2006-09-29 15:57:55.000000000 -0500
*************** ppc64_sysv_abi_push_dummy_call (struct g
*** 786,806 ****
  		      if (len > tdep->wordsize)
  			len = tdep->wordsize;
  		      memset (regval, 0, sizeof regval);
! 		      /* WARNING: cagney/2003-09-21: As best I can
! 		         tell, the ABI specifies that the value should
! 		         be left aligned.  Unfortunately, GCC doesn't
! 		         do this - it instead right aligns even sized
! 		         values and puts odd sized values on the
! 		         stack.  Work around that by putting both a
! 		         left and right aligned value into the
! 		         register (hopefully no one notices :-^).
! 		         Arrrgh!  */
! 		      /* Left aligned (8 byte values such as pointers
! 		         fill the buffer).  */
! 		      memcpy (regval, val + byte, len);
! 		      /* Right aligned (but only if even).  */
! 		      if (len == 1 || len == 2 || len == 4)
! 			memcpy (regval + tdep->wordsize - len,
  				val + byte, len);
  		      regcache_cooked_write (regcache, greg, regval);
  		    }
--- 786,793 ----
  		      if (len > tdep->wordsize)
  			len = tdep->wordsize;
  		      memset (regval, 0, sizeof regval);
! 		      /* GCC expects values to be right aligned */
! 		      memcpy (regval + tdep->wordsize - len,
  				val + byte, len);
  		      regcache_cooked_write (regcache, greg, regval);
  		    }


GDB Test from testsuite -- results before the patch. 
Note, after the patch is applied,
the results are as expected by the test case. 

GCC Version ---- gcc (GCC) 4.1.0 (SUSE Linux)

gdb.base/call-ar-st.exp: continue to 1281
(gdb)print print_small_structs(*struct1, *struct2, *struct3, *struct4, 
*flags, *flags_combo, *three_char,*five_char, *int_char_combo, *d1, *d2, *d3, 
*f1, *f2, *f3)

alpha

gamma

epsilon

alpha

gamma

epsilon

ch1: y	ch2: n

Contents of three_char_t: 

			  <----- This should be  "a   b   c"

Contents of five_char_t: 


o	p	         <----- This should be "l   m   n   o   p"
....


Janani Janakiraman


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