* gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
authorAdam Fedor <fedor@gnu.org>
Mon, 2 Jun 2003 02:54:35 +0000 (02:54 +0000)
committerAdam Fedor <fedor@gnu.org>
Mon, 2 Jun 2003 02:54:35 +0000 (02:54 +0000)
* gdbarch.[ch]: Regenerate.
* hppa-tdep.c (hppa_fetch_pointer_argument): New function.
(hppa_gdbarch_init): Set it in the gdbarch vector.
* i386-tdep.c (i386_fetch_pointer_argument): New
(i386_gdbarch_init): Set it into gdbarch.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
(rs6000_gdbarch_init): Set it in gdbarch.
* sparc-tdep.c (sparc_fetch_pointer_argument): New
(sparc_gdbarch_init): Set it in gdbarch.

gdb/ChangeLog
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/hppa-tdep.c
gdb/i386-tdep.c
gdb/rs6000-tdep.c
gdb/sparc-tdep.c

index b3c34c2d2237e495f57fd960e3f773d29cac9184..6ee0ba5918e22d82b8ac7e6faf4292f68272fb1f 100644 (file)
@@ -1,3 +1,16 @@
+2003-06-01  Adam Fedor  <fedor@gnu.org>
+
+       * gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
+       * gdbarch.[ch]: Regenerate.
+       * hppa-tdep.c (hppa_fetch_pointer_argument): New function.
+       (hppa_gdbarch_init): Set it in the gdbarch vector.
+       * i386-tdep.c (i386_fetch_pointer_argument): New
+       (i386_gdbarch_init): Set it into gdbarch.
+       * rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
+       (rs6000_gdbarch_init): Set it in gdbarch.
+       * sparc-tdep.c (sparc_fetch_pointer_argument): New
+       (sparc_gdbarch_init): Set it in gdbarch.
+
 2003-06-01  Andrew Cagney  <cagney@redhat.com>
 
        * defs.h (extract_address): Delete declaration.
index 8bf2c328de74baaaa768b037a99fdfa5014c3675..7c0a8fde40583232ab55cc182bdc8abb08c68e96 100644 (file)
@@ -280,6 +280,7 @@ struct gdbarch
   gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
   gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
   gdbarch_register_reggroup_p_ftype *register_reggroup_p;
+  gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
 };
 
 
@@ -446,6 +447,7 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   default_register_reggroup_p,
+  0,
   /* startup_gdbarch() */
 };
 
@@ -762,6 +764,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of address_class_type_flags_to_name, has predicate */
   /* Skip verify of address_class_name_to_type_flags, has predicate */
   /* Skip verify of register_reggroup_p, invalid_p == 0 */
+  /* Skip verify of fetch_pointer_argument, has predicate */
   buf = ui_file_xstrdup (log, &dummy);
   make_cleanup (xfree, buf);
   if (strlen (buf) > 0)
@@ -1693,6 +1696,26 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                         (long) current_gdbarch->extract_struct_value_address
                         /*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
 #endif
+#ifdef FETCH_POINTER_ARGUMENT_P
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: %s # %s\n",
+                      "FETCH_POINTER_ARGUMENT_P()",
+                      XSTRING (FETCH_POINTER_ARGUMENT_P ()));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: FETCH_POINTER_ARGUMENT_P() = %d\n",
+                      FETCH_POINTER_ARGUMENT_P ());
+#endif
+#ifdef FETCH_POINTER_ARGUMENT
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: %s # %s\n",
+                      "FETCH_POINTER_ARGUMENT(frame, argi, type)",
+                      XSTRING (FETCH_POINTER_ARGUMENT (frame, argi, type)));
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: FETCH_POINTER_ARGUMENT = <0x%08lx>\n",
+                        (long) current_gdbarch->fetch_pointer_argument
+                        /*FETCH_POINTER_ARGUMENT ()*/);
+#endif
 #ifdef FP0_REGNUM
   fprintf_unfiltered (file,
                       "gdbarch_dump: FP0_REGNUM # %s\n",
@@ -5691,6 +5714,32 @@ set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch,
   gdbarch->register_reggroup_p = register_reggroup_p;
 }
 
+int
+gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->fetch_pointer_argument != 0;
+}
+
+CORE_ADDR
+gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch->fetch_pointer_argument == 0)
+    internal_error (__FILE__, __LINE__,
+                    "gdbarch: gdbarch_fetch_pointer_argument invalid");
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
+  return gdbarch->fetch_pointer_argument (frame, argi, type);
+}
+
+void
+set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
+                                    gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
+{
+  gdbarch->fetch_pointer_argument = fetch_pointer_argument;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
index 6a822f3b663cfcff95d373850ff56df13b0978ee..9678f4fb12fa8ebb2b99a10f933b85cf050786ea 100644 (file)
@@ -2940,6 +2940,43 @@ typedef int (gdbarch_register_reggroup_p_ftype) (struct gdbarch *gdbarch, int re
 extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
 extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
 
+/* Fetch the pointer to the ith function argument. */
+
+#if defined (FETCH_POINTER_ARGUMENT)
+/* Legacy for systems yet to multi-arch FETCH_POINTER_ARGUMENT */
+#if !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (0)
+#endif
+
+extern int gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT_P)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (gdbarch_fetch_pointer_argument_p (current_gdbarch))
+#endif
+
+/* Default (function) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(frame, argi, type) (internal_error (__FILE__, __LINE__, "FETCH_POINTER_ARGUMENT"), 0)
+#endif
+
+typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
+extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
+extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(frame, argi, type) (gdbarch_fetch_pointer_argument (current_gdbarch, frame, argi, type))
+#endif
+
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
index fd014cd36bcbc2f92b9a97cd859728b43274852c..006ec96680fc0d5e1d10d04f0b1d9ef732946d70 100755 (executable)
@@ -716,6 +716,8 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:const char *:address_class_type_flags_to_na
 M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
 # Is a register in a group
 m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0
+# Fetch the pointer to the ith function argument.  
+F::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct type *type:frame, argi, type:::::::::
 EOF
 }
 
index 1f78d06d164723cfb940f0247184f54e2c7f7ed0..9366afcff54653042af1f45e7a6aca48c626bc49 100644 (file)
@@ -4993,6 +4993,16 @@ hppa_smash_text_address (CORE_ADDR addr)
   return (addr &= ~0x3);
 }
 
+/* Get the ith function argument for the current function.  */
+CORE_ADDR
+hppa_fetch_pointer_argument (struct frame_info *frame, int argi, 
+                            struct type *type)
+{
+  CORE_ADDR addr;
+  frame_read_register (frame, R0_REGNUM + 26 - argi, &addr);
+  return addr;
+}
+
 static struct gdbarch *
 hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
@@ -5071,6 +5081,9 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
   set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
 
+  /* Helper for function argument information.  */
+  set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
+
   return gdbarch;
 }
 
index 65a645ab0da5d5bacc376138d442815a03d2b623..b8fd0e5d888584efe3223f275d0518e51975fe44 100644 (file)
@@ -1605,6 +1605,17 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 }
 \f
 
+/* Get the ith function argument for the current function.  */
+CORE_ADDR
+i386_fetch_pointer_argument (struct frame_info *frame, int argi, 
+                            struct type *type)
+{
+  CORE_ADDR stack;
+  frame_read_register (frame, SP_REGNUM, &stack);
+  return read_memory_unsigned_integer (stack + (4 * (argi + 1)), 4);
+}
+
+\f
 static struct gdbarch *
 i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
@@ -1715,6 +1726,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   i386_add_reggroups (gdbarch);
   set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
 
+  /* Helper for function argument information.  */
+  set_gdbarch_fetch_pointer_argument (gdbarch, i386_fetch_pointer_argument);
+
   /* Hook in the DWARF CFI frame unwinder.  */
   frame_unwind_append_predicate (gdbarch, dwarf2_frame_p);
   set_gdbarch_dwarf2_build_frame_info (gdbarch, dwarf2_build_frame_info);
index 23fc0541e69ebd74be41ae2fcaf62fb532116d5a..98e1a0ca088ee69f5975627d5dbb4ebe0dfd9f2c 100644 (file)
@@ -230,6 +230,16 @@ rs6000_saved_pc_after_call (struct frame_info *fi)
   return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
 }
 
+/* Get the ith function argument for the current function.  */
+CORE_ADDR
+rs6000_fetch_pointer_argument (struct frame_info *frame, int argi, 
+                              struct type *type)
+{
+  CORE_ADDR addr;
+  frame_read_register (frame, 3 + argi, &addr);
+  return addr;
+}
+
 /* Calculate the destination of a branch/jump.  Return -1 if not a branch.  */
 
 static CORE_ADDR
@@ -2991,6 +3001,9 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
   set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
 
+  /* Helpers for function argument information.  */
+  set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument);
+
   /* We can't tell how many args there are
      now that the C compiler delays popping them.  */
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
index f387ad8677c24155b0bfaf6f13c4d9b5169b28ec..c3fd6dd8be209e63eb2121fc91d6037aad1d2d60 100644 (file)
@@ -3243,6 +3243,15 @@ sparc_return_value_on_stack (struct type *type)
     return 0;
 }
 
+/* Get the ith function argument for the current function.  */
+CORE_ADDR
+sparc_fetch_pointer_argument (struct frame_info *frame, int argi, struct type *type)
+{
+  CORE_ADDR addr;
+  frame_read_register (frame, O0_REGNUM + argi, &addr);
+  return addr;
+}
+
 /*
  * Gdbarch "constructor" function.
  */
@@ -3354,6 +3363,9 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
 
+  /* Helper for function argument information.  */
+  set_gdbarch_fetch_pointer_argument (gdbarch, sparc_fetch_pointer_argument);
+
   /*
    * Settings that depend only on 32/64 bit word size 
    */