]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/rs6000-aix-tdep.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / rs6000-aix-tdep.c
index 62bc6eed9ad2681698d3bce81b8e890b591d3ead..3faefe58cebdae33cd6a2b3f39324a73c1771172 100644 (file)
@@ -1,6 +1,6 @@
 /* Native support code for PPC AIX, for GDB the GNU debugger.
 
-   Copyright (C) 2006-2013 Free Software Foundation, Inc.
+   Copyright (C) 2006-2024 Free Software Foundation, Inc.
 
    Free Software Foundation, Inc.
 
@@ -19,9 +19,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
-#include "gdb_string.h"
-#include "gdb_assert.h"
+#include "extract-store-integer.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
 #include "infcall.h"
 #include "objfiles.h"
 #include "breakpoint.h"
-#include "rs6000-tdep.h"
 #include "ppc-tdep.h"
 #include "rs6000-aix-tdep.h"
-#include "exceptions.h"
 #include "xcoffread.h"
 #include "solib.h"
 #include "solib-aix.h"
-#include "xml-utils.h"
+#include "target-float.h"
+#include "gdbsupport/xml-utils.h"
+#include "trad-frame.h"
+#include "frame-unwind.h"
 
 /* If the kernel has to deliver a signal, it pushes a sigcontext
    structure on the stack and then calls the signal handler, passing
    the signal handler doesn't save this register, so we have to
    access the sigcontext structure via an offset from the signal handler
    frame.
-   The following constants were determined by experimentation on AIX 3.2.  */
+   The following constants were determined by experimentation on AIX 3.2.
+
+   sigcontext structure have the mstsave saved under the
+   sc_jmpbuf.jmp_context. STKMIN(minimum stack size) is 56 for 32-bit
+   processes, and iar offset under sc_jmpbuf.jmp_context is 40.
+   ie offsetof(struct sigcontext, sc_jmpbuf.jmp_context.iar).
+   so PC offset in this case is STKMIN+iar offset, which is 96. */
+
 #define SIG_FRAME_PC_OFFSET 96
 #define SIG_FRAME_LR_OFFSET 108
+/* STKMIN+grp1 offset, which is 56+228=284 */
 #define SIG_FRAME_FP_OFFSET 284
 
+/* 64 bit process.
+   STKMIN64  is 112 and iar offset is 312. So 112+312=424 */
+#define SIG_FRAME_LR_OFFSET64 424
+/* STKMIN64+grp1 offset. 112+56=168 */
+#define SIG_FRAME_FP_OFFSET64 168
+
+/* Minimum possible text address in AIX.  */
+#define AIX_TEXT_SEGMENT_BASE 0x10000000
+
+struct rs6000_aix_reg_vrreg_offset
+{
+  int vr0_offset;
+  int vscr_offset;
+  int vrsave_offset;
+};
+
+static struct rs6000_aix_reg_vrreg_offset rs6000_aix_vrreg_offset =
+{
+   /* AltiVec registers.  */
+  32, /* vr0_offset */
+  544, /* vscr_offset. */
+  560 /* vrsave_offset */
+};
+
+static int
+rs6000_aix_get_vrreg_offset (ppc_gdbarch_tdep *tdep,
+  const struct rs6000_aix_reg_vrreg_offset *offsets,
+  int regnum)
+{
+  if (regnum >= tdep->ppc_vr0_regnum &&
+  regnum < tdep->ppc_vr0_regnum + ppc_num_vrs)
+    return offsets->vr0_offset + (regnum - tdep->ppc_vr0_regnum) * 16;
+
+  if (regnum == tdep->ppc_vrsave_regnum - 1)
+    return offsets->vscr_offset;
+
+  if (regnum == tdep->ppc_vrsave_regnum)
+    return offsets->vrsave_offset;
+
+  return -1;
+}
+
+static void
+rs6000_aix_supply_vrregset (const struct regset *regset, struct regcache *regcache,
+                           int regnum, const void *vrregs, size_t len)
+{
+  struct gdbarch *gdbarch = regcache->arch ();
+  const struct rs6000_aix_reg_vrreg_offset  *offsets;
+  size_t offset;
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  if (!(tdep->ppc_vr0_regnum >= 0  && tdep->ppc_vrsave_regnum >= 0))
+    return;
+
+  offsets = (const struct rs6000_aix_reg_vrreg_offset *) regset->regmap;
+  if (regnum == -1)
+    {
+      int i;
+
+      for (i = tdep->ppc_vr0_regnum, offset = offsets->vr0_offset;
+                          i < tdep->ppc_vr0_regnum + ppc_num_vrs;
+                                               i++, offset += 16)
+       ppc_supply_reg (regcache, i, (const gdb_byte *) vrregs, offset, 16);
+
+      ppc_supply_reg (regcache, (tdep->ppc_vrsave_regnum - 1),
+         (const gdb_byte *) vrregs, offsets->vscr_offset, 4);
+
+      ppc_supply_reg (regcache, tdep->ppc_vrsave_regnum,
+       (const gdb_byte *) vrregs, offsets->vrsave_offset, 4);
+
+      return;
+    }
+  offset = rs6000_aix_get_vrreg_offset (tdep, offsets, regnum);
+  if (regnum != tdep->ppc_vrsave_regnum &&
+      regnum != tdep->ppc_vrsave_regnum - 1)
+    ppc_supply_reg (regcache, regnum, (const gdb_byte *) vrregs, offset, 16);
+  else
+    ppc_supply_reg (regcache, regnum,
+     (const gdb_byte *) vrregs, offset, 4);
+
+}
+
+static void
+rs6000_aix_supply_vsxregset (const struct regset *regset, struct regcache *regcache,
+                            int regnum, const void *vsxregs, size_t len)
+{
+  struct gdbarch *gdbarch = regcache->arch ();
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  if (!(tdep->ppc_vsr0_regnum >= 0))
+    return;
+
+  if (regnum == -1)
+    {
+      int i, offset = 0;
+
+      for (i = tdep->ppc_vsr0_upper_regnum; i < tdep->ppc_vsr0_upper_regnum 
+                                                    + 32; i++, offset += 8)
+       ppc_supply_reg (regcache, i, (const gdb_byte *) vsxregs, offset, 8);
+
+      return;
+    }
+  else
+    ppc_supply_reg (regcache, regnum, (const gdb_byte *) vsxregs, 0, 8);
+}
+
+static void
+rs6000_aix_collect_vsxregset (const struct regset *regset,
+                             const struct regcache *regcache,
+                             int regnum, void *vsxregs, size_t len)
+{
+  struct gdbarch *gdbarch = regcache->arch ();
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  if (!(tdep->ppc_vsr0_regnum >= 0))
+    return;
+
+  if (regnum == -1)
+    {
+      int i;
+      int offset = 0;
+      for (i = tdep->ppc_vsr0_upper_regnum; i < tdep->ppc_vsr0_upper_regnum
+                                                    + 32; i++, offset += 8)
+       ppc_collect_reg (regcache, i, (gdb_byte *) vsxregs, offset, 8);
+
+      return;
+    }
+  else
+    ppc_collect_reg (regcache, regnum, (gdb_byte *) vsxregs, 0, 8);
+}
+
+static void
+rs6000_aix_collect_vrregset (const struct regset *regset,
+                            const struct regcache *regcache,
+                            int regnum, void *vrregs, size_t len)
+{
+  struct gdbarch *gdbarch = regcache->arch ();
+  const struct rs6000_aix_reg_vrreg_offset *offsets;
+  size_t offset;
+
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  if (!(tdep->ppc_vr0_regnum >= 0 && tdep->ppc_vrsave_regnum >= 0))
+    return;
+
+  offsets = (const struct rs6000_aix_reg_vrreg_offset *) regset->regmap;
+  if (regnum == -1)
+    {
+      int i;
+
+      for (i = tdep->ppc_vr0_regnum, offset = offsets->vr0_offset; i <
+               tdep->ppc_vr0_regnum + ppc_num_vrs; i++, offset += 16)
+       ppc_collect_reg (regcache, i, (gdb_byte *) vrregs, offset, 16);
+
+      ppc_collect_reg (regcache, (tdep->ppc_vrsave_regnum - 1),
+                (gdb_byte *) vrregs, offsets->vscr_offset, 4);
+
+      ppc_collect_reg (regcache, tdep->ppc_vrsave_regnum,
+        (gdb_byte *) vrregs, offsets->vrsave_offset, 4);
+
+      return;
+    }
+
+  offset = rs6000_aix_get_vrreg_offset (tdep, offsets, regnum);
+  if (regnum != tdep->ppc_vrsave_regnum
+      && regnum != tdep->ppc_vrsave_regnum - 1)
+    ppc_collect_reg (regcache, regnum, (gdb_byte *) vrregs, offset, 16);
+  else
+    ppc_collect_reg (regcache, regnum,
+                    (gdb_byte *) vrregs, offset, 4);
+}
+
+static const struct regset rs6000_aix_vrregset = {
+  &rs6000_aix_vrreg_offset,
+  rs6000_aix_supply_vrregset,
+  rs6000_aix_collect_vrregset
+};
+
+static const struct regset rs6000_aix_vsxregset = {
+  &rs6000_aix_vrreg_offset,
+  rs6000_aix_supply_vsxregset,
+  rs6000_aix_collect_vsxregset
+};
+
+static struct trad_frame_cache *
+aix_sighandle_frame_cache (const frame_info_ptr &this_frame,
+                          void **this_cache)
+{
+  LONGEST backchain;
+  CORE_ADDR base, base_orig, func;
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  struct trad_frame_cache *this_trad_cache;
+
+  if ((*this_cache) != NULL)
+    return (struct trad_frame_cache *) (*this_cache);
+
+  this_trad_cache = trad_frame_cache_zalloc (this_frame);
+  (*this_cache) = this_trad_cache;
+
+  base = get_frame_register_unsigned (this_frame,
+                                     gdbarch_sp_regnum (gdbarch));
+  base_orig = base;
+
+  if (tdep->wordsize == 4)
+    {
+      func = read_memory_unsigned_integer (base_orig +
+                                          SIG_FRAME_PC_OFFSET + 8,
+                                          tdep->wordsize, byte_order);
+      safe_read_memory_integer (base_orig + SIG_FRAME_FP_OFFSET + 8,
+                               tdep->wordsize, byte_order, &backchain);
+      base = (CORE_ADDR)backchain;
+    }
+  else
+    {
+      func = read_memory_unsigned_integer (base_orig +
+                                          SIG_FRAME_LR_OFFSET64,
+                                          tdep->wordsize, byte_order);
+      safe_read_memory_integer (base_orig + SIG_FRAME_FP_OFFSET64,
+                               tdep->wordsize, byte_order, &backchain);
+      base = (CORE_ADDR)backchain;
+    }
+
+  trad_frame_set_reg_value (this_trad_cache, gdbarch_pc_regnum (gdbarch), func);
+  trad_frame_set_reg_value (this_trad_cache, gdbarch_sp_regnum (gdbarch), base);
+
+  if (tdep->wordsize == 4)
+    trad_frame_set_reg_addr (this_trad_cache, tdep->ppc_lr_regnum,
+                            base_orig + 0x38 + 52 + 8);
+  else
+    trad_frame_set_reg_addr (this_trad_cache, tdep->ppc_lr_regnum,
+                            base_orig + 0x70 + 320);
+
+  trad_frame_set_id (this_trad_cache, frame_id_build (base, func));
+  trad_frame_set_this_base (this_trad_cache, base);
+
+  return this_trad_cache;
+}
+
+static void
+aix_sighandle_frame_this_id (const frame_info_ptr &this_frame,
+                            void **this_prologue_cache,
+                            struct frame_id *this_id)
+{
+  struct trad_frame_cache *this_trad_cache
+    = aix_sighandle_frame_cache (this_frame, this_prologue_cache);
+  trad_frame_get_id (this_trad_cache, this_id);
+}
+
+static struct value *
+aix_sighandle_frame_prev_register (const frame_info_ptr &this_frame,
+                                  void **this_prologue_cache, int regnum)
+{
+  struct trad_frame_cache *this_trad_cache
+    = aix_sighandle_frame_cache (this_frame, this_prologue_cache);
+  return trad_frame_get_register (this_trad_cache, this_frame, regnum);
+}
+
+static int
+aix_sighandle_frame_sniffer (const struct frame_unwind *self,
+                            const frame_info_ptr &this_frame,
+                            void **this_prologue_cache)
+{
+  CORE_ADDR pc = get_frame_pc (this_frame);
+  if (pc && pc < AIX_TEXT_SEGMENT_BASE)
+    return 1;
+
+  return 0;
+}
+
+/* AIX signal handler frame unwinder */
+
+static const struct frame_unwind aix_sighandle_frame_unwind = {
+  "rs6000 aix sighandle",
+  SIGTRAMP_FRAME,
+  default_frame_unwind_stop_reason,
+  aix_sighandle_frame_this_id,
+  aix_sighandle_frame_prev_register,
+  NULL,
+  aix_sighandle_frame_sniffer
+};
 
 /* Core file support.  */
 
@@ -72,12 +357,7 @@ static struct ppc_reg_offsets rs6000_aix32_reg_offsets =
   /* Floating-point registers.  */
   336, /* f0_offset */
   56, /* fpscr_offset */
-  4,  /* fpscr_size */
-
-  /* AltiVec registers.  */
-  -1, /* vr0_offset */
-  -1, /* vscr_offset */
-  -1 /* vrsave_offset */
+  4  /* fpscr_size */
 };
 
 static struct ppc_reg_offsets rs6000_aix64_reg_offsets =
@@ -97,12 +377,7 @@ static struct ppc_reg_offsets rs6000_aix64_reg_offsets =
   /* Floating-point registers.  */
   312, /* f0_offset */
   296, /* fpscr_offset */
-  4,  /* fpscr_size */
-
-  /* AltiVec registers.  */
-  -1, /* vr0_offset */
-  -1, /* vscr_offset */
-  -1 /* vrsave_offset */
+  4  /* fpscr_size */
 };
 
 
@@ -135,41 +410,75 @@ rs6000_aix_collect_regset (const struct regset *regset,
 
 /* AIX register set.  */
 
-static struct regset rs6000_aix32_regset =
+static const struct regset rs6000_aix32_regset =
 {
   &rs6000_aix32_reg_offsets,
   rs6000_aix_supply_regset,
   rs6000_aix_collect_regset,
 };
 
-static struct regset rs6000_aix64_regset =
+static const struct regset rs6000_aix64_regset =
 {
   &rs6000_aix64_reg_offsets,
   rs6000_aix_supply_regset,
   rs6000_aix_collect_regset,
 };
 
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
+/* Iterate over core file register note sections.  */
 
-static const struct regset *
-rs6000_aix_regset_from_core_section (struct gdbarch *gdbarch,
-                                    const char *sect_name, size_t sect_size)
+static void
+rs6000_aix_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                        iterate_over_regset_sections_cb *cb,
+                                        void *cb_data,
+                                        const struct regcache *regcache)
 {
-  if (gdbarch_tdep (gdbarch)->wordsize == 4)
-    {
-      if (strcmp (sect_name, ".reg") == 0 && sect_size >= 592)
-        return &rs6000_aix32_regset;
-    }
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  int have_altivec = tdep->ppc_vr0_regnum != -1;
+  int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
+
+  if (tdep->wordsize == 4)
+    cb (".reg", 592, 592, &rs6000_aix32_regset, NULL, cb_data);
   else
-    {
-      if (strcmp (sect_name, ".reg") == 0 && sect_size >= 576)
-        return &rs6000_aix64_regset;
-    }
+    cb (".reg", 576, 576, &rs6000_aix64_regset, NULL, cb_data);
+
+  if (have_altivec)
+   cb (".aix-vmx", 560, 560, &rs6000_aix_vrregset, "AIX altivec", cb_data);
+
+  if (have_vsx)
+   cb (".aix-vsx", 256, 256, &rs6000_aix_vsxregset, "AIX vsx", cb_data);
 
-  return NULL;
 }
 
+/* Read core file description for AIX.  */
+
+static const struct target_desc *
+ppc_aix_core_read_description (struct gdbarch *gdbarch,
+                              struct target_ops *target,
+                              bfd *abfd)
+{
+  asection *altivec = bfd_get_section_by_name (abfd, ".aix-vmx");
+  asection *vsx = bfd_get_section_by_name (abfd, ".aix-vsx");
+  asection *section = bfd_get_section_by_name (abfd, ".reg");
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+
+  if (!section)
+    return NULL;
+
+  int arch64 = 0;
+  if (tdep->wordsize == 8)
+    arch64 = 1;
+
+  if (vsx && arch64)
+    return tdesc_powerpc_vsx64;
+  else if (vsx && !arch64)
+    return tdesc_powerpc_vsx32;
+  else if (altivec && arch64)
+    return tdesc_powerpc_altivec64;
+  else if (altivec && !arch64)
+    return tdesc_powerpc_altivec32;
+
+  return NULL;
+}
 
 /* Pass the arguments in either registers, or in the stack.  In RS/6000,
    the first eight words of the argument list (that might be less than
@@ -191,9 +500,10 @@ static CORE_ADDR
 rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                        struct regcache *regcache, CORE_ADDR bp_addr,
                        int nargs, struct value **args, CORE_ADDR sp,
-                       int struct_return, CORE_ADDR struct_addr)
+                       function_call_return_method return_method,
+                       CORE_ADDR struct_addr)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii;
   int len = 0;
@@ -201,7 +511,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argbytes;                        /* current argument byte */
   gdb_byte tmp_buffer[50];
   int f_argno = 0;             /* current floating point argno */
-  int wordsize = gdbarch_tdep (gdbarch)->wordsize;
+  int wordsize = tdep->wordsize;
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   struct value *arg = 0;
@@ -222,7 +532,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
      (which will be passed in r3) is used for struct return address.
      In that case we should advance one word and start from r4
      register to copy parameters.  */
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       regcache_raw_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
                                   struct_addr);
@@ -251,10 +561,10 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       int reg_size = register_size (gdbarch, ii + 3);
 
       arg = args[argno];
-      type = check_typedef (value_type (arg));
-      len = TYPE_LENGTH (type);
+      type = check_typedef (arg->type ());
+      len = type->length ();
 
-      if (TYPE_CODE (type) == TYPE_CODE_FLT)
+      if (type->code () == TYPE_CODE_FLT)
        {
          /* Floating point arguments are passed in fpr's, as well as gpr's.
             There are 13 fpr's reserved for passing parameters.  At this point
@@ -263,14 +573,14 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
             Always store the floating point value using the register's
             floating-point format.  */
          const int fp_regnum = tdep->ppc_fp0_regnum + 1 + f_argno;
-         gdb_byte reg_val[MAX_REGISTER_SIZE];
+         gdb_byte reg_val[PPC_MAX_REGISTER_SIZE];
          struct type *reg_type = register_type (gdbarch, fp_regnum);
 
          gdb_assert (len <= 8);
 
-         convert_typed_floating (value_contents (arg), type,
-                                 reg_val, reg_type);
-         regcache_cooked_write (regcache, fp_regnum, reg_val);
+         target_float_convert (arg->contents ().data (), type, reg_val,
+                               reg_type);
+         regcache->cooked_write (fp_regnum, reg_val);
          ++f_argno;
        }
 
@@ -280,15 +590,13 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          /* Argument takes more than one register.  */
          while (argbytes < len)
            {
-             gdb_byte word[MAX_REGISTER_SIZE];
+             gdb_byte word[PPC_MAX_REGISTER_SIZE];
              memset (word, 0, reg_size);
              memcpy (word,
-                     ((char *) value_contents (arg)) + argbytes,
+                     ((char *) arg->contents ().data ()) + argbytes,
                      (len - argbytes) > reg_size
-                       ? reg_size : len - argbytes);
-             regcache_cooked_write (regcache,
-                                   tdep->ppc_gp0_regnum + 3 + ii,
-                                   word);
+                       ? reg_size : len - argbytes);
+             regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word);
              ++ii, argbytes += reg_size;
 
              if (ii >= 8)
@@ -300,13 +608,19 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       else
        {
          /* Argument can fit in one register.  No problem.  */
-         int adj = gdbarch_byte_order (gdbarch)
-                   == BFD_ENDIAN_BIG ? reg_size - len : 0;
-         gdb_byte word[MAX_REGISTER_SIZE];
+         gdb_byte word[PPC_MAX_REGISTER_SIZE];
 
          memset (word, 0, reg_size);
-         memcpy (word, value_contents (arg), len);
-         regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3 +ii, word);
+         if (type->code () == TYPE_CODE_INT
+            || type->code () == TYPE_CODE_ENUM
+            || type->code () == TYPE_CODE_BOOL
+            || type->code () == TYPE_CODE_CHAR)
+           /* Sign or zero extend the "int" into a "word".  */
+           store_unsigned_integer (word, reg_size, byte_order,
+                                   unpack_long (type, arg->contents ().data ()));
+         else
+           memcpy (word, arg->contents ().data (), len);
+         regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word);
        }
       ++argno;
     }
@@ -335,7 +649,7 @@ ran_out_of_registers_for_arguments:
 
       if (argbytes)
        {
-         space += ((len - argbytes + 3) & -4);
+         space += ((len - argbytes + wordsize -1) & -wordsize);
          jj = argno + 1;
        }
       else
@@ -344,7 +658,7 @@ ran_out_of_registers_for_arguments:
       for (; jj < nargs; ++jj)
        {
          struct value *val = args[jj];
-         space += ((TYPE_LENGTH (value_type (val))) + 3) & -4;
+         space += ((val->type ()->length () + wordsize -1) & -wordsize);
        }
 
       /* Add location required for the rest of the parameters.  */
@@ -352,24 +666,24 @@ ran_out_of_registers_for_arguments:
       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.  */
+        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,
                                 gdbarch_sp_regnum (gdbarch), sp);
 
       /* If the last argument copied into the registers didn't fit there 
-         completely, push the rest of it into stack.  */
+        completely, push the rest of it into stack.  */
 
       if (argbytes)
        {
-         write_memory (sp + 24 + (ii * 4),
-                       value_contents (arg) + argbytes,
+         write_memory (sp + 6 * wordsize + (ii * wordsize),
+                       arg->contents ().data () + argbytes,
                        len - argbytes);
          ++argno;
-         ii += ((len - argbytes + 3) & -4) / 4;
+         ii += ((len - argbytes + wordsize - 1) & -wordsize) / wordsize;
        }
 
       /* Push the rest of the arguments into stack.  */
@@ -377,25 +691,36 @@ ran_out_of_registers_for_arguments:
        {
 
          arg = args[argno];
-         type = check_typedef (value_type (arg));
-         len = TYPE_LENGTH (type);
+         type = check_typedef (arg->type ());
+         len = type->length ();
 
 
          /* Float types should be passed in fpr's, as well as in the
-             stack.  */
-         if (TYPE_CODE (type) == TYPE_CODE_FLT && f_argno < 13)
+            stack.  */
+         if (type->code () == TYPE_CODE_FLT && f_argno < 13)
            {
 
              gdb_assert (len <= 8);
 
-             regcache_cooked_write (regcache,
-                                    tdep->ppc_fp0_regnum + 1 + f_argno,
-                                    value_contents (arg));
+             regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno,
+                                     arg->contents ().data ());
              ++f_argno;
            }
 
-         write_memory (sp + 24 + (ii * 4), value_contents (arg), len);
-         ii += ((len + 3) & -4) / 4;
+         if (type->code () == TYPE_CODE_INT
+            || type->code () == TYPE_CODE_ENUM
+            || type->code () == TYPE_CODE_BOOL
+            || type->code () == TYPE_CODE_CHAR )
+           {
+             gdb_byte word[PPC_MAX_REGISTER_SIZE];
+             memset (word, 0, PPC_MAX_REGISTER_SIZE);
+             store_unsigned_integer (word, tdep->wordsize, byte_order,
+                                     unpack_long (type, arg->contents ().data ()));
+             write_memory (sp + 6 * wordsize + (ii * wordsize), word, PPC_MAX_REGISTER_SIZE);
+           }
+         else
+           write_memory (sp + 6 * wordsize + (ii * wordsize), arg->contents ().data (), len);
+         ii += ((len + wordsize -1) & -wordsize) / wordsize;
        }
     }
 
@@ -428,7 +753,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
                     struct type *valtype, struct regcache *regcache,
                     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* The calling convention this function implements assumes the
@@ -438,13 +763,13 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
 
   /* AltiVec extension: Functions that declare a vector data type as a
      return value place that return value in VR2.  */
-  if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype)
-      && TYPE_LENGTH (valtype) == 16)
+  if (valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector ()
+      && valtype->length () == 16)
     {
       if (readbuf)
-       regcache_cooked_read (regcache, tdep->ppc_vr0_regnum + 2, readbuf);
+       regcache->cooked_read (tdep->ppc_vr0_regnum + 2, readbuf);
       if (writebuf)
-       regcache_cooked_write (regcache, tdep->ppc_vr0_regnum + 2, writebuf);
+       regcache->cooked_write (tdep->ppc_vr0_regnum + 2, writebuf);
 
       return RETURN_VALUE_REGISTER_CONVENTION;
     }
@@ -454,17 +779,17 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
      allocated buffer into which the callee is assumed to store its
      return value.  All explicit parameters are appropriately
      relabeled.  */
-  if (TYPE_CODE (valtype) == TYPE_CODE_STRUCT
-      || TYPE_CODE (valtype) == TYPE_CODE_UNION
-      || TYPE_CODE (valtype) == TYPE_CODE_ARRAY)
+  if (valtype->code () == TYPE_CODE_STRUCT
+      || valtype->code () == TYPE_CODE_UNION
+      || valtype->code () == TYPE_CODE_ARRAY)
     return RETURN_VALUE_STRUCT_CONVENTION;
 
   /* Scalar floating-point values are returned in FPR1 for float or
      double, and in FPR1:FPR2 for quadword precision.  Fortran
      complex*8 and complex*16 are returned in FPR1:FPR2, and
      complex*32 is returned in FPR1:FPR4.  */
-  if (TYPE_CODE (valtype) == TYPE_CODE_FLT
-      && (TYPE_LENGTH (valtype) == 4 || TYPE_LENGTH (valtype) == 8))
+  if (valtype->code () == TYPE_CODE_FLT
+      && (valtype->length () == 4 || valtype->length () == 8))
     {
       struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
       gdb_byte regval[8];
@@ -474,13 +799,13 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
 
       if (readbuf)
        {
-         regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
-         convert_typed_floating (regval, regtype, readbuf, valtype);
+         regcache->cooked_read (tdep->ppc_fp0_regnum + 1, regval);
+         target_float_convert (regval, regtype, readbuf, valtype);
        }
       if (writebuf)
        {
-         convert_typed_floating (writebuf, valtype, regval, regtype);
-         regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
+         target_float_convert (writebuf, valtype, regval, regtype);
+         regcache->cooked_write (tdep->ppc_fp0_regnum + 1, regval);
        }
 
       return RETURN_VALUE_REGISTER_CONVENTION;
@@ -491,7 +816,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
      lengths less than or equal to 32 bits, must be returned right
      justified in GPR3 with signed values sign extended and unsigned
      values zero extended, as necessary.  */
-  if (TYPE_LENGTH (valtype) <= tdep->wordsize)
+  if (valtype->length () <= tdep->wordsize)
     {
       if (readbuf)
        {
@@ -500,7 +825,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
          /* For reading we don't have to worry about sign extension.  */
          regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
                                         &regval);
-         store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+         store_unsigned_integer (readbuf, valtype->length (), byte_order,
                                  regval);
        }
       if (writebuf)
@@ -517,25 +842,23 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
   /* Eight-byte non-floating-point scalar values must be returned in
      GPR3:GPR4.  */
 
-  if (TYPE_LENGTH (valtype) == 8)
+  if (valtype->length () == 8)
     {
-      gdb_assert (TYPE_CODE (valtype) != TYPE_CODE_FLT);
+      gdb_assert (valtype->code () != TYPE_CODE_FLT);
       gdb_assert (tdep->wordsize == 4);
 
       if (readbuf)
        {
          gdb_byte regval[8];
 
-         regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, regval);
-         regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
-                               regval + 4);
+         regcache->cooked_read (tdep->ppc_gp0_regnum + 3, regval);
+         regcache->cooked_read (tdep->ppc_gp0_regnum + 4, regval + 4);
          memcpy (readbuf, regval, 8);
        }
       if (writebuf)
        {
-         regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, writebuf);
-         regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
-                                writebuf + 4);
+         regcache->cooked_write (tdep->ppc_gp0_regnum + 3, writebuf);
+         regcache->cooked_write (tdep->ppc_gp0_regnum + 4, writebuf + 4);
        }
 
       return RETURN_VALUE_REGISTER_CONVENTION;
@@ -568,7 +891,7 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
                                   CORE_ADDR addr,
                                   struct target_ops *targ)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *s;
 
@@ -582,23 +905,23 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
     {
       CORE_ADDR pc = 0;
       struct obj_section *pc_section;
-      volatile struct gdb_exception e;
-
-      TRY_CATCH (e, RETURN_MASK_ERROR)
-        {
-          pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
-        }
-      if (e.reason < 0)
-        {
-          /* An error occured during reading.  Probably a memory error
-             due to the section not being loaded yet.  This address
-             cannot be a function descriptor.  */
-          return addr;
-        }
+
+      try
+       {
+         pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
+       }
+      catch (const gdb_exception_error &e)
+       {
+         /* An error occurred during reading.  Probably a memory error
+            due to the section not being loaded yet.  This address
+            cannot be a function descriptor.  */
+         return addr;
+       }
+
       pc_section = find_pc_section (pc);
 
       if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
-        return pc;
+       return pc;
     }
 
   return addr;
@@ -608,11 +931,11 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 /* Calculate the destination of a branch/jump.  Return -1 if not a branch.  */
 
 static CORE_ADDR
-branch_dest (struct frame_info *frame, int opcode, int instr,
+branch_dest (struct regcache *regcache, int opcode, int instr,
             CORE_ADDR pc, CORE_ADDR safety)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  struct gdbarch *gdbarch = regcache->arch ();
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR dest;
   int immediate;
@@ -644,29 +967,33 @@ branch_dest (struct frame_info *frame, int opcode, int instr,
 
       if (ext_op == 16)                /* br conditional register */
        {
-          dest = get_frame_register_unsigned (frame, tdep->ppc_lr_regnum) & ~3;
+         dest = regcache_raw_get_unsigned (regcache, tdep->ppc_lr_regnum) & ~3;
 
          /* If we are about to return from a signal handler, dest is
             something like 0x3c90.  The current frame is a signal handler
             caller frame, upon completion of the sigreturn system call
             execution will return to the saved PC in the frame.  */
          if (dest < AIX_TEXT_SEGMENT_BASE)
-           dest = read_memory_unsigned_integer
-                    (get_frame_base (frame) + SIG_FRAME_PC_OFFSET,
-                     tdep->wordsize, byte_order);
+           {
+             frame_info_ptr frame = get_current_frame ();
+
+             dest = read_memory_unsigned_integer
+               (get_frame_base (frame) + SIG_FRAME_PC_OFFSET,
+                tdep->wordsize, byte_order);
+           }
        }
 
       else if (ext_op == 528)  /* br cond to count reg */
        {
-          dest = get_frame_register_unsigned (frame,
-                                             tdep->ppc_ctr_regnum) & ~3;
+         dest = regcache_raw_get_unsigned (regcache,
+                                           tdep->ppc_ctr_regnum) & ~3;
 
          /* If we are about to execute a system call, dest is something
             like 0x22fc or 0x3b00.  Upon completion the system call
             will return to the address in the link register.  */
          if (dest < AIX_TEXT_SEGMENT_BASE)
-            dest = get_frame_register_unsigned (frame,
-                                               tdep->ppc_lr_regnum) & ~3;
+           dest = regcache_raw_get_unsigned (regcache,
+                                             tdep->ppc_lr_regnum) & ~3;
        }
       else
        return -1;
@@ -680,27 +1007,31 @@ branch_dest (struct frame_info *frame, int opcode, int instr,
 
 /* AIX does not support PT_STEP.  Simulate it.  */
 
-static int
-rs6000_software_single_step (struct frame_info *frame)
+static std::vector<CORE_ADDR>
+rs6000_software_single_step (struct regcache *regcache)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct address_space *aspace = get_frame_address_space (frame);
+  struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii, insn;
   CORE_ADDR loc;
   CORE_ADDR breaks[2];
   int opcode;
 
-  loc = get_frame_pc (frame);
+  loc = regcache_read_pc (regcache);
 
   insn = read_memory_integer (loc, 4, byte_order);
 
-  if (ppc_deal_with_atomic_sequence (frame))
-    return 1;
+  std::vector<CORE_ADDR> next_pcs = ppc_deal_with_atomic_sequence (regcache);
+  if (!next_pcs.empty ())
+    return next_pcs;
   
-  breaks[0] = loc + PPC_INSN_SIZE;
+  /* Here 0xfc000000 is the opcode mask to detect a P10 prefix instruction.  */
+  if ((insn & 0xfc000000) == 1 << 26)
+    breaks[0] = loc + 2 * PPC_INSN_SIZE;
+  else
+    breaks[0] = loc + PPC_INSN_SIZE;
   opcode = insn >> 26;
-  breaks[1] = branch_dest (frame, opcode, insn, loc, breaks[0]);
+  breaks[1] = branch_dest (regcache, opcode, insn, loc, breaks[0]);
 
   /* Don't put two breakpoints on the same address.  */
   if (breaks[1] == breaks[0])
@@ -711,12 +1042,13 @@ rs6000_software_single_step (struct frame_info *frame)
       /* ignore invalid breakpoint.  */
       if (breaks[ii] == -1)
        continue;
-      insert_single_step_breakpoint (gdbarch, aspace, breaks[ii]);
+
+      next_pcs.push_back (breaks[ii]);
     }
 
   errno = 0;                   /* FIXME, don't ignore errors!  */
   /* What errors?  {read,write}_memory call error().  */
-  return 1;
+  return next_pcs;
 }
 
 /* Implement the "auto_wide_charset" gdbarch method for this platform.  */
@@ -752,7 +1084,7 @@ rs6000_aix_osabi_sniffer (bfd *abfd)
 /* A structure encoding the offset and size of a field within
    a struct.  */
 
-struct field_info
+struct ldinfo_field
 {
   int offset;
   int size;
@@ -764,13 +1096,13 @@ struct field_info
 
 struct ld_info_desc
 {
-  struct field_info ldinfo_next;
-  struct field_info ldinfo_fd;
-  struct field_info ldinfo_textorg;
-  struct field_info ldinfo_textsize;
-  struct field_info ldinfo_dataorg;
-  struct field_info ldinfo_datasize;
-  struct field_info ldinfo_filename;
+  struct ldinfo_field ldinfo_next;
+  struct ldinfo_field ldinfo_fd;
+  struct ldinfo_field ldinfo_textorg;
+  struct ldinfo_field ldinfo_textsize;
+  struct ldinfo_field ldinfo_dataorg;
+  struct ldinfo_field ldinfo_datasize;
+  struct ldinfo_field ldinfo_filename;
 };
 
 /* The following data has been generated by compiling and running
@@ -786,11 +1118,11 @@ struct ld_info_desc
 #define pinfo(type,member)                  \
   {                                         \
     struct type ldi = {0};                  \
-                                            \
+                                           \
     printf ("  {%d, %d},\t/* %s */\n",      \
-            offsetof (struct type, member), \
-            sizeof (ldi.member),            \
-            #member);                       \
+           offsetof (struct type, member), \
+           sizeof (ldi.member),            \
+           #member);                       \
   }                                         \
   while (0)
 
@@ -875,7 +1207,7 @@ static struct ld_info
 rs6000_aix_extract_ld_info (struct gdbarch *gdbarch,
                            const gdb_byte *ldi_buf)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
   const struct ld_info_desc desc
@@ -906,48 +1238,41 @@ rs6000_aix_extract_ld_info (struct gdbarch *gdbarch,
   return info;
 }
 
-/* Append to OBJSTACK an XML string description of the shared library
+/* Append to XML an XML string description of the shared library
    corresponding to LDI, following the TARGET_OBJECT_LIBRARIES_AIX
    format.  */
 
 static void
-rs6000_aix_shared_library_to_xml (struct ld_info *ldi,
-                                 struct obstack *obstack)
+rs6000_aix_shared_library_to_xml (struct ld_info *ldi, std::string &xml)
 {
-  char *p;
-
-  obstack_grow_str (obstack, "<library name=\"");
-  p = xml_escape_text (ldi->filename);
-  obstack_grow_str (obstack, p);
-  xfree (p);
-  obstack_grow_str (obstack, "\"");
+  xml += "<library name=\"";
+  xml_escape_text_append (xml, ldi->filename);
+  xml += '"';
 
   if (ldi->member_name[0] != '\0')
     {
-      obstack_grow_str (obstack, " member=\"");
-      p = xml_escape_text (ldi->member_name);
-      obstack_grow_str (obstack, p);
-      xfree (p);
-      obstack_grow_str (obstack, "\"");
+      xml += " member=\"";
+      xml_escape_text_append (xml, ldi->member_name);
+      xml += '"';
     }
 
-  obstack_grow_str (obstack, " text_addr=\"");
-  obstack_grow_str (obstack, core_addr_to_string (ldi->textorg));
-  obstack_grow_str (obstack, "\"");
+  xml += " text_addr=\"";
+  xml += core_addr_to_string (ldi->textorg);
+  xml += '"';
 
-  obstack_grow_str (obstack, " text_size=\"");
-  obstack_grow_str (obstack, pulongest (ldi->textsize));
-  obstack_grow_str (obstack, "\"");
+  xml += " text_size=\"";
+  xml += pulongest (ldi->textsize);
+  xml += '"';
 
-  obstack_grow_str (obstack, " data_addr=\"");
-  obstack_grow_str (obstack, core_addr_to_string (ldi->dataorg));
-  obstack_grow_str (obstack, "\"");
+  xml += " data_addr=\"";
+  xml += core_addr_to_string (ldi->dataorg);
+  xml += '"';
 
-  obstack_grow_str (obstack, " data_size=\"");
-  obstack_grow_str (obstack, pulongest (ldi->datasize));
-  obstack_grow_str (obstack, "\"");
+  xml += " data_size=\"";
+  xml += pulongest (ldi->datasize);
+  xml += '"';
 
-  obstack_grow_str (obstack, "></library>");
+  xml += "></library>";
 }
 
 /* Convert the ld_info binary data provided by the AIX loader into
@@ -965,23 +1290,18 @@ rs6000_aix_shared_library_to_xml (struct ld_info *ldi,
    as the consumer of the XML library list might live in a different
    process.  */
 
-LONGEST
+ULONGEST
 rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch, const gdb_byte *ldi_buf,
-                          gdb_byte *readbuf, ULONGEST offset, LONGEST len,
+                          gdb_byte *readbuf, ULONGEST offset, ULONGEST len,
                           int close_ldinfo_fd)
 {
-  struct obstack obstack;
-  const char *buf;
-  LONGEST len_avail;
-
-  obstack_init (&obstack);
-  obstack_grow_str (&obstack, "<library-list-aix version=\"1.0\">\n");
+  std::string xml = "<library-list-aix version=\"1.0\">\n";
 
   while (1)
     {
       struct ld_info ldi = rs6000_aix_extract_ld_info (gdbarch, ldi_buf);
 
-      rs6000_aix_shared_library_to_xml (&ldi, &obstack);
+      rs6000_aix_shared_library_to_xml (&ldi, xml);
       if (close_ldinfo_fd)
        close (ldi.fd);
 
@@ -990,72 +1310,66 @@ rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch, const gdb_byte *ldi_buf,
       ldi_buf = ldi_buf + ldi.next;
     }
 
-  obstack_grow_str0 (&obstack, "</library-list-aix>\n");
+  xml += "</library-list-aix>\n";
 
-  buf = obstack_finish (&obstack);
-  len_avail = strlen (buf);
+  ULONGEST len_avail = xml.length ();
   if (offset >= len_avail)
     len= 0;
   else
     {
       if (len > len_avail - offset)
-        len = len_avail - offset;
-      memcpy (readbuf, buf + offset, len);
+       len = len_avail - offset;
+      memcpy (readbuf, xml.data () + offset, len);
     }
 
-  obstack_free (&obstack, NULL);
   return len;
 }
 
 /* Implement the core_xfer_shared_libraries_aix gdbarch method.  */
 
-static LONGEST
+static ULONGEST
 rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
                                           gdb_byte *readbuf,
                                           ULONGEST offset,
-                                          LONGEST len)
+                                          ULONGEST len)
 {
   struct bfd_section *ldinfo_sec;
   int ldinfo_size;
-  gdb_byte *ldinfo_buf;
-  struct cleanup *cleanup;
-  LONGEST result;
 
-  ldinfo_sec = bfd_get_section_by_name (core_bfd, ".ldinfo");
+  ldinfo_sec = bfd_get_section_by_name (current_program_space->core_bfd (),
+                                       ".ldinfo");
   if (ldinfo_sec == NULL)
     error (_("cannot find .ldinfo section from core file: %s"),
           bfd_errmsg (bfd_get_error ()));
-  ldinfo_size = bfd_get_section_size (ldinfo_sec);
+  ldinfo_size = bfd_section_size (ldinfo_sec);
 
-  ldinfo_buf = xmalloc (ldinfo_size);
-  cleanup = make_cleanup (xfree, ldinfo_buf);
+  gdb::byte_vector ldinfo_buf (ldinfo_size);
 
-  if (! bfd_get_section_contents (core_bfd, ldinfo_sec,
-                                 ldinfo_buf, 0, ldinfo_size))
+  if (! bfd_get_section_contents (current_program_space->core_bfd (),
+                                 ldinfo_sec, ldinfo_buf.data (), 0,
+                                 ldinfo_size))
     error (_("unable to read .ldinfo section from core file: %s"),
          bfd_errmsg (bfd_get_error ()));
 
-  result = rs6000_aix_ld_info_to_xml (gdbarch, ldinfo_buf, readbuf,
-                                     offset, len, 0);
-
-  do_cleanups (cleanup);
-  return result;
+  return rs6000_aix_ld_info_to_xml (gdbarch, ldinfo_buf.data (), readbuf,
+                                   offset, len, 0);
 }
 
 static void
 rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
 
   /* RS6000/AIX does not support PT_STEP.  Has to be simulated.  */
   set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
 
   /* Displaced stepping is currently not supported in combination with
-     software single-stepping.  */
+     software single-stepping.  These override the values set by
+     rs6000_gdbarch_init.  */
   set_gdbarch_displaced_step_copy_insn (gdbarch, NULL);
   set_gdbarch_displaced_step_fixup (gdbarch, NULL);
-  set_gdbarch_displaced_step_free_closure (gdbarch, NULL);
-  set_gdbarch_displaced_step_location (gdbarch, NULL);
+  set_gdbarch_displaced_step_prepare (gdbarch, NULL);
+  set_gdbarch_displaced_step_finish (gdbarch, NULL);
 
   set_gdbarch_push_dummy_call (gdbarch, rs6000_push_dummy_call);
   set_gdbarch_return_value (gdbarch, rs6000_return_value);
@@ -1067,10 +1381,11 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
     (gdbarch, rs6000_convert_from_func_ptr_addr);
 
   /* Core file support.  */
-  set_gdbarch_regset_from_core_section
-    (gdbarch, rs6000_aix_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, rs6000_aix_iterate_over_regset_sections);
   set_gdbarch_core_xfer_shared_libraries_aix
     (gdbarch, rs6000_aix_core_xfer_shared_libraries_aix);
+  set_gdbarch_core_read_description (gdbarch, ppc_aix_core_read_description);
 
   if (tdep->wordsize == 8)
     tdep->lr_frame_offset = 16;
@@ -1084,29 +1399,35 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
        224.  */
     set_gdbarch_frame_red_zone_size (gdbarch, 224);
   else
-    set_gdbarch_frame_red_zone_size (gdbarch, 0);
+    /* In 64 bit mode the red zone should have 18 8 byte GPRS + 18 8 byte
+       FPRS making it 288 bytes.  This is 16 byte aligned as well.  */
+    set_gdbarch_frame_red_zone_size (gdbarch, 288);
 
+  if (tdep->wordsize == 8)
+    set_gdbarch_wchar_bit (gdbarch, 32);
+  else
+    set_gdbarch_wchar_bit (gdbarch, 16);
+  set_gdbarch_wchar_signed (gdbarch, 0);
   set_gdbarch_auto_wide_charset (gdbarch, rs6000_aix_auto_wide_charset);
 
-  set_solib_ops (gdbarch, &solib_aix_so_ops);
+  set_gdbarch_so_ops (gdbarch, &solib_aix_so_ops);
+  frame_unwind_append_unwinder (gdbarch, &aix_sighandle_frame_unwind);
 }
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_rs6000_aix_tdep;
-
+void _initialize_rs6000_aix_tdep ();
 void
-_initialize_rs6000_aix_tdep (void)
+_initialize_rs6000_aix_tdep ()
 {
   gdbarch_register_osabi_sniffer (bfd_arch_rs6000,
-                                  bfd_target_xcoff_flavour,
-                                  rs6000_aix_osabi_sniffer);
+                                 bfd_target_xcoff_flavour,
+                                 rs6000_aix_osabi_sniffer);
   gdbarch_register_osabi_sniffer (bfd_arch_powerpc,
-                                  bfd_target_xcoff_flavour,
-                                  rs6000_aix_osabi_sniffer);
+                                 bfd_target_xcoff_flavour,
+                                 rs6000_aix_osabi_sniffer);
 
   gdbarch_register_osabi (bfd_arch_rs6000, 0, GDB_OSABI_AIX,
-                          rs6000_aix_init_osabi);
+                         rs6000_aix_init_osabi);
   gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_AIX,
-                          rs6000_aix_init_osabi);
+                         rs6000_aix_init_osabi);
 }