* infcmd.c (print_return_value): Remove compatibility code calling
authorAndrew Cagney <cagney@redhat.com>
Wed, 3 Jul 2002 20:36:54 +0000 (20:36 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 3 Jul 2002 20:36:54 +0000 (20:36 +0000)
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.

gdb/ChangeLog
gdb/Makefile.in
gdb/infcmd.c
gdb/inferior.h
gdb/regcache.c
gdb/regcache.h
gdb/valops.c
gdb/value.h
gdb/values.c

index e20d22d..915ab3e 100644 (file)
@@ -1,3 +1,28 @@
+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.
+
 2002-07-03  Martin M. Hunt  <hunt@redhat.com>
 
        * event-top.c (command_line_handler): Don't read past
index d62c4f8..99538e2 100644 (file)
@@ -2234,7 +2234,7 @@ valprint.o: valprint.c $(defs_h) $(expression_h) $(gdbcmd_h) \
 
 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 d3949d3..83267ad 100644 (file)
@@ -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 @@ breakpoint_auto_delete_contents (PTR arg)
    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 @@ run_stack_dummy (CORE_ADDR addr, char *buffer)
     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;
 }
 \f
@@ -1146,15 +1143,7 @@ print_return_value (int structure_return, struct type *value_type)
 
   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 @@ print_return_value (int structure_return, struct type *value_type)
       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 38c5b28..716daf9 100644 (file)
@@ -154,7 +154,7 @@ extern void generic_mourn_inferior (void);
 
 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 70a75b5..6927f3e 100644 (file)
@@ -269,6 +269,18 @@ regcache_xfree (struct regcache *regcache)
 }
 
 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 c0f402e..108b3fa 100644 (file)
@@ -29,6 +29,7 @@ struct gdbarch;
 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 3e72e94..df42e09 100644 (file)
@@ -1316,7 +1316,7 @@ hand_function_call (struct value *function, int nargs, struct value **args)
   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 @@ hand_function_call (struct value *function, int nargs, struct value **args)
      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 a0eb990..a596f5b 100644 (file)
@@ -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_repeat (struct value *arg1, int count);
 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 28f0f4f..3c577f3 100644 (file)
@@ -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 @@ value_from_double (struct type *type, DOUBLEST num)
 
 /* 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;