* target-memory.c (blocks_to_erase): Correct off-by-one error.
[deliverable/binutils-gdb.git] / gdb / hppa-tdep.c
index d089c5d972f5a03aae1f669d6a647b35467e0cdd..8a05c7379732323fefd6f87e6d5a7fe9feca8dc6 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for the HP PA-RISC architecture.
 
-   Copyright (C) 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
@@ -31,6 +31,7 @@
 #include "completer.h"
 #include "osabi.h"
 #include "gdb_assert.h"
+#include "gdb_stdint.h"
 #include "arch-utils.h"
 /* For argument passing to the inferior */
 #include "symtab.h"
@@ -41,6 +42,7 @@
 
 #include "gdbcore.h"
 #include "gdbcmd.h"
+#include "gdbtypes.h"
 #include "objfiles.h"
 #include "hppa-tdep.h"
 
@@ -280,7 +282,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
          table[i].Millicode = (tmp >> 30) & 0x1;
          table[i].Millicode_save_sr0 = (tmp >> 29) & 0x1;
          table[i].Region_description = (tmp >> 27) & 0x3;
-         table[i].reserved1 = (tmp >> 26) & 0x1;
+         table[i].reserved = (tmp >> 26) & 0x1;
          table[i].Entry_SR = (tmp >> 25) & 0x1;
          table[i].Entry_FR = (tmp >> 21) & 0xf;
          table[i].Entry_GR = (tmp >> 16) & 0x1f;
@@ -290,23 +292,23 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
          table[i].Frame_Extension_Millicode = (tmp >> 12) & 0x1;
          table[i].Stack_Overflow_Check = (tmp >> 11) & 0x1;
          table[i].Two_Instruction_SP_Increment = (tmp >> 10) & 0x1;
-         table[i].Ada_Region = (tmp >> 9) & 0x1;
+         table[i].sr4export = (tmp >> 9) & 0x1;
          table[i].cxx_info = (tmp >> 8) & 0x1;
          table[i].cxx_try_catch = (tmp >> 7) & 0x1;
          table[i].sched_entry_seq = (tmp >> 6) & 0x1;
-         table[i].reserved2 = (tmp >> 5) & 0x1;
+         table[i].reserved1 = (tmp >> 5) & 0x1;
          table[i].Save_SP = (tmp >> 4) & 0x1;
          table[i].Save_RP = (tmp >> 3) & 0x1;
          table[i].Save_MRP_in_frame = (tmp >> 2) & 0x1;
-         table[i].extn_ptr_defined = (tmp >> 1) & 0x1;
+         table[i].save_r19 = (tmp >> 1) & 0x1;
          table[i].Cleanup_defined = tmp & 0x1;
          tmp = bfd_get_32 (objfile->obfd, (bfd_byte *) buf);
          buf += 4;
          table[i].MPE_XL_interrupt_marker = (tmp >> 31) & 0x1;
          table[i].HP_UX_interrupt_marker = (tmp >> 30) & 0x1;
          table[i].Large_frame = (tmp >> 29) & 0x1;
-         table[i].Pseudo_SP_Set = (tmp >> 28) & 0x1;
-         table[i].reserved4 = (tmp >> 27) & 0x1;
+         table[i].alloca_frame = (tmp >> 28) & 0x1;
+         table[i].reserved2 = (tmp >> 27) & 0x1;
          table[i].Total_frame_size = tmp & 0x7ffffff;
 
          /* Stub unwinds are handled elsewhere. */
@@ -501,7 +503,7 @@ find_unwind_entry (CORE_ADDR pc)
       {
        if (hppa_debug)
          fprintf_unfiltered (gdb_stdlog, "0x%s (cached) }\n",
-            paddr_nz ((CORE_ADDR) ui->cache));
+            paddr_nz ((uintptr_t) ui->cache));
         return ui->cache;
       }
 
@@ -519,7 +521,7 @@ find_unwind_entry (CORE_ADDR pc)
            ui->cache = &ui->table[middle];
            if (hppa_debug)
              fprintf_unfiltered (gdb_stdlog, "0x%s }\n",
-                paddr_nz ((CORE_ADDR) ui->cache));
+                paddr_nz ((uintptr_t) ui->cache));
            return &ui->table[middle];
          }
 
@@ -549,7 +551,7 @@ hppa_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   char buf[4];
   int off;
 
-  status = deprecated_read_memory_nobpt (pc, buf, 4);
+  status = read_memory_nobpt (pc, buf, 4);
   if (status != 0)
     return 0;
 
@@ -1555,7 +1557,7 @@ restart:
       old_save_sp = save_sp;
       old_stack_remaining = stack_remaining;
 
-      status = deprecated_read_memory_nobpt (pc, buf, 4);
+      status = read_memory_nobpt (pc, buf, 4);
       inst = extract_unsigned_integer (buf, 4);
 
       /* Yow! */
@@ -1604,7 +1606,7 @@ restart:
          while (reg_num >= (TARGET_PTR_BIT == 64 ? 19 : 23) && reg_num <= 26)
            {
              pc += 4;
-             status = deprecated_read_memory_nobpt (pc, buf, 4);
+             status = read_memory_nobpt (pc, buf, 4);
              inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
@@ -1617,7 +1619,7 @@ restart:
       reg_num = inst_saves_fr (inst);
       save_fr &= ~(1 << reg_num);
 
-      status = deprecated_read_memory_nobpt (pc + 4, buf, 4);
+      status = read_memory_nobpt (pc + 4, buf, 4);
       next_inst = extract_unsigned_integer (buf, 4);
 
       /* Yow! */
@@ -1644,13 +1646,13 @@ restart:
          while (reg_num >= 4 && reg_num <= (TARGET_PTR_BIT == 64 ? 11 : 7))
            {
              pc += 8;
-             status = deprecated_read_memory_nobpt (pc, buf, 4);
+             status = read_memory_nobpt (pc, buf, 4);
              inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
              if ((inst & 0xfc000000) != 0x34000000)
                break;
-             status = deprecated_read_memory_nobpt (pc + 4, buf, 4);
+             status = read_memory_nobpt (pc + 4, buf, 4);
              next_inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
@@ -1782,6 +1784,22 @@ hppa_skip_prologue (CORE_ADDR pc)
     return (skip_prologue_hard_way (pc, 1));
 }
 
+/* Return an unwind entry that falls within the frame's code block.  */
+static struct unwind_table_entry *
+hppa_find_unwind_entry_in_block (struct frame_info *f)
+{
+  CORE_ADDR pc = frame_unwind_address_in_block (f, NORMAL_FRAME);
+
+  /* FIXME drow/20070101: Calling gdbarch_addr_bits_remove on the
+     result of frame_unwind_address_in_block implies a problem.
+     The bits should have been removed earlier, before the return
+     value of frame_pc_unwind.  That might be happening already;
+     if it isn't, it should be fixed.  Then this call can be
+     removed.  */
+  pc = gdbarch_addr_bits_remove (get_frame_arch (f), pc);
+  return find_unwind_entry (pc);
+}
+
 struct hppa_frame_cache
 {
   CORE_ADDR base;
@@ -1817,7 +1835,7 @@ hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
   /* Yow! */
-  u = find_unwind_entry (frame_pc_unwind (next_frame));
+  u = hppa_find_unwind_entry_in_block (next_frame);
   if (!u)
     {
       if (hppa_debug)
@@ -1887,7 +1905,7 @@ hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
     if ((u->Region_description & 0x2) == 0)
       start_pc = u->region_start;
     else
-      start_pc = frame_func_unwind (next_frame);
+      start_pc = frame_func_unwind (next_frame, NORMAL_FRAME);
 
     prologue_end = skip_prologue_hard_way (start_pc, 0);
     end_pc = frame_pc_unwind (next_frame);
@@ -2065,11 +2083,11 @@ hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
  
      fp = frame_unwind_register_unsigned (next_frame, HPPA_FP_REGNUM);
 
-     if (u->Pseudo_SP_Set)
+     if (u->alloca_frame)
        fp -= u->Total_frame_size << 3;
  
      if (frame_pc_unwind (next_frame) >= prologue_end
-         && (u->Save_SP || u->Pseudo_SP_Set) && fp != 0)
+         && (u->Save_SP || u->alloca_frame) && fp != 0)
       {
        cache->base = fp;
  
@@ -2162,7 +2180,7 @@ hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
   {
     /* Convert all the offsets into addresses.  */
     int reg;
-    for (reg = 0; reg < NUM_REGS; reg++)
+    for (reg = 0; reg < gdbarch_num_regs (current_gdbarch); reg++)
       {
        if (trad_frame_addr_p (cache->saved_regs, reg))
          cache->saved_regs[reg].addr += cache->base;
@@ -2197,7 +2215,7 @@ hppa_frame_this_id (struct frame_info *next_frame, void **this_cache,
   struct unwind_table_entry *u;
 
   info = hppa_frame_cache (next_frame, this_cache);
-  u = find_unwind_entry (pc);
+  u = hppa_find_unwind_entry_in_block (next_frame);
 
   (*this_id) = frame_id_build (info->base, u->region_start);
 }
@@ -2224,9 +2242,7 @@ static const struct frame_unwind hppa_frame_unwind =
 static const struct frame_unwind *
 hppa_frame_unwind_sniffer (struct frame_info *next_frame)
 {
-  CORE_ADDR pc = frame_pc_unwind (next_frame);
-
-  if (find_unwind_entry (pc))
+  if (hppa_find_unwind_entry_in_block (next_frame))
     return &hppa_frame_unwind;
 
   return NULL;
@@ -2257,7 +2273,7 @@ hppa_fallback_frame_cache (struct frame_info *next_frame, void **this_cache)
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
-  start_pc = frame_func_unwind (next_frame);
+  start_pc = frame_func_unwind (next_frame, NORMAL_FRAME);
   if (start_pc)
     {
       CORE_ADDR cur_pc = frame_pc_unwind (next_frame);
@@ -2316,7 +2332,8 @@ hppa_fallback_frame_this_id (struct frame_info *next_frame, void **this_cache,
 {
   struct hppa_frame_cache *info = 
     hppa_fallback_frame_cache (next_frame, this_cache);
-  (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame));
+  (*this_id) = frame_id_build (info->base,
+                              frame_func_unwind (next_frame, NORMAL_FRAME));
 }
 
 static void
@@ -2399,7 +2416,8 @@ hppa_stub_frame_this_id (struct frame_info *next_frame,
     = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
 
   if (info)
-    *this_id = frame_id_build (info->base, frame_func_unwind (next_frame));
+    *this_id = frame_id_build (info->base,
+                              frame_func_unwind (next_frame, NORMAL_FRAME));
   else
     *this_id = null_frame_id;
 }
@@ -2431,7 +2449,7 @@ static const struct frame_unwind hppa_stub_frame_unwind = {
 static const struct frame_unwind *
 hppa_stub_unwind_sniffer (struct frame_info *next_frame)
 {
-  CORE_ADDR pc = frame_pc_unwind (next_frame);
+  CORE_ADDR pc = frame_unwind_address_in_block (next_frame, NORMAL_FRAME);
   struct gdbarch *gdbarch = get_frame_arch (next_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
@@ -2540,15 +2558,19 @@ unwind_command (char *exp, int from_tty)
   pif (Frame_Extension_Millicode);
   pif (Stack_Overflow_Check);
   pif (Two_Instruction_SP_Increment);
-  pif (Ada_Region);
+  pif (sr4export);
+  pif (cxx_info);
+  pif (cxx_try_catch);
+  pif (sched_entry_seq);
   pif (Save_SP);
   pif (Save_RP);
   pif (Save_MRP_in_frame);
-  pif (extn_ptr_defined);
+  pif (save_r19);
   pif (Cleanup_defined);
   pif (MPE_XL_interrupt_marker);
   pif (HP_UX_interrupt_marker);
   pif (Large_frame);
+  pif (alloca_frame);
 
   putchar_unfiltered ('\n');
 
@@ -2622,7 +2644,7 @@ hppa32_register_type (struct gdbarch *gdbarch, int regnum)
    if (regnum < HPPA_FP4_REGNUM)
      return builtin_type_uint32;
    else
-     return builtin_type_ieee_single_big;
+     return builtin_type_ieee_single;
 }
 
 static struct type *
@@ -2631,7 +2653,7 @@ hppa64_register_type (struct gdbarch *gdbarch, int regnum)
    if (regnum < HPPA64_FP4_REGNUM)
      return builtin_type_uint64;
    else
-     return builtin_type_ieee_double_big;
+     return builtin_type_ieee_double;
 }
 
 /* Return non-zero if REGNUM is not a register available to the user
@@ -2842,7 +2864,7 @@ hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
     {
       gdb_byte buf[HPPA_INSN_SIZE];
 
-      deprecated_read_memory_nobpt (npc, buf, HPPA_INSN_SIZE);
+      read_memory_nobpt (npc, buf, HPPA_INSN_SIZE);
       insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
       if ((insn[i] & pattern[i].mask) == pattern[i].data)
         npc += 4;
@@ -3072,7 +3094,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      and LP64, but might show differences some day.  */
   set_gdbarch_long_long_bit (gdbarch, 64);
   set_gdbarch_long_double_bit (gdbarch, 128);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
 
   /* The following gdbarch vector elements do not depend on the address
      size, or in any other gdbarch element previously set.  */
This page took 0.028591 seconds and 4 git commands to generate.