This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch/commit] function descriptor handling for push_dummy_call


> (BTW, here are sort of three parts: the gdbarch change; the 
> corresponding doco update (changelog goes in doco/ChangeLog); and the 
> hp/ux tweak.)
> 
> I'm ok with the gdbarch and hp/ux mods (suggest separate commits?).  I'd 
> just first check that Eli is ok with the doco aspect of the 
> gdbint.texinfo change.

This is what i finally checked in, as three patches:
- gdbarch change
- hppa-specific change
- documentation change

2004-06-03  Randolph Chung  <tausq@debian.org>

	* gdbarch.sh (PUSH_DUMMY_CALL): Change CORE_ADDR func_addr argument
	to struct value *function.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* infcall.c (call_function_by_hand): Pass entire function value
	to push_dummy_call.

	* Makefile.in (alpha-tdep.o, frv-tdep.o, ia64-tdep.o, mips-tdep.o)
	(ppc-sysv-tdep.o, rs6000-tdep.o): Update dependencies.
	* alpha-tdep.c (alpha_push_dummy_call): Update call signature.
	* amd64-tdep.c (amd64_push_dummy_call): Likewise.
	* arm-tdep.c (arm_push_dummy_call): Likewise.
	* avr-tdep.c (avr_push_dummy_call): Likewise.
	* cris-tdep.c (cris_push_dummy_call): Likewise.
	* d10v-tdep.c (d10v_push_dummy_call): Likewise.
	* frv-tdep.c (frv_push_dummy_call): Likewise.
	* h8300-tdep.c (h8300_push_dummy_call): Likewise.
	* hppa-tdep.c (hppa32_push_dummy_call)
	(hppa64_push_dummy_call): Likewise.
	* i386-tdep.c (i386_push_dummy_call): Likewise.
	* ia64-tdep.c (ia64_push_dummy_call): Likewise.
	* m32r-tdep.c (m32r_push_dummy_call): Likewise.
	* m68hc11-tdep.c (m68hc11_push_dummy_call): Likewise.
	* m68k-tdep.c (m68k_push_dummy_call): Likewise.
	* m88k-tdep.c (m88k_push_dummy_call): Likewise.
	* mips-tdep.c (mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call)
	(mips_o32_push_dummy_call, mips_o64_push_dummy_call): Likewise.
	* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call)
	(ppc64_sysv_abi_push_dummy_call): Likewise.
	* ppc-tdep.h (ppc_sysv_abi_push_dummy_call)
	(ppc64_sysv_abi_push_dummy_call): Likewise.
	* rs6000-tdep.c (rs6000_push_dummy_call): Likewise.
	* s390-tdep.c (s390_push_dummy_call): Likewise.
	* sh-tdep.c (sh_push_dummy_call_fpu)
	(sh_push_dummy_call_nofpu): Likewise.
	* sparc-tdep.c (sparc32_push_dummy_call): Likewise.
	* sparc64-tdep.c (sparc64_push_dummy_call): Likewise.
	* vax-tdep.c (vax_push_dummy_call): Likewise.

Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.317
diff -u -p -r1.317 gdbarch.sh
--- gdbarch.sh	8 May 2004 21:52:50 -0000	1.317
+++ gdbarch.sh	4 Jun 2004 05:39:07 -0000
@@ -514,7 +514,7 @@ F::DEPRECATED_TARGET_READ_FP:CORE_ADDR:d
 
 # See gdbint.texinfo.  See infcall.c.  New, all singing all dancing,
 # replacement for DEPRECATED_PUSH_ARGUMENTS.
-M::PUSH_DUMMY_CALL:CORE_ADDR:push_dummy_call:CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:func_addr, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr
+M::PUSH_DUMMY_CALL:CORE_ADDR:push_dummy_call:struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:function, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr
 # PUSH_DUMMY_CALL is a direct replacement for DEPRECATED_PUSH_ARGUMENTS.
 F:2:DEPRECATED_PUSH_ARGUMENTS:CORE_ADDR:deprecated_push_arguments:int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:nargs, args, sp, struct_return, struct_addr
 # Implement PUSH_RETURN_ADDRESS, and then merge in
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.253
diff -u -p -r1.253 gdbarch.h
--- gdbarch.h	8 May 2004 21:52:50 -0000	1.253
+++ gdbarch.h	4 Jun 2004 05:39:07 -0000
@@ -721,8 +721,8 @@ extern void set_gdbarch_deprecated_targe
 
 extern int gdbarch_push_dummy_call_p (struct gdbarch *gdbarch);
 
-typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
-extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
+typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
+extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
 extern void set_gdbarch_push_dummy_call (struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call);
 
 /* PUSH_DUMMY_CALL is a direct replacement for DEPRECATED_PUSH_ARGUMENTS. */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.290
diff -u -p -r1.290 gdbarch.c
--- gdbarch.c	8 May 2004 21:52:50 -0000	1.290
+++ gdbarch.c	4 Jun 2004 05:39:07 -0000
@@ -3073,13 +3073,13 @@ gdbarch_push_dummy_call_p (struct gdbarc
 }
 
 CORE_ADDR
-gdbarch_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
+gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->push_dummy_call != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_push_dummy_call called\n");
-  return gdbarch->push_dummy_call (gdbarch, func_addr, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr);
+  return gdbarch->push_dummy_call (gdbarch, function, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr);
 }
 
 void
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.47
diff -u -p -r1.47 infcall.c
--- infcall.c	8 May 2004 22:19:30 -0000	1.47
+++ infcall.c	4 Jun 2004 06:01:55 -0000
@@ -205,7 +205,8 @@ find_function_addr (struct value *functi
   else
     error ("Invalid data type for function to be called.");
 
-  *retval_type = value_type;
+  if (retval_type != NULL)
+    *retval_type = value_type;
   return funaddr + FUNCTION_START_OFFSET;
 }
 
@@ -660,7 +661,7 @@ You must use a pointer to function type 
     /* When there is no push_dummy_call method, should this code
        simply error out.  That would the implementation of this method
        for all ABIs (which is probably a good thing).  */
-    sp = gdbarch_push_dummy_call (current_gdbarch, funaddr, current_regcache,
+    sp = gdbarch_push_dummy_call (current_gdbarch, function, current_regcache,
 				  bp_addr, nargs, args, sp, struct_return,
 				  struct_addr);
   else  if (DEPRECATED_PUSH_ARGUMENTS_P ())
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.583
diff -u -p -r1.583 Makefile.in
--- Makefile.in	31 May 2004 10:01:18 -0000	1.583
+++ Makefile.in	4 Jun 2004 05:39:07 -0000
@@ -1532,7 +1532,7 @@ alpha-tdep.o: alpha-tdep.c $(defs_h) $(d
 	$(symtab_h) $(value_h) $(gdbcmd_h) $(gdbcore_h) $(dis_asm_h) \
 	$(symfile_h) $(objfiles_h) $(gdb_string_h) $(linespec_h) \
 	$(regcache_h) $(reggroups_h) $(arch_utils_h) $(osabi_h) $(block_h) \
-	$(elf_bfd_h) $(alpha_tdep_h)
+	$(elf_bfd_h) $(infcall_h) $(alpha_tdep_h)
 amd64bsd-nat.o: amd64bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
 	$(gdb_assert_h) $(amd64_tdep_h) $(amd64_nat_h)
 amd64fbsd-nat.o: amd64fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
@@ -1791,7 +1791,7 @@ frv-tdep.o: frv-tdep.c $(defs_h) $(gdb_s
 	$(arch_utils_h) $(regcache_h) $(frame_h) $(frame_unwind_h) \
 	$(frame_base_h) $(trad_frame_h) $(dis_asm_h) $(gdb_assert_h) \
 	$(sim_regno_h) $(gdb_sim_frv_h) $(opcodes_frv_desc_h) $(symtab_h) \
-	$(elf_bfd_h) $(elf_frv_h) $(osabi_h) $(frv_tdep_h)
+	$(elf_bfd_h) $(elf_frv_h) $(osabi_h) $(infcall_h) $(frv_tdep_h)
 f-typeprint.o: f-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
 	$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \
 	$(f_lang_h) $(gdb_string_h)
@@ -1921,7 +1921,7 @@ ia64-tdep.o: ia64-tdep.c $(defs_h) $(inf
 	$(arch_utils_h) $(floatformat_h) $(regcache_h) $(reggroups_h) \
 	$(frame_h) $(frame_base_h) $(frame_unwind_h) $(doublest_h) \
 	$(value_h) $(gdb_assert_h) $(objfiles_h) $(elf_common_h) \
-	$(elf_bfd_h) $(elf_h) $(dis_asm_h) $(ia64_tdep_h) \
+	$(elf_bfd_h) $(elf_h) $(dis_asm_h) $(infcall_h) $(ia64_tdep_h) \
 	$(libunwind_frame_h) $(libunwind_ia64_h)
 infcall.o: infcall.c $(defs_h) $(breakpoint_h) $(target_h) $(regcache_h) \
 	$(inferior_h) $(gdb_assert_h) $(block_h) $(gdbcore_h) $(language_h) \
@@ -2096,7 +2096,7 @@ mips-tdep.o: mips-tdep.c $(defs_h) $(gdb
 	$(target_h) $(arch_utils_h) $(regcache_h) $(osabi_h) $(mips_tdep_h) \
 	$(block_h) $(reggroups_h) $(opcode_mips_h) $(elf_mips_h) \
 	$(elf_bfd_h) $(symcat_h) $(sim_regno_h) $(dis_asm_h) \
-	$(frame_unwind_h) $(frame_base_h) $(trad_frame_h)
+	$(frame_unwind_h) $(frame_base_h) $(trad_frame_h) $(infcall_h)
 mipsv4-nat.o: mipsv4-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \
 	$(regcache_h) $(gregset_h)
 mn10300-tdep.o: mn10300-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
@@ -2182,7 +2182,7 @@ ppcobsd-tdep.o: ppcobsd-tdep.c $(defs_h)
         $(ppc_tdep_h) $(ppcobsd_tdep_h) $(solib_svr4_h)
 ppc-sysv-tdep.o: ppc-sysv-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
 	$(regcache_h) $(value_h) $(gdb_string_h) $(gdb_assert_h) \
-	$(ppc_tdep_h) $(target_h) $(objfiles_h)
+	$(ppc_tdep_h) $(target_h) $(objfiles_h) $(infcall_h)
 printcmd.o: printcmd.c $(defs_h) $(gdb_string_h) $(frame_h) $(symtab_h) \
 	$(gdbtypes_h) $(value_h) $(language_h) $(expression_h) $(gdbcore_h) \
 	$(gdbcmd_h) $(target_h) $(breakpoint_h) $(demangle_h) $(valprint_h) \
@@ -2282,7 +2282,7 @@ rs6000-tdep.o: rs6000-tdep.c $(defs_h) $
 	$(osabi_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \
 	$(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \
 	$(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \
-	$(frame_unwind_h) $(frame_base_h)
+	$(frame_unwind_h) $(frame_base_h) $(infcall_h)
 s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \
 	$(s390_tdep_h)
 s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.131
diff -u -p -r1.131 alpha-tdep.c
--- alpha-tdep.c	18 May 2004 21:20:25 -0000	1.131
+++ alpha-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "osabi.h"
 #include "block.h"
+#include "infcall.h"
 
 #include "elf-bfd.h"
 
@@ -263,7 +264,7 @@ alpha_value_to_register (struct frame_in
    structure to be returned is passed as a hidden first argument.  */
 
 static CORE_ADDR
-alpha_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		       struct regcache *regcache, CORE_ADDR bp_addr,
 		       int nargs, struct value **args, CORE_ADDR sp,
 		       int struct_return, CORE_ADDR struct_addr)
@@ -281,6 +282,7 @@ alpha_push_dummy_call (struct gdbarch *g
   struct alpha_arg *m_arg;
   char arg_reg_buffer[ALPHA_REGISTER_SIZE * ALPHA_NUM_ARG_REGS];
   int required_arg_regs;
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* The ABI places the address of the called function in T12.  */
   regcache_cooked_write_signed (regcache, ALPHA_T12_REGNUM, func_addr);
Index: amd64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-tdep.c,v
retrieving revision 1.14
diff -u -p -r1.14 amd64-tdep.c
--- amd64-tdep.c	30 May 2004 16:56:08 -0000	1.14
+++ amd64-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -646,7 +646,7 @@ amd64_push_arguments (struct regcache *r
 }
 
 static CORE_ADDR
-amd64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		       struct regcache *regcache, CORE_ADDR bp_addr,
 		       int nargs, struct value **args,	CORE_ADDR sp,
 		       int struct_return, CORE_ADDR struct_addr)
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.173
diff -u -p -r1.173 arm-tdep.c
--- arm-tdep.c	8 May 2004 21:27:02 -0000	1.173
+++ arm-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -1210,7 +1210,7 @@ pop_stack_item (struct stack_item *si)
    we should probably support some of them based on the selected ABI.  */
 
 static CORE_ADDR
-arm_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		     struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		     struct value **args, CORE_ADDR sp, int struct_return,
 		     CORE_ADDR struct_addr)
Index: avr-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/avr-tdep.c,v
retrieving revision 1.79
diff -u -p -r1.79 avr-tdep.c
--- avr-tdep.c	22 Apr 2004 17:02:31 -0000	1.79
+++ avr-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -1146,7 +1146,7 @@ pop_stack_item (struct stack_item *si)
    registers R0 to R2. */
 
 static CORE_ADDR
-avr_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr,
                      int nargs, struct value **args, CORE_ADDR sp,
                      int struct_return, CORE_ADDR struct_addr)
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.105
diff -u -p -r1.105 cris-tdep.c
--- cris-tdep.c	21 Apr 2004 17:47:10 -0000	1.105
+++ cris-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -511,7 +511,7 @@ cris_push_dummy_code (struct gdbarch *gd
 }
 
 static CORE_ADDR
-cris_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr,
 		      int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.143
diff -u -p -r1.143 d10v-tdep.c
--- d10v-tdep.c	21 Apr 2004 23:52:20 -0000	1.143
+++ d10v-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -953,7 +953,7 @@ d10v_push_dummy_code (struct gdbarch *gd
 }
 
 static CORE_ADDR
-d10v_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+d10v_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr,
 		      int nargs, struct value **args, CORE_ADDR sp, 
 		      int struct_return, CORE_ADDR struct_addr)
Index: frv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/frv-tdep.c,v
retrieving revision 1.83
diff -u -p -r1.83 frv-tdep.c
--- frv-tdep.c	1 May 2004 14:00:57 -0000	1.83
+++ frv-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -37,6 +37,7 @@
 #include "elf-bfd.h"
 #include "elf/frv.h"
 #include "osabi.h"
+#include "infcall.h"
 #include "frv-tdep.h"
 
 extern void _initialize_frv_tdep (void);
@@ -1118,7 +1119,7 @@ frv_convert_from_func_ptr_addr (struct g
 }
 
 static CORE_ADDR
-frv_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr,
                      int nargs, struct value **args, CORE_ADDR sp,
 		     int struct_return, CORE_ADDR struct_addr)
@@ -1135,6 +1136,7 @@ frv_push_dummy_call (struct gdbarch *gdb
   int stack_space;
   int stack_offset;
   enum frv_abi abi = frv_abi (gdbarch);
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
 #if 0
   printf("Push %d args at sp = %x, struct_return=%d (%x)\n",
Index: h8300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/h8300-tdep.c,v
retrieving revision 1.93
diff -u -p -r1.93 h8300-tdep.c
--- h8300-tdep.c	22 Mar 2004 16:58:07 -0000	1.93
+++ h8300-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -632,7 +632,7 @@ h8300_init_extra_frame_info (int fromlea
      to begin with.  */
 
 static CORE_ADDR
-h8300_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		       struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		       struct value **args, CORE_ADDR sp, int struct_return,
 		       CORE_ADDR struct_addr)
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.166
diff -u -p -r1.166 hppa-tdep.c
--- hppa-tdep.c	30 May 2004 14:11:00 -0000	1.166
+++ hppa-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -709,7 +721,7 @@ hppa64_register_name (int i)
    arguments into their proper slots.  */
    
 CORE_ADDR
-hppa32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			struct regcache *regcache, CORE_ADDR bp_addr,
 			int nargs, struct value **args, CORE_ADDR sp,
 			int struct_return, CORE_ADDR struct_addr)
@@ -870,7 +897,7 @@ hppa32_push_dummy_call (struct gdbarch *
    to the callee, so we do that too.  */
    
 CORE_ADDR
-hppa64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			struct regcache *regcache, CORE_ADDR bp_addr,
 			int nargs, struct value **args, CORE_ADDR sp,
 			int struct_return, CORE_ADDR struct_addr)
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.195
diff -u -p -r1.195 i386-tdep.c
--- i386-tdep.c	30 May 2004 14:13:49 -0000	1.195
+++ i386-tdep.c	4 Jun 2004 05:39:07 -0000
@@ -1119,7 +1119,7 @@ i386_get_longjmp_target (CORE_ADDR *pc)
 
 
 static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.122
diff -u -p -r1.122 ia64-tdep.c
--- ia64-tdep.c	18 May 2004 21:20:26 -0000	1.122
+++ ia64-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -37,6 +37,7 @@
 #include "elf/common.h"		/* for DT_PLTGOT value */
 #include "elf-bfd.h"
 #include "dis-asm.h"
+#include "infcall.h"
 #include "ia64-tdep.h"
 
 #ifdef HAVE_LIBUNWIND_IA64_H
@@ -3023,7 +3024,7 @@ ia64_frame_align (struct gdbarch *gdbarc
 }
 
 static CORE_ADDR
-ia64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, 
+ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr,
 		      int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
@@ -3035,6 +3036,7 @@ ia64_push_dummy_call (struct gdbarch *gd
   int nslots, rseslots, memslots, slotnum, nfuncargs;
   int floatreg;
   CORE_ADDR bsp, cfm, pfs, new_bsp, funcdescaddr, pc, global_pointer;
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   nslots = 0;
   nfuncargs = 0;
Index: m32r-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
retrieving revision 1.26
diff -u -p -r1.26 m32r-tdep.c
--- m32r-tdep.c	22 Apr 2004 17:02:31 -0000	1.26
+++ m32r-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -686,7 +686,7 @@ m32r_unwind_sp (struct gdbarch *gdbarch,
 
 
 static CORE_ADDR
-m32r_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
Index: m68hc11-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68hc11-tdep.c,v
retrieving revision 1.101
diff -u -p -r1.101 m68hc11-tdep.c
--- m68hc11-tdep.c	22 Apr 2004 17:02:31 -0000	1.101
+++ m68hc11-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -1172,7 +1172,7 @@ m68hc11_stack_align (CORE_ADDR addr)
 }
 
 static CORE_ADDR
-m68hc11_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                          struct regcache *regcache, CORE_ADDR bp_addr,
                          int nargs, struct value **args, CORE_ADDR sp,
                          int struct_return, CORE_ADDR struct_addr)
Index: m68k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68k-tdep.c,v
retrieving revision 1.91
diff -u -p -r1.91 m68k-tdep.c
--- m68k-tdep.c	16 May 2004 23:04:15 -0000	1.91
+++ m68k-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -405,7 +405,7 @@ m68k_svr4_return_value (struct gdbarch *
 
 
 static CORE_ADDR
-m68k_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
Index: m88k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m88k-tdep.c,v
retrieving revision 1.12
diff -u -p -r1.12 m88k-tdep.c
--- m88k-tdep.c	30 May 2004 18:16:31 -0000	1.12
+++ m88k-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -344,7 +344,7 @@ m88k_store_arguments (struct regcache *r
 }
 
 static CORE_ADDR
-m88k_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+m88k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.294
diff -u -p -r1.294 mips-tdep.c
--- mips-tdep.c	3 May 2004 22:20:18 -0000	1.294
+++ mips-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -53,6 +53,7 @@
 #include "frame-unwind.h"
 #include "frame-base.h"
 #include "trad-frame.h"
+#include "infcall.h"
 
 static const struct objfile_data *mips_pdr_data;
 
@@ -2767,7 +2768,7 @@ mips_eabi_reg_struct_has_addr (int gcc_p
 }
 
 static CORE_ADDR
-mips_eabi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			   struct regcache *regcache, CORE_ADDR bp_addr,
 			   int nargs, struct value **args, CORE_ADDR sp,
 			   int struct_return, CORE_ADDR struct_addr)
@@ -2778,6 +2779,7 @@ mips_eabi_push_dummy_call (struct gdbarc
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
      address.  */
@@ -3085,7 +3087,7 @@ mips_eabi_store_return_value (struct typ
 /* N32/N64 ABI stuff.  */
 
 static CORE_ADDR
-mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			     struct regcache *regcache, CORE_ADDR bp_addr,
 			     int nargs, struct value **args, CORE_ADDR sp,
 			     int struct_return, CORE_ADDR struct_addr)
@@ -3096,6 +3098,7 @@ mips_n32n64_push_dummy_call (struct gdba
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
      address.  */
@@ -3423,7 +3426,7 @@ mips_n32n64_return_value (struct gdbarch
 /* O32 ABI stuff.  */
 
 static CORE_ADDR
-mips_o32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			  struct regcache *regcache, CORE_ADDR bp_addr,
 			  int nargs, struct value **args, CORE_ADDR sp,
 			  int struct_return, CORE_ADDR struct_addr)
@@ -3434,6 +3437,7 @@ mips_o32_push_dummy_call (struct gdbarch
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
      address.  */
@@ -3875,7 +3879,7 @@ mips_o32_return_value (struct gdbarch *g
    ABI.  */
 
 static CORE_ADDR
-mips_o64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			  struct regcache *regcache, CORE_ADDR bp_addr,
 			  int nargs,
 			  struct value **args, CORE_ADDR sp,
@@ -3887,6 +3891,7 @@ mips_o64_push_dummy_call (struct gdbarch
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
      address.  */
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.23
diff -u -p -r1.23 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c	7 May 2004 20:48:43 -0000	1.23
+++ ppc-sysv-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -30,6 +30,7 @@
 #include "ppc-tdep.h"
 #include "target.h"
 #include "objfiles.h"
+#include "infcall.h"
 
 /* Pass the arguments in either registers, or in the stack. Using the
    ppc sysv ABI, the first eight words of the argument list (that might
@@ -43,7 +44,7 @@
    starting from r4. */
 
 CORE_ADDR
-ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			      struct regcache *regcache, CORE_ADDR bp_addr,
 			      int nargs, struct value **args, CORE_ADDR sp,
 			      int struct_return, CORE_ADDR struct_addr)
@@ -540,11 +541,12 @@ ppc_sysv_abi_broken_return_value (struct
    greatly simplifies the logic. */
 
 CORE_ADDR
-ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 				struct regcache *regcache, CORE_ADDR bp_addr,
 				int nargs, struct value **args, CORE_ADDR sp,
 				int struct_return, CORE_ADDR struct_addr)
 {
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   /* By this stage in the proceedings, SP has been decremented by "red
      zone size" + "struct return size".  Fetch the stack-pointer from
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.36
diff -u -p -r1.36 ppc-tdep.h
--- ppc-tdep.h	2 Jun 2004 03:06:23 -0000	1.36
+++ ppc-tdep.h	4 Jun 2004 05:39:08 -0000
@@ -41,14 +41,14 @@ enum return_value_convention ppc_sysv_ab
 							       void *readbuf,
 							       const void *writebuf);
 CORE_ADDR ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
-					CORE_ADDR func_addr,
+					struct value *function,
 					struct regcache *regcache,
 					CORE_ADDR bp_addr, int nargs,
 					struct value **args, CORE_ADDR sp,
 					int struct_return,
 					CORE_ADDR struct_addr);
 CORE_ADDR ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
-					  CORE_ADDR func_addr,
+					  struct value *function,
 					  struct regcache *regcache,
 					  CORE_ADDR bp_addr, int nargs,
 					  struct value **args, CORE_ADDR sp,
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.211
diff -u -p -r1.211 rs6000-tdep.c
--- rs6000-tdep.c	2 Jun 2004 03:06:23 -0000	1.211
+++ rs6000-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -36,6 +36,7 @@
 #include "value.h"
 #include "parser-defs.h"
 #include "osabi.h"
+#include "infcall.h"
 
 #include "libbfd.h"		/* for bfd_default_set_arch_mach */
 #include "coff/internal.h"	/* for libcoff.h */
@@ -1271,7 +1272,7 @@ rs6000_frame_align (struct gdbarch *gdba
    starting from r4.  */
 
 static CORE_ADDR
-rs6000_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			struct regcache *regcache, CORE_ADDR bp_addr,
 			int nargs, struct value **args, CORE_ADDR sp,
 			int struct_return, CORE_ADDR struct_addr)
@@ -1284,6 +1285,7 @@ rs6000_push_dummy_call (struct gdbarch *
   char tmp_buffer[50];
   int f_argno = 0;		/* current floating point argno */
   int wordsize = gdbarch_tdep (current_gdbarch)->wordsize;
+  CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   struct value *arg = 0;
   struct type *type;
Index: s390-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/s390-tdep.c,v
retrieving revision 1.132
diff -u -p -r1.132 s390-tdep.c
--- s390-tdep.c	4 May 2004 18:50:26 -0000	1.132
+++ s390-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -2565,7 +2565,7 @@ alignment_of (struct type *type)
    Our caller has taken care of any type promotions needed to satisfy
    prototypes or the old K&R argument-passing rules.  */
 static CORE_ADDR
-s390_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      struct regcache *regcache, CORE_ADDR bp_addr,
 		      int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.168
diff -u -p -r1.168 sh-tdep.c
--- sh-tdep.c	3 Jun 2004 11:46:34 -0000	1.168
+++ sh-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -885,7 +885,7 @@ sh_treat_as_flt_p (struct type *type)
 
 static CORE_ADDR
 sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
-			CORE_ADDR func_addr,
+			struct value *function,
 			struct regcache *regcache,
 			CORE_ADDR bp_addr, int nargs,
 			struct value **args,
@@ -997,7 +997,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
 
 static CORE_ADDR
 sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
-			  CORE_ADDR func_addr,
+			  struct value *function,
 			  struct regcache *regcache,
 			  CORE_ADDR bp_addr,
 			  int nargs, struct value **args,
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.152
diff -u -p -r1.152 sparc-tdep.c
--- sparc-tdep.c	5 Mar 2004 20:58:00 -0000	1.152
+++ sparc-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -450,7 +450,7 @@ sparc32_store_arguments (struct regcache
 }
 
 static CORE_ADDR
-sparc32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+sparc32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			 struct regcache *regcache, CORE_ADDR bp_addr,
 			 int nargs, struct value **args, CORE_ADDR sp,
 			 int struct_return, CORE_ADDR struct_addr)
Index: sparc64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v
retrieving revision 1.11
diff -u -p -r1.11 sparc64-tdep.c
--- sparc64-tdep.c	9 Apr 2004 12:30:02 -0000	1.11
+++ sparc64-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -949,7 +949,7 @@ sparc64_store_arguments (struct regcache
 }
 
 static CORE_ADDR
-sparc64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+sparc64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			 struct regcache *regcache, CORE_ADDR bp_addr,
 			 int nargs, struct value **args, CORE_ADDR sp,
 			 int struct_return, CORE_ADDR struct_addr)
Index: vax-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.c,v
retrieving revision 1.80
diff -u -p -r1.80 vax-tdep.c
--- vax-tdep.c	17 May 2004 22:12:13 -0000	1.80
+++ vax-tdep.c	4 Jun 2004 05:39:08 -0000
@@ -144,7 +144,7 @@ vax_store_arguments (struct regcache *re
 }
 
 static CORE_ADDR
-vax_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+vax_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		     struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
 		     struct value **args, CORE_ADDR sp, int struct_return,
 		     CORE_ADDR struct_addr)



2004-06-06  Randolph Chung  <tausq@debian.org>

	* hppa-tdep.h (struct value): Forward declaration.
	(gdbarch_tdep): Define tdep find_global_pointer method.
	* hppa-tdep.c (hppa32_push_dummy_call): Find the global pointer
	associated with the function we are trying to call, and write it
	to the gp register.
	(hppa32_convert_from_funct_ptr_addr): New function.
	(hppa_find_global_pointer): New function.
	(hppa_gdbarch_init): Set default find_global_pointer method; set
	convert_from_func_ptr_addr method.
	* hppa-linux-tdep.c (hppa_linux_find_global_pointer): New function.
	(hppa_linux_init_abi): Set find_global_pointer method.
	* Makefile.in (hppa-linux-tdep.o): Add value.h dependency.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.584
diff -u -p -r1.584 Makefile.in
--- Makefile.in	7 Jun 2004 02:02:44 -0000	1.584
+++ Makefile.in	7 Jun 2004 02:06:50 -0000
@@ -1845,7 +1845,7 @@ hppa-tdep.o: hppa-tdep.c $(defs_h) $(fra
 hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
 	$(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \
 	$(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \
-	$(elf_common_h) 
+	$(elf_common_h) $(value_h)
 hppa-linux-nat.o: hppa-linux-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \
 	$(gdb_string_h) $(inferior_h)
 hpread.o: hpread.c $(defs_h) $(bfd_h) $(gdb_string_h) $(hp_symtab_h) \
Index: hppa-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 hppa-linux-tdep.c
--- hppa-linux-tdep.c	26 May 2004 05:51:39 -0000	1.6
+++ hppa-linux-tdep.c	7 Jun 2004 02:06:50 -0000
@@ -28,8 +28,11 @@ Foundation, Inc., 59 Temple Place - Suit
 #include "frame-unwind.h"
 #include "trad-frame.h"
 #include "dwarf2-frame.h"
+#include "value.h"
 #include "hppa-tdep.h"
 
+#include "elf/common.h"
+
 #if 0
 /* Convert DWARF register number REG to the appropriate register
    number used by GDB.  */
@@ -466,6 +469,93 @@ hppa_linux_sigtramp_unwind_sniffer (stru
   return NULL;
 }
 
+/* Attempt to find (and return) the global pointer for the given
+   function.
+
+   This is a rather nasty bit of code searchs for the .dynamic section
+   in the objfile corresponding to the pc of the function we're trying
+   to call.  Once it finds the addresses at which the .dynamic section
+   lives in the child process, it scans the Elf32_Dyn entries for a
+   DT_PLTGOT tag.  If it finds one of these, the corresponding
+   d_un.d_ptr value is the global pointer.  */
+
+static CORE_ADDR
+hppa_linux_find_global_pointer (struct value *function)
+{
+  struct obj_section *faddr_sect;
+  CORE_ADDR faddr;
+  
+  faddr = value_as_address (function);
+
+  /* Is this a plabel? If so, dereference it to get the gp value.  */
+  if (faddr & 2)
+    {
+      int status;
+      char buf[4];
+
+      faddr &= ~3;
+
+      status = target_read_memory (faddr + 4, buf, sizeof (buf));
+      if (status == 0)
+	return extract_unsigned_integer (buf, sizeof (buf));
+    }
+
+  /* If the address is in the plt section, then the real function hasn't 
+     yet been fixed up by the linker so we cannot determine the gp of 
+     that function.  */
+  if (in_plt_section (faddr, NULL))
+    return 0;
+
+  faddr_sect = find_pc_section (faddr);
+  if (faddr_sect != NULL)
+    {
+      struct obj_section *osect;
+
+      ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
+	{
+	  if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+	    break;
+	}
+
+      if (osect < faddr_sect->objfile->sections_end)
+	{
+	  CORE_ADDR addr;
+
+	  addr = osect->addr;
+	  while (addr < osect->endaddr)
+	    {
+	      int status;
+	      LONGEST tag;
+	      char buf[4];
+
+	      status = target_read_memory (addr, buf, sizeof (buf));
+	      if (status != 0)
+		break;
+	      tag = extract_signed_integer (buf, sizeof (buf));
+
+	      if (tag == DT_PLTGOT)
+		{
+		  CORE_ADDR global_pointer;
+
+		  status = target_read_memory (addr + 4, buf, sizeof (buf));
+		  if (status != 0)
+		    break;
+		  global_pointer = extract_unsigned_integer (buf, sizeof (buf));
+
+		  /* The payoff... */
+		  return global_pointer;
+		}
+
+	      if (tag == DT_NULL)
+		break;
+
+	      addr += 8;
+	    }
+	}
+    }
+  return 0;
+}
+
 /* Forward declarations.  */
 extern initialize_file_ftype _initialize_hppa_linux_tdep;
 
@@ -477,6 +567,8 @@ hppa_linux_init_abi (struct gdbarch_info
   /* Linux is always ELF.  */
   tdep->is_elf = 1;
 
+  tdep->find_global_pointer = hppa_linux_find_global_pointer;
+
   set_gdbarch_write_pc (gdbarch, hppa_linux_target_write_pc);
 
   frame_unwind_append_sniffer (gdbarch, hppa_linux_sigtramp_unwind_sniffer);
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.167
diff -u -p -r1.167 hppa-tdep.c
--- hppa-tdep.c	7 Jun 2004 02:02:47 -0000	1.167
+++ hppa-tdep.c	7 Jun 2004 02:06:51 -0000
@@ -727,6 +727,12 @@ hppa32_push_dummy_call (struct gdbarch *
   /* Two passes.  First pass computes the location of everything,
      second pass writes the bytes out.  */
   int write_pass;
+
+  /* Global pointer (r19) of the function we are trying to call.  */
+  CORE_ADDR gp;
+
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
   for (write_pass = 0; write_pass < 2; write_pass++)
     {
       CORE_ADDR struct_ptr = 0;
@@ -847,6 +853,11 @@ hppa32_push_dummy_call (struct gdbarch *
   if (struct_return)
     write_register (28, struct_addr);
 
+  gp = tdep->find_global_pointer (function);
+
+  if (gp != 0)
+    write_register (19, gp);
+
   /* Set the return address.  */
   regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, bp_addr);
 
@@ -980,6 +991,22 @@ hppa64_push_dummy_call (struct gdbarch *
 }
 
 static CORE_ADDR
+hppa32_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
+				   CORE_ADDR addr,
+				   struct target_ops *targ)
+{
+  if (addr & 2)
+    {
+      CORE_ADDR plabel;
+
+      plabel = addr & ~3;
+      target_read_memory(plabel, (char *)&addr, 4);
+    }
+
+  return addr;
+}
+
+static CORE_ADDR
 hppa32_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   /* HP frames are 64-byte (or cache line) aligned (yes that's _byte_
@@ -2309,6 +2336,12 @@ hppa_pseudo_register_read (struct gdbarc
     store_unsigned_integer (buf, sizeof(tmp), tmp);
 }
 
+static CORE_ADDR
+hppa_find_global_pointer (struct value *function)
+{
+  return 0;
+}
+
 void
 hppa_frame_prev_register_helper (struct frame_info *next_frame,
 			         struct trad_frame_saved_reg saved_regs[],
@@ -2410,6 +2443,8 @@ hppa_gdbarch_init (struct gdbarch_info i
   else
     tdep->bytes_per_address = 4;
 
+  tdep->find_global_pointer = hppa_find_global_pointer;
+
   /* Some parts of the gdbarch vector depend on whether we are running
      on a 32 bits or 64 bits target.  */
   switch (tdep->bytes_per_address)
@@ -2469,6 +2504,8 @@ hppa_gdbarch_init (struct gdbarch_info i
     case 4:
       set_gdbarch_push_dummy_call (gdbarch, hppa32_push_dummy_call);
       set_gdbarch_frame_align (gdbarch, hppa32_frame_align);
+      set_gdbarch_convert_from_func_ptr_addr
+        (gdbarch, hppa32_convert_from_func_ptr_addr);
       break;
     case 8:
       set_gdbarch_push_dummy_call (gdbarch, hppa64_push_dummy_call);
Index: hppa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.h,v
retrieving revision 1.11
diff -u -p -r1.11 hppa-tdep.h
--- hppa-tdep.h	30 May 2004 14:31:29 -0000	1.11
+++ hppa-tdep.h	7 Jun 2004 02:06:51 -0000
@@ -78,6 +78,10 @@ struct gdbarch_tdep
   /* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux
      system.  */
   int is_elf;
+
+  /* Given a function address, try to find the global pointer for the 
+     corresponding shared object.  */
+  CORE_ADDR (*find_global_pointer) (struct value *);
 };
 
 /*
2004-06-06  Randolph Chung  <tausq@debian.org>

	* gdb.texinfo (push_dummy_call): Update argument list to match 
	the new push_dummy_call method signature.  Describe the function
	argument.

Index: gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.203
diff -u -p -r1.203 gdbint.texinfo
--- gdbint.texinfo	8 May 2004 22:26:10 -0000	1.203
+++ gdbint.texinfo	7 Jun 2004 02:12:02 -0000
@@ -3635,7 +3635,7 @@ definition is only used in generic code 
 If defined, used by @code{frame_pop} to remove a stack frame.  This
 method has been superseeded by generic code.
 
-@item push_dummy_call (@var{gdbarch}, @var{func_addr}, @var{regcache}, @var{pc_addr}, @var{nargs}, @var{args}, @var{sp}, @var{struct_return}, @var{struct_addr})
+@item push_dummy_call (@var{gdbarch}, @var{function}, @var{regcache}, @var{pc_addr}, @var{nargs}, @var{args}, @var{sp}, @var{struct_return}, @var{struct_addr})
 @findex push_dummy_call
 @findex DEPRECATED_PUSH_ARGUMENTS.
 @anchor{push_dummy_call} Define this to push the dummy frame's call to
@@ -3643,6 +3643,9 @@ the inferior function onto the stack.  I
 @var{nargs}, the code should push @var{struct_addr} (when
 @var{struct_return}), and the return address (@var{bp_addr}).
 
+@var{function} is a pointer to a struct value; on architectures that use
+function descriptors, this contains the function descriptor value.
+
 Returns the updated top-of-stack pointer.
 
 This method replaces @code{DEPRECATED_PUSH_ARGUMENTS}.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]