2011-12-09 Hui Zhu Yao Qi * target.c (target_get_trace_status): New function. Call observer_notify_trace_stopped if trace is stopped. * target.h (target_get_trace_status): Remove macro. * tracepoint.c (stop_tracing): Call observer_notify_trace_stopped. (trace_start_command): Call stop_tracing. (trace_stopped): New. (_initialize_tracepoint): Install trace_stopped to observer `trace_stopped'. gdb/doc: 2011-12-09 Yao Qi * observer.texi (trace_stopped): New observer. --- gdb/doc/observer.texi | 4 ++++ gdb/target.c | 12 ++++++++++++ gdb/target.h | 3 +-- gdb/tracepoint.c | 25 ++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi index 689b303..1daf75a 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -188,6 +188,10 @@ A tracepoint has been modified in some way. The argument @var{tpnum} is the number of the modified tracepoint. @end deftypefun +@deftypefun void trace_stopped (void) +A trace run has been stopped. +@end deftypefun + @deftypefun void architecture_changed (struct gdbarch *@var{newarch}) The current architecture has changed. The argument @var{newarch} is a pointer to the new architecture. diff --git a/gdb/target.c b/gdb/target.c index 5700066..e5bac02 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -44,6 +44,7 @@ #include "exec.h" #include "inline-frame.h" #include "tracepoint.h" +#include "observer.h" static void target_info (char *, int); @@ -505,6 +506,17 @@ target_terminal_inferior (void) (*current_target.to_terminal_inferior) (); } +int +target_get_trace_status(struct trace_status *ts) +{ + int ret = (*current_target.to_get_trace_status) (ts); + + if (!ts->running) + observer_notify_trace_stopped (); + + return ret; +} + static int nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write, struct target_ops *t) diff --git a/gdb/target.h b/gdb/target.h index fd488d6..8a6dce9 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1517,8 +1517,7 @@ extern int target_search_memory (CORE_ADDR start_addr, #define target_trace_set_readonly_regions() \ (*current_target.to_trace_set_readonly_regions) () -#define target_get_trace_status(ts) \ - (*current_target.to_get_trace_status) (ts) +extern int target_get_trace_status(struct trace_status *ts); #define target_get_tracepoint_status(tp,utp) \ (*current_target.to_get_tracepoint_status) (tp, utp) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index e00538c..7b4c56a 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1824,6 +1824,8 @@ trace_start_command (char *args, int from_tty) if (from_tty && !query (_("A trace is running already. Start a new run? "))) error (_("New trace run not started.")); + + stop_tracing (NULL); } start_tracing (args); @@ -1857,8 +1859,27 @@ stop_tracing (char *note) if (!ret && note) warning ("Target does not support trace notes, note ignored"); - /* Should change in response to reply? */ + observer_notify_trace_stopped (); +} + +static void +trace_stopped (void) +{ + VEC(breakpoint_p) *tp_vec = NULL; + int ix; + struct breakpoint *b; + current_trace_status ()->running = 0; + + tp_vec = all_tracepoints (); + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++) + { + struct bp_location *loc; + + for (loc = b->loc; loc; loc = loc->next) + loc->inserted = 0; + } + VEC_free (breakpoint_p, tp_vec); } /* tstatus command */ @@ -5327,5 +5348,7 @@ Show the notes string to use for future tstop commands"), NULL, init_tfile_ops (); + observer_attach_trace_stopped (trace_stopped); + add_target (&tfile_ops); } -- 1.7.0.4