This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[obish] Add target to convert_from_func_ptr_addr
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 21 Oct 2003 12:00:18 -0400
- Subject: [obish] Add target to convert_from_func_ptr_addr
Hello,
This patch simply makes the implicit "struct target_ops" parameter to
convert_from_func_ptr_addr explicit (it also makes it pure multi-arch).
It doesn't try to update any actual architecture code so I think this
is pretty save and will commit in a few hours (after my cross builds
finish).
By doing this, the new architecture bfd_entry_point previous proposed in:
[ppc64-linux] gdbarch hook to find true execution entry point
http://sources.redhat.com/ml/gdb-patches/2003-06/msg00362.html
[ppc64-linux]: correctly find a BFD's code entry point address
http://sources.redhat.com/ml/gdb-patches/2003-06/msg00437.html
made entirely redundant. ya!
I'll follow this up with patches that fill in the dots needed to make
PPC64 GDB actually work.
Andrew
2003-10-21 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.
* 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.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.458
diff -u -r1.458 Makefile.in
--- Makefile.in 18 Oct 2003 18:41:22 -0000 1.458
+++ Makefile.in 21 Oct 2003 15:34:19 -0000
@@ -1676,8 +1676,8 @@
$(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) \
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.97
diff -u -r1.97 arch-utils.c
--- arch-utils.c 30 Sep 2003 13:29:43 -0000 1.97
+++ arch-utils.c 21 Oct 2003 15:34:19 -0000
@@ -221,6 +221,13 @@
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)
{
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.57
diff -u -r1.57 arch-utils.h
--- arch-utils.h 27 Sep 2003 15:51:02 -0000 1.57
+++ arch-utils.h 21 Oct 2003 15:34:19 -0000
@@ -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 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. */
Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.22
diff -u -r1.22 c-valprint.c
--- c-valprint.c 14 Sep 2003 16:32:12 -0000 1.22
+++ c-valprint.c 21 Oct 2003 15:34:19 -0000
@@ -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. */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.254
diff -u -r1.254 gdbarch.c
--- gdbarch.c 20 Oct 2003 15:37:58 -0000 1.254
+++ gdbarch.c 21 Oct 2003 15:34:20 -0000
@@ -418,7 +418,7 @@
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 @@
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: 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 @@
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 @@
}
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
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.222
diff -u -r1.222 gdbarch.h
--- gdbarch.h 20 Oct 2003 15:37:58 -0000 1.222
+++ gdbarch.h 21 Oct 2003 15:34:21 -0000
@@ -45,6 +45,7 @@
struct reggroup;
struct regset;
struct disassemble_info;
+struct target_ops;
extern struct gdbarch *current_gdbarch;
@@ -2039,15 +2040,9 @@
#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.
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.279
diff -u -r1.279 gdbarch.sh
--- gdbarch.sh 20 Oct 2003 15:38:01 -0000 1.279
+++ gdbarch.sh 21 Oct 2003 15:34:21 -0000
@@ -671,7 +671,7 @@
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 reggroup;
struct regset;
struct disassemble_info;
+struct target_ops;
extern struct gdbarch *current_gdbarch;
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.33
diff -u -r1.33 infcall.c
--- infcall.c 2 Oct 2003 04:40:58 -0000 1.33
+++ infcall.c 21 Oct 2003 15:34:22 -0000
@@ -182,7 +182,9 @@
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 @@
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 @@
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;
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.42
diff -u -r1.42 ppc-linux-tdep.c
--- ppc-linux-tdep.c 3 Oct 2003 20:50:56 -0000 1.42
+++ ppc-linux-tdep.c 21 Oct 2003 15:34:22 -0000
@@ -908,7 +908,8 @@
}
-/* 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 @@
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;
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.169
diff -u -r1.169 rs6000-tdep.c
--- rs6000-tdep.c 10 Oct 2003 21:32:47 -0000 1.169
+++ rs6000-tdep.c 21 Oct 2003 15:34:23 -0000
@@ -2054,7 +2054,7 @@
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 @@
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;