aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-02-14 11:22:29 +0000
committerPedro Alves <palves@redhat.com>2011-02-14 11:22:29 +0000
commite6e4e7014d3721283cf0415cadb3c7f1a1200f7b (patch)
tree9107c3b03c92b237512758b98bf539c616ea90b9 /gdb/remote.c
parente6ca34fcfbd6f341cb70c680d45f229cb5801eeb (diff)
downloadgdb-e6e4e7014d3721283cf0415cadb3c7f1a1200f7b.zip
gdb-e6e4e7014d3721283cf0415cadb3c7f1a1200f7b.tar.gz
gdb-e6e4e7014d3721283cf0415cadb3c7f1a1200f7b.tar.bz2
gdb/
* target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index da04932..c0fd9a7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1353,6 +1353,10 @@ static ptid_t any_thread_ptid;
static ptid_t general_thread;
static ptid_t continue_thread;
+/* This the traceframe which we last selected on the remote system.
+ It will be -1 if no traceframe is selected. */
+static int remote_traceframe_number = -1;
+
/* Find out if the stub attached to PID (and hence GDB should offer to
detach instead of killing it when bailing out). */
@@ -4002,6 +4006,7 @@ remote_open_1 (char *name, int from_tty,
general_thread = not_sent_ptid;
continue_thread = not_sent_ptid;
+ remote_traceframe_number = -1;
/* Probe for ability to use "ThreadInfo" query, as required. */
use_threadinfo_query = 1;
@@ -5770,6 +5775,28 @@ fetch_registers_using_g (struct regcache *regcache)
process_g_packet (regcache);
}
+/* Make the remote selected traceframe match GDB's selected
+ traceframe. */
+
+static void
+set_remote_traceframe (void)
+{
+ int newnum;
+
+ if (remote_traceframe_number == get_traceframe_number ())
+ return;
+
+ /* Avoid recursion, remote_trace_find calls us again. */
+ remote_traceframe_number = get_traceframe_number ();
+
+ newnum = target_trace_find (tfind_number,
+ get_traceframe_number (), 0, 0, NULL);
+
+ /* Should not happen. If it does, all bets are off. */
+ if (newnum != get_traceframe_number ())
+ warning (_("could not set remote traceframe"));
+}
+
static void
remote_fetch_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
@@ -5777,6 +5804,7 @@ remote_fetch_registers (struct target_ops *ops,
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
+ set_remote_traceframe ();
set_general_thread (inferior_ptid);
if (regnum >= 0)
@@ -5934,6 +5962,7 @@ remote_store_registers (struct target_ops *ops,
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
+ set_remote_traceframe ();
set_general_thread (inferior_ptid);
if (regnum >= 0)
@@ -6502,6 +6531,7 @@ remote_xfer_memory (CORE_ADDR mem_addr, gdb_byte *buffer, int mem_len,
{
int res;
+ set_remote_traceframe ();
set_general_thread (inferior_ptid);
if (should_write)
@@ -8084,6 +8114,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
char *p2;
char query_type;
+ set_remote_traceframe ();
set_general_thread (inferior_ptid);
rs = get_remote_state ();
@@ -9972,6 +10003,12 @@ remote_trace_find (enum trace_find_type type, int num,
char *p, *reply;
int target_frameno = -1, target_tracept = -1;
+ /* Lookups other than by absolute frame number depend on the current
+ trace selected, so make sure it is correct on the remote end
+ first. */
+ if (type != tfind_number)
+ set_remote_traceframe ();
+
p = rs->buf;
strcpy (p, "QTFrame:");
p = strchr (p, '\0');
@@ -10009,6 +10046,8 @@ remote_trace_find (enum trace_find_type type, int num,
target_frameno = (int) strtol (p, &reply, 16);
if (reply == p)
error (_("Unable to parse trace frame number"));
+ /* Don't update our remote traceframe number cache on failure
+ to select a remote traceframe. */
if (target_frameno == -1)
return -1;
break;
@@ -10029,6 +10068,8 @@ remote_trace_find (enum trace_find_type type, int num,
}
if (tpp)
*tpp = target_tracept;
+
+ remote_traceframe_number = target_frameno;
return target_frameno;
}
@@ -10039,6 +10080,8 @@ remote_get_trace_state_variable_value (int tsvnum, LONGEST *val)
char *reply;
ULONGEST uval;
+ set_remote_traceframe ();
+
sprintf (rs->buf, "qTV:%x", tsvnum);
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);