Support i386 AVX.
[deliverable/binutils-gdb.git] / gdb / hppa-hpux-tdep.c
index ba2390cd6b03ae82250a4c7f04a65f4a084e347c..fd8d7ccf3d9c8b54d4773deec2d6534a89d3d533 100644 (file)
@@ -1,12 +1,13 @@
 /* Target-dependent code for HP-UX on PA-RISC.
 
-   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "arch-utils.h"
@@ -87,8 +86,10 @@ in_opd_section (CORE_ADDR pc)
    just shared library trampolines (import, export).  */
 
 static int
-hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+                                     CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct minimal_symbol *minsym;
   struct unwind_table_entry *u;
 
@@ -98,7 +99,7 @@ hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
     return 1;
 
   minsym = lookup_minimal_symbol_by_pc (pc);
-  if (minsym && strcmp (DEPRECATED_SYMBOL_NAME (minsym), ".stub") == 0)
+  if (minsym && strcmp (SYMBOL_LINKAGE_NAME (minsym), ".stub") == 0)
     return 1;
 
   /* Get the unwind descriptor corresponding to PC, return zero
@@ -134,7 +135,7 @@ hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
        {
          unsigned long insn;
 
-         insn = read_memory_integer (addr, 4);
+         insn = read_memory_integer (addr, 4, byte_order);
 
          /* Does it look like a bl?  If so then it's the call path, if
             we find a bv or be first, then we're on the return path.  */
@@ -155,8 +156,11 @@ hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
 }
 
 static int
-hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+                                     CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* PA64 has a completely different stub/trampoline scheme.  Is it
      better?  Maybe.  It's certainly harder to determine with any
      certainty that we are in a stub because we can not refer to the
@@ -180,7 +184,7 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
   if (! minsym)
     return 0;
 
-  sec = SYMBOL_BFD_SECTION (minsym);
+  sec = SYMBOL_OBJ_SECTION (minsym)->the_bfd_section;
 
   if (bfd_get_section_vma (sec->owner, sec) <= pc
       && pc < (bfd_get_section_vma (sec->owner, sec)
@@ -189,7 +193,7 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
 
   /* We might be in a stub.  Peek at the instructions.  Stubs are 3
      instructions long. */
-  insn = read_memory_integer (pc, 4);
+  insn = read_memory_integer (pc, 4, byte_order);
 
   /* Find out where we think we are within the stub.  */
   if ((insn & 0xffffc00e) == 0x53610000)
@@ -202,17 +206,17 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
     return 0;
 
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr, 4);
+  insn = read_memory_integer (addr, 4, byte_order);
   if ((insn & 0xffffc00e) != 0x53610000)
     return 0;
        
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr + 4, 4);
+  insn = read_memory_integer (addr + 4, 4, byte_order);
   if ((insn & 0xffffffff) != 0xe820d000)
     return 0;
     
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr + 8, 4);
+  insn = read_memory_integer (addr + 8, 4, byte_order);
   if ((insn & 0xffffc00e) != 0x537b0000)
     return 0;
 
@@ -226,8 +230,10 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
    just shared library trampolines (import, export).  */
 
 static int
-hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+hppa_hpux_in_solib_return_trampoline (struct gdbarch *gdbarch,
+                                     CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct unwind_table_entry *u;
 
   /* Get the unwind descriptor corresponding to PC, return zero
@@ -260,7 +266,7 @@ hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
        {
          unsigned long insn;
 
-         insn = read_memory_integer (addr, 4);
+         insn = read_memory_integer (addr, 4, byte_order);
 
          /* Does it look like a bl?  If so then it's the call path, if
             we find a bv or be first, then we're on the return path.  */
@@ -299,8 +305,11 @@ hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
    used in dynamic executables.  */
 
 static CORE_ADDR
-hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
+hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   long orig_pc = pc;
   long prev_inst, curr_inst, loc;
   struct minimal_symbol *msym;
@@ -310,21 +319,21 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
      of the function.  So we may have to do something special.  */
   if (pc == hppa_symbol_address("$$dyncall"))
     {
-      pc = (CORE_ADDR) read_register (22);
+      pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
 
       /* If bit 30 (counting from the left) is on, then pc is the address of
          the PLT entry for this function, not the address of the function
          itself.  Bit 31 has meaning too, but only for MPE.  */
       if (pc & 0x2)
-       pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
+       pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
     }
   if (pc == hppa_symbol_address("$$dyncall_external"))
     {
-      pc = (CORE_ADDR) read_register (22);
-      pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
+      pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
+      pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
     }
   else if (pc == hppa_symbol_address("_sr4export"))
-    pc = (CORE_ADDR) (read_register (22));
+    pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
 
   /* Get the unwind descriptor corresponding to PC, return zero
      if no unwind was found.  */
@@ -374,7 +383,8 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
          ALL_MSYMBOLS (objfile, msymbol)
          {
            if (MSYMBOL_TYPE (msymbol) == mst_text
-               && DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym)))
+               && strcmp (SYMBOL_LINKAGE_NAME (msymbol),
+                           SYMBOL_LINKAGE_NAME (msym)) == 0)
              {
                function_found = 1;
                break;
@@ -417,7 +427,7 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
        }
 
       prev_inst = curr_inst;
-      curr_inst = read_memory_integer (loc, 4);
+      curr_inst = read_memory_integer (loc, 4, byte_order);
 
       /* Does it look like a branch external using %r1?  Then it's the
          branch from the stub to the actual function.  */
@@ -469,11 +479,11 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
              return orig_pc == pc ? 0 : pc & ~0x3;
            }
 
-         libsym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (stubsym), NULL, NULL);
+         libsym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (stubsym), NULL, NULL);
          if (libsym == NULL)
            {
              warning (_("Unable to find library symbol for %s."),
-                      DEPRECATED_SYMBOL_NAME (stubsym));
+                      SYMBOL_PRINT_NAME (stubsym));
              return orig_pc == pc ? 0 : pc & ~0x3;
            }
 
@@ -498,8 +508,11 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
          /* Yup.  See if the previous instruction loaded
             rp from sp - 8.  */
          if (prev_inst == 0x4bc23ff1)
-           return (read_memory_integer
-                   (read_register (HPPA_SP_REGNUM) - 8, 4)) & ~0x3;
+           {
+             CORE_ADDR sp;
+             sp = get_frame_register_unsigned (frame, HPPA_SP_REGNUM);
+             return read_memory_integer (sp - 8, 4, byte_order) & ~0x3;
+           }
          else
            {
              warning (_("Unable to find restore of %%rp before bv (%%rp)."));
@@ -513,7 +526,8 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
       else if ((curr_inst & 0xffe0f000) == 0xe840d000)
        {
          return (read_memory_integer
-                 (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3;
+                 (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
+                  word_size, byte_order)) & ~0x3;
        }
 
       /* What about be,n 0(sr0,%rp)?  It's just another way we return to
@@ -525,7 +539,8 @@ hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
             I guess we could check for the previous instruction being
             mtsp %r1,%sr0 if we want to do sanity checking.  */
          return (read_memory_integer
-                 (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3;
+                 (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
+                  word_size, byte_order)) & ~0x3;
        }
 
       /* Haven't found the branch yet, but we're still in the stub.
@@ -604,12 +619,13 @@ static int hppa_hpux_tramp_reg[] = {
 };
 
 static struct hppa_hpux_sigtramp_unwind_cache *
-hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *next_frame,
+hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
                                       void **this_cache)
 
 {
-  struct gdbarch *gdbarch = get_frame_arch (next_frame);
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct hppa_hpux_sigtramp_unwind_cache *info;
   unsigned int flag;
   CORE_ADDR sp, scptr, off;
@@ -620,9 +636,9 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *next_frame,
 
   info = FRAME_OBSTACK_ZALLOC (struct hppa_hpux_sigtramp_unwind_cache);
   *this_cache = info;
-  info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
+  info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
-  sp = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
+  sp = get_frame_register_unsigned (this_frame, HPPA_SP_REGNUM);
 
   if (IS_32BIT_TARGET (gdbarch))
     scptr = sp - 1352;
@@ -634,7 +650,8 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *next_frame,
   /* See /usr/include/machine/save_state.h for the structure of the save_state_t
      structure. */
   
-  flag = read_memory_unsigned_integer(scptr + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+  flag = read_memory_unsigned_integer (scptr + HPPA_HPUX_SS_FLAGS_OFFSET,
+                                      4, byte_order);
 
   if (!(flag & HPPA_HPUX_SS_WIDEREGS))
     {
@@ -667,46 +684,42 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *next_frame,
 
   /* TODO: fp regs */
 
-  info->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
+  info->base = get_frame_register_unsigned (this_frame, HPPA_SP_REGNUM);
 
   return info;
 }
 
 static void
-hppa_hpux_sigtramp_frame_this_id (struct frame_info *next_frame,
+hppa_hpux_sigtramp_frame_this_id (struct frame_info *this_frame,
                                   void **this_prologue_cache,
                                   struct frame_id *this_id)
 {
   struct hppa_hpux_sigtramp_unwind_cache *info
-    = hppa_hpux_sigtramp_frame_unwind_cache (next_frame, this_prologue_cache);
-  *this_id = frame_id_build (info->base, frame_pc_unwind (next_frame));
+    = hppa_hpux_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
+
+  *this_id = frame_id_build (info->base, get_frame_pc (this_frame));
 }
 
-static void
-hppa_hpux_sigtramp_frame_prev_register (struct frame_info *next_frame,
+static struct value *
+hppa_hpux_sigtramp_frame_prev_register (struct frame_info *this_frame,
                                        void **this_prologue_cache,
-                                       int regnum, int *optimizedp,
-                                       enum lval_type *lvalp, 
-                                       CORE_ADDR *addrp,
-                                       int *realnump, gdb_byte *valuep)
+                                       int regnum)
 {
   struct hppa_hpux_sigtramp_unwind_cache *info
-    = hppa_hpux_sigtramp_frame_unwind_cache (next_frame, this_prologue_cache);
-  hppa_frame_prev_register_helper (next_frame, info->saved_regs, regnum,
-                                  optimizedp, lvalp, addrp, realnump, valuep);
-}
+    = hppa_hpux_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
 
-static const struct frame_unwind hppa_hpux_sigtramp_frame_unwind = {
-  SIGTRAMP_FRAME,
-  hppa_hpux_sigtramp_frame_this_id,
-  hppa_hpux_sigtramp_frame_prev_register
-};
+  return hppa_frame_prev_register_helper (this_frame, info->saved_regs, regnum);
+}
 
-static const struct frame_unwind *
-hppa_hpux_sigtramp_unwind_sniffer (struct frame_info *next_frame)
+static int
+hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind *self,
+                                   struct frame_info *this_frame,
+                                   void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct unwind_table_entry *u;
-  CORE_ADDR pc = frame_pc_unwind (next_frame);
+  CORE_ADDR pc = get_frame_pc (this_frame);
 
   u = find_unwind_entry (pc);
 
@@ -717,24 +730,34 @@ hppa_hpux_sigtramp_unwind_sniffer (struct frame_info *next_frame)
       gdb_byte buf[HPPA_INSN_SIZE];
       unsigned long insn;
 
-      if (!safe_frame_unwind_memory (next_frame, u->region_start,
+      if (!safe_frame_unwind_memory (this_frame, u->region_start,
                                     buf, sizeof buf))
-       return NULL;
+       return 0;
 
-      insn = extract_unsigned_integer (buf, sizeof buf);
+      insn = extract_unsigned_integer (buf, sizeof buf, byte_order);
       if ((insn & 0xffe0e000) == 0xe8400000)
        u = find_unwind_entry(u->region_start + hppa_extract_17 (insn) + 8);
     }
 
   if (u && u->HP_UX_interrupt_marker)
-    return &hppa_hpux_sigtramp_frame_unwind;
+    return 1;
 
-  return NULL;
+  return 0;
 }
 
+static const struct frame_unwind hppa_hpux_sigtramp_frame_unwind = {
+  SIGTRAMP_FRAME,
+  hppa_hpux_sigtramp_frame_this_id,
+  hppa_hpux_sigtramp_frame_prev_register,
+  NULL,
+  hppa_hpux_sigtramp_unwind_sniffer
+};
+
 static CORE_ADDR
-hppa32_hpux_find_global_pointer (struct value *function)
+hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
+                                struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR faddr;
   
   faddr = value_as_address (function);
@@ -749,15 +772,17 @@ hppa32_hpux_find_global_pointer (struct value *function)
 
       status = target_read_memory (faddr + 4, buf, sizeof (buf));
       if (status == 0)
-       return extract_unsigned_integer (buf, sizeof (buf));
+       return extract_unsigned_integer (buf, sizeof (buf), byte_order);
     }
 
-  return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+  return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
 }
 
 static CORE_ADDR
-hppa64_hpux_find_global_pointer (struct value *function)
+hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
+                                struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR faddr;
   char buf[32];
 
@@ -766,11 +791,11 @@ hppa64_hpux_find_global_pointer (struct value *function)
   if (in_opd_section (faddr))
     {
       target_read_memory (faddr, buf, sizeof (buf));
-      return extract_unsigned_integer (&buf[24], 8);
+      return extract_unsigned_integer (&buf[24], 8, byte_order);
     }
   else
     {
-      return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+      return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
     }
 }
 
@@ -781,9 +806,11 @@ static unsigned int ldsid_pattern[] = {
 };
 
 static CORE_ADDR
-hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end, 
+hppa_hpux_search_pattern (struct gdbarch *gdbarch,
+                         CORE_ADDR start, CORE_ADDR end,
                          unsigned int *patterns, int count)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int num_insns = (end - start + HPPA_INSN_SIZE) / HPPA_INSN_SIZE;
   unsigned int *insns;
   gdb_byte *buf;
@@ -794,7 +821,7 @@ hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end,
 
   read_memory (start, buf, num_insns * HPPA_INSN_SIZE);
   for (i = 0; i < num_insns; i++, buf += HPPA_INSN_SIZE)
-    insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
+    insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
 
   for (offset = 0; offset <= num_insns - count; offset++)
     {
@@ -817,6 +844,7 @@ static CORE_ADDR
 hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
                                        int *argreg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct objfile *obj;
   struct obj_section *sec;
   struct hppa_objfile_private *priv;
@@ -849,7 +877,8 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
   u = find_unwind_entry (rp);
   if (u && u->stub_unwind.stub_type == EXPORT)
     {
-      addr = hppa_hpux_search_pattern (u->region_start, u->region_end, 
+      addr = hppa_hpux_search_pattern (gdbarch,
+                                      u->region_start, u->region_end,
                                       ldsid_pattern, 
                                       ARRAY_SIZE (ldsid_pattern));
       if (addr)
@@ -867,7 +896,8 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
          u = &priv->unwind_info->table[i];
          if (u->stub_unwind.stub_type == EXPORT)
            {
-             addr = hppa_hpux_search_pattern (u->region_start, u->region_end, 
+             addr = hppa_hpux_search_pattern (gdbarch,
+                                              u->region_start, u->region_end,
                                               ldsid_pattern, 
                                               ARRAY_SIZE (ldsid_pattern));
              if (addr)
@@ -890,7 +920,7 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
       find_pc_partial_function (addr, NULL, &start, &end);
       if (start != 0 && end != 0)
         {
-         addr = hppa_hpux_search_pattern (start, end, ldsid_pattern,
+         addr = hppa_hpux_search_pattern (gdbarch, start, end, ldsid_pattern,
                                           ARRAY_SIZE (ldsid_pattern));
          if (addr)
            goto found_pattern;
@@ -902,7 +932,7 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
 
 found_pattern:
   target_read_memory (addr, buf, sizeof (buf));
-  insn = extract_unsigned_integer (buf, sizeof (buf));
+  insn = extract_unsigned_integer (buf, sizeof (buf), byte_order);
   priv->dummy_call_sequence_addr = addr;
   priv->dummy_call_sequence_reg = (insn >> 21) & 0x1f;
 
@@ -914,6 +944,7 @@ static CORE_ADDR
 hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
                                        int *argreg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct objfile *obj;
   struct obj_section *sec;
   struct hppa_objfile_private *priv;
@@ -961,7 +992,8 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
            {
              unsigned int insn;
 
-             insn = extract_unsigned_integer (buf + offset, HPPA_INSN_SIZE);
+             insn = extract_unsigned_integer (buf + offset,
+                                              HPPA_INSN_SIZE, byte_order);
              if (insn == 0xe840d002) /* bve,n (rp) */
                {
                  addr = (end - sizeof (buf)) + offset;
@@ -1023,11 +1055,11 @@ hppa_hpux_find_import_stub_for_addr (CORE_ADDR funcaddr)
 }
 
 static int
-hppa_hpux_sr_for_addr (CORE_ADDR addr)
+hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   int sr;
   /* The space register to use is encoded in the top 2 bits of the address.  */
-  sr = addr >> (gdbarch_tdep (current_gdbarch)->bytes_per_address * 8 - 2);
+  sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
   return sr + 4;
 }
 
@@ -1056,9 +1088,9 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
     {
       /* First try the lowest address in the section; we can use it as long
          as it is "regular" code (i.e. not a stub) */
-      u = find_unwind_entry (sec->addr);
+      u = find_unwind_entry (obj_section_addr (sec));
       if (!u || u->stub_unwind.stub_type == 0)
-        return sec->addr;
+        return obj_section_addr (sec);
 
       /* Otherwise, we need to find a symbol for a regular function.  We
          do this by walking the list of msymbols in the objfile.  The symbol
@@ -1087,15 +1119,16 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
 
 static CORE_ADDR
 hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
-                          CORE_ADDR funcaddr, int using_gcc,
+                          CORE_ADDR funcaddr,
                           struct value **args, int nargs,
                           struct type *value_type,
-                          CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+                          CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+                          struct regcache *regcache)
 {
   CORE_ADDR pc, stubaddr;
   int argreg = 0;
 
-  pc = read_pc ();
+  pc = regcache_read_pc (regcache);
 
   /* Note: we don't want to pass a function descriptor here; push_dummy_call
      fills in the PIC register for us.  */
@@ -1103,12 +1136,13 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
 
   /* The simple case is where we call a function in the same space that we are
      currently in; in that case we don't really need to do anything.  */
-  if (hppa_hpux_sr_for_addr (pc) == hppa_hpux_sr_for_addr (funcaddr))
+  if (hppa_hpux_sr_for_addr (gdbarch, pc)
+      == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
     {
       /* Intraspace call.  */
       *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
       *real_pc = funcaddr;
-      regcache_cooked_write_unsigned (current_regcache, HPPA_RP_REGNUM, *bp_addr);
+      regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, *bp_addr);
 
       return sp;
     }
@@ -1186,18 +1220,18 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
       if (stubaddr == 0)
         error (_("Cannot call external function not referenced by application "
               "(no import stub).\n"));
-      regcache_cooked_write_unsigned (current_regcache, 22, stubaddr);
+      regcache_cooked_write_unsigned (regcache, 22, stubaddr);
 
       write_memory (sp, (char *)&hppa32_tramp, sizeof (hppa32_tramp));
 
       *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
-      regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr);
+      regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
 
       *real_pc = hppa32_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
       if (*real_pc == 0)
         error (_("Cannot make interspace call from here."));
 
-      regcache_cooked_write_unsigned (current_regcache, argreg, sp);
+      regcache_cooked_write_unsigned (regcache, argreg, sp);
 
       sp += sizeof (hppa32_tramp);
     }
@@ -1213,17 +1247,17 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
 
       /* for hppa64, we don't need to call through a stub; all functions
          return via a bve.  */
-      regcache_cooked_write_unsigned (current_regcache, 22, funcaddr);
+      regcache_cooked_write_unsigned (regcache, 22, funcaddr);
       write_memory (sp, (char *)&hppa64_tramp, sizeof (hppa64_tramp));
 
       *bp_addr = pc - 4;
-      regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr);
+      regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
 
       *real_pc = hppa64_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
       if (*real_pc == 0)
         error (_("Cannot make interspace call from here."));
 
-      regcache_cooked_write_unsigned (current_regcache, argreg, sp);
+      regcache_cooked_write_unsigned (regcache, argreg, sp);
 
       sp += sizeof (hppa64_tramp);
     }
@@ -1310,18 +1344,20 @@ hppa_hpux_supply_save_state (const struct regset *regset,
                             struct regcache *regcache,
                             int regnum, const void *regs, size_t len)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const char *proc_info = regs;
   const char *save_state = proc_info + 8;
   ULONGEST flags;
 
-  flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+  flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET,
+                                   4, byte_order);
   if (regnum == -1 || regnum == HPPA_FLAGS_REGNUM)
     {
-      struct gdbarch *arch = get_regcache_arch (regcache);
-      size_t size = register_size (arch, HPPA_FLAGS_REGNUM);
+      size_t size = register_size (gdbarch, HPPA_FLAGS_REGNUM);
       char buf[8];
 
-      store_unsigned_integer (buf, size, flags);
+      store_unsigned_integer (buf, size, byte_order, flags);
       regcache_raw_supply (regcache, HPPA_FLAGS_REGNUM, buf);
     }
 
@@ -1364,29 +1400,33 @@ hppa_hpux_regset_from_core_section (struct gdbarch *gdbarch,
 #define HPPA_HPUX_SS_INSYSCALL 0x02
 
 static CORE_ADDR
-hppa_hpux_read_pc (ptid_t ptid)
+hppa_hpux_read_pc (struct regcache *regcache)
 {
   ULONGEST flags;
 
   /* If we're currently in a system call return the contents of %r31.  */
-  flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
+  regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
   if (flags & HPPA_HPUX_SS_INSYSCALL)
-    return read_register_pid (HPPA_R31_REGNUM, ptid) & ~0x3;
+    {
+      ULONGEST pc;
+      regcache_cooked_read_unsigned (regcache, HPPA_R31_REGNUM, &pc);
+      return pc & ~0x3;
+    }
 
-  return hppa_read_pc (ptid);
+  return hppa_read_pc (regcache);
 }
 
 static void
-hppa_hpux_write_pc (CORE_ADDR pc, ptid_t ptid)
+hppa_hpux_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   ULONGEST flags;
 
   /* If we're currently in a system call also write PC into %r31.  */
-  flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
+  regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
   if (flags & HPPA_HPUX_SS_INSYSCALL)
-    write_register_pid (HPPA_R31_REGNUM, pc | 0x3, ptid);
+    regcache_cooked_write_unsigned (regcache, HPPA_R31_REGNUM, pc | 0x3);
 
-  return hppa_write_pc (pc, ptid);
+  hppa_write_pc (regcache, pc);
 }
 
 static CORE_ADDR
@@ -1405,38 +1445,38 @@ hppa_hpux_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 
 /* Given the current value of the pc, check to see if it is inside a stub, and
    if so, change the value of the pc to point to the caller of the stub.
-   NEXT_FRAME is the next frame in the current list of frames.
+   THIS_FRAME is the current frame in the current list of frames.
    BASE contains to stack frame base of the current frame. 
    SAVE_REGS is the register file stored in the frame cache. */
 static void
-hppa_hpux_unwind_adjust_stub (struct frame_info *next_frame, CORE_ADDR base,
+hppa_hpux_unwind_adjust_stub (struct frame_info *this_frame, CORE_ADDR base,
                              struct trad_frame_saved_reg *saved_regs)
 {
-  int optimized, realreg;
-  enum lval_type lval;
-  CORE_ADDR addr;
-  char buffer[sizeof(ULONGEST)];
-  ULONGEST val;
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+  struct value *pcoq_head_val;
+  ULONGEST pcoq_head;
   CORE_ADDR stubpc;
   struct unwind_table_entry *u;
 
-  trad_frame_get_prev_register (next_frame, saved_regs, 
-                               HPPA_PCOQ_HEAD_REGNUM, 
-                               &optimized, &lval, &addr, &realreg, buffer);
-  val = extract_unsigned_integer (buffer, 
-                                 register_size (get_frame_arch (next_frame), 
-                                                HPPA_PCOQ_HEAD_REGNUM));
+  pcoq_head_val = trad_frame_get_prev_register (this_frame, saved_regs, 
+                                               HPPA_PCOQ_HEAD_REGNUM);
+  pcoq_head =
+    extract_unsigned_integer (value_contents_all (pcoq_head_val),
+                             register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM),
+                             byte_order);
 
-  u = find_unwind_entry (val);
+  u = find_unwind_entry (pcoq_head);
   if (u && u->stub_unwind.stub_type == EXPORT)
     {
-      stubpc = read_memory_integer (base - 24, TARGET_PTR_BIT / 8);
+      stubpc = read_memory_integer (base - 24, word_size, byte_order);
       trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
     }
   else if (hppa_symbol_address ("__gcc_plt_call") 
-           == get_pc_function_start (val))
+           == get_pc_function_start (pcoq_head))
     {
-      stubpc = read_memory_integer (base - 8, TARGET_PTR_BIT / 8);
+      stubpc = read_memory_integer (base - 8, word_size, byte_order);
       trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
     }
 }
@@ -1469,7 +1509,7 @@ hppa_hpux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_regset_from_core_section
     (gdbarch, hppa_hpux_regset_from_core_section);
 
-  frame_unwind_append_sniffer (gdbarch, hppa_hpux_sigtramp_unwind_sniffer);
+  frame_unwind_append_unwinder (gdbarch, &hppa_hpux_sigtramp_frame_unwind);
 }
 
 static void
@@ -1482,7 +1522,7 @@ hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   tdep->find_global_pointer = hppa32_hpux_find_global_pointer;
 
   hppa_hpux_init_abi (info, gdbarch);
-  som_solib_select (tdep);
+  som_solib_select (gdbarch);
 }
 
 static void
@@ -1494,7 +1534,7 @@ hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   tdep->find_global_pointer = hppa64_hpux_find_global_pointer;
 
   hppa_hpux_init_abi (info, gdbarch);
-  pa64_solib_select (tdep);
+  pa64_solib_select (gdbarch);
 }
 
 static enum gdb_osabi
This page took 0.034755 seconds and 4 git commands to generate.