* 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 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.
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;
};
0,
0,
default_register_reggroup_p,
+ 0,
/* startup_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)
(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",
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. */
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);
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
}
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)
{
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;
}
}
\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)
{
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);
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
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);
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.
*/
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
*/