* arch-utils.c (gdbarch_info_init): Set osabi to
[deliverable/binutils-gdb.git] / gdb / vax-tdep.c
index 46dce5a6cd4c38b07bddcc9093581a88c9dfd592..1d1b83a94989d6c976894cefee8d631c3bee19c4 100644 (file)
@@ -1,5 +1,5 @@
 /* Print VAX instructions for GDB, the GNU debugger.
-   Copyright 1986, 1989, 1991, 1992, 1995, 1996, 1998, 1999, 2000, 2002
+   Copyright 1986, 1989, 1991, 1992, 1995, 1996, 1998, 1999, 2000, 2002, 2003
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -28,6 +28,8 @@
 #include "frame.h"
 #include "value.h"
 #include "arch-utils.h"
+#include "gdb_string.h"
+#include "osabi.h"
 
 #include "vax-tdep.h"
 
@@ -45,11 +47,9 @@ static gdbarch_frame_saved_pc_ftype vax_frame_saved_pc;
 static gdbarch_frame_args_address_ftype vax_frame_args_address;
 static gdbarch_frame_locals_address_ftype vax_frame_locals_address;
 static gdbarch_frame_init_saved_regs_ftype vax_frame_init_saved_regs;
-static gdbarch_get_saved_register_ftype vax_get_saved_register;
 
 static gdbarch_store_struct_return_ftype vax_store_struct_return;
 static gdbarch_deprecated_extract_return_value_ftype vax_extract_return_value;
-static gdbarch_store_return_value_ftype vax_store_return_value;
 static gdbarch_deprecated_extract_struct_value_address_ftype
     vax_extract_struct_value_address;
 
@@ -124,58 +124,13 @@ vax_register_virtual_type (int regno)
   return (builtin_type_int);
 }
 \f
-static void
-vax_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
-                        struct frame_info *frame, int regnum,
-                        enum lval_type *lval)
-{
-  CORE_ADDR addr;
-
-  if (!target_has_registers)
-    error ("No registers.");
-
-  /* Normal systems don't optimize out things with register numbers.  */
-  if (optimized != NULL)
-    *optimized = 0;
-  addr = find_saved_register (frame, regnum);
-  if (addr != 0)
-    {
-      if (lval != NULL)
-       *lval = lval_memory;
-      if (regnum == SP_REGNUM)
-       {
-         if (raw_buffer != NULL)
-           {
-             /* Put it back in target format.  */
-             store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
-                            (LONGEST) addr);
-           }
-         if (addrp != NULL)
-           *addrp = 0;
-         return;
-       }
-      if (raw_buffer != NULL)
-       target_read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
-    }
-  else
-    {
-      if (lval != NULL)
-       *lval = lval_register;
-      addr = REGISTER_BYTE (regnum);
-      if (raw_buffer != NULL)
-       read_register_gen (regnum, raw_buffer);
-    }
-  if (addrp != NULL)
-    *addrp = addr;
-}
-
 static void
 vax_frame_init_saved_regs (struct frame_info *frame)
 {
   int regnum, regmask;
   CORE_ADDR next_addr;
 
-  if (frame->saved_regs)
+  if (get_frame_saved_regs (frame))
     return;
 
   frame_saved_regs_zalloc (frame);
@@ -189,25 +144,51 @@ vax_frame_init_saved_regs (struct frame_info *frame)
   for (regnum = 0; regnum < VAX_AP_REGNUM; regnum++)
     {
       if (regmask & (1 << regnum))
-        frame->saved_regs[regnum] = next_addr += 4;
+        get_frame_saved_regs (frame)[regnum] = next_addr += 4;
     }
 
-  frame->saved_regs[SP_REGNUM] = next_addr + 4;
+  get_frame_saved_regs (frame)[SP_REGNUM] = next_addr + 4;
   if (regmask & (1 << FP_REGNUM))
-    frame->saved_regs[SP_REGNUM] +=
+    get_frame_saved_regs (frame)[SP_REGNUM] +=
       4 + (4 * read_memory_integer (next_addr + 4, 4));
 
-  frame->saved_regs[PC_REGNUM] = frame->frame + 16;
-  frame->saved_regs[FP_REGNUM] = frame->frame + 12;
-  frame->saved_regs[VAX_AP_REGNUM] = frame->frame + 8;
-  frame->saved_regs[PS_REGNUM] = frame->frame + 4;
+  get_frame_saved_regs (frame)[PC_REGNUM] = frame->frame + 16;
+  get_frame_saved_regs (frame)[FP_REGNUM] = frame->frame + 12;
+  get_frame_saved_regs (frame)[VAX_AP_REGNUM] = frame->frame + 8;
+  get_frame_saved_regs (frame)[PS_REGNUM] = frame->frame + 4;
+}
+
+/* Get saved user PC for sigtramp from sigcontext for BSD style sigtramp.  */
+
+static CORE_ADDR
+vax_sigtramp_saved_pc (struct frame_info *frame)
+{
+  CORE_ADDR sigcontext_addr;
+  char *buf;
+  int ptrbytes = TYPE_LENGTH (builtin_type_void_func_ptr);
+  int sigcontext_offs = (2 * TARGET_INT_BIT) / TARGET_CHAR_BIT;
+
+  buf = alloca (ptrbytes);
+  /* Get sigcontext address, it is the third parameter on the stack.  */
+  if (frame->next)
+    sigcontext_addr = read_memory_typed_address
+      (FRAME_ARGS_ADDRESS (frame->next) + FRAME_ARGS_SKIP + sigcontext_offs,
+       builtin_type_void_data_ptr);
+  else
+    sigcontext_addr = read_memory_typed_address
+      (read_register (SP_REGNUM) + sigcontext_offs, builtin_type_void_data_ptr);
+
+  /* Don't cause a memory_error when accessing sigcontext in case the stack
+     layout has changed or the stack is corrupt.  */
+  target_read_memory (sigcontext_addr + SIGCONTEXT_PC_OFFSET, buf, ptrbytes);
+  return extract_typed_address (buf, builtin_type_void_func_ptr);
 }
 
 static CORE_ADDR
 vax_frame_saved_pc (struct frame_info *frame)
 {
-  if (frame->signal_handler_caller)
-    return (sigtramp_saved_pc (frame)); /* XXXJRT */
+  if ((get_frame_type (frame) == SIGTRAMP_FRAME))
+    return (vax_sigtramp_saved_pc (frame)); /* XXXJRT */
 
   return (read_memory_integer (frame->frame + 16, 4));
 }
@@ -259,7 +240,7 @@ vax_frame_chain (struct frame_info *frame)
 {
   /* In the case of the VAX, the frame's nominal address is the FP value,
      and 12 bytes later comes the saved previous FP value as a 4-byte word.  */
-  if (inside_entry_file (frame->pc))
+  if (inside_entry_file (get_frame_pc (frame)))
     return (0);
 
   return (read_memory_integer (frame->frame + 12, 4));
@@ -344,7 +325,7 @@ vax_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
 static void
 vax_store_return_value (struct type *valtype, char *valbuf)
 {
-  write_register_bytes (0, valbuf, TYPE_LENGTH (valtype));
+  deprecated_write_register_bytes (0, valbuf, TYPE_LENGTH (valtype));
 }
 
 static CORE_ADDR
@@ -629,30 +610,18 @@ print_insn_arg (char *d, register char *p, CORE_ADDR addr,
 static struct gdbarch *
 vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* Try to determine the ABI of the object we are loading.  */
-
-  if (info.abfd != NULL)
-    osabi = gdbarch_lookup_osabi (info.abfd);
-
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-       return arches->gdbarch;
-    }
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
-  tdep = xmalloc (sizeof (struct gdbarch_tdep));
-  gdbarch = gdbarch_alloc (&info, tdep);
+  gdbarch = gdbarch_alloc (&info, NULL);
 
-  tdep->osabi = osabi;
+  /* 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);
 
   /* Register info */
   set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS);
@@ -691,14 +660,12 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_frame_args_skip (gdbarch, 4);
 
-  set_gdbarch_get_saved_register (gdbarch, vax_get_saved_register);
-
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
   /* Return value info */
   set_gdbarch_store_struct_return (gdbarch, vax_store_struct_return);
   set_gdbarch_deprecated_extract_return_value (gdbarch, vax_extract_return_value);
-  set_gdbarch_store_return_value (gdbarch, vax_store_return_value);
+  set_gdbarch_deprecated_store_return_value (gdbarch, vax_store_return_value);
   set_gdbarch_deprecated_extract_struct_value_address (gdbarch, vax_extract_struct_value_address);
 
   /* Call dummy info */
@@ -712,8 +679,8 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_call_dummy_start_offset (gdbarch, 0);
   set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
   set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 7);
-  set_gdbarch_use_generic_dummy_frames (gdbarch, 0);
-  set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack);
+  set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
+  set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_on_stack);
   set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
 
   /* Breakpoint info */
@@ -725,27 +692,15 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return (gdbarch);
 }
 
-static void
-vax_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
-{
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
-  if (tdep == NULL)
-    return;
-
-  fprintf_unfiltered (file, "vax_dump_tdep: OS ABI = %s\n",
-                     gdbarch_osabi_name (tdep->osabi));
-}
-
 void
 _initialize_vax_tdep (void)
 {
-  gdbarch_register (bfd_arch_vax, vax_gdbarch_init, vax_dump_tdep);
+  gdbarch_register (bfd_arch_vax, vax_gdbarch_init, NULL);
 
   tm_print_insn = vax_print_insn;
 }
This page took 0.026594 seconds and 4 git commands to generate.