2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com>
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index c2133747686ab3bfe1eb9743bb3b6bb525d33160..e5b57e1a9264d945596c4e6be4093b970b58a6af 100644 (file)
@@ -52,6 +52,7 @@
 #include "memrange.h"
 #include "exceptions.h"
 #include "cli/cli-utils.h"
+#include "probe.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -1717,6 +1718,7 @@ start_tracing (char *notes)
   for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
     {
       struct tracepoint *t = (struct tracepoint *) b;
+      struct bp_location *loc;
 
       if (b->enable_state == bp_enabled)
        any_enabled = 1;
@@ -1779,6 +1781,9 @@ start_tracing (char *notes)
        }
 
       t->number_on_target = b->number;
+
+      for (loc = b->loc; loc; loc = loc->next)
+       loc->probe->pops->set_semaphore (loc->probe, loc->gdbarch);
     }
   VEC_free (breakpoint_p, tp_vec);
 
@@ -1851,9 +1856,34 @@ void
 stop_tracing (char *note)
 {
   int ret;
+  VEC(breakpoint_p) *tp_vec = NULL;
+  int ix;
+  struct breakpoint *t;
 
   target_trace_stop ();
 
+  tp_vec = all_tracepoints ();
+  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
+    {
+      struct bp_location *loc;
+
+      if ((t->type == bp_fast_tracepoint
+          ? !may_insert_fast_tracepoints
+          : !may_insert_tracepoints))
+       continue;
+
+      for (loc = t->loc; loc; loc = loc->next)
+       {
+         /* GDB can be totally absent in some disconnected trace scenarios,
+            but we don't really care if this semaphore goes out of sync.
+            That's why we are decrementing it here, but not taking care
+            in other places.  */
+         loc->probe->pops->clear_semaphore (loc->probe, loc->gdbarch);
+       }
+    }
+
+  VEC_free (breakpoint_p, tp_vec);
+
   if (!note)
     note = trace_stop_notes;
   ret = target_set_trace_notes (NULL, NULL, note);
This page took 0.02557 seconds and 4 git commands to generate.