public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap: make tracepoints work when a probe has a semaphore
@ 2011-03-23 20:44 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-03-23 20:44 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap has been updated
       via  8531c9a99512b24369506b9dd2748e8f692e3839 (commit)
      from  1cc4a26d82cf57ab2e9bf96447c2e6e1013345cb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 8531c9a99512b24369506b9dd2748e8f692e3839
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Mar 23 14:48:57 2011 -0600

    make tracepoints work when a probe has a semaphore

-----------------------------------------------------------------------

Summary of changes:
 gdb/breakpoint.c |   35 +++++++++++++++++++++++++----------
 gdb/breakpoint.h |    7 +++++++
 gdb/tracepoint.c |   26 ++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 10 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 07d105d..9f97c9d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1502,19 +1502,36 @@ should_be_inserted (struct bp_location *bl)
   return 1;
 }
 
-/* Set or clear a SystemTap semaphore.  ARCH is the target
-   architecture; ADDRESS is the address of the semaphore, and SETTING
-   is either zero or one.  */
+/* See the comment in breakpoint.h.  */
 
-static void
-modify_semaphore (struct gdbarch *arch, CORE_ADDR address, int setting)
+void
+modify_semaphore (struct bp_location *loc, int set)
 {
+  struct gdbarch *arch = loc->gdbarch;
   gdb_byte bytes[sizeof (LONGEST)];
   /* The ABI specifies "unsigned short".  */
   struct type *type = builtin_type (arch)->builtin_unsigned_short;
+  CORE_ADDR address = loc->semaphore;
+  ULONGEST value;
+
+  if (address == 0)
+    return;
+
+  /* Swallow errors.  */
+  if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
+    return;
+
+  value = extract_unsigned_integer (bytes, TYPE_LENGTH (type),
+				    gdbarch_byte_order (arch));
+  /* Note that we explicitly don't worry about overflow or
+     underflow.  */
+  if (set)
+    ++value;
+  else
+    --value;
 
   store_unsigned_integer (bytes, TYPE_LENGTH (type),
-			  gdbarch_byte_order (arch), setting);
+			  gdbarch_byte_order (arch), value);
 
   /* Ignore errors.  FIXME.  */
   target_write_memory (address, bytes, TYPE_LENGTH (type));
@@ -1616,8 +1633,7 @@ insert_bp_location (struct bp_location *bl,
 	    val = target_insert_breakpoint (bl->gdbarch,
 					    &bl->target_info);
 
-	  if (bl->semaphore != 0)
-	    modify_semaphore (bl->gdbarch, bl->semaphore, 1);
+	  modify_semaphore (bl, 1);
 	}
       else
 	{
@@ -2613,8 +2629,7 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is)
 	  else
 	    val = target_remove_breakpoint (bl->gdbarch, &bl->target_info);
 
-	  if (bl->semaphore != 0)
-	    modify_semaphore (bl->gdbarch, bl->semaphore, 0);
+	  modify_semaphore (bl, 0);
 	}
       else
 	{
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 508699b..c53af61 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1196,4 +1196,11 @@ extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint *
 
 extern int user_breakpoint_p (struct breakpoint *);
 
+/* Set or clear a SystemTap semaphore.  LOC is the location which may
+   hold a semaphore.  SET is non-zero if the semaphore should be set,
+   or zero if the semaphore should be cleared.  Semaphores act as
+   reference counters, so calls to this function must be paired.  */
+
+extern void modify_semaphore (struct bp_location *location, int set);
+
 #endif /* !defined (BREAKPOINT_H) */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e1d2e82..d3cd593 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1600,6 +1600,8 @@ start_tracing (void)
 
   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))
@@ -1608,6 +1610,9 @@ start_tracing (void)
       t->number_on_target = 0;
       target_download_tracepoint (t);
       t->number_on_target = t->number;
+
+      for (loc = t->loc; loc; loc = loc->next)
+	modify_semaphore (loc, 1);
     }
   VEC_free (breakpoint_p, tp_vec);
 
@@ -1669,7 +1674,28 @@ trace_stop_command (char *args, int from_tty)
 void
 stop_tracing (void)
 {
+  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)
+	modify_semaphore (loc, 0);
+    }
+
+  VEC_free (breakpoint_p, tp_vec);
+
   /* Should change in response to reply?  */
   current_trace_status ()->running = 0;
 }


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-23 20:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 20:44 [SCM] archer-sergiodj-stap: make tracepoints work when a probe has a semaphore tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).