--- remote.c | 30 ++++++++++++++++++++---------- tracepoint.c | 1 + tracepoint.h | 3 +++ 3 files changed, 24 insertions(+), 10 deletions(-) --- a/remote.c +++ b/remote.c @@ -3203,6 +3203,7 @@ remote_start_remote (int from_tty, struc struct remote_state *rs = get_remote_state (); struct packet_config *noack_config; char *wait_status = NULL; + struct trace_status *ts = current_trace_status (); immediate_quit++; /* Allow user to interrupt it. */ @@ -3212,6 +3213,9 @@ remote_start_remote (int from_tty, struc /* Ack any packet which the remote side has already sent. */ serial_write (remote_desc, "+", 1); + /* Set status to not initialized. */ + ts->initialized = 0; + /* The first packet we send to the target is the optional "supported packets" request. If the target can answer this, it will tell us which later probes to skip. */ @@ -3435,7 +3439,8 @@ remote_start_remote (int from_tty, struc /* Possibly the target has been engaged in a trace run started previously; find out where things are at. */ - if (remote_get_trace_status (current_trace_status ()) != -1) + ts->initialized = 1; + if (remote_get_trace_status (ts) != -1) { struct uploaded_tp *uploaded_tps = NULL; struct uploaded_tsv *uploaded_tsvs = NULL; @@ -10276,6 +10281,19 @@ remote_get_trace_status (struct trace_st extern int trace_regblock_size; volatile struct gdb_exception ex; + /* We're working with a live target. */ + ts->from_file = 0; + + /* Set some defaults. */ + ts->running_known = 0; + ts->stop_reason = trace_stop_reason_unknown; + ts->traceframe_count = -1; + ts->buffer_free = 0; + ts->running = 0; + + if (!ts->initialized) + goto out; + trace_regblock_size = get_remote_arch_state ()->sizeof_g_packet; putpkt ("qTStatus"); @@ -10294,20 +10312,12 @@ remote_get_trace_status (struct trace_st if (*p == '\0') return -1; - /* We're working with a live target. */ - ts->from_file = 0; - - /* Set some defaults. */ - ts->running_known = 0; - ts->stop_reason = trace_stop_reason_unknown; - ts->traceframe_count = -1; - ts->buffer_free = 0; - if (*p++ != 'T') error (_("Bogus trace status reply from target: %s"), target_buf); parse_trace_status (p, ts); +out: return ts->running; } --- a/tracepoint.c +++ b/tracepoint.c @@ -3670,6 +3670,7 @@ tfile_open (char *filename, int from_tty trace_regblock_size = 0; ts = current_trace_status (); + ts->initialized = 1; /* We know we're working with a file. */ ts->from_file = 1; /* Set defaults in case there is no status line. */ --- a/tracepoint.h +++ b/tracepoint.h @@ -72,6 +72,9 @@ enum trace_stop_reason struct trace_status { + /* The target will try to get the status only when this is true. */ + int initialized; + /* This is true if the status is coming from a file rather than a live target. */ int from_file;