* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
[deliverable/binutils-gdb.git] / gdb / ia64-tdep.c
index ec0d14ebbae05f3bc0bbb8a2d948b317f0a0eb90..d5daf5064cca5814eb00b84678b2c60cc211685f 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for the IA-64 for GDB, the GNU debugger.
 
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-   Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -110,6 +110,12 @@ typedef enum instruction_type
 
 #define BUNDLE_LEN 16
 
+/* See the saved memory layout comment for ia64_memory_insert_breakpoint.  */
+
+#if BREAKPOINT_MAX < BUNDLE_LEN - 2
+# error "BREAKPOINT_MAX < BUNDLE_LEN - 2"
+#endif
+
 static gdbarch_init_ftype ia64_gdbarch_init;
 
 static gdbarch_register_name_ftype ia64_register_name;
@@ -119,8 +125,6 @@ static gdbarch_skip_prologue_ftype ia64_skip_prologue;
 static struct type *is_float_or_hfa_type (struct type *t);
 static CORE_ADDR ia64_find_global_pointer (CORE_ADDR faddr);
 
-static struct type *builtin_type_ia64_ext;
-
 #define NUM_IA64_RAW_REGS 462
 
 static int sp_regnum = IA64_GR12_REGNUM;
@@ -274,7 +278,38 @@ struct ia64_frame_cache
 
 };
 
-int
+static int
+floatformat_valid (const struct floatformat *fmt, const void *from)
+{
+  return 1;
+}
+
+static const struct floatformat floatformat_ia64_ext =
+{
+  floatformat_little, 82, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+  floatformat_intbit_yes, "floatformat_ia64_ext", floatformat_valid, NULL
+};
+
+static const struct floatformat *floatformats_ia64_ext[2] =
+{
+  &floatformat_ia64_ext,
+  &floatformat_ia64_ext
+};
+
+static struct type *
+ia64_ext_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (!tdep->ia64_ext_type)
+    tdep->ia64_ext_type
+      = arch_float_type (gdbarch, 128, "builtin_type_ia64_ext",
+                        floatformats_ia64_ext);
+
+  return tdep->ia64_ext_type;
+}
+
+static int
 ia64_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
                          struct reggroup *group)
 {
@@ -307,9 +342,9 @@ struct type *
 ia64_register_type (struct gdbarch *arch, int reg)
 {
   if (reg >= IA64_FR0_REGNUM && reg <= IA64_FR127_REGNUM)
-    return builtin_type_ia64_ext;
+    return ia64_ext_type (arch);
   else
-    return builtin_type_long;
+    return builtin_type (arch)->builtin_long;
 }
 
 static int
@@ -320,24 +355,6 @@ ia64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
   return reg;
 }
 
-static int
-floatformat_valid (const struct floatformat *fmt, const void *from)
-{
-  return 1;
-}
-
-const struct floatformat floatformat_ia64_ext =
-{
-  floatformat_little, 82, 0, 1, 17, 65535, 0x1ffff, 18, 64,
-  floatformat_intbit_yes, "floatformat_ia64_ext", floatformat_valid, NULL
-};
-
-const struct floatformat *floatformats_ia64_ext[2] =
-{
-  &floatformat_ia64_ext,
-  &floatformat_ia64_ext
-};
-
 
 /* Extract ``len'' bits from an instruction bundle starting at
    bit ``from''.  */
@@ -442,7 +459,7 @@ replace_slotN_contents (char *bundle, long long instr, int slotnum)
   replace_bit_field (bundle, instr, 5+41*slotnum, 41);
 }
 
-static enum instruction_type template_encoding_table[32][3] =
+static const enum instruction_type template_encoding_table[32][3] =
 {
   { M, I, I },                         /* 00 */
   { M, I, I },                         /* 01 */
@@ -545,11 +562,46 @@ fetch_instruction (CORE_ADDR addr, instruction_type *it, long long *instr)
    simulators.  So I changed the pattern slightly to do "break.i 0x080001"
    instead.  But that didn't work either (I later found out that this
    pattern was used by the simulator that I was using.)  So I ended up
-   using the pattern seen below. */
+   using the pattern seen below.
+
+   SHADOW_CONTENTS has byte-based addressing (PLACED_ADDRESS and SHADOW_LEN)
+   while we need bit-based addressing as the instructions length is 41 bits and
+   we must not modify/corrupt the adjacent slots in the same bundle.
+   Fortunately we may store larger memory incl. the adjacent bits with the
+   original memory content (not the possibly already stored breakpoints there).
+   We need to be careful in ia64_memory_remove_breakpoint to always restore
+   only the specific bits of this instruction ignoring any adjacent stored
+   bits.
+
+   We use the original addressing with the low nibble in the range <0..2> which
+   gets incorrectly interpreted by generic non-ia64 breakpoint_restore_shadows
+   as the direct byte offset of SHADOW_CONTENTS.  We store whole BUNDLE_LEN
+   bytes just without these two possibly skipped bytes to not to exceed to the
+   next bundle.
+
+   If we would like to store the whole bundle to SHADOW_CONTENTS we would have
+   to store already the base address (`address & ~0x0f') into PLACED_ADDRESS.
+   In such case there is no other place where to store
+   SLOTNUM (`adress & 0x0f', value in the range <0..2>).  We need to know
+   SLOTNUM in ia64_memory_remove_breakpoint.
+
+   ia64 16-byte bundle layout:
+   | 5 bits | slot 0 with 41 bits | slot 1 with 41 bits | slot 2 with 41 bits |
+   
+   The current addressing used by the code below:
+   original PC   placed_address   placed_size             required    covered
+                                  == bp_tgt->shadow_len   reqd \subset covered
+   0xABCDE0      0xABCDE0         0xE                     <0x0...0x5> <0x0..0xD>
+   0xABCDE1      0xABCDE1         0xE                     <0x5...0xA> <0x1..0xE>
+   0xABCDE2      0xABCDE2         0xE                     <0xA...0xF> <0x2..0xF>
+   
+   `objdump -d' and some other tools show a bit unjustified offsets:
+   original PC   byte where starts the instruction   objdump offset
+   0xABCDE0      0xABCDE0                            0xABCDE0
+   0xABCDE1      0xABCDE5                            0xABCDE6
+   0xABCDE2      0xABCDEA                            0xABCDEC
+   */
 
-#if 0
-#define IA64_BREAKPOINT 0x00002000040LL
-#endif
 #define IA64_BREAKPOINT 0x00003333300LL
 
 static int
@@ -557,34 +609,55 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch,
                               struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
-  char bundle[BUNDLE_LEN];
+  gdb_byte bundle[BUNDLE_LEN];
   int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
-  long long instr;
+  long long instr_breakpoint;
   int val;
   int template;
+  struct cleanup *cleanup;
 
   if (slotnum > 2)
     error (_("Can't insert breakpoint for slot numbers greater than 2."));
 
   addr &= ~0x0f;
 
+  /* Disable the automatic memory restoration from breakpoints while
+     we read our instruction bundle.  Otherwise, the general restoration
+     mechanism kicks in and we would possibly remove parts of the adjacent
+     placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping the real
+     breakpoint instruction bits region.  */
+  cleanup = make_show_memory_breakpoints_cleanup (1);
   val = target_read_memory (addr, bundle, BUNDLE_LEN);
 
-  /* Check for L type instruction in 2nd slot, if present then
-     bump up the slot number to the 3rd slot */
+  /* Check for L type instruction in slot 1, if present then bump up the slot
+     number to the slot 2.  */
   template = extract_bit_field (bundle, 0, 5);
-  if (slotnum == 1 && template_encoding_table[template][1] == L)
-    {
-      slotnum = 2;
-    }
-
-  instr = slotN_contents (bundle, slotnum);
-  memcpy (bp_tgt->shadow_contents, &instr, sizeof (instr));
-  bp_tgt->placed_size = bp_tgt->shadow_len = sizeof (instr);
+  if (slotnum == 1 && template_encoding_table[template][slotnum] == L)
+    slotnum = 2;
+
+  /* Slot number 2 may skip at most 2 bytes at the beginning.  */
+  bp_tgt->placed_size = bp_tgt->shadow_len = BUNDLE_LEN - 2;
+
+  /* Store the whole bundle, except for the initial skipped bytes by the slot
+     number interpreted as bytes offset in PLACED_ADDRESS.  */
+  memcpy (bp_tgt->shadow_contents, bundle + slotnum, bp_tgt->shadow_len);
+
+  /* Breakpoints already present in the code will get deteacted and not get
+     reinserted by bp_loc_is_permanent.  Multiple breakpoints at the same
+     location cannot induce the internal error as they are optimized into
+     a single instance by update_global_location_list.  */
+  instr_breakpoint = slotN_contents (bundle, slotnum);
+  if (instr_breakpoint == IA64_BREAKPOINT)
+    internal_error (__FILE__, __LINE__,
+                   _("Address %s already contains a breakpoint."),
+                   paddr_nz (bp_tgt->placed_address));
   replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
+
   if (val == 0)
-    target_write_memory (addr, bundle, BUNDLE_LEN);
+    val = target_write_memory (addr + slotnum, bundle + slotnum,
+                              bp_tgt->shadow_len);
 
+  do_cleanups (cleanup);
   return val;
 }
 
@@ -593,9 +666,9 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
                               struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
-  char bundle[BUNDLE_LEN];
+  gdb_byte bundle_mem[BUNDLE_LEN], bundle_saved[BUNDLE_LEN];
   int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
-  long long instr;
+  long long instr_breakpoint, instr_saved;
   int val;
   int template;
   struct cleanup *cleanup;
@@ -604,40 +677,96 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
 
   /* Disable the automatic memory restoration from breakpoints while
      we read our instruction bundle.  Otherwise, the general restoration
-     mechanism kicks in and ends up corrupting our bundle, because it
-     is not aware of the concept of instruction bundles.  */
+     mechanism kicks in and we would possibly remove parts of the adjacent
+     placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping the real
+     breakpoint instruction bits region.  */
   cleanup = make_show_memory_breakpoints_cleanup (1);
-  val = target_read_memory (addr, bundle, BUNDLE_LEN);
+  val = target_read_memory (addr, bundle_mem, BUNDLE_LEN);
 
-  /* Check for L type instruction in 2nd slot, if present then
-     bump up the slot number to the 3rd slot */
-  template = extract_bit_field (bundle, 0, 5);
-  if (slotnum == 1 && template_encoding_table[template][1] == L)
+  /* Check for L type instruction in slot 1, if present then bump up the slot
+     number to the slot 2.  */
+  template = extract_bit_field (bundle_mem, 0, 5);
+  if (slotnum == 1 && template_encoding_table[template][slotnum] == L)
+    slotnum = 2;
+
+  gdb_assert (bp_tgt->placed_size == BUNDLE_LEN - 2);
+  gdb_assert (bp_tgt->placed_size == bp_tgt->shadow_len);
+
+  instr_breakpoint = slotN_contents (bundle_mem, slotnum);
+  if (instr_breakpoint != IA64_BREAKPOINT)
     {
-      slotnum = 2;
+      warning (_("Cannot remove breakpoint at address %s, "
+                "no break instruction at such address."),
+              paddr_nz (bp_tgt->placed_address));
+      return -1;
     }
 
-  memcpy (&instr, bp_tgt->shadow_contents, sizeof instr);
-  replace_slotN_contents (bundle, instr, slotnum);
+  /* Extract the original saved instruction from SLOTNUM normalizing its
+     bit-shift for INSTR_SAVED.  */
+  memcpy (bundle_saved, bundle_mem, BUNDLE_LEN);
+  memcpy (bundle_saved + slotnum, bp_tgt->shadow_contents, bp_tgt->shadow_len);
+  instr_saved = slotN_contents (bundle_saved, slotnum);
+
+  /* In BUNDLE_MEM be careful to modify only the bits belonging to SLOTNUM and
+     never any other possibly also stored in SHADOW_CONTENTS.  */
+  replace_slotN_contents (bundle_mem, instr_saved, slotnum);
   if (val == 0)
-    target_write_memory (addr, bundle, BUNDLE_LEN);
+    val = target_write_memory (addr, bundle_mem, BUNDLE_LEN);
 
   do_cleanups (cleanup);
   return val;
 }
 
-/* We don't really want to use this, but remote.c needs to call it in order
-   to figure out if Z-packets are supported or not.  Oh, well. */
-const unsigned char *
+/* As gdbarch_breakpoint_from_pc ranges have byte granularity and ia64
+   instruction slots ranges are bit-granular (41 bits) we have to provide an
+   extended range as described for ia64_memory_insert_breakpoint.  We also take
+   care of preserving the `break' instruction 21-bit (or 62-bit) parameter to
+   make a match for permanent breakpoints.  */
+
+static const gdb_byte *
 ia64_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
 {
-  static unsigned char breakpoint[] =
-    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-  *lenptr = sizeof (breakpoint);
-#if 0
-  *pcptr &= ~0x0f;
-#endif
-  return breakpoint;
+  CORE_ADDR addr = *pcptr;
+  static gdb_byte bundle[BUNDLE_LEN];
+  int slotnum = (int) (*pcptr & 0x0f) / SLOT_MULTIPLIER;
+  long long instr_fetched;
+  int val;
+  int template;
+  struct cleanup *cleanup;
+
+  if (slotnum > 2)
+    error (_("Can't insert breakpoint for slot numbers greater than 2."));
+
+  addr &= ~0x0f;
+
+  /* Enable the automatic memory restoration from breakpoints while
+     we read our instruction bundle to match bp_loc_is_permanent.  */
+  cleanup = make_show_memory_breakpoints_cleanup (0);
+  val = target_read_memory (addr, bundle, BUNDLE_LEN);
+  do_cleanups (cleanup);
+
+  /* The memory might be unreachable.  This can happen, for instance,
+     when the user inserts a breakpoint at an invalid address.  */
+  if (val != 0)
+    return NULL;
+
+  /* Check for L type instruction in slot 1, if present then bump up the slot
+     number to the slot 2.  */
+  template = extract_bit_field (bundle, 0, 5);
+  if (slotnum == 1 && template_encoding_table[template][slotnum] == L)
+    slotnum = 2;
+
+  /* A break instruction has its all its opcode bits cleared except for
+     the parameter value.  For L+X slot pair we are at the X slot (slot 2) so
+     we should not touch the L slot - the upper 41 bits of the parameter.  */
+  instr_fetched = slotN_contents (bundle, slotnum);
+  instr_fetched &= 0x1003ffffc0LL;
+  replace_slotN_contents (bundle, instr_fetched, slotnum);
+
+  *lenptr = BUNDLE_LEN - 2;
+
+  /* SLOTNUM is possibly already locally modified - use caller's *PCPTR.  */
+  return bundle + (*pcptr & 0x0f);
 }
 
 static CORE_ADDR
@@ -930,24 +1059,26 @@ static int
 ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
 {
   return (regno >= IA64_FR0_REGNUM && regno <= IA64_FR127_REGNUM
-         && type != builtin_type_ia64_ext);
+         && type != ia64_ext_type (gdbarch));
 }
 
 static void
 ia64_register_to_value (struct frame_info *frame, int regnum,
                          struct type *valtype, gdb_byte *out)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   char in[MAX_REGISTER_SIZE];
   frame_register_read (frame, regnum, in);
-  convert_typed_floating (in, builtin_type_ia64_ext, out, valtype);
+  convert_typed_floating (in, ia64_ext_type (gdbarch), out, valtype);
 }
 
 static void
 ia64_value_to_register (struct frame_info *frame, int regnum,
                          struct type *valtype, const gdb_byte *in)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   char out[MAX_REGISTER_SIZE];
-  convert_typed_floating (in, valtype, out, builtin_type_ia64_ext);
+  convert_typed_floating (in, valtype, out, ia64_ext_type (gdbarch));
   put_frame_register (frame, regnum, out);
 }
 
@@ -1599,10 +1730,11 @@ ia64_frame_this_id (struct frame_info *this_frame, void **this_cache,
     (*this_id) = frame_id_build_special (cache->base, cache->pc, cache->bsp);
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
-                       "regular frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %p\n",
+                       "regular frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %s\n",
                        paddr_nz (this_id->code_addr), 
                        paddr_nz (this_id->stack_addr), 
-                       paddr_nz (cache->bsp), this_frame);
+                       paddr_nz (cache->bsp),
+                       host_address_to_string (this_frame));
 }
 
 static struct value *
@@ -1954,10 +2086,11 @@ ia64_sigtramp_frame_this_id (struct frame_info *this_frame,
                                        cache->bsp);
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
-                       "sigtramp frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %p\n",
+                       "sigtramp frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %s\n",
                        paddr_nz (this_id->code_addr), 
                        paddr_nz (this_id->stack_addr), 
-                       paddr_nz (cache->bsp), this_frame);
+                       paddr_nz (cache->bsp),
+                       host_address_to_string (this_frame));
 }
 
 static struct value *
@@ -2396,7 +2529,7 @@ get_kernel_table (unw_word_t ip, unw_dyn_info_t *di)
                        "segbase=0x%s, length=%s, gp=0x%s\n",
                        (char *) di->u.ti.name_ptr, 
                        paddr_nz (di->u.ti.segbase), 
-                       paddr_u (di->u.ti.table_len), 
+                       pulongest (di->u.ti.table_len), 
                        paddr_nz (di->gp));
   return 0;
 }
@@ -2505,7 +2638,7 @@ ia64_find_proc_info_x (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
                            paddr_nz (di.u.ti.segbase), 
                            paddr_nz (di.start_ip), paddr_nz (di.end_ip),
                            paddr_nz (di.gp), 
-                           paddr_u (di.u.ti.table_len), 
+                           pulongest (di.u.ti.table_len), 
                            paddr_nz ((CORE_ADDR)di.u.ti.table_data));
     }
   else
@@ -2522,7 +2655,7 @@ ia64_find_proc_info_x (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
                            paddr_nz (di.u.rti.segbase), 
                            paddr_nz (di.start_ip), paddr_nz (di.end_ip),
                            paddr_nz (di.gp), 
-                           paddr_u (di.u.rti.table_len), 
+                           pulongest (di.u.rti.table_len), 
                            paddr_nz (di.u.rti.table_data));
     }
 
@@ -2563,7 +2696,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
       void *buf = NULL;
 
       text_sec = objfile->sections + SECT_OFF_TEXT (objfile);
-      ip = text_sec->addr;
+      ip = obj_section_addr (text_sec);
       ret = ia64_find_unwind_table (objfile, ip, &di, &buf);
       if (ret >= 0)
        {
@@ -2615,9 +2748,10 @@ ia64_libunwind_frame_this_id (struct frame_info *this_frame, void **this_cache,
 
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
-                       "libunwind frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %p\n",
+                       "libunwind frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %s\n",
                        paddr_nz (id.code_addr), paddr_nz (id.stack_addr), 
-                       paddr_nz (bsp), this_frame);
+                       paddr_nz (bsp),
+                       host_address_to_string (this_frame));
 }
 
 static struct value *
@@ -2740,9 +2874,10 @@ ia64_libunwind_sigtramp_frame_this_id (struct frame_info *this_frame,
 
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
-                       "libunwind sigtramp frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %p\n",
+                       "libunwind sigtramp frame id: code 0x%s, stack 0x%s, special 0x%s, this_frame %s\n",
                        paddr_nz (id.code_addr), paddr_nz (id.stack_addr), 
-                       paddr_nz (bsp), this_frame);
+                       paddr_nz (bsp),
+                       host_address_to_string (this_frame));
 }
 
 static struct value *
@@ -2863,6 +2998,7 @@ static void
 ia64_extract_return_value (struct type *type, struct regcache *regcache,
                           gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct type *float_elt_type;
 
   float_elt_type = is_float_or_hfa_type (type);
@@ -2876,7 +3012,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
       while (n-- > 0)
        {
          regcache_cooked_read (regcache, regnum, from);
-         convert_typed_floating (from, builtin_type_ia64_ext,
+         convert_typed_floating (from, ia64_ext_type (gdbarch),
                                  (char *)valbuf + offset, float_elt_type);       
          offset += TYPE_LENGTH (float_elt_type);
          regnum++;
@@ -2887,8 +3023,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
       ULONGEST val;
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
-      int reglen = TYPE_LENGTH (register_type (get_regcache_arch (regcache),
-                                              IA64_GR8_REGNUM));
+      int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
       int n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
@@ -2913,6 +3048,7 @@ static void
 ia64_store_return_value (struct type *type, struct regcache *regcache, 
                         const gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct type *float_elt_type;
 
   float_elt_type = is_float_or_hfa_type (type);
@@ -2926,7 +3062,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache,
       while (n-- > 0)
        {
          convert_typed_floating ((char *)valbuf + offset, float_elt_type,
-                                 to, builtin_type_ia64_ext);
+                                 to, ia64_ext_type (gdbarch));
          regcache_cooked_write (regcache, regnum, to);
          offset += TYPE_LENGTH (float_elt_type);
          regnum++;
@@ -2937,8 +3073,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache,
       ULONGEST val;
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
-      int reglen = TYPE_LENGTH (register_type (get_regcache_arch (regcache),
-                                              IA64_GR8_REGNUM));
+      int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
       int n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
@@ -3095,10 +3230,12 @@ ia64_find_global_pointer (CORE_ADDR faddr)
 
       if (osect < faddr_sect->objfile->sections_end)
        {
-         CORE_ADDR addr;
+         CORE_ADDR addr, endaddr;
+
+         addr = obj_section_addr (osect);
+         endaddr = obj_section_endaddr (osect);
 
-         addr = osect->addr;
-         while (addr < osect->endaddr)
+         while (addr < endaddr)
            {
              int status;
              LONGEST tag;
@@ -3156,10 +3293,12 @@ find_extant_func_descr (CORE_ADDR faddr)
 
       if (osect < faddr_sect->objfile->sections_end)
        {
-         CORE_ADDR addr;
+         CORE_ADDR addr, endaddr;
+
+         addr = obj_section_addr (osect);
+         endaddr = obj_section_endaddr (osect);
 
-         addr = osect->addr;
-         while (addr < osect->endaddr)
+         while (addr < endaddr)
            {
              int status;
              LONGEST faddr2;
@@ -3229,11 +3368,18 @@ ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
   if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
     return read_memory_unsigned_integer (addr, 8);
 
-  /* If ADDR points to a section that is not executable, then it cannot
-     be pointing to a function.  So it must be pointing to a function
-     descriptor.  */
+  /* Normally, functions live inside a section that is executable.
+     So, if ADDR points to a non-executable section, then treat it
+     as a function descriptor and return the target address iff
+     the target address itself points to a section that is executable.  */
   if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
-    return read_memory_unsigned_integer (addr, 8);
+    {
+      CORE_ADDR pc = read_memory_unsigned_integer (addr, 8);
+      struct obj_section *pc_section = find_pc_section (pc);
+
+      if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
+        return pc;
+    }
 
   /* There are also descriptors embedded in vtables.  */
   if (s)
@@ -3387,7 +3533,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
            {
              char to[MAX_REGISTER_SIZE];
              convert_typed_floating (value_contents (arg) + argoffset, float_elt_type,
-                                     to, builtin_type_ia64_ext);
+                                     to, ia64_ext_type (gdbarch));
              regcache_cooked_write (regcache, floatreg, (void *)to);
              floatreg++;
              argoffset += TYPE_LENGTH (float_elt_type);
@@ -3429,7 +3575,7 @@ ia64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
                        "dummy frame id: code 0x%s, stack 0x%s, special 0x%s\n",
-                       paddr_nz (frame_pc_unwind (this_frame)), 
+                       paddr_nz (get_frame_pc (this_frame)),
                        paddr_nz (sp), paddr_nz (bsp));
 
   return frame_id_build_special (sp, get_frame_pc (this_frame), bsp);
@@ -3558,11 +3704,5 @@ extern initialize_file_ftype _initialize_ia64_tdep; /* -Wmissing-prototypes */
 void
 _initialize_ia64_tdep (void)
 {
-  /* Define the ia64 floating-point format to gdb.  */
-  builtin_type_ia64_ext =
-    init_type (TYPE_CODE_FLT, 128 / 8,
-               0, "builtin_type_ia64_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_ext) = floatformats_ia64_ext;
-
   gdbarch_register (bfd_arch_ia64, ia64_gdbarch_init, NULL);
 }
This page took 0.050559 seconds and 4 git commands to generate.