+2002-06-25 Andrew Cagney <cagney@redhat.com>
+
+ * infrun.c (stop_registers): Change variable's type to ``struct
+ regcache'''.
+ (xmalloc_inferior_status): Delete function.
+ (free_inferior_status): Delete function.
+ (normal_stop): Use regcache_cpy.
+ (struct inferior_status): Change type of fields ``stop_registers''
+ and ``registers'' to ``struct regcache''.
+ (write_inferior_status_register): Use regcache_write.
+ (save_inferior_status): Instead of calling
+ xmalloc_inferior_status, allocate the inf_status buffer directly.
+ Use regcache_dup_no_passthrough and regcache_dup to save the
+ buffers.
+ (restore_inferior_status): Use regcache_xfree and regcache_cpy.
+ Replace the stop_registers regcache instead of overriding it. Use
+ regcache_xfree. Instead of calling free_inferior_status, xfree
+ the buffer directly.
+ (discard_inferior_status): Use regcache_xfree. Instead of calling
+ free_inferior_status, xfree the buffer directly.
+ (build_infrun): Use regcache_xmalloc.
+ (_initialize_infrun): Delete redundant call to build_infrun.
+
+ * Makefile.in (infcmd.o): Add $(regcache_h).
+
+ * infcmd.c: Include "regcache.h".
+ (run_stack_dummy): Use deprecated_grub_regcache_for_registers to
+ obtain the address of `stop_registers' register buffer.
+ (print_return_value): Ditto.
+
+ * inferior.h (struct regcache): Add opaque declaration.
+ (stop_registers): Change variable's declared type to ``struct
+ regcache''.
+
2002-06-24 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.c (add_show_from_set): Fixed typo in comment.
#include "event-top.h"
#include "parser-defs.h"
+#include "regcache.h" /* for deprecated_grub_regcache_for_registers(). */
+
/* Functions exported for general use: */
void nofp_registers_info (char *, int);
/* On normal return, the stack dummy has been popped already. */
- memcpy (buffer, stop_registers, REGISTER_BYTES);
+ memcpy (buffer, deprecated_grub_regcache_for_registers (stop_registers),
+ REGISTER_BYTES);
return 0;
}
\f
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));
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));
static void set_follow_fork_mode_command (char *arg, int from_tty,
struct cmd_list_element * c);
-static struct inferior_status *xmalloc_inferior_status (void);
-
-static void free_inferior_status (struct inferior_status *);
-
static int restore_selected_frame (void *);
static void build_infrun (void);
Thus this contains the return value from the called function (assuming
values are returned in a register). */
-char *stop_registers;
+struct regcache *stop_registers;
/* Nonzero if program stopped due to error trying to insert breakpoints. */
/* Save the function value return registers, if we care.
We might be about to restore their previous contents. */
if (proceed_to_finish)
- read_register_bytes (0, stop_registers, REGISTER_BYTES);
+ /* NB: The copy goes through to the target picking up the value of
+ all the registers. */
+ regcache_cpy (stop_registers, current_regcache);
if (stop_stack_dummy)
{
CORE_ADDR step_resume_break_address;
int stop_after_trap;
int stop_soon_quietly;
- char *stop_registers;
+ struct regcache *stop_registers;
/* These are here because if call_function_by_hand has written some
registers and then decides to call error(), we better not have changed
any registers. */
- char *registers;
+ struct regcache *registers;
/* A frame unique identifier. */
struct frame_id selected_frame_id;
int proceed_to_finish;
};
-static struct inferior_status *
-xmalloc_inferior_status (void)
-{
- struct inferior_status *inf_status;
- inf_status = xmalloc (sizeof (struct inferior_status));
- inf_status->stop_registers = xmalloc (REGISTER_BYTES);
- inf_status->registers = xmalloc (REGISTER_BYTES);
- return inf_status;
-}
-
-static void
-free_inferior_status (struct inferior_status *inf_status)
-{
- xfree (inf_status->registers);
- xfree (inf_status->stop_registers);
- xfree (inf_status);
-}
-
void
write_inferior_status_register (struct inferior_status *inf_status, int regno,
LONGEST val)
int size = REGISTER_RAW_SIZE (regno);
void *buf = alloca (size);
store_signed_integer (buf, size, val);
- memcpy (&inf_status->registers[REGISTER_BYTE (regno)], buf, size);
+ regcache_write (inf_status->registers, regno, buf);
}
/* Save all of the information associated with the inferior<==>gdb
struct inferior_status *
save_inferior_status (int restore_stack_info)
{
- struct inferior_status *inf_status = xmalloc_inferior_status ();
+ struct inferior_status *inf_status = XMALLOC (struct inferior_status);
inf_status->stop_signal = stop_signal;
inf_status->stop_pc = stop_pc;
inf_status->restore_stack_info = restore_stack_info;
inf_status->proceed_to_finish = proceed_to_finish;
- memcpy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
+ inf_status->stop_registers = regcache_dup_no_passthrough (stop_registers);
- read_register_bytes (0, inf_status->registers, REGISTER_BYTES);
+ inf_status->registers = regcache_dup (current_regcache);
get_frame_id (selected_frame, &inf_status->selected_frame_id);
return inf_status;
breakpoint_proceeded = inf_status->breakpoint_proceeded;
proceed_to_finish = inf_status->proceed_to_finish;
- /* FIXME: Is the restore of stop_registers always needed */
- memcpy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
+ /* FIXME: Is the restore of stop_registers always needed. */
+ regcache_xfree (stop_registers);
+ stop_registers = inf_status->stop_registers;
/* The inferior can be gone if the user types "print exit(0)"
(and perhaps other times). */
if (target_has_execution)
- write_register_bytes (0, inf_status->registers, REGISTER_BYTES);
+ /* NB: The register write goes through to the target. */
+ regcache_cpy (current_regcache, inf_status->registers);
+ regcache_xfree (inf_status->registers);
/* FIXME: If we are being called after stopping in a function which
is called from gdb, we should not be trying to restore the
}
- free_inferior_status (inf_status);
+ xfree (inf_status);
}
static void
{
/* See save_inferior_status for info on stop_bpstat. */
bpstat_clear (&inf_status->stop_bpstat);
- free_inferior_status (inf_status);
+ regcache_xfree (inf_status->registers);
+ regcache_xfree (inf_status->stop_registers);
+ xfree (inf_status);
}
/* Oft used ptids */
static void
build_infrun (void)
{
- stop_registers = xmalloc (REGISTER_BYTES);
+ stop_registers = regcache_xmalloc (current_gdbarch);
}
void