public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-jankratochvil-fedora16: Merge remote-tracking branch 'archer/archer-sergiodj-stap-patch-split' into archer-jankratochvil-fedora16
@ 2011-07-21  9:14 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2011-07-21  9:14 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-fedora16 has been updated
       via  e21b616cf5060a796c9c0fccdc5581ec00d9e13a (commit)
       via  183a3b78cfd1dfede0418631628d2115c0159f17 (commit)
       via  546d057aa9504e63c027ebc2a8fbae74d4801d2b (commit)
       via  fcd897a3915691e185df413bd32e22744bc106b1 (commit)
       via  d21606aeeaf31eca7ed2b3a67ace52adc6dbf17d (commit)
       via  ece7225f44e5eafd7817f19109bfcf740c259f96 (commit)
       via  ef9fe0b2edcf9d1a97cc995d14c2c863d10fa701 (commit)
       via  53246cde132053e86526163a1d86d0ebf57f3b67 (commit)
      from  762a658d6fbcc36bf4bc87e0ecbe7dd93ec6fd5e (commit)

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

- Log -----------------------------------------------------------------
commit e21b616cf5060a796c9c0fccdc5581ec00d9e13a
Merge: 183a3b7 546d057
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Jul 21 11:12:06 2011 +0200

    Merge remote-tracking branch 'archer/archer-sergiodj-stap-patch-split' into archer-jankratochvil-fedora16

commit 183a3b78cfd1dfede0418631628d2115c0159f17
Merge: 762a658 53246cd
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Jul 21 11:11:44 2011 +0200

    Merge remote-tracking branch 'archer/archer-tromey-python' into archer-jankratochvil-fedora16

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

Summary of changes:
 gdb/Makefile.in                        |    8 +-
 gdb/NEWS                               |    4 +
 gdb/ax-gdb.c                           |    5 +-
 gdb/breakpoint.c                       |  181 +++-
 gdb/breakpoint.h                       |   12 +
 gdb/cli/cli-utils.c                    |   29 +
 gdb/cli/cli-utils.h                    |    7 +
 gdb/coffread.c                         |    1 +
 gdb/dbxread.c                          |    1 +
 gdb/doc/gdb.texinfo                    |   82 ++
 gdb/elfread.c                          |  281 +++++
 gdb/infrun.c                           |   91 ++-
 gdb/linespec.c                         |    5 +
 gdb/linespec.h                         |    4 +
 gdb/machoread.c                        |    1 +
 gdb/mipsread.c                         |    1 +
 gdb/objfiles.c                         |    5 +
 gdb/somread.c                          |    1 +
 gdb/stap-probe.c                       | 2042 ++++++++++++++++++++++++++++++++
 gdb/stap-probe.h                       |  114 ++
 gdb/symfile.h                          |   55 +
 gdb/symtab.c                           |    1 +
 gdb/symtab.h                           |    4 +
 gdb/testsuite/gdb.base/default.exp     |   11 +
 gdb/testsuite/gdb.base/stap-probe.c    |   69 ++
 gdb/testsuite/gdb.base/stap-probe.exp  |   72 ++
 gdb/testsuite/gdb.cp/nextoverthrow.exp |   11 +
 gdb/testsuite/gdb.trace/stap-trace.c   |   71 ++
 gdb/testsuite/gdb.trace/stap-trace.exp |  129 ++
 gdb/thread.c                           |   14 +-
 gdb/tracepoint.c                       |   40 +-
 gdb/value.c                            |   58 +-
 gdb/value.h                            |   48 +-
 gdb/windows-tdep.c                     |   13 +-
 gdb/xcoffread.c                        |    1 +
 35 files changed, 3428 insertions(+), 44 deletions(-)
 create mode 100644 gdb/stap-probe.c
 create mode 100644 gdb/stap-probe.h
 create mode 100644 gdb/testsuite/gdb.base/stap-probe.c
 create mode 100644 gdb/testsuite/gdb.base/stap-probe.exp
 create mode 100644 gdb/testsuite/gdb.trace/stap-trace.c
 create mode 100644 gdb/testsuite/gdb.trace/stap-trace.exp

First 500 lines of diff:
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 633e637..d0a7ab8 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -720,8 +720,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	sentinel-frame.c \
 	serial.c ser-base.c ser-unix.c \
 	solib.c solib-target.c source.c \
-	stabsread.c stack.c std-regs.c symfile.c symfile-mem.c symmisc.c \
-	symtab.c \
+	stabsread.c stack.c stap-probe.c std-regs.c \
+	symfile.c symfile-mem.c symmisc.c symtab.c \
 	target.c target-descriptions.c target-memory.c \
 	thread.c top.c tracepoint.c \
 	trad-frame.c \
@@ -816,7 +816,7 @@ osdata.h procfs.h python/py-event.h python/py-events.h python/py-stopevent.h \
 python/python-internal.h python/python.h ravenscar-thread.h record.h \
 solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \
 gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \
-gnulib/stddef.in.h inline-frame.h
+gnulib/stddef.in.h inline-frame.h stap-probe.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
@@ -901,7 +901,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
 	prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o \
 	target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
 	inferior.o osdata.o gdb_usleep.o record.o gcore.o \
-	jit.o progspace.o
+	jit.o progspace.o stap-probe.o
 
 TSOBS = inflow.o
 
diff --git a/gdb/NEWS b/gdb/NEWS
index 22d5a9c..3547eaf 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -102,6 +102,10 @@ QTDisable
   Initial support for the OpenCL C language (http://www.khronos.org/opencl)
   has been integrated into GDB.
 
+* GDB now has support for SystemTap <sys/sdt.h> probes.  You can set a
+  breakpoint using the new "probe:" linespec and inspect the probe
+  arguments using the new $_probe_arg family of convenience variables.
+
 * Python scripting
 
   ** The function gdb.Write now accepts an optional keyword 'stream'.
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 5258167..8afefa8 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2001,7 +2001,8 @@ gen_expr (struct expression *exp, union exp_element **pc,
 
     case OP_INTERNALVAR:
       {
-	const char *name = internalvar_name ((*pc)[1].internalvar);
+	struct internalvar *var = (*pc)[1].internalvar;
+	const char *name = internalvar_name (var);
 	struct trace_state_variable *tsv;
 
 	(*pc) += 3;
@@ -2015,7 +2016,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
 	    value->kind = axs_rvalue;
 	    value->type = builtin_type (exp->gdbarch)->builtin_long_long;
 	  }
-	else
+	else if (! compile_internalvar_to_ax (var, ax, value))
 	  error (_("$%s is not a trace state variable; GDB agent "
 		   "expressions cannot use convenience variables."), name);
       }
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b2f1f0a..0a9b4cf 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -63,6 +63,8 @@
 #include "jit.h"
 #include "xml-syscall.h"
 #include "parser-defs.h"
+#include "gdb_regex.h"
+#include "stap-probe.h"
 #include "cli/cli-utils.h"
 #include "continuations.h"
 
@@ -1535,6 +1537,40 @@ should_be_inserted (struct bp_location *bl)
   return 1;
 }
 
+/* See the comment in breakpoint.h.  */
+
+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), value);
+
+  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.
@@ -1631,6 +1667,8 @@ insert_bp_location (struct bp_location *bl,
 	  else
 	    val = target_insert_breakpoint (bl->gdbarch,
 					    &bl->target_info);
+
+	  modify_semaphore (bl, 1);
 	}
       else
 	{
@@ -2124,11 +2162,23 @@ struct breakpoint_objfile_data
   /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any).  */
   struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES];
 
+  /* True if we have looked for longjmp probes.  */
+  int longjmp_searched;
+
+  /* SystemTap probe points for longjmp (if any).  */
+  VEC (stap_probe_p) *longjmp_probes;
+
   /* Minimal symbol for "std::terminate()" (if any).  */
   struct minimal_symbol *terminate_msym;
 
   /* Minimal symbol for "_Unwind_DebugHook" (if any).  */
   struct minimal_symbol *exception_msym;
+
+  /* True if we have looked for exception probes.  */
+  int exception_searched;
+
+  /* SystemTap probe points for unwinding (if any).  */
+  VEC (stap_probe_p) *exception_probes;
 };
 
 static const struct objfile_data *breakpoint_objfile_key;
@@ -2165,6 +2215,15 @@ get_breakpoint_objfile_data (struct objfile *objfile)
 }
 
 static void
+free_breakpoint_probes (struct objfile *obj, void *data)
+{
+  struct breakpoint_objfile_data *bp_objfile_data = data;
+
+  VEC_free (stap_probe_p, bp_objfile_data->longjmp_probes);
+  VEC_free (stap_probe_p, bp_objfile_data->exception_probes);
+}
+
+static void
 create_overlay_event_breakpoint (void)
 {
   struct objfile *objfile;
@@ -2240,6 +2299,36 @@ create_longjmp_master_breakpoint (void)
 
       bp_objfile_data = get_breakpoint_objfile_data (objfile);
 
+      if (!bp_objfile_data->longjmp_searched)
+	{
+	  bp_objfile_data->longjmp_probes
+	    = find_probes_in_objfile (objfile, "libc", "longjmp");
+	  bp_objfile_data->longjmp_searched = 1;
+	}
+
+      if (bp_objfile_data->longjmp_probes != NULL)
+	{
+	  int i;
+	  const struct stap_probe *probe;
+	  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
+	  for (i = 0;
+	       VEC_iterate (stap_probe_p,
+			    bp_objfile_data->longjmp_probes,
+			    i, probe);
+	       ++i)
+	    {
+	      struct breakpoint *b;
+	       
+	      b = create_internal_breakpoint (gdbarch, probe->address,
+					      bp_longjmp_master);
+	      b->addr_string = xstrdup ("probe:libc:longjmp");
+	      b->enable_state = bp_disabled;
+	    }
+
+	  continue;
+	}
+
       for (i = 0; i < NUM_LONGJMP_NAMES; i++)
 	{
 	  struct breakpoint *b;
@@ -2348,6 +2437,39 @@ create_exception_master_breakpoint (void)
 
       bp_objfile_data = get_breakpoint_objfile_data (objfile);
 
+      /* We prefer the SystemTap probe point if it exists.  */
+      if (!bp_objfile_data->exception_searched)
+	{
+	  bp_objfile_data->exception_probes
+	    = find_probes_in_objfile (objfile, "libgcc", "unwind");
+	  bp_objfile_data->exception_searched = 1;
+	}
+
+      if (bp_objfile_data->exception_probes != NULL)
+	{
+	  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+	  int i;
+	  const struct stap_probe *probe;
+
+	  for (i = 0;
+	       VEC_iterate (stap_probe_p,
+			    bp_objfile_data->exception_probes,
+			    i, probe);
+	       ++i)
+	    {
+	      struct breakpoint *b;
+
+	      b = create_internal_breakpoint (gdbarch, probe->address,
+					      bp_exception_master);
+	      b->addr_string = xstrdup ("probe:libgcc:unwind");
+	      b->enable_state = bp_disabled;
+	    }
+
+	  continue;
+	}
+
+      /* Otherwise, try the hook function.  */
+
       if (msym_not_found_p (bp_objfile_data->exception_msym))
 	continue;
 
@@ -2566,6 +2688,8 @@ 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);
+
+	  modify_semaphore (bl, 0);
 	}
       else
 	{
@@ -5971,6 +6095,7 @@ init_raw_breakpoint (struct breakpoint *b, 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.  */
@@ -7240,6 +7365,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;
@@ -7458,6 +7584,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;
 
@@ -7806,6 +7933,16 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 {
   int i;
 
+  if (canonical->pre_expanded)
+    {
+      create_breakpoint_sal (gdbarch, sals, canonical->canonical[0],
+			     cond_string, type, disposition,
+			     thread, task, ignore_count, ops,
+			     from_tty, enabled, internal,
+			     canonical->special_display);
+      return;
+    }
+
   for (i = 0; i < sals.nelts; ++i)
     {
       struct symtabs_and_lines expanded = 
@@ -8314,7 +8451,7 @@ create_breakpoint (struct gdbarch *gdbarch,
       observer_notify_breakpoint_created (b);
     }
   
-  if (sals.nelts > 1)
+  if (sals.nelts > 1 && !canonical.pre_expanded)
     {
       warning (_("Multiple breakpoints were set.\nUse the "
 		 "\"delete\" command to delete unwanted breakpoints."));
@@ -11351,12 +11488,14 @@ update_breakpoint_locations (struct breakpoint *b,
    On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
 
 static struct symtabs_and_lines
-addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
+addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
+		     int *pre_expanded)
 {
   char *s;
   int marker_spec;
   struct symtabs_and_lines sals = {0};
   struct gdb_exception e;
+  int my_pre_expanded = 0;
 
   s = addr_string;
   marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s);
@@ -11375,7 +11514,27 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 	    error (_("marker %s not found"), b->static_trace_marker_id);
 	}
       else
-	sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL);
+	{
+	  struct linespec_result canonical;
+
+	  init_linespec_result (&canonical);
+	  sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0,
+				&canonical);
+
+	  /* We don't need the contents.  */
+	  if (canonical.canonical)
+	    {
+	      int i;
+
+	      for (i = 0; i < sals.nelts; ++i)
+		xfree (canonical.canonical[i]);
+	      xfree (canonical.canonical);
+	    }
+
+	  my_pre_expanded = canonical.pre_expanded;
+	  if (pre_expanded)
+	    *pre_expanded = my_pre_expanded;
+	}
     }
   if (e.reason < 0)
     {
@@ -11408,7 +11567,7 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 
   if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
     {
-      gdb_assert (sals.nelts == 1);
+      gdb_assert (my_pre_expanded || sals.nelts == 1);
 
       resolve_sal_pc (&sals.sals[0]);
       if (b->condition_not_parsed && s && s[0])
@@ -11444,17 +11603,22 @@ breakpoint_re_set_default (struct breakpoint *b)
   struct symtabs_and_lines sals, sals_end;
   struct symtabs_and_lines expanded = {0};
   struct symtabs_and_lines expanded_end = {0};
+  int pre_expanded = 0;
 
-  sals = addr_string_to_sals (b, b->addr_string, &found);
+  sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded);
   if (found)
     {
       make_cleanup (xfree, sals.sals);
-      expanded = expand_line_sal_maybe (sals.sals[0]);
+      if (pre_expanded)
+	expanded = sals;
+      else
+	expanded = expand_line_sal_maybe (sals.sals[0]);
     }
 
   if (b->addr_string_range_end)
     {
-      sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found);
+      sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found,
+				      NULL);
       if (found)
 	{
 	  make_cleanup (xfree, sals_end.sals);
@@ -13041,7 +13205,8 @@ _initialize_breakpoint (void)
   observer_attach_inferior_exit (clear_syscall_counts);
   observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
 
-  breakpoint_objfile_key = register_objfile_data ();
+  breakpoint_objfile_key
+    = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes);
 
   breakpoint_chain = 0;
   /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6fca479..b82f956 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -383,6 +383,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.  */
@@ -1316,4 +1321,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/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 62a2f12..dd2824f 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -245,3 +245,32 @@ remove_trailing_whitespace (const char *start, char *s)
 
   return s;
 }
+
+/* See documentation in cli-utils.h.  */
+
+char *
+extract_arg (char **arg)
+{
+  char *result, *copy;
+
+  if (!*arg)
+    return NULL;
+
+  /* Find the start of the argument.  */
+  *arg = skip_spaces (*arg);
+  if (! **arg)
+    return NULL;
+  result = *arg;
+
+  /* Find the end of the argument.  */
+  *arg = skip_to_space (*arg + 1);
+
+  if (result == *arg)
+    return NULL;
+
+  copy = xmalloc (*arg - result + 1);
+  memcpy (copy, result, *arg - result);
+  copy[*arg - result] = '\0';
+
+  return copy;
+}
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 8a6e5b3..ed1a63e 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -103,4 +103,11 @@ extern char *skip_to_space (char *inp);
    START.  */
 
 extern char *remove_trailing_whitespace (const char *start, char *s);
+
+/* A helper function to extract an argument from *ARG.  An argument is
+   delimited by whitespace.  The return value is either NULL if no
+   argument was found, or an xmalloc'd string.  */
+
+extern char *extract_arg (char **arg);
+
 #endif /* CLI_UTILS_H */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index cf8fb54..f17ead9 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2197,6 +2197,7 @@ static const struct sym_fns coff_sym_fns =
 
   default_symfile_relocate,	/* sym_relocate: Relocate a debug
 				   section.  */
+  NULL,				/* sym_probe_fns */
   &psym_functions
 };
 
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 33c776f..14a1bab 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -3590,6 +3590,7 @@ static const struct sym_fns aout_sym_fns =
   default_symfile_segments,	/* Get segment information from a file.  */
   NULL,


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


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

only message in thread, other threads:[~2011-07-21  9:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21  9:14 [SCM] archer-jankratochvil-fedora16: Merge remote-tracking branch 'archer/archer-sergiodj-stap-patch-split' into archer-jankratochvil-fedora16 jkratoch

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).