From: Andrew Cagney Date: Wed, 22 Oct 2003 23:54:11 +0000 (+0000) Subject: 2003-10-22 Andrew Cagney X-Git-Tag: cagney_bigcore-20040122-branchpoint~1081 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2d0e7eb0476ade97ed7c00e7a3838609d52d084;p=platform%2Fupstream%2Fbinutils.git 2003-10-22 Andrew Cagney * gdbarch.sh (convert_from_func_ptr_addr): Convert to a pure multi-arch method, add "targ" parameter. (struct target_ops): Declare. * gdbarch.h, gdbarch.c: Re-generate. * Makefile.in (c-valprint.o): Update dependencies. * arch-utils.h: Update copyright. (convert_from_func_ptr_addr_identity): Declare. * arch-utils.c (convert_from_func_ptr_addr_identity): New function. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. * rs6000-tdep.c (rs6000_convert_from_func_ptr_addr): Upate. * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): Update. * infcall.c (find_function_addr, call_function_by_hand): Update. * c-valprint.c: Include "target.h". (print_function_pointer_address): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 26114e7..6f40b2b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,22 @@ 2003-10-22 Andrew Cagney + * gdbarch.sh (convert_from_func_ptr_addr): Convert to a pure + multi-arch method, add "targ" parameter. + (struct target_ops): Declare. + * gdbarch.h, gdbarch.c: Re-generate. + * Makefile.in (c-valprint.o): Update dependencies. + * arch-utils.h: Update copyright. + (convert_from_func_ptr_addr_identity): Declare. + * arch-utils.c (convert_from_func_ptr_addr_identity): New function. + * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. + * rs6000-tdep.c (rs6000_convert_from_func_ptr_addr): Upate. + * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): Update. + * infcall.c (find_function_addr, call_function_by_hand): Update. + * c-valprint.c: Include "target.h". + (print_function_pointer_address): Update. + +2003-10-22 Andrew Cagney + * target.c (target_close): New function. (debug_to_close): Use "target_close". (push_target): Use "target_close". diff --git a/gdb/Makefile.in b/gdb/Makefile.in index d6c88f1..247d8d1 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1676,8 +1676,8 @@ c-typeprint.o: c-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \ $(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \ $(gdb_string_h) c-valprint.o: c-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \ - $(gdbtypes_h) $(expression_h) $(value_h) $(valprint_h) $(language_h) \ - $(c_lang_h) $(cp_abi_h) + $(gdbtypes_h) $(expression_h) $(value_h) $(valprint_h) \ + $(language_h) $(c_lang_h) $(cp_abi_h) $(target_h) d10v-tdep.o: d10v-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) \ $(frame_base_h) $(symtab_h) $(gdbtypes_h) $(gdbcmd_h) $(gdbcore_h) \ $(gdb_string_h) $(value_h) $(inferior_h) $(dis_asm_h) $(symfile_h) \ diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index a38a6e4..5b7a71f 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -221,6 +221,13 @@ core_addr_identity (CORE_ADDR addr) return addr; } +CORE_ADDR +convert_from_func_ptr_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr, + struct target_ops *targ) +{ + return addr; +} + int no_op_reg_to_regnum (int reg) { diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index c0d79ec..9d67180 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -1,6 +1,7 @@ /* Dynamic architecture support for GDB, the GNU debugger. - Copyright 1998, 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2002, 2003 Free Software Foundation, + Inc. This file is part of GDB. @@ -75,9 +76,10 @@ extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs); extern const struct floatformat *default_float_format (struct gdbarch *gdbarch); extern const struct floatformat *default_double_format (struct gdbarch *gdbarch); -/* Identity function on a CORE_ADDR. Just returns its parameter. */ +/* Identity functions on a CORE_ADDR. Just return the "addr". */ extern CORE_ADDR core_addr_identity (CORE_ADDR addr); +extern gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr_identity; /* No-op conversion of reg to regnum. */ diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 62ad59f..fd42ae0 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -30,6 +30,7 @@ #include "language.h" #include "c-lang.h" #include "cp-abi.h" +#include "target.h" /* Print function pointer with inferior address ADDRESS onto stdio @@ -38,7 +39,9 @@ static void print_function_pointer_address (CORE_ADDR address, struct ui_file *stream) { - CORE_ADDR func_addr = CONVERT_FROM_FUNC_PTR_ADDR (address); + CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + address, + ¤t_target); /* If the function pointer is represented by a description, print the address of the description. */ diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 1983421..8198bb0 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -418,7 +418,7 @@ struct gdbarch startup_gdbarch = 0, /* float_format */ 0, /* double_format */ 0, /* long_double_format */ - 0, /* convert_from_func_ptr_addr */ + convert_from_func_ptr_addr_identity, /* convert_from_func_ptr_addr */ 0, /* addr_bits_remove */ 0, /* smash_text_address */ 0, /* software_single_step */ @@ -549,7 +549,7 @@ gdbarch_alloc (const struct gdbarch_info *info, current_gdbarch->deprecated_frame_args_address = get_frame_base; current_gdbarch->deprecated_frame_locals_address = get_frame_base; current_gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr; - current_gdbarch->convert_from_func_ptr_addr = core_addr_identity; + current_gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity; current_gdbarch->addr_bits_remove = core_addr_identity; current_gdbarch->smash_text_address = core_addr_identity; current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code; @@ -799,6 +799,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: GDB_MULTI_ARCH = %d\n", GDB_MULTI_ARCH); fprintf_unfiltered (file, + "gdbarch_dump: convert_from_func_ptr_addr = 0x%08lx\n", + (long) current_gdbarch->convert_from_func_ptr_addr); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_frame_align_p() = %d\n", gdbarch_frame_align_p (current_gdbarch)); fprintf_unfiltered (file, @@ -969,16 +972,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: construct_inferior_arguments = 0x%08lx\n", (long) current_gdbarch->construct_inferior_arguments); -#ifdef CONVERT_FROM_FUNC_PTR_ADDR - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "CONVERT_FROM_FUNC_PTR_ADDR(addr)", - XSTRING (CONVERT_FROM_FUNC_PTR_ADDR (addr))); - fprintf_unfiltered (file, - "gdbarch_dump: CONVERT_FROM_FUNC_PTR_ADDR = <0x%08lx>\n", - (long) current_gdbarch->convert_from_func_ptr_addr - /*CONVERT_FROM_FUNC_PTR_ADDR ()*/); -#endif #ifdef CONVERT_REGISTER_P fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -5110,13 +5103,13 @@ set_gdbarch_long_double_format (struct gdbarch *gdbarch, } CORE_ADDR -gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr) +gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->convert_from_func_ptr_addr != NULL); if (gdbarch_debug >= 2) fprintf_unfiltered (gdb_stdlog, "gdbarch_convert_from_func_ptr_addr called\n"); - return gdbarch->convert_from_func_ptr_addr (addr); + return gdbarch->convert_from_func_ptr_addr (gdbarch, addr, targ); } void diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 03dcc37..36e0e7a 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -45,6 +45,7 @@ struct regcache; struct reggroup; struct regset; struct disassemble_info; +struct target_ops; extern struct gdbarch *current_gdbarch; @@ -2039,15 +2040,9 @@ extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struc #define TARGET_LONG_DOUBLE_FORMAT (gdbarch_long_double_format (current_gdbarch)) #endif -typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (CORE_ADDR addr); -extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr); +typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ); +extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ); extern void set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr); -#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CONVERT_FROM_FUNC_PTR_ADDR) -#error "Non multi-arch definition of CONVERT_FROM_FUNC_PTR_ADDR" -#endif -#if !defined (CONVERT_FROM_FUNC_PTR_ADDR) -#define CONVERT_FROM_FUNC_PTR_ADDR(addr) (gdbarch_convert_from_func_ptr_addr (current_gdbarch, addr)) -#endif /* On some machines there are bits in addresses which are not really part of the address, but are used by the kernel, the hardware, etc. diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 8e1c0a4..d11e2fa 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -671,7 +671,7 @@ v:2:PARM_BOUNDARY:int:parm_boundary v:2:TARGET_FLOAT_FORMAT:const struct floatformat *:float_format::::::default_float_format (gdbarch)::%s:(TARGET_FLOAT_FORMAT)->name v:2:TARGET_DOUBLE_FORMAT:const struct floatformat *:double_format::::::default_double_format (gdbarch)::%s:(TARGET_DOUBLE_FORMAT)->name v:2:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat *:long_double_format::::::default_double_format (gdbarch)::%s:(TARGET_LONG_DOUBLE_FORMAT)->name -f:2:CONVERT_FROM_FUNC_PTR_ADDR:CORE_ADDR:convert_from_func_ptr_addr:CORE_ADDR addr:addr:::core_addr_identity::0 +m:::CORE_ADDR:convert_from_func_ptr_addr:CORE_ADDR addr, struct target_ops *targ:addr, targ:::convert_from_func_ptr_addr_identity::0 # On some machines there are bits in addresses which are not really # part of the address, but are used by the kernel, the hardware, etc. # for special purposes. ADDR_BITS_REMOVE takes out any such bits so @@ -872,6 +872,7 @@ struct regcache; struct reggroup; struct regset; struct disassemble_info; +struct target_ops; extern struct gdbarch *current_gdbarch; diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 460c134..703493f 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -2293,7 +2293,8 @@ find_func_descr (CORE_ADDR faddr, CORE_ADDR *fdaptr) so the user can see the function address rather than just the function descriptor. */ static CORE_ADDR -ia64_convert_from_func_ptr_addr (CORE_ADDR addr) +ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, + struct target_ops *targ) { struct obj_section *s; diff --git a/gdb/infcall.c b/gdb/infcall.c index f9cb87e..75c7f4e 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -182,7 +182,9 @@ find_function_addr (struct value *function, struct type **retval_type) if (TYPE_CODE (ftype) == TYPE_CODE_FUNC || TYPE_CODE (ftype) == TYPE_CODE_METHOD) { - funaddr = CONVERT_FROM_FUNC_PTR_ADDR (funaddr); + funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + funaddr, + ¤t_target); value_type = TYPE_TARGET_TYPE (ftype); } else @@ -562,7 +564,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) dummy_addr = DEPRECATED_CALL_DUMMY_ADDRESS (); /* Make certain that the address points at real code, and not a function descriptor. */ - dummy_addr = CONVERT_FROM_FUNC_PTR_ADDR (dummy_addr); + dummy_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + dummy_addr, + ¤t_target); /* A call dummy always consists of just a single breakpoint, so it's address is the same as the address of the dummy. */ bp_addr = dummy_addr; @@ -583,7 +587,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) dummy_addr = entry_point_address (); /* Make certain that the address points at real code, and not a function descriptor. */ - dummy_addr = CONVERT_FROM_FUNC_PTR_ADDR (dummy_addr); + dummy_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + dummy_addr, + ¤t_target); /* A call dummy always consists of just a single breakpoint, so it's address is the same as the address of the dummy. */ bp_addr = dummy_addr; diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 60b976f..4bb8326 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -908,7 +908,8 @@ ppc64_skip_trampoline_code (CORE_ADDR pc) } -/* Support for CONVERT_FROM_FUNC_PTR_ADDR(ADDR) on PPC64 GNU/Linux. +/* Support for CONVERT_FROM_FUNC_PTR_ADDR (ARCH, ADDR, TARG) on PPC64 + GNU/Linux. Usually a function pointer's representation is simply the address of the function. On GNU/Linux on the 64-bit PowerPC however, a @@ -931,7 +932,9 @@ ppc64_skip_trampoline_code (CORE_ADDR pc) random addresses such as occures when there is no symbol table. */ static CORE_ADDR -ppc64_linux_convert_from_func_ptr_addr (CORE_ADDR addr) +ppc64_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, + CORE_ADDR addr, + struct target_ops *targ) { struct obj_section *s; diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 98ad98b..9cd6120 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2054,7 +2054,7 @@ rs6000_create_inferior (int pid) rs6000_set_host_arch_hook (pid); } -/* Support for CONVERT_FROM_FUNC_PTR_ADDR(ADDR). +/* Support for CONVERT_FROM_FUNC_PTR_ADDR (ARCH, ADDR, TARG). Usually a function pointer's representation is simply the address of the function. On the RS/6000 however, a function pointer is @@ -2074,7 +2074,9 @@ rs6000_create_inferior (int pid) space and is therefore a special function pointer. */ static CORE_ADDR -rs6000_convert_from_func_ptr_addr (CORE_ADDR addr) +rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch, + CORE_ADDR addr, + struct target_ops *targ) { struct obj_section *s;