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

[commit/ppc] AIX fixes


Hello,

Peter Schauer's asked me to commit these fixes needed for AIX. Here are his notes:

- Stepping didn't work with AIX executables, as GDB did not recognize
  from_xcoff_exec in rs6000_gdbarch_init and consequently didn't set
  rs6000_software_single_step, which is needed on AIX.
  Passing exec_bfd in rs6000-nat.c:set_host_arch to gdbarch_update_p
  did the trick:

- callfuncs.exp: backtrace at nested call level 2-4
failed, as the back chain was not stored properly to the inferior stack.
IIRC, AIX has some sort of ptrace transfer area below the current inferior
stack pointer and declines to write too far below the current sp.
This can be easily fixed by rearranging the write sp/write backchain
sequence (and perhaps updating the comment above the
regcache_raw_write_signed (regcache, SP_REGNUM, sp);
call accordingly).


In addition, some tests in call-ar-st.exp and call-rt-st.exp started
failing, as the structure contents were not written properly to the stack.
This is the same problem as above, caused by your Sep 11 2003 change,
which removed the stack securing before the struct write.
Maybe this could/should be conditionalized on AIX, but it is definitely
needed for AIX.


I also tested them on a non-aix system and got no regressions.

committed,
Andrew
2004-01-16  Andrew Cagney  <cagney@redhat.com>

	Changes from Peter Schauer.
	* rs6000-tdep.c: Update copyright year.
	(rs6000_push_dummy_call): Update the stack pointer before
	accessing the corresponding stack region.
	* rs6000-nat.c: Update copyright year.
	(set_host_arch): Set "info.abfd" to "exec_bfd".

Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.37
diff -u -r1.37 rs6000-nat.c
--- rs6000-nat.c	23 Nov 2003 20:41:17 -0000	1.37
+++ rs6000-nat.c	16 Jan 2004 23:58:25 -0000
@@ -1,8 +1,8 @@
 /* IBM RS/6000 native-dependent code for GDB, the GNU debugger.
 
    Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
-   Inc.
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -1002,6 +1002,7 @@
 
   gdbarch_info_init (&info);
   info.bfd_arch_info = bfd_get_arch_info (&abfd);
+  info.abfd = exec_bfd;
 
   if (!gdbarch_update_p (info))
     {
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.174
diff -u -r1.174 rs6000-tdep.c
--- rs6000-tdep.c	13 Jan 2004 21:38:47 -0000	1.174
+++ rs6000-tdep.c	16 Jan 2004 23:58:26 -0000
@@ -1,7 +1,8 @@
 /* Target-dependent code for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003
-   Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -1247,6 +1248,14 @@
       space = (space + 15) & -16;
       sp -= space;
 
+      /* This is another instance we need to be concerned about
+         securing our stack space. If we write anything underneath %sp
+         (r1), we might conflict with the kernel who thinks he is free
+         to use this area.  So, update %sp first before doing anything
+         else.  */
+
+      regcache_raw_write_signed (regcache, SP_REGNUM, sp);
+
       /* If the last argument copied into the registers didn't fit there 
          completely, push the rest of it into stack.  */
 
@@ -1288,15 +1297,17 @@
 	}
     }
 
-  /* set back chain properly */
-  store_unsigned_integer (tmp_buffer, 4, saved_sp);
-  write_memory (sp, tmp_buffer, 4);
-
   /* Set the stack pointer.  According to the ABI, the SP is meant to
-     be set _before_ the corresponding stack space is used.  No need
-     for that here though - the target has been completely stopped -
-     it isn't possible for an exception handler to stomp on the stack.  */
+     be set _before_ the corresponding stack space is used.  On AIX,
+     this even applies when the target has been completely stopped!
+     Not doing this can lead to conflicts with the kernel which thinks
+     that it still has control over this not-yet-allocated stack
+     region.  */
   regcache_raw_write_signed (regcache, SP_REGNUM, sp);
+
+  /* Set back chain properly.  */
+  store_unsigned_integer (tmp_buffer, 4, saved_sp);
+  write_memory (sp, tmp_buffer, 4);
 
   /* Point the inferior function call's return address at the dummy's
      breakpoint.  */

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