2003-10-22 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Wed, 22 Oct 2003 23:54:11 +0000 (23:54 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 22 Oct 2003 23:54:11 +0000 (23:54 +0000)
* 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.

12 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/arch-utils.c
gdb/arch-utils.h
gdb/c-valprint.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/ia64-tdep.c
gdb/infcall.c
gdb/ppc-linux-tdep.c
gdb/rs6000-tdep.c

index 26114e7..6f40b2b 100644 (file)
@@ -1,5 +1,22 @@
 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>
+
        * target.c (target_close): New function.
        (debug_to_close): Use "target_close".
        (push_target): Use "target_close".
index d6c88f1..247d8d1 100644 (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) \
        $(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 a38a6e4..5b7a71f 100644 (file)
@@ -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)
 {
index c0d79ec..9d67180 100644 (file)
@@ -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. */
 
index 62ad59f..fd42ae0 100644 (file)
@@ -30,6 +30,7 @@
 #include "language.h"
 #include "c-lang.h"
 #include "cp-abi.h"
+#include "target.h"
 \f
 
 /* 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,
+                                                           &current_target);
 
   /* If the function pointer is represented by a description, print the
      address of the description.  */
index 1983421..8198bb0 100644 (file)
@@ -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
index 03dcc37..36e0e7a 100644 (file)
@@ -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.
index 8e1c0a4..d11e2fa 100755 (executable)
@@ -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;
 
index 460c134..703493f 100644 (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
    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;
 
index f9cb87e..75c7f4e 100644 (file)
@@ -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,
+                                                       &current_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,
+                                                      &current_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,
+                                                        &current_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 60b976f..4bb8326 100644 (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
    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;
 
index 98ad98b..9cd6120 100644 (file)
@@ -2054,7 +2054,7 @@ rs6000_create_inferior (int pid)
     rs6000_set_host_arch_hook (pid);
 }
 \f
-/* 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;