*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / ia64-tdep.c
index 9bbf31757262a05eaf849e770165c727fa746e4b..fab210aa860e90b3a863b67c6b7cc6201a7be0ef 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the IA-64 for GDB, the GNU debugger.
-   Copyright 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -27,6 +27,7 @@
 #include "floatformat.h"
 #include "regcache.h"
 #include "doublest.h"
+#include "value.h"
 
 #include "objfiles.h"
 #include "elf/common.h"                /* for DT_PLTGOT value */
@@ -95,12 +96,11 @@ static gdbarch_frame_saved_pc_ftype ia64_frame_saved_pc;
 static gdbarch_skip_prologue_ftype ia64_skip_prologue;
 static gdbarch_frame_init_saved_regs_ftype ia64_frame_init_saved_regs;
 static gdbarch_get_saved_register_ftype ia64_get_saved_register;
-static gdbarch_extract_return_value_ftype ia64_extract_return_value;
-static gdbarch_extract_struct_value_address_ftype ia64_extract_struct_value_address;
+static gdbarch_deprecated_extract_return_value_ftype ia64_extract_return_value;
+static gdbarch_deprecated_extract_struct_value_address_ftype ia64_extract_struct_value_address;
 static gdbarch_use_struct_convention_ftype ia64_use_struct_convention;
 static gdbarch_frameless_function_invocation_ftype ia64_frameless_function_invocation;
 static gdbarch_init_extra_frame_info_ftype ia64_init_extra_frame_info;
-static gdbarch_store_return_value_ftype ia64_store_return_value;
 static gdbarch_store_struct_return_ftype ia64_store_struct_return;
 static gdbarch_push_arguments_ftype ia64_push_arguments;
 static gdbarch_push_return_address_ftype ia64_push_return_address;
@@ -242,7 +242,7 @@ struct gdbarch_tdep
 #define FIND_GLOBAL_POINTER \
   (gdbarch_tdep (current_gdbarch)->find_global_pointer)
 
-static char *
+static const char *
 ia64_register_name (int reg)
 {
   return ia64_register_names[reg];
@@ -328,9 +328,9 @@ read_sigcontext_register (struct frame_info *frame, int regnum)
   if (frame == NULL)
     internal_error (__FILE__, __LINE__,
                    "read_sigcontext_register: NULL frame");
-  if (!frame->signal_handler_caller)
+  if (!(get_frame_type (frame) == SIGTRAMP_FRAME))
     internal_error (__FILE__, __LINE__,
-                   "read_sigcontext_register: frame not a signal_handler_caller");
+                   "read_sigcontext_register: frame not a signal trampoline");
   if (SIGCONTEXT_REGISTER_ADDRESS == 0)
     internal_error (__FILE__, __LINE__,
                    "read_sigcontext_register: SIGCONTEXT_REGISTER_ADDRESS is 0");
@@ -563,6 +563,7 @@ ia64_memory_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
   int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
   long long instr;
   int val;
+  int template;
 
   if (slotnum > 2)
     error("Can't insert breakpoint for slot numbers greater than 2.");
@@ -570,6 +571,15 @@ ia64_memory_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
   addr &= ~0x0f;
 
   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 */
+  template = extract_bit_field (bundle, 0, 5);
+  if (slotnum == 1 && template_encoding_table[template][1] == L)
+    {
+      slotnum = 2;
+    }
+
   instr = slotN_contents (bundle, slotnum);
   memcpy(contents_cache, &instr, sizeof(instr));
   replace_slotN_contents (bundle, BREAKPOINT, slotnum);
@@ -586,10 +596,20 @@ ia64_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
   int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
   long long instr;
   int val;
+  int template;
 
   addr &= ~0x0f;
 
   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 */
+  template = extract_bit_field (bundle, 0, 5);
+  if (slotnum == 1 && template_encoding_table[template][1] == L)
+    {
+      slotnum = 2;
+    }
+
   memcpy (&instr, contents_cache, sizeof instr);
   replace_slotN_contents (bundle, instr, slotnum);
   if (val == 0)
@@ -600,7 +620,7 @@ ia64_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 
 /* 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. */
-unsigned char *
+const unsigned char *
 ia64_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] =
@@ -666,10 +686,9 @@ rse_address_add(CORE_ADDR addr, int nslots)
    even really hard to compute the frame chain, but it can be
    computationally expensive.  So, instead of making life difficult
    (and slow), we pick a more convenient representation of the frame
-   chain, knowing that we'll have to make some small adjustments
-   in other places.  (E.g, note that read_fp() and write_fp() are
-   actually read_sp() and write_sp() below in ia64_gdbarch_init()
-   below.) 
+   chain, knowing that we'll have to make some small adjustments in
+   other places.  (E.g, note that read_fp() is actually read_sp() in
+   ia64_gdbarch_init() below.)
 
    Okay, so what is the frame chain exactly?  It'll be the SP value
    at the time that the function in question was entered.
@@ -684,9 +703,9 @@ rse_address_add(CORE_ADDR addr, int nslots)
 CORE_ADDR
 ia64_frame_chain (struct frame_info *frame)
 {
-  if (frame->signal_handler_caller)
+  if ((get_frame_type (frame) == SIGTRAMP_FRAME))
     return read_sigcontext_register (frame, sp_regnum);
-  else if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+  else if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
     return frame->frame;
   else
     {
@@ -701,17 +720,17 @@ ia64_frame_chain (struct frame_info *frame)
 CORE_ADDR
 ia64_frame_saved_pc (struct frame_info *frame)
 {
-  if (frame->signal_handler_caller)
+  if ((get_frame_type (frame) == SIGTRAMP_FRAME))
     return read_sigcontext_register (frame, pc_regnum);
-  else if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
-    return generic_read_register_dummy (frame->pc, frame->frame, pc_regnum);
+  else if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+    return deprecated_read_register_dummy (frame->pc, frame->frame, pc_regnum);
   else
     {
       FRAME_INIT_SAVED_REGS (frame);
 
       if (frame->saved_regs[IA64_VRAP_REGNUM])
        return read_memory_integer (frame->saved_regs[IA64_VRAP_REGNUM], 8);
-      else if (frame->next && frame->next->signal_handler_caller)
+      else if (frame->next && (get_frame_type (frame->next) == SIGTRAMP_FRAME))
        return read_sigcontext_register (frame->next, IA64_BR0_REGNUM);
       else     /* either frameless, or not far enough along in the prologue... */
        return ia64_saved_pc_after_call (frame);
@@ -1144,7 +1163,7 @@ ia64_frame_init_saved_regs (struct frame_info *frame)
   if (frame->saved_regs)
     return;
 
-  if (frame->signal_handler_caller && SIGCONTEXT_REGISTER_ADDRESS)
+  if ((get_frame_type (frame) == SIGTRAMP_FRAME) && SIGCONTEXT_REGISTER_ADDRESS)
     {
       int regno;
 
@@ -1214,7 +1233,7 @@ ia64_get_saved_register (char *raw_buffer,
   if (lval != NULL)
     *lval = not_lval;
 
-  is_dummy_frame = PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame);
+  is_dummy_frame = DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame);
 
   if (regnum == SP_REGNUM && frame->next)
     {
@@ -1356,8 +1375,8 @@ ia64_get_saved_register (char *raw_buffer,
                 + ((regnum - IA64_FR32_REGNUM) + rrb_fr) % 96;
        }
 
-      generic_get_saved_register (raw_buffer, optimized, addrp, frame,
-                                  regnum, lval);
+      deprecated_generic_get_saved_register (raw_buffer, optimized, addrp,
+                                            frame, regnum, lval);
     }
 }
 
@@ -1462,7 +1481,7 @@ ia64_init_extra_frame_info (int fromleaf, struct frame_info *frame)
 {
   CORE_ADDR bsp, cfm;
   int next_frame_is_call_dummy = ((frame->next != NULL)
-    && PC_IN_CALL_DUMMY (frame->next->pc, frame->next->frame,
+    && DEPRECATED_PC_IN_CALL_DUMMY (frame->next->pc, frame->next->frame,
                                           frame->next->frame));
 
   frame->extra_info = (struct frame_extra_info *)
@@ -1474,17 +1493,19 @@ ia64_init_extra_frame_info (int fromleaf, struct frame_info *frame)
       cfm = read_register (IA64_CFM_REGNUM);
 
     }
-  else if (frame->next->signal_handler_caller)
+  else if ((get_frame_type (frame->next) == SIGTRAMP_FRAME))
     {
       bsp = read_sigcontext_register (frame->next, IA64_BSP_REGNUM);
       cfm = read_sigcontext_register (frame->next, IA64_CFM_REGNUM);
     }
   else if (next_frame_is_call_dummy)
     {
-      bsp = generic_read_register_dummy (frame->next->pc, frame->next->frame,
-                                         IA64_BSP_REGNUM);
-      cfm = generic_read_register_dummy (frame->next->pc, frame->next->frame,
-                                         IA64_CFM_REGNUM);
+      bsp = deprecated_read_register_dummy (frame->next->pc,
+                                           frame->next->frame,
+                                           IA64_BSP_REGNUM);
+      cfm = deprecated_read_register_dummy (frame->next->pc,
+                                           frame->next->frame,
+                                           IA64_CFM_REGNUM);
     }
   else
     {
@@ -1494,13 +1515,13 @@ ia64_init_extra_frame_info (int fromleaf, struct frame_info *frame)
 
       if (frn->saved_regs[IA64_CFM_REGNUM] != 0)
        cfm = read_memory_integer (frn->saved_regs[IA64_CFM_REGNUM], 8);
-      else if (frn->next && frn->next->signal_handler_caller)
+      else if (frn->next && (get_frame_type (frn->next) == SIGTRAMP_FRAME))
        cfm = read_sigcontext_register (frn->next, IA64_PFS_REGNUM);
       else if (frn->next
-               && PC_IN_CALL_DUMMY (frn->next->pc, frn->next->frame,
+               && DEPRECATED_PC_IN_CALL_DUMMY (frn->next->pc, frn->next->frame,
                                                   frn->next->frame))
-       cfm = generic_read_register_dummy (frn->next->pc, frn->next->frame,
-                                          IA64_PFS_REGNUM);
+       cfm = deprecated_read_register_dummy (frn->next->pc, frn->next->frame,
+                                             IA64_PFS_REGNUM);
       else
        cfm = read_register (IA64_PFS_REGNUM);
 
@@ -1510,7 +1531,7 @@ ia64_init_extra_frame_info (int fromleaf, struct frame_info *frame)
   frame->extra_info->sof = cfm & 0x7f;
   frame->extra_info->sol = (cfm >> 7) & 0x7f;
   if (frame->next == 0 
-      || frame->next->signal_handler_caller 
+      || (get_frame_type (frame->next) == SIGTRAMP_FRAME) 
       || next_frame_is_call_dummy)
     frame->extra_info->bsp = rse_address_add (bsp, -frame->extra_info->sof);
   else
@@ -1881,7 +1902,7 @@ ia64_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
                float_elt_type,
                floatreg,
                VALUE_CONTENTS (arg) + argoffset,
-               &registers[REGISTER_BYTE (floatreg)]);
+               &deprecated_registers[REGISTER_BYTE (floatreg)]);
              floatreg++;
              argoffset += TYPE_LENGTH (float_elt_type);
              len -= TYPE_LENGTH (float_elt_type);
@@ -1892,7 +1913,7 @@ ia64_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
   /* Store the struct return value in r8 if necessary. */
   if (struct_return)
     {
-      store_address (&registers[REGISTER_BYTE (IA64_GR8_REGNUM)],
+      store_address (&deprecated_registers[REGISTER_BYTE (IA64_GR8_REGNUM)],
                      REGISTER_RAW_SIZE (IA64_GR8_REGNUM),
                     struct_addr);
     }
@@ -1933,12 +1954,12 @@ ia64_store_return_value (struct type *type, char *valbuf)
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
       ia64_register_convert_to_raw (type, IA64_FR8_REGNUM, valbuf,
-                                 &registers[REGISTER_BYTE (IA64_FR8_REGNUM)]);
+                                   &deprecated_registers[REGISTER_BYTE (IA64_FR8_REGNUM)]);
       target_store_registers (IA64_FR8_REGNUM);
     }
   else
-    write_register_bytes (REGISTER_BYTE (IA64_GR8_REGNUM),
-                         valbuf, TYPE_LENGTH (type));
+    deprecated_write_register_bytes (REGISTER_BYTE (IA64_GR8_REGNUM),
+                                    valbuf, TYPE_LENGTH (type));
 }
 
 void
@@ -1989,7 +2010,7 @@ ia64_pop_frame_regular (struct frame_info *frame)
      size of the frame and the size of the locals (both wrt the
      frame that we're going back to).  This seems kind of strange,
      especially since it seems like we ought to be subtracting the
-     size of the locals... and we should; but the linux kernel
+     size of the locals... and we should; but the Linux kernel
      wants bsp to be set at the end of all used registers.  It's
      likely that this code will need to be revised to accomodate
      other operating systems. */
@@ -2071,10 +2092,11 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     {
       os_ident = elf_elfheader (info.abfd)->e_ident[EI_OSABI];
 
-      /* If os_ident is 0, it is not necessarily the case that we're on a
-         SYSV system.  (ELFOSABI_NONE is defined to be 0.) GNU/Linux uses
-        a note section to record OS/ABI info, but leaves e_ident[EI_OSABI]
-        zero.  So we have to check for note sections too. */
+      /* If os_ident is 0, it is not necessarily the case that we're
+         on a SYSV system.  (ELFOSABI_NONE is defined to be 0.)
+         GNU/Linux uses a note section to record OS/ABI info, but
+         leaves e_ident[EI_OSABI] zero.  So we have to check for note
+         sections too. */
       if (os_ident == 0)
        {
          bfd_map_over_sections (info.abfd,
@@ -2089,15 +2111,18 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches != NULL;
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
-      if (gdbarch_tdep (current_gdbarch)->os_ident != os_ident)
-       continue;
-      return arches->gdbarch;
+      tdep = gdbarch_tdep (arches->gdbarch);
+      if (tdep &&tdep->os_ident == os_ident)
+       return arches->gdbarch;
     }
 
   tdep = xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->os_ident = os_ident;
 
+  /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
+     ready to unwind the PC first (see frame.c:get_prev_frame()).  */
+  set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
   /* Set the method of obtaining the sigcontext addresses at which
      registers are saved.  The method of checking to see if
@@ -2111,12 +2136,13 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   else
     tdep->sigcontext_register_address = 0;
 
-  /* We know that Linux won't have to resort to the native_find_global_pointer
-     hackery.  But that's the only one we know about so far, so if
-     native_find_global_pointer is set to something non-zero, then use
-     it.  Otherwise fall back to using generic_elf_find_global_pointer.  
-     This arrangement should (in theory) allow us to cross debug Linux
-     binaries from an AIX machine.  */
+  /* We know that GNU/Linux won't have to resort to the
+     native_find_global_pointer hackery.  But that's the only one we
+     know about so far, so if native_find_global_pointer is set to
+     something non-zero, then use it.  Otherwise fall back to using
+     generic_elf_find_global_pointer.  This arrangement should (in
+     theory) allow us to cross debug GNU/Linux binaries from an AIX
+     machine.  */
   if (os_ident == ELFOSABI_LINUX)
     tdep->find_global_pointer = generic_elf_find_global_pointer;
   else if (native_find_global_pointer != 0)
@@ -2168,11 +2194,11 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_register_convert_to_raw (gdbarch, ia64_register_convert_to_raw);
 
   set_gdbarch_use_struct_convention (gdbarch, ia64_use_struct_convention);
-  set_gdbarch_extract_return_value (gdbarch, ia64_extract_return_value);
+  set_gdbarch_deprecated_extract_return_value (gdbarch, ia64_extract_return_value);
 
   set_gdbarch_store_struct_return (gdbarch, ia64_store_struct_return);
-  set_gdbarch_store_return_value (gdbarch, ia64_store_return_value);
-  set_gdbarch_extract_struct_value_address (gdbarch, ia64_extract_struct_value_address);
+  set_gdbarch_deprecated_store_return_value (gdbarch, ia64_store_return_value);
+  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, ia64_extract_struct_value_address);
 
   set_gdbarch_memory_insert_breakpoint (gdbarch, ia64_memory_insert_breakpoint);
   set_gdbarch_memory_remove_breakpoint (gdbarch, ia64_memory_remove_breakpoint);
@@ -2181,7 +2207,6 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_write_pc (gdbarch, ia64_write_pc);
 
   /* Settings for calling functions in the inferior.  */
-  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
   set_gdbarch_call_dummy_length (gdbarch, 0);
   set_gdbarch_push_arguments (gdbarch, ia64_push_arguments);
   set_gdbarch_push_return_address (gdbarch, ia64_push_return_address);
@@ -2201,7 +2226,6 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      is all read_fp() is used for), simply use the stack pointer value
      instead.  */
   set_gdbarch_read_fp (gdbarch, generic_target_read_sp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_sp);
 
   /* Settings that should be unnecessary.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
@@ -2209,17 +2233,16 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
 
-  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
   set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
   set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
   set_gdbarch_call_dummy_start_offset (gdbarch, 0);
-  set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
   set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
   set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
   set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
 
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
   set_gdbarch_function_start_offset (gdbarch, 0);
+  set_gdbarch_frame_args_skip (gdbarch, 0);
 
   set_gdbarch_remote_translate_xfer_address (
     gdbarch, ia64_remote_translate_xfer_address);
This page took 0.030606 seconds and 4 git commands to generate.