aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-06-25 18:38:57 +0000
committerAndrew Cagney <cagney@redhat.com>2002-06-25 18:38:57 +0000
commit72cec14173f4137ae3bc9f4caf110a84e77ce623 (patch)
tree70f74445562c99c7bccb157809524aa9dd9b140a
parent8f28b84541f99bb5bef014e28439762f0ff32844 (diff)
downloadgdb-72cec14173f4137ae3bc9f4caf110a84e77ce623.zip
gdb-72cec14173f4137ae3bc9f4caf110a84e77ce623.tar.gz
gdb-72cec14173f4137ae3bc9f4caf110a84e77ce623.tar.bz2
* 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''.
-rw-r--r--gdb/ChangeLog34
-rw-r--r--gdb/Makefile.in2
-rw-r--r--gdb/infcmd.c21
-rw-r--r--gdb/inferior.h3
-rw-r--r--gdb/infrun.c57
5 files changed, 78 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94458b0..9695da2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,37 @@
+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.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index b32af7f..29e7060 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1690,7 +1690,7 @@ ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \
infcmd.o: infcmd.c $(defs_h) environ.h $(gdbcmd_h) $(gdbcore_h) \
$(inferior_h) $(target_h) $(language_h) $(symfile_h) $(gdb_string_h) \
- $(ui_out_h) $(completer_h)
+ $(ui_out_h) $(completer_h) $(regcache_h)
inflow.o: inflow.c $(bfd_h) $(command_h) $(defs_h) $(inferior_h) \
$(target_h) $(terminal_h) $(gdbthread_h) $(gdb_string_h)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 6d3f792..d3949d3 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -41,6 +41,8 @@
#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);
@@ -1043,7 +1045,8 @@ run_stack_dummy (CORE_ADDR addr, char *buffer)
/* 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;
}
@@ -1143,7 +1146,15 @@ 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));
@@ -1164,7 +1175,15 @@ 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));
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 2c05f35..38c5b28 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -24,6 +24,7 @@
#define INFERIOR_H 1
struct gdbarch;
+struct regcache;
/* For bpstat. */
#include "breakpoint.h"
@@ -396,7 +397,7 @@ extern int proceed_to_finish;
Thus this contains the return value from the called function (assuming
values are returned in a register). */
-extern char *stop_registers;
+extern struct regcache *stop_registers;
/* Nonzero if the child process in inferior_ptid was attached rather
than forked. */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5f72aff..542d79f 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -62,10 +62,6 @@ static void delete_breakpoint_current_contents (void *);
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);
@@ -341,7 +337,7 @@ int proceed_to_finish;
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. */
@@ -3505,7 +3501,9 @@ and/or watchpoints.\n");
/* 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)
{
@@ -3910,12 +3908,12 @@ struct inferior_status
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;
@@ -3925,24 +3923,6 @@ struct inferior_status
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)
@@ -3950,7 +3930,7 @@ write_inferior_status_register (struct inferior_status *inf_status, int regno,
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
@@ -3960,7 +3940,7 @@ write_inferior_status_register (struct inferior_status *inf_status, int regno,
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;
@@ -3984,9 +3964,9 @@ save_inferior_status (int restore_stack_info)
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;
@@ -4033,13 +4013,16 @@ restore_inferior_status (struct inferior_status *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
@@ -4062,7 +4045,7 @@ restore_inferior_status (struct inferior_status *inf_status)
}
- free_inferior_status (inf_status);
+ xfree (inf_status);
}
static void
@@ -4082,7 +4065,9 @@ discard_inferior_status (struct inferior_status *inf_status)
{
/* 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 */
@@ -4173,7 +4158,7 @@ save_inferior_ptid (void)
static void
build_infrun (void)
{
- stop_registers = xmalloc (REGISTER_BYTES);
+ stop_registers = regcache_xmalloc (current_gdbarch);
}
void