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] hand_call_function() using a regcache


Hello,

This patch changes the RETBUF in hand_call_function() to a regcache. It then updates the parameter type of all the functions to which that buffer is passed.

While the patch touches a number of files, it is very mechanical - just fix the -Werror warnings :-)

I've checked it in,
Andrew

2002-07-03  Andrew Cagney  <ac131313@redhat.com>

	* infcmd.c (print_return_value): Remove compatibility code calling
	deprecated_grub_regcache_for_registers.
	
	* values.c: Include "regcache.h".
	(value_being_returned): Update.  Use
	deprecated_grub_regcache_for_registers to extract the register
	buffer address.  
	* value.h (value_being_returned): Change ``retbuf'' parameter to a
	``struct regcache''.
	* Makefile.in (values.o): Add dependency on $(regcache_h).

	* inferior.h (run_stack_dummy): Change type of second parameter to
	a ``struct regcache''.
	* valops.c (hand_function_call): Change type of retbuf to ``struct
	regcache''.  Allocate using regcache_xmalloc, clean using
	make_cleanup_regcache_xfree.
	* infcmd.c (run_stack_dummy): Update.  Use
	regcache_cpu_no_passthrough instead of memcpy to copy the buffer.

	* regcache.c (do_regcache_xfree): New function.
	(make_cleanup_regcache_xfree): New function.
	* regcache.h (make_cleanup_regcache_xfree): Declare.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.217
diff -u -r1.217 Makefile.in
--- Makefile.in	28 Jun 2002 23:42:33 -0000	1.217
+++ Makefile.in	3 Jul 2002 20:14:15 -0000
@@ -2234,7 +2234,7 @@
 
 values.o: values.c $(defs_h) $(expression_h) $(frame_h) $(gdbcmd_h) \
 	$(gdbcore_h) $(gdbtypes_h) $(symtab_h) $(target_h) $(value_h) \
-	$(gdb_string_h) scm-lang.h $(doublest_h)
+	$(gdb_string_h) scm-lang.h $(doublest_h) $(regcache_h)
 
 vax-tdep.o: vax-tdep.c $(OP_INCLUDE)/vax.h $(defs_h) $(symtab_h) \
 	$(arch_utils_h) $(inferior_h) $(vax_tdep_h)
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.48
diff -u -r1.48 infcmd.c
--- infcmd.c	25 Jun 2002 18:38:57 -0000	1.48
+++ infcmd.c	3 Jul 2002 20:14:17 -0000
@@ -40,8 +40,7 @@
 #include "ui-out.h"
 #include "event-top.h"
 #include "parser-defs.h"
-
-#include "regcache.h"	/* for deprecated_grub_regcache_for_registers().  */
+#include "regcache.h"
 
 /* Functions exported for general use: */
 
@@ -971,7 +970,7 @@
    will eventually be popped when we do hit the dummy end breakpoint).  */
 
 int
-run_stack_dummy (CORE_ADDR addr, char *buffer)
+run_stack_dummy (CORE_ADDR addr, struct regcache *buffer)
 {
   struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
   int saved_async = 0;
@@ -1044,9 +1043,7 @@
     return 2;
 
   /* On normal return, the stack dummy has been popped already.  */
-
-  memcpy (buffer, deprecated_grub_regcache_for_registers (stop_registers),
-	  REGISTER_BYTES);
+  regcache_cpy_no_passthrough (buffer, stop_registers);
   return 0;
 }
 
@@ -1146,15 +1143,7 @@
 
   if (!structure_return)
     {
-#if 0
       value = value_being_returned (value_type, stop_registers, structure_return);
-#else
-      /* FIXME: cagney/2002-06-22: Function value_being_returned()
-         should take a regcache as a parameter.  */
-      value = value_being_returned
-	(value_type, deprecated_grub_regcache_for_registers (stop_registers),
-	 structure_return);
-#endif
       stb = ui_out_stream_new (uiout);
       ui_out_text (uiout, "Value returned is ");
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
@@ -1175,15 +1164,7 @@
       ui_out_text (uiout, ".");
       ui_out_text (uiout, " Cannot determine contents\n");
 #else
-#if 0
       value = value_being_returned (value_type, stop_registers, structure_return);
-#else
-      /* FIXME: cagney/2002-06-22: Function value_being_returned()
-         should take a regcache as a parameter.  */
-      value = value_being_returned
-	(value_type, deprecated_grub_regcache_for_registers (stop_registers),
-	 structure_return);
-#endif
       stb = ui_out_stream_new (uiout);
       ui_out_text (uiout, "Value returned is ");
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.28
diff -u -r1.28 inferior.h
--- inferior.h	25 Jun 2002 18:38:57 -0000	1.28
+++ inferior.h	3 Jul 2002 20:14:17 -0000
@@ -154,7 +154,7 @@
 
 extern void terminal_ours (void);
 
-extern int run_stack_dummy (CORE_ADDR, char *);
+extern int run_stack_dummy (CORE_ADDR , struct regcache *);
 
 extern CORE_ADDR read_pc (void);
 
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.39
diff -u -r1.39 regcache.c
--- regcache.c	27 Jun 2002 18:28:23 -0000	1.39
+++ regcache.c	3 Jul 2002 20:14:17 -0000
@@ -269,6 +269,18 @@
 }
 
 void
+do_regcache_xfree (void *data)
+{
+  regcache_xfree (data);
+}
+
+struct cleanup *
+make_cleanup_regcache_xfree (struct regcache *regcache)
+{
+  return make_cleanup (do_regcache_xfree, regcache);
+}
+
+void
 regcache_cpy (struct regcache *dst, struct regcache *src)
 {
   int i;
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.8
diff -u -r1.8 regcache.h
--- regcache.h	22 Jun 2002 21:18:32 -0000	1.8
+++ regcache.h	3 Jul 2002 20:14:18 -0000
@@ -29,6 +29,7 @@
 extern struct regcache *current_regcache;
 
 void regcache_xfree (struct regcache *regcache);
+struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
 struct regcache *regcache_xmalloc (struct gdbarch *gdbarch);
 
 /* Transfer a raw register [0..NUM_REGS) between core-gdb and the
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.62
diff -u -r1.62 valops.c
--- valops.c	3 Jul 2002 18:31:29 -0000	1.62
+++ valops.c	3 Jul 2002 20:14:20 -0000
@@ -1316,7 +1316,7 @@
   struct type *value_type;
   unsigned char struct_return;
   CORE_ADDR struct_addr = 0;
-  char *retbuf;
+  struct regcache *retbuf;
   struct cleanup *retbuf_cleanup;
   struct inferior_status *inf_status;
   struct cleanup *inf_status_cleanup;
@@ -1339,8 +1339,8 @@
      containing the register values).  This chain is create BEFORE the
      inf_status chain so that the inferior status can cleaned up
      (restored or discarded) without having the retbuf freed.  */
-  retbuf = xmalloc (REGISTER_BYTES);
-  retbuf_cleanup = make_cleanup (xfree, retbuf);
+  retbuf = regcache_xmalloc (current_gdbarch);
+  retbuf_cleanup = make_cleanup_regcache_xfree (retbuf);
 
   /* A cleanup for the inferior status.  Create this AFTER the retbuf
      so that this can be discarded or applied without interfering with
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.31
diff -u -r1.31 value.h
--- value.h	12 May 2002 02:20:38 -0000	1.31
+++ value.h	3 Jul 2002 20:14:20 -0000
@@ -23,6 +23,8 @@
 #if !defined (VALUE_H)
 #define VALUE_H 1
 
+struct regcache;
+
 #include "doublest.h"
 
 /*
@@ -406,7 +408,8 @@
 extern struct value *value_subscript (struct value *array, struct value *idx);
 
 extern struct value *value_being_returned (struct type *valtype,
-					   char *retbuf, int struct_return);
+					   struct regcache *retbuf,
+					   int struct_return);
 
 extern struct value *value_in (struct value *element, struct value *set);
 
Index: values.c
===================================================================
RCS file: /cvs/src/src/gdb/values.c,v
retrieving revision 1.36
diff -u -r1.36 values.c
--- values.c	14 Jun 2002 22:55:41 -0000	1.36
+++ values.c	3 Jul 2002 20:14:21 -0000
@@ -34,6 +34,7 @@
 #include "demangle.h"
 #include "doublest.h"
 #include "gdb_assert.h"
+#include "regcache.h"
 
 /* Prototypes for exported functions. */
 
@@ -1224,8 +1225,10 @@
 
 /* ARGSUSED */
 struct value *
-value_being_returned (struct type *valtype, char *retbuf, int struct_return)
+value_being_returned (struct type *valtype, struct regcache *buf,
+		      int struct_return)
 {
+  char *retbuf = deprecated_grub_regcache_for_registers (buf);
   struct value *val;
   CORE_ADDR addr;
 

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