daily update
[deliverable/binutils-gdb.git] / gdb / hppa-tdep.c
index a4731acf277be0d482293d4d4f56433123f62455..38e38cee0641f4e69e8eb2af486879fc983c4afe 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, 2007, 2008
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
@@ -29,7 +29,6 @@
 #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"
@@ -231,6 +230,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
 
   if (size > 0)
     {
+      struct gdbarch *gdbarch = get_objfile_arch (objfile);
       unsigned long tmp;
       unsigned i;
       char *buf = alloca (size);
@@ -242,7 +242,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
         Note that when loading a shared library (text_offset != 0) the
         unwinds are already relative to the text_offset that will be
         passed in.  */
-      if (gdbarch_tdep (current_gdbarch)->is_elf && text_offset == 0)
+      if (gdbarch_tdep (gdbarch)->is_elf && text_offset == 0)
        {
           low_text_segment_address = -1;
 
@@ -252,9 +252,9 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
 
          text_offset = low_text_segment_address;
        }
-      else if (gdbarch_tdep (current_gdbarch)->solib_get_text_base)
+      else if (gdbarch_tdep (gdbarch)->solib_get_text_base)
         {
-         text_offset = gdbarch_tdep (current_gdbarch)->solib_get_text_base (objfile);
+         text_offset = gdbarch_tdep (gdbarch)->solib_get_text_base (objfile);
        }
 
       bfd_get_section_contents (objfile->obfd, section, buf, 0, size);
@@ -658,18 +658,19 @@ hppa64_register_name (struct gdbarch *gdbarch, int i)
     return names[i];
 }
 
+/* Map dwarf DBX register numbers to GDB register numbers.  */
 static int
 hppa64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  /* r0-r31 and sar map one-to-one.  */
+  /* The general registers and the sar are the same in both sets.  */
   if (reg <= 32)
     return reg;
 
   /* fr4-fr31 are mapped from 72 in steps of 2.  */
-  if (reg >= 72 || reg < 72 + 28 * 2)
+  if (reg >= 72 && reg < 72 + 28 * 2 && !(reg & 1))
     return HPPA64_FP4_REGNUM + (reg - 72) / 2;
 
-  error ("Invalid DWARF register num %d.", reg);
+  warning (_("Unmapped DWARF DBX Register #%d encountered."), reg);
   return -1;
 }
 
@@ -913,15 +914,17 @@ hppa64_convert_code_addr_to_fptr (CORE_ADDR code)
   ALL_OBJFILE_OSECTIONS (sec->objfile, opd)
     {
       if (strcmp (opd->the_bfd_section->name, ".opd") == 0)
-        break;
+       break;
     }
 
   if (opd < sec->objfile->sections_end)
     {
       CORE_ADDR addr;
 
-      for (addr = opd->addr; addr < opd->endaddr; addr += 2 * 8)
-        {
+      for (addr = obj_section_addr (opd);
+          addr < obj_section_endaddr (opd);
+          addr += 2 * 8)
+       {
          ULONGEST opdaddr;
          char tmp[8];
 
@@ -929,7 +932,7 @@ hppa64_convert_code_addr_to_fptr (CORE_ADDR code)
              break;
          opdaddr = extract_unsigned_integer (tmp, sizeof (tmp));
 
-          if (opdaddr == code)
+         if (opdaddr == code)
            return addr - 16;
        }
     }
@@ -1243,8 +1246,9 @@ hppa32_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
 {
   if (addr & 2)
     {
+      struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
       CORE_ADDR plabel = addr & ~3;
-      return read_memory_typed_address (plabel, builtin_type_void_func_ptr);
+      return read_memory_typed_address (plabel, func_ptr_type);
     }
 
   return addr;
@@ -1309,7 +1313,7 @@ hppa_alignof (struct type *type)
     case TYPE_CODE_FLT:
       return TYPE_LENGTH (type);
     case TYPE_CODE_ARRAY:
-      return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
+      return hppa_alignof (TYPE_INDEX_TYPE (type));
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
       max_align = 1;
@@ -1793,7 +1797,7 @@ hppa_find_unwind_entry_in_block (struct frame_info *this_frame)
   CORE_ADDR pc = get_frame_address_in_block (this_frame);
 
   /* FIXME drow/20070101: Calling gdbarch_addr_bits_remove on the
-     result of frame_unwind_address_in_block implies a problem.
+     result of get_frame_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
@@ -1895,9 +1899,9 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
        in hppa_skip_prologue will return a prologue end that is too early
        for us to notice any potential frame adjustments.  */
 
-    /* We used to use frame_func_unwind () to locate the beginning of the
-       function to pass to skip_prologue ().  However, when objects are 
-       compiled without debug symbols, frame_func_unwind can return the wrong 
+    /* We used to use get_frame_func to locate the beginning of the
+       function to pass to skip_prologue.  However, when objects are
+       compiled without debug symbols, get_frame_func can return the wrong
        function (or 0).  We can do better than that by using unwind records.  
        This only works if the Region_description of the unwind record
        indicates that it includes the entry point of the function.  
@@ -2662,7 +2666,7 @@ hppa64_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
 }
 
 static CORE_ADDR
-hppa_smash_text_address (CORE_ADDR addr)
+hppa_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   /* The low two bits of the PC on the PA contain the privilege level.
      Some genius implementing a (non-GCC) compiler apparently decided
@@ -2896,6 +2900,9 @@ hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name)
 CORE_ADDR
 hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
   int dp_rel;
 
@@ -2906,7 +2913,7 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 
       /* PLABELs have bit 30 set; if it's a PLABEL, then dereference it.  */
       if (pc & 0x2)
-       pc = read_memory_typed_address (pc & ~0x3, builtin_type_void_func_ptr);
+       pc = read_memory_typed_address (pc & ~0x3, func_ptr_type);
 
       return pc;
     }
@@ -2927,7 +2934,7 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 
   if (in_plt_section (pc, NULL))
     {
-      pc = read_memory_typed_address (pc, builtin_type_void_func_ptr);
+      pc = read_memory_typed_address (pc, func_ptr_type);
 
       /* If the PLT slot has not yet been resolved, the target will be
          the PLT stub.  */
@@ -2941,7 +2948,7 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
            }
 
          /* This should point to the fixup routine.  */
-         pc = read_memory_typed_address (pc + 8, builtin_type_void_func_ptr);
+         pc = read_memory_typed_address (pc + 8, func_ptr_type);
        }
     }
 
@@ -3035,7 +3042,6 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
         set_gdbarch_num_regs (gdbarch, hppa64_num_regs);
         set_gdbarch_register_name (gdbarch, hppa64_register_name);
         set_gdbarch_register_type (gdbarch, hppa64_register_type);
-        set_gdbarch_dwarf_reg_to_regnum (gdbarch, hppa64_dwarf_reg_to_regnum);
         set_gdbarch_dwarf2_reg_to_regnum (gdbarch, hppa64_dwarf_reg_to_regnum);
        set_gdbarch_cannot_store_register (gdbarch,
                                           hppa64_cannot_store_register);
This page took 0.026413 seconds and 4 git commands to generate.