public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap: make gdb enable semaphores
@ 2011-02-11 16:16 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-02-11 16:16 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap has been updated
       via  18c80cb69448f129b9b13b3b8288a437d260cdb0 (commit)
      from  3eb16a82b0d09e0be398246165355a5e2711adb3 (commit)

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

- Log -----------------------------------------------------------------
commit 18c80cb69448f129b9b13b3b8288a437d260cdb0
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Feb 11 09:15:38 2011 -0700

    make gdb enable semaphores

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

Summary of changes:
 gdb/breakpoint.c |   27 +++++++++++++++++++++++++++
 gdb/breakpoint.h |    5 +++++
 gdb/stap-probe.c |    1 +
 gdb/symtab.c     |    1 +
 gdb/symtab.h     |    4 ++++
 5 files changed, 38 insertions(+), 0 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8390be8..6f694fc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1592,6 +1592,24 @@ 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.  */
+
+static void
+modify_semaphore (struct gdbarch *arch, CORE_ADDR address, int setting)
+{
+  gdb_byte bytes[sizeof (LONGEST)];
+  /* The ABI specifies "unsigned short".  */
+  struct type *type = builtin_type (arch)->builtin_unsigned_short;
+
+  store_unsigned_integer (bytes, TYPE_LENGTH (type),
+			  gdbarch_byte_order (arch), setting);
+
+  /* Ignore errors.  FIXME.  */
+  target_write_memory (address, bytes, TYPE_LENGTH (type));
+}
+
 /* Insert a low-level "breakpoint" of some type.  BL is the breakpoint
    location.  Any error messages are printed to TMP_ERROR_STREAM; and
    DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems.
@@ -1687,6 +1705,9 @@ insert_bp_location (struct bp_location *bl,
 	  else
 	    val = target_insert_breakpoint (bl->gdbarch,
 					    &bl->target_info);
+
+	  if (bl->semaphore != 0)
+	    modify_semaphore (bl->gdbarch, bl->semaphore, 1);
 	}
       else
 	{
@@ -2494,6 +2515,9 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is)
 	    val = target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info);
 	  else
 	    val = target_remove_breakpoint (bl->gdbarch, &bl->target_info);
+
+	  if (bl->semaphore != 0)
+	    modify_semaphore (bl->gdbarch, bl->semaphore, 0);
 	}
       else
 	{
@@ -5713,6 +5737,7 @@ set_raw_breakpoint (struct gdbarch *gdbarch,
   b->loc->requested_address = sal.pc;
   b->loc->address = adjusted_address;
   b->loc->pspace = sal.pspace;
+  b->loc->semaphore = sal.semaphore;
 
   /* Store the program space that was used to set the breakpoint, for
      breakpoint resetting.  */
@@ -6822,6 +6847,7 @@ clone_momentary_breakpoint (struct breakpoint *orig)
   copy->loc->address = orig->loc->address;
   copy->loc->section = orig->loc->section;
   copy->loc->pspace = orig->loc->pspace;
+  copy->loc->semaphore = orig->loc->semaphore;
 
   if (orig->source_file == NULL)
     copy->source_file = NULL;
@@ -7041,6 +7067,7 @@ add_location_to_breakpoint (struct breakpoint *b,
   loc->address = adjust_breakpoint_address (loc->gdbarch,
 					    loc->requested_address, b->type);
   loc->pspace = sal->pspace;
+  loc->semaphore = sal->semaphore;
   gdb_assert (loc->pspace != NULL);
   loc->section = sal->section;
 
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 2d815c2..f5bf34b 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -344,6 +344,11 @@ struct bp_location
      processor's architectual constraints.  */
   CORE_ADDR requested_address;
 
+  /* If the location comes from a SystemTap probe point, and the probe
+     has an associated semaphore variable, then this is the address of
+     the semaphore.  Otherwise, this is zero.  */
+  CORE_ADDR semaphore;
+
   char *function_name;
 
   /* Details of the placed breakpoint, when inserted.  */
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 8deaf3a..138e888 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -386,6 +386,7 @@ parse_stap_probe (char **argptr)
 	sal->explicit_pc = 1;
 	sal->section = find_pc_overlay (sal->pc);
 	sal->pspace = current_program_space;
+	sal->semaphore = probes[i].sem_addr;
       }
   }
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index bdf34d6..e74bfcf 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -770,6 +770,7 @@ init_sal (struct symtab_and_line *sal)
   sal->end = 0;
   sal->explicit_pc = 0;
   sal->explicit_line = 0;
+  sal->semaphore = 0;
 }
 \f
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 6864b96..b3798e5 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1073,6 +1073,10 @@ struct symtab_and_line
   CORE_ADDR end;
   int explicit_pc;
   int explicit_line;
+
+  /* If non-zero, the semaphore location associated with a SystemTap
+     probe.  */
+  CORE_ADDR semaphore;
 };
 
 extern void init_sal (struct symtab_and_line *sal);


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


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

only message in thread, other threads:[~2011-02-11 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-11 16:16 [SCM] archer-sergiodj-stap: make gdb enable semaphores 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).