diff mbox

[RFC,06/15] Add possibility to restart trace after tfind.

Message ID 1dcc0d92d986b5ecc43973dc75832e01edf69c9f.1444820235.git.henrik.wallin@windriver.com
State New
Headers show

Commit Message

henrik.wallin@windriver.com Oct. 14, 2015, 11:14 a.m. UTC
From: Par Olsson <par.olsson@windriver.com>

After starting examine the collected trace data
with tfind it was not possible to re-start a trace session.
This patch will add a question if the user wants to
drop all collected data and start a new session.

gdb/ChangeLog:

	* tracepoint.c : Initiate traceframe_number.
	(trace_start_command): Add interactive question if
	user wants to clear and restart a trace session when issuing a
	tstart while in progress examining trace data.

Signed-off-by: Par Olsson <par.olsson@windriver.com>
Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
---
 gdb/tracepoint.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Pedro Alves Oct. 15, 2015, 5:26 p.m. UTC | #1
On 10/14/2015 12:14 PM, henrik.wallin@windriver.com wrote:
> From: Par Olsson <par.olsson@windriver.com>
> 
> After starting examine the collected trace data
> with tfind it was not possible to re-start a trace session.

What would happen?

> This patch will add a question if the user wants to
> drop all collected data and start a new session.

Testcase.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 6ca66e7c8d18..4aad1d6a4197 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -123,7 +123,7 @@  static VEC(tsv_s) *tvariables;
 static int next_tsv_number = 1;
 
 /* Number of last traceframe collected.  */
-static int traceframe_number;
+static int traceframe_number = -1;
 
 /* Tracepoint for last traceframe collected.  */
 static int tracepoint_number;
@@ -1914,6 +1914,18 @@  trace_start_command (char *args, int from_tty)
 	  && !query (_("A trace is running already.  Start a new run? ")))
 	error (_("New trace run not started."));
     }
+  if (traceframe_number >= 0)
+    {
+      if (from_tty
+	  && !query (_("Currently examining trace data. "
+		       "Start a new run? ")))
+	error (_("New trace run not started."));
+      /* Reset our local state.  */
+      set_traceframe_num (-1);
+      set_tracepoint_num (-1);
+      set_traceframe_context (NULL);
+      clear_traceframe_info ();
+    }
 
   start_tracing (args);
 }