2003-10-22 Andrew Cagney <cagney@redhat.com>

* 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.
This commit is contained in:
Andrew Cagney 2003-10-22 23:54:11 +00:00
parent f1c07ab0ca
commit e2d0e7eb04
12 changed files with 66 additions and 36 deletions

View file

@ -1,3 +1,20 @@
2003-10-22 Andrew Cagney <cagney@redhat.com>
* 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 <cagney@redhat.com> 2003-10-22 Andrew Cagney <cagney@redhat.com>
* target.c (target_close): New function. * target.c (target_close): New function.

View file

@ -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) \ $(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \
$(gdb_string_h) $(gdb_string_h)
c-valprint.o: c-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \ c-valprint.o: c-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(valprint_h) $(language_h) \ $(gdbtypes_h) $(expression_h) $(value_h) $(valprint_h) \
$(c_lang_h) $(cp_abi_h) $(language_h) $(c_lang_h) $(cp_abi_h) $(target_h)
d10v-tdep.o: d10v-tdep.c $(defs_h) $(frame_h) $(frame_unwind_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) \ $(frame_base_h) $(symtab_h) $(gdbtypes_h) $(gdbcmd_h) $(gdbcore_h) \
$(gdb_string_h) $(value_h) $(inferior_h) $(dis_asm_h) $(symfile_h) \ $(gdb_string_h) $(value_h) $(inferior_h) $(dis_asm_h) $(symfile_h) \

View file

@ -221,6 +221,13 @@ core_addr_identity (CORE_ADDR addr)
return addr; return addr;
} }
CORE_ADDR
convert_from_func_ptr_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
return addr;
}
int int
no_op_reg_to_regnum (int reg) no_op_reg_to_regnum (int reg)
{ {

View file

@ -1,6 +1,7 @@
/* Dynamic architecture support for GDB, the GNU debugger. /* 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. 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_float_format (struct gdbarch *gdbarch);
extern const struct floatformat *default_double_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 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. */ /* No-op conversion of reg to regnum. */

View file

@ -30,6 +30,7 @@
#include "language.h" #include "language.h"
#include "c-lang.h" #include "c-lang.h"
#include "cp-abi.h" #include "cp-abi.h"
#include "target.h"
/* Print function pointer with inferior address ADDRESS onto stdio /* Print function pointer with inferior address ADDRESS onto stdio
@ -38,7 +39,9 @@
static void static void
print_function_pointer_address (CORE_ADDR address, struct ui_file *stream) 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,
&current_target);
/* If the function pointer is represented by a description, print the /* If the function pointer is represented by a description, print the
address of the description. */ address of the description. */

View file

@ -418,7 +418,7 @@ struct gdbarch startup_gdbarch =
0, /* float_format */ 0, /* float_format */
0, /* double_format */ 0, /* double_format */
0, /* long_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, /* addr_bits_remove */
0, /* smash_text_address */ 0, /* smash_text_address */
0, /* software_single_step */ 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_args_address = get_frame_base;
current_gdbarch->deprecated_frame_locals_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->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->addr_bits_remove = core_addr_identity;
current_gdbarch->smash_text_address = core_addr_identity; current_gdbarch->smash_text_address = core_addr_identity;
current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code; current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
@ -798,6 +798,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
fprintf_unfiltered (file, fprintf_unfiltered (file,
"gdbarch_dump: GDB_MULTI_ARCH = %d\n", "gdbarch_dump: GDB_MULTI_ARCH = %d\n",
GDB_MULTI_ARCH); 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, fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_frame_align_p() = %d\n", "gdbarch_dump: gdbarch_frame_align_p() = %d\n",
gdbarch_frame_align_p (current_gdbarch)); gdbarch_frame_align_p (current_gdbarch));
@ -969,16 +972,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
fprintf_unfiltered (file, fprintf_unfiltered (file,
"gdbarch_dump: construct_inferior_arguments = 0x%08lx\n", "gdbarch_dump: construct_inferior_arguments = 0x%08lx\n",
(long) current_gdbarch->construct_inferior_arguments); (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 #ifdef CONVERT_REGISTER_P
fprintf_unfiltered (file, fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n", "gdbarch_dump: %s # %s\n",
@ -5110,13 +5103,13 @@ set_gdbarch_long_double_format (struct gdbarch *gdbarch,
} }
CORE_ADDR 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 != NULL);
gdb_assert (gdbarch->convert_from_func_ptr_addr != NULL); gdb_assert (gdbarch->convert_from_func_ptr_addr != NULL);
if (gdbarch_debug >= 2) if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_convert_from_func_ptr_addr called\n"); 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 void

View file

@ -45,6 +45,7 @@ struct regcache;
struct reggroup; struct reggroup;
struct regset; struct regset;
struct disassemble_info; struct disassemble_info;
struct target_ops;
extern struct gdbarch *current_gdbarch; 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)) #define TARGET_LONG_DOUBLE_FORMAT (gdbarch_long_double_format (current_gdbarch))
#endif #endif
typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (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); 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); 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 /* 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. part of the address, but are used by the kernel, the hardware, etc.

View file

@ -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_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_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 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 # 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. # 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 # for special purposes. ADDR_BITS_REMOVE takes out any such bits so
@ -872,6 +872,7 @@ struct regcache;
struct reggroup; struct reggroup;
struct regset; struct regset;
struct disassemble_info; struct disassemble_info;
struct target_ops;
extern struct gdbarch *current_gdbarch; extern struct gdbarch *current_gdbarch;

View file

@ -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 so the user can see the function address rather than just the
function descriptor. */ function descriptor. */
static CORE_ADDR 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; struct obj_section *s;

View file

@ -182,7 +182,9 @@ find_function_addr (struct value *function, struct type **retval_type)
if (TYPE_CODE (ftype) == TYPE_CODE_FUNC if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
|| TYPE_CODE (ftype) == TYPE_CODE_METHOD) || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
{ {
funaddr = CONVERT_FROM_FUNC_PTR_ADDR (funaddr); funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
funaddr,
&current_target);
value_type = TYPE_TARGET_TYPE (ftype); value_type = TYPE_TARGET_TYPE (ftype);
} }
else else
@ -562,7 +564,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
dummy_addr = DEPRECATED_CALL_DUMMY_ADDRESS (); dummy_addr = DEPRECATED_CALL_DUMMY_ADDRESS ();
/* Make certain that the address points at real code, and not a /* Make certain that the address points at real code, and not a
function descriptor. */ function descriptor. */
dummy_addr = CONVERT_FROM_FUNC_PTR_ADDR (dummy_addr); dummy_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
dummy_addr,
&current_target);
/* A call dummy always consists of just a single breakpoint, so /* A call dummy always consists of just a single breakpoint, so
it's address is the same as the address of the dummy. */ it's address is the same as the address of the dummy. */
bp_addr = dummy_addr; 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 (); dummy_addr = entry_point_address ();
/* Make certain that the address points at real code, and not /* Make certain that the address points at real code, and not
a function descriptor. */ a function descriptor. */
dummy_addr = CONVERT_FROM_FUNC_PTR_ADDR (dummy_addr); dummy_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
dummy_addr,
&current_target);
/* A call dummy always consists of just a single breakpoint, /* A call dummy always consists of just a single breakpoint,
so it's address is the same as the address of the dummy. */ so it's address is the same as the address of the dummy. */
bp_addr = dummy_addr; bp_addr = dummy_addr;

View file

@ -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 Usually a function pointer's representation is simply the address
of the function. On GNU/Linux on the 64-bit PowerPC however, a 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. */ random addresses such as occures when there is no symbol table. */
static CORE_ADDR 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; struct obj_section *s;

View file

@ -2054,7 +2054,7 @@ rs6000_create_inferior (int pid)
rs6000_set_host_arch_hook (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 Usually a function pointer's representation is simply the address
of the function. On the RS/6000 however, a function pointer is 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. */ space and is therefore a special function pointer. */
static CORE_ADDR 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; struct obj_section *s;