* 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.
This commit is contained in:
Andrew Cagney 2002-07-03 20:36:54 +00:00
parent 4dd79c29b4
commit 36160dc4b2
9 changed files with 54 additions and 29 deletions

View 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> 2002-07-03 Martin M. Hunt <hunt@redhat.com>
* event-top.c (command_line_handler): Don't read past * event-top.c (command_line_handler): Don't read past

View 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) \ values.o: values.c $(defs_h) $(expression_h) $(frame_h) $(gdbcmd_h) \
$(gdbcore_h) $(gdbtypes_h) $(symtab_h) $(target_h) $(value_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) \ vax-tdep.o: vax-tdep.c $(OP_INCLUDE)/vax.h $(defs_h) $(symtab_h) \
$(arch_utils_h) $(inferior_h) $(vax_tdep_h) $(arch_utils_h) $(inferior_h) $(vax_tdep_h)

View file

@ -40,8 +40,7 @@
#include "ui-out.h" #include "ui-out.h"
#include "event-top.h" #include "event-top.h"
#include "parser-defs.h" #include "parser-defs.h"
#include "regcache.h"
#include "regcache.h" /* for deprecated_grub_regcache_for_registers(). */
/* Functions exported for general use: */ /* 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). */ will eventually be popped when we do hit the dummy end breakpoint). */
int 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); struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
int saved_async = 0; int saved_async = 0;
@ -1044,9 +1043,7 @@ run_stack_dummy (CORE_ADDR addr, char *buffer)
return 2; return 2;
/* On normal return, the stack dummy has been popped already. */ /* On normal return, the stack dummy has been popped already. */
regcache_cpy_no_passthrough (buffer, stop_registers);
memcpy (buffer, deprecated_grub_regcache_for_registers (stop_registers),
REGISTER_BYTES);
return 0; return 0;
} }
@ -1146,15 +1143,7 @@ print_return_value (int structure_return, struct type *value_type)
if (!structure_return) if (!structure_return)
{ {
#if 0
value = value_being_returned (value_type, stop_registers, structure_return); 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); stb = ui_out_stream_new (uiout);
ui_out_text (uiout, "Value returned is "); ui_out_text (uiout, "Value returned is ");
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value)); 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, ".");
ui_out_text (uiout, " Cannot determine contents\n"); ui_out_text (uiout, " Cannot determine contents\n");
#else #else
#if 0
value = value_being_returned (value_type, stop_registers, structure_return); 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); stb = ui_out_stream_new (uiout);
ui_out_text (uiout, "Value returned is "); ui_out_text (uiout, "Value returned is ");
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value)); ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));

View file

@ -154,7 +154,7 @@ extern void generic_mourn_inferior (void);
extern void terminal_ours (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); extern CORE_ADDR read_pc (void);

View file

@ -268,6 +268,18 @@ regcache_xfree (struct regcache *regcache)
xfree (regcache); xfree (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 void
regcache_cpy (struct regcache *dst, struct regcache *src) regcache_cpy (struct regcache *dst, struct regcache *src)
{ {

View file

@ -29,6 +29,7 @@ struct gdbarch;
extern struct regcache *current_regcache; extern struct regcache *current_regcache;
void regcache_xfree (struct regcache *regcache); void regcache_xfree (struct regcache *regcache);
struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
struct regcache *regcache_xmalloc (struct gdbarch *gdbarch); struct regcache *regcache_xmalloc (struct gdbarch *gdbarch);
/* Transfer a raw register [0..NUM_REGS) between core-gdb and the /* Transfer a raw register [0..NUM_REGS) between core-gdb and the

View file

@ -1316,7 +1316,7 @@ hand_function_call (struct value *function, int nargs, struct value **args)
struct type *value_type; struct type *value_type;
unsigned char struct_return; unsigned char struct_return;
CORE_ADDR struct_addr = 0; CORE_ADDR struct_addr = 0;
char *retbuf; struct regcache *retbuf;
struct cleanup *retbuf_cleanup; struct cleanup *retbuf_cleanup;
struct inferior_status *inf_status; struct inferior_status *inf_status;
struct cleanup *inf_status_cleanup; 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 containing the register values). This chain is create BEFORE the
inf_status chain so that the inferior status can cleaned up inf_status chain so that the inferior status can cleaned up
(restored or discarded) without having the retbuf freed. */ (restored or discarded) without having the retbuf freed. */
retbuf = xmalloc (REGISTER_BYTES); retbuf = regcache_xmalloc (current_gdbarch);
retbuf_cleanup = make_cleanup (xfree, retbuf); retbuf_cleanup = make_cleanup_regcache_xfree (retbuf);
/* A cleanup for the inferior status. Create this AFTER the retbuf /* A cleanup for the inferior status. Create this AFTER the retbuf
so that this can be discarded or applied without interfering with so that this can be discarded or applied without interfering with

View file

@ -23,6 +23,8 @@
#if !defined (VALUE_H) #if !defined (VALUE_H)
#define VALUE_H 1 #define VALUE_H 1
struct regcache;
#include "doublest.h" #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_subscript (struct value *array, struct value *idx);
extern struct value *value_being_returned (struct type *valtype, 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); extern struct value *value_in (struct value *element, struct value *set);

View file

@ -34,6 +34,7 @@
#include "demangle.h" #include "demangle.h"
#include "doublest.h" #include "doublest.h"
#include "gdb_assert.h" #include "gdb_assert.h"
#include "regcache.h"
/* Prototypes for exported functions. */ /* Prototypes for exported functions. */
@ -1224,8 +1225,10 @@ value_from_double (struct type *type, DOUBLEST num)
/* ARGSUSED */ /* ARGSUSED */
struct value * 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; struct value *val;
CORE_ADDR addr; CORE_ADDR addr;