public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap: initial support for $_marker_arg* variables
@ 2011-02-08 18:05 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-02-08 18:05 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap has been updated
       via  b565b326318dd4f1f2acb315fa0893bac684aacc (commit)
       via  76e428b270fddd2bebf1848f96c307ea4a3f0c6b (commit)
       via  97cfc33dbf75cc927930d3637d4c8c9013867bc4 (commit)
      from  6009dab0499648c1bf3c3731f070529367afade7 (commit)

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

- Log -----------------------------------------------------------------
commit b565b326318dd4f1f2acb315fa0893bac684aacc
Author: Tom Tromey <tromey@redhat.com>
Date:   Tue Feb 8 11:05:26 2011 -0700

    initial support for $_marker_arg* variables

commit 76e428b270fddd2bebf1848f96c307ea4a3f0c6b
Author: Tom Tromey <tromey@redhat.com>
Date:   Tue Feb 8 10:58:28 2011 -0700

    mention sdt.h in the docs

commit 97cfc33dbf75cc927930d3637d4c8c9013867bc4
Author: Tom Tromey <tromey@redhat.com>
Date:   Tue Feb 8 10:37:21 2011 -0700

    add user-data to create_internalvar_type_lazy

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

Summary of changes:
 gdb/doc/gdb.texinfo |    7 +++--
 gdb/infrun.c        |    5 ++-
 gdb/stap-probe.c    |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/thread.c        |    5 ++-
 gdb/tracepoint.c    |    5 ++-
 gdb/value.c         |   31 +++++++++++++++++++---
 gdb/value.h         |    6 +++-
 gdb/windows-tdep.c  |    4 +-
 8 files changed, 115 insertions(+), 18 deletions(-)

First 500 lines of diff:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a93ddf3..747a545 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4522,10 +4522,11 @@ that can no longer be recreated.
 @subsection Static Probe Points
 
 @cindex SystemTap static probe point
+@cindex sdt-probe
 The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
-applications to embed static probes.  @value{GDBN} can list the
-available probes, and you can put breakpoints at the probe points
-(@pxref{Specify Location}).
+applications to embed static probes, using @file{sdt.h}.  @value{GDBN}
+can list the available probes, and you can put breakpoints at the
+probe points (@pxref{Specify Location}).
 
 You can examine the available @code{SystemTap} static probes using
 @code{info probes}:
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 664d91b..6fdd9df 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6225,7 +6225,8 @@ static struct lval_funcs siginfo_value_funcs =
    if there's no object available.  */
 
 static struct value *
-siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+		    void *ignore)
 {
   if (target_has_stack
       && !ptid_equal (inferior_ptid, null_ptid)
@@ -7070,7 +7071,7 @@ Tells gdb whether to detach the child of a fork."),
      value with a void typed value, and when we get here, gdbarch
      isn't initialized yet.  At this point, we're quite sure there
      isn't another convenience variable of the same name.  */
-  create_internalvar_type_lazy ("_siginfo", siginfo_make_value);
+  create_internalvar_type_lazy ("_siginfo", siginfo_make_value, NULL, NULL);
 
   add_setshow_boolean_cmd ("observer", no_class,
 			   &observer_mode_1, _("\
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index bae91f7..f19dd11 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -26,6 +26,7 @@
 #include "arch-utils.h"
 #include "command.h"
 #include "filenames.h"
+#include "value.h"
 
 #include <ctype.h>
 
@@ -366,6 +367,52 @@ parse_stap_probe (char **argptr)
 
 \f
 
+/* This is called to compute the value of one of the $_marker_arg*
+   convenience variables.  */
+
+static struct value *
+compute_marker_arg (struct gdbarch *arch, struct internalvar *ivar,
+		    void *data)
+{
+  struct frame_info *frame = get_selected_frame (_("No frame selected"));
+  CORE_ADDR pc = get_frame_pc (frame);
+  int sel = (int) (uintptr_t) data;
+  struct objfile *objfile;
+  const struct stap_probe *pc_probe = NULL;
+
+  /* Note that SEL is biased by 1; SEL==0 means "_marker_argc".  */
+  gdb_assert (sel >= 0 && sel <= 10);
+
+  ALL_OBJFILES (objfile)
+  {
+    const struct stap_probe *probes;
+    int i, num_probes;
+    stap_entry entry;
+
+    if (! objfile->sf || ! objfile->sf->sym_get_probes)
+      continue;
+
+    /* If this proves too inefficient, we can replace with a hash.  */
+    probes = objfile->sf->sym_get_probes (objfile, &num_probes);
+    for (i = 0; i < num_probes; ++i)
+      {
+	if (probes[i].address == pc)
+	  {
+	    pc_probe = &probes[i];
+	    break;
+	  }
+      }
+  }
+
+  if (pc_probe == NULL)
+    error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
+
+  /* FIXME: now the hard work... */
+  error (_("Unimplemented"));
+}
+
+\f
+
 void
 _initialize_stap_probe (void)
 {
@@ -376,4 +423,27 @@ Each argument is a regular expression, used to select probes.\n\
 PROVIDER matches probe provider names.\n\
 NAME matches the probe names.\n\
 OBJECT match the executable or shared library name."));
+
+  create_internalvar_type_lazy ("_marker_argc", compute_marker_arg,
+				(void *) (uintptr_t) 0, NULL);
+  create_internalvar_type_lazy ("_marker_arg0", compute_marker_arg,
+				(void *) (uintptr_t) 1, NULL);
+  create_internalvar_type_lazy ("_marker_arg1", compute_marker_arg,
+				(void *) (uintptr_t) 2, NULL);
+  create_internalvar_type_lazy ("_marker_arg2", compute_marker_arg,
+				(void *) (uintptr_t) 3, NULL);
+  create_internalvar_type_lazy ("_marker_arg3", compute_marker_arg,
+				(void *) (uintptr_t) 4, NULL);
+  create_internalvar_type_lazy ("_marker_arg4", compute_marker_arg,
+				(void *) (uintptr_t) 5, NULL);
+  create_internalvar_type_lazy ("_marker_arg5", compute_marker_arg,
+				(void *) (uintptr_t) 6, NULL);
+  create_internalvar_type_lazy ("_marker_arg6", compute_marker_arg,
+				(void *) (uintptr_t) 7, NULL);
+  create_internalvar_type_lazy ("_marker_arg7", compute_marker_arg,
+				(void *) (uintptr_t) 8, NULL);
+  create_internalvar_type_lazy ("_marker_arg8", compute_marker_arg,
+				(void *) (uintptr_t) 9, NULL);
+  create_internalvar_type_lazy ("_marker_arg9", compute_marker_arg,
+				(void *) (uintptr_t) 10, NULL);
 }
diff --git a/gdb/thread.c b/gdb/thread.c
index 99b4a93..8efb2cc 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1339,7 +1339,8 @@ update_thread_list (void)
    no thread is selected, or no threads exist.  */
 
 static struct value *
-thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+		      void *ignore)
 {
   struct thread_info *tp = find_thread_ptid (inferior_ptid);
 
@@ -1381,5 +1382,5 @@ Show printing of thread events (such as thread start and exit)."), NULL,
          show_print_thread_events,
          &setprintlist, &showprintlist);
 
-  create_internalvar_type_lazy ("_thread", thread_id_make_value);
+  create_internalvar_type_lazy ("_thread", thread_id_make_value, NULL, NULL);
 }
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 8f261af..4a42f40 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4389,7 +4389,8 @@ info_static_tracepoint_markers_command (char *arg, int from_tty)
    available.  */
 
 static struct value *
-sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+		  void *ignore)
 {
   LONGEST size;
   gdb_byte *buf;
@@ -4424,7 +4425,7 @@ _initialize_tracepoint (void)
      value with a void typed value, and when we get here, gdbarch
      isn't initialized yet.  At this point, we're quite sure there
      isn't another convenience variable of the same name.  */
-  create_internalvar_type_lazy ("_sdata", sdata_make_value);
+  create_internalvar_type_lazy ("_sdata", sdata_make_value, NULL, NULL);
 
   traceframe_number = -1;
   tracepoint_number = -1;
diff --git a/gdb/value.c b/gdb/value.c
index 1c50428..1b3cfe5 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1058,7 +1058,17 @@ struct internalvar
       struct value *value;
 
       /* The call-back routine used with INTERNALVAR_MAKE_VALUE.  */
-      internalvar_make_value make_value;
+      struct
+        {
+	  /* The function to call.  */
+	  internalvar_make_value function;
+
+	  /* The function's user-data.  */
+	  void *data;
+
+	  /* The cleanup function for DATA.  */
+	  make_cleanup_ftype *cleanup;
+        } make_value;
 
       /* The internal function used with INTERNALVAR_FUNCTION.  */
       struct
@@ -1164,15 +1174,20 @@ create_internalvar (const char *name)
 /* Create an internal variable with name NAME and register FUN as the
    function that value_of_internalvar uses to create a value whenever
    this variable is referenced.  NAME should not normally include a
-   dollar sign.  */
+   dollar sign.  DATA is passed uninterpreted to FUN when it is
+   called.  CLEANUP, if not NULL, is called when the internal variable
+   is destroyed.  It is passed DATA as its only argument.  */
 
 struct internalvar *
-create_internalvar_type_lazy (char *name, internalvar_make_value fun)
+create_internalvar_type_lazy (char *name, internalvar_make_value fun,
+			      void *data, make_cleanup_ftype *cleanup)
 {
   struct internalvar *var = create_internalvar (name);
 
   var->kind = INTERNALVAR_MAKE_VALUE;
-  var->u.make_value = fun;
+  var->u.make_value.function = fun;
+  var->u.make_value.data = data;
+  var->u.make_value.cleanup = cleanup;
   return var;
 }
 
@@ -1252,7 +1267,8 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var)
       break;
 
     case INTERNALVAR_MAKE_VALUE:
-      val = (*var->u.make_value) (gdbarch, var);
+      val = (*var->u.make_value.function) (gdbarch, var,
+					   var->u.make_value.data);
       break;
 
     default:
@@ -1451,6 +1467,11 @@ clear_internalvar (struct internalvar *var)
       xfree (var->u.string);
       break;
 
+    case INTERNALVAR_MAKE_VALUE:
+      if (var->u.make_value.cleanup != NULL)
+	var->u.make_value.cleanup (var->u.make_value.data);
+      break;
+
     default:
       break;
     }
diff --git a/gdb/value.h b/gdb/value.h
index e637842..dabc668 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -610,9 +610,11 @@ extern struct internalvar *lookup_only_internalvar (const char *name);
 extern struct internalvar *create_internalvar (const char *name);
 
 typedef struct value * (*internalvar_make_value) (struct gdbarch *,
-						  struct internalvar *);
+						  struct internalvar *,
+						  void *);
 extern struct internalvar *
-  create_internalvar_type_lazy (char *name, internalvar_make_value fun);
+create_internalvar_type_lazy (char *name, internalvar_make_value fun,
+			      void *data, make_cleanup_ftype *cleanup);
 
 extern struct internalvar *lookup_internalvar (const char *name);
 
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index ab0aaf9..7d489ee 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -263,7 +263,7 @@ static struct lval_funcs tlb_value_funcs =
    if there's no object available.  */
 
 static struct value *
-tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
 {
   if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid))
     {
@@ -446,5 +446,5 @@ even if their meaning is unknown."),
      value with a void typed value, and when we get here, gdbarch
      isn't initialized yet.  At this point, we're quite sure there
      isn't another convenience variable of the same name.  */
-  create_internalvar_type_lazy ("_tlb", tlb_make_value);
+  create_internalvar_type_lazy ("_tlb", tlb_make_value, NULL, NULL);
 }


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


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

only message in thread, other threads:[~2011-02-08 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-08 18:05 [SCM] archer-sergiodj-stap: initial support for $_marker_arg* variables 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).