From: Adam Fedor Date: Mon, 2 Jun 2003 02:54:35 +0000 (+0000) Subject: * gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=143985b7f3c98d0644b2eef50059f14974fe9d64;p=binutils-gdb.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b3c34c2d223..6ee0ba5918e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2003-06-01 Adam Fedor + + * 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 * defs.h (extract_address): Delete declaration. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 8bf2c328de7..7c0a8fde405 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -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. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 6a822f3b663..9678f4fb12f 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -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); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index fd014cd36bc..006ec96680f 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -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 } diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 1f78d06d164..9366afcff54 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -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; } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 65a645ab0da..b8fd0e5d888 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1605,6 +1605,17 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum, } +/* 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); +} + + 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); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 23fc0541e69..98e1a0ca088 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -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); diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index f387ad8677c..c3fd6dd8be2 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -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 */