public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap-patches: Addressing more comments from Jan, part N.
@ 2012-04-20 23:06 sergiodj
  0 siblings, 0 replies; only message in thread
From: sergiodj @ 2012-04-20 23:06 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap-patches has been updated
       via  67b4029e1247f8b0097d9f1809b66ae702139adb (commit)
      from  ccaaf2154dfffef1ac11055f9bf0b8564ec73181 (commit)

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

- Log -----------------------------------------------------------------
commit 67b4029e1247f8b0097d9f1809b66ae702139adb
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Fri Apr 20 20:06:13 2012 -0300

    Addressing more comments from Jan, part N.

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

Summary of changes:
 gdb/probe.c      |  229 ++++++++++++++++++++++++++++--------------------------
 gdb/probe.h      |  105 +++++++++++++------------
 gdb/stap-probe.c |   14 ++--
 3 files changed, 184 insertions(+), 164 deletions(-)

First 500 lines of diff:
diff --git a/gdb/probe.c b/gdb/probe.c
index 8659d34..4b49c0c 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -247,8 +247,8 @@ struct probe_and_objfile
   struct objfile *objfile;
 };
 
-typedef struct probe_and_objfile probe_entry;
-DEF_VEC_O (probe_entry);
+typedef struct probe_and_objfile probe_and_objfile_s;
+DEF_VEC_O (probe_and_objfile_s);
 
 /* A helper function for collect_probes that compiles a regexp and
    throws an exception on error.  This installs a cleanup to free the
@@ -278,16 +278,16 @@ compile_rx_or_error (regex_t *pattern, const char *rx, const char *message)
    If POPS is not NULL, only probes of this certain probe_ops will match.
    Each argument is a regexp, or NULL, which matches anything.  */
 
-static VEC (probe_entry) *
+static VEC (probe_and_objfile_s) *
 collect_probes (char *objname, char *provider, char *probe_name,
 		const struct probe_ops *pops)
 {
   struct objfile *objfile;
-  VEC (probe_entry) *result = NULL;
+  VEC (probe_and_objfile_s) *result = NULL;
   struct cleanup *cleanup, *cleanup_temps;
   regex_t obj_pat, prov_pat, probe_pat;
 
-  cleanup = make_cleanup (VEC_cleanup (probe_entry), &result);
+  cleanup = make_cleanup (VEC_cleanup (probe_and_objfile_s), &result);
 
   cleanup_temps = make_cleanup (null_cleanup, NULL);
   compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp"));
@@ -313,7 +313,7 @@ collect_probes (char *objname, char *provider, char *probe_name,
 
       for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
 	{
-	  probe_entry entry;
+	  probe_and_objfile_s entry;
 
 	  if (pops != NULL && probe->pops != pops)
 	    continue;
@@ -328,7 +328,7 @@ collect_probes (char *objname, char *provider, char *probe_name,
 
 	  entry.probe = probe;
 	  entry.objfile = objfile;
-	  VEC_safe_push (probe_entry, result, &entry);
+	  VEC_safe_push (probe_and_objfile_s, result, &entry);
 	}
     }
 
@@ -337,13 +337,13 @@ collect_probes (char *objname, char *provider, char *probe_name,
   return result;
 }
 
-/* A qsort comparison function for probe_entry objects.  */
+/* A qsort comparison function for probe_and_objfile_s objects.  */
 
 static int
 compare_entries (const void *a, const void *b)
 {
-  const probe_entry *ea = a;
-  const probe_entry *eb = b;
+  const probe_and_objfile_s *ea = a;
+  const probe_and_objfile_s *eb = b;
   int v;
 
   v = strcmp (ea->probe->provider, eb->probe->provider);
@@ -366,31 +366,46 @@ compare_entries (const void *a, const void *b)
    crafted by `info_probes_for_ops'.  */
 
 static void
-gen_ui_out_table_header_info (VEC (probe_entry) *items,
+gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
 			      const struct probe_ops *p)
 {
-  VEC (const_char_ptr) *fields = NULL;
+  /* `headings' refers to the names of the columns when printing `info
+     probes'.  */
+  VEC (const_char_ptr) *headings = NULL;
   struct cleanup *c;
-  const char *f;
-  int jx;
+  const char *internal_field_name;
+  int ix;
 
   gdb_assert (p != NULL);
 
-  if (p->gen_ui_out_table_header == NULL || p->gen_ui_out_fields == NULL)
+  if (p->gen_info_probes_table_header == NULL
+      && p->gen_info_probes_table_values == NULL)
     return;
 
-  c = make_cleanup (VEC_cleanup (const_char_ptr), &fields);
-  p->gen_ui_out_table_header (&fields);
+  gdb_assert (p->gen_info_probes_table_header != NULL
+	      && p->gen_info_probes_table_values != NULL);
+
+  c = make_cleanup (VEC_cleanup (const_char_ptr), &headings);
+  p->gen_info_probes_table_header (&headings);
+
+  /* The length of this vector should always be even.  See the comments
+     for the method `gen_info_probes_table_header' for better explanation.  */
+  gdb_assert (VEC_length (const_char_ptr, headings) % 2 == 0);
 
-  for (jx = 0; VEC_iterate (const_char_ptr, fields, jx, f); ++jx)
+  for (ix = 0;
+       VEC_iterate (const_char_ptr, headings, ix, internal_field_name);
+       ix += 2)
     {
-      probe_entry *entry;
-      int ix;
-      size_t size_max = strlen (f);
+      probe_and_objfile_s *entry;
+      int jx;
+      const char *field_name = VEC_index (const_char_ptr, headings, ix + 1);
+      size_t size_max = strlen (field_name);
 
-      for (ix = 0; VEC_iterate (probe_entry, items, ix, entry); ++ix)
+      for (jx = 0; VEC_iterate (probe_and_objfile_s, probes, jx, entry); ++jx)
 	{
-	  VEC (const_char_ptr) *values = NULL;
+	  /* `probe_fields' refers to the values of each new field that this
+	     probe will display.  */
+	  VEC (const_char_ptr) *probe_fields = NULL;
 	  struct cleanup *c2;
 	  const char *val;
 	  int kx;
@@ -398,29 +413,29 @@ gen_ui_out_table_header_info (VEC (probe_entry) *items,
 	  if (entry->probe->pops != p)
 	    continue;
 
-	  c2 = make_cleanup (VEC_cleanup (const_char_ptr), &values);
-	  p->gen_ui_out_fields (entry->probe, entry->objfile, &values);
+	  c2 = make_cleanup (VEC_cleanup (const_char_ptr), &probe_fields);
+	  p->gen_info_probes_table_values (entry->probe, entry->objfile,
+					   &probe_fields);
 
-	  for (kx = 0; VEC_iterate (const_char_ptr, values, kx, val); ++kx)
-	    {
-	      size_t s;
+	  gdb_assert (VEC_length (const_char_ptr, headings) ==
+		      VEC_length (const_char_ptr, probe_fields) * 2);
 
+	  for (kx = 0; VEC_iterate (const_char_ptr, probe_fields, kx, val);
+	       ++kx)
+	    {
 	      /* It is valid to have a NULL value here, which means that the
 		 backend does not have something to write and this particular
 		 field should be skipped.  */
 	      if (val == NULL)
 		continue;
 
-	      s = strlen (val);
-
-	      if (s > size_max)
-		size_max = s;
+	      size_max = max (strlen (val), size_max);
 	    }
-
 	  do_cleanups (c2);
 	}
 
-      ui_out_table_header (current_uiout, size_max, ui_left, f, f);
+      ui_out_table_header (current_uiout, size_max, ui_left,
+			   internal_field_name, field_name);
     }
 
   do_cleanups (c);
@@ -430,44 +445,77 @@ gen_ui_out_table_header_info (VEC (probe_entry) *items,
    represented by ENTRY.  */
 
 static void
-print_ui_out_info (probe_entry *entry)
+print_ui_out_info (probe_and_objfile_s *entry)
 {
-  const char *val, *field;
+  const char *internal_field_name;
   int ix;
-  VEC (const_char_ptr) *values = NULL, *fields = NULL;
+  int j = 0;
+  /* `values' refers to the actual values of each new field in the output
+     of `info probe'.  `headings' refers to the names of each new field.  */
+  VEC (const_char_ptr) *values = NULL, *headings = NULL;
   struct cleanup *c;
 
-  gdb_assert (entry != NULL && entry->probe != NULL
-	      && entry->probe->pops != NULL);
+  gdb_assert (entry != NULL);
+  gdb_assert (entry->probe != NULL);
+  gdb_assert (entry->probe->pops != NULL);
 
-  if (entry->probe->pops->gen_ui_out_table_header == NULL
-      || entry->probe->pops->gen_ui_out_fields == NULL)
+  if (entry->probe->pops->gen_info_probes_table_header == NULL
+      && entry->probe->pops->gen_info_probes_table_values == NULL)
     return;
 
-  c = make_cleanup (VEC_cleanup (const_char_ptr), &fields);
+  gdb_assert (entry->probe->pops->gen_info_probes_table_header != NULL
+	      && entry->probe->pops->gen_info_probes_table_values != NULL);
+
+  c = make_cleanup (VEC_cleanup (const_char_ptr), &headings);
   make_cleanup (VEC_cleanup (const_char_ptr), &values);
 
-  entry->probe->pops->gen_ui_out_table_header (&fields);
-  entry->probe->pops->gen_ui_out_fields (entry->probe, entry->objfile,
-					 &values);
+  entry->probe->pops->gen_info_probes_table_header (&headings);
+  entry->probe->pops->gen_info_probes_table_values (entry->probe,
+						    entry->objfile, &values);
 
-  gdb_assert (VEC_length (const_char_ptr, fields)
-	      == VEC_length (const_char_ptr, values));
+  gdb_assert (VEC_length (const_char_ptr, headings)
+	      == VEC_length (const_char_ptr, values) * 2);
 
   for (ix = 0;
-       VEC_iterate (const_char_ptr, fields, ix, field),
-       VEC_iterate (const_char_ptr, values, ix, val);
-       ++ix)
+       VEC_iterate (const_char_ptr, headings, ix, internal_field_name);
+       ix += 2)
     {
+      const char *val = VEC_index (const_char_ptr, values, j++);
+
       if (val == NULL)
-	ui_out_field_skip (current_uiout, field);
+	ui_out_field_skip (current_uiout, internal_field_name);
       else
-	ui_out_field_string (current_uiout, field, val);
+	ui_out_field_string (current_uiout, internal_field_name, val);
     }
 
   do_cleanups (c);
 }
 
+/* Helper function that returns the number of extra fields which POPS will
+   need.  */
+
+static int
+get_number_extra_fields (const struct probe_ops *pops)
+{
+  VEC (const_char_ptr) *headings = NULL;
+  struct cleanup *c;
+  int n;
+
+  if (pops->gen_info_probes_table_header == NULL)
+    return 0;
+
+  c = make_cleanup (VEC_cleanup (const_char_ptr), &headings);
+  pops->gen_info_probes_table_header (&headings);
+
+  n = VEC_length (const_char_ptr, headings);
+
+  gdb_assert (n % 2 == 0);
+
+  do_cleanups (c);
+
+  return n / 2;
+}
+
 /* See comment in probe.h.  */
 
 void
@@ -475,14 +523,14 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 {
   char *provider, *probe = NULL, *objname = NULL;
   struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
-  VEC (probe_entry) *items;
+  VEC (probe_and_objfile_s) *items;
   int i, any_found;
   int ui_out_extra_fields = 0;
-  int size_addr;
-  int size_name = strlen ("Name");
-  int size_objname = strlen ("Object");
-  int size_provider = strlen ("Provider");
-  probe_entry *entry;
+  size_t size_addr;
+  size_t size_name = strlen ("Name");
+  size_t size_objname = strlen ("Object");
+  size_t size_provider = strlen ("Provider");
+  probe_and_objfile_s *entry;
   struct gdbarch *gdbarch = get_current_arch ();
 
   /* Do we have a `provider:probe:objfile' style of linespec?  */
@@ -517,70 +565,33 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 	 that number.  */
 
       for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
-	{
-	  VEC (const_char_ptr) *fields = NULL;
-	  struct cleanup *c;
-
-	  if (po->gen_ui_out_table_header == NULL)
-	    continue;
-
-	  c = make_cleanup (VEC_cleanup (const_char_ptr), &fields);
-	  po->gen_ui_out_table_header (&fields);
-
-	  ui_out_extra_fields += VEC_length (const_char_ptr, fields);
-
-	  do_cleanups (c);
-	}
+	ui_out_extra_fields += get_number_extra_fields (po);
     }
   else
-    {
-      if (pops->gen_ui_out_table_header != NULL)
-	{
-	  VEC (const_char_ptr) *fields = NULL;
-	  struct cleanup *c;
-
-	  /* We have a probe_ops, and it exports the function used to
-	     obtains the extra fields.  So we just ask the backend about
-	     what are those extra fields, and increment `ui_out_extra_fields'
-	     accordingly.  */
-
-	  c = make_cleanup (VEC_cleanup (const_char_ptr), &fields);
-	  pops->gen_ui_out_table_header (&fields);
-	  ui_out_extra_fields = VEC_length (const_char_ptr, fields);
-	  do_cleanups (c);
-	}
-    }
+    ui_out_extra_fields = get_number_extra_fields (pops);
 
   items = collect_probes (objname, provider, probe, pops);
-  make_cleanup (VEC_cleanup (probe_entry), &items);
+  make_cleanup (VEC_cleanup (probe_and_objfile_s), &items);
   make_cleanup_ui_out_table_begin_end (current_uiout,
 				       4 + ui_out_extra_fields,
-				       VEC_length (probe_entry, items),
+				       VEC_length (probe_and_objfile_s, items),
 				       "StaticProbes");
 
-  if (!VEC_empty (probe_entry, items))
-    qsort (VEC_address (probe_entry, items), VEC_length (probe_entry, items),
-	   sizeof (probe_entry), compare_entries);
+  if (!VEC_empty (probe_and_objfile_s, items))
+    qsort (VEC_address (probe_and_objfile_s, items),
+	   VEC_length (probe_and_objfile_s, items),
+	   sizeof (probe_and_objfile_s), compare_entries);
 
   /* What's the size of an address in our architecture?  */
   size_addr = gdbarch_addr_bit (gdbarch) == 64 ? 18 : 10;
 
   /* Determining the maximum size of each field (`provider', `name' and
      `objname').  */
-  for (i = 0; VEC_iterate (probe_entry, items, i, entry); ++i)
+  for (i = 0; VEC_iterate (probe_and_objfile_s, items, i, entry); ++i)
     {
-      int s_name = strlen (entry->probe->name);
-      int s_provider = strlen (entry->probe->provider);
-      int s_objname = strlen (entry->objfile->name);
-
-      if (s_name > size_name)
-	size_name = s_name;
-
-      if (s_provider > size_provider)
-	size_provider = s_provider;
-
-      if (s_objname > size_objname)
-	size_objname = s_objname;
+      size_name = max (strlen (entry->probe->name), size_name);
+      size_provider = max (strlen (entry->probe->provider), size_provider);
+      size_objname = max (strlen (entry->objfile->name), size_objname);
     }
 
   ui_out_table_header (current_uiout, size_provider, ui_left, "provider",
@@ -605,7 +616,7 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 		       _("Object"));
   ui_out_table_body (current_uiout);
 
-  for (i = 0; VEC_iterate (probe_entry, items, i, entry); ++i)
+  for (i = 0; VEC_iterate (probe_and_objfile_s, items, i, entry); ++i)
     {
       struct cleanup *inner;
 
@@ -636,7 +647,7 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
       do_cleanups (inner);
     }
 
-  any_found = !VEC_empty (probe_entry, items);
+  any_found = !VEC_empty (probe_and_objfile_s, items);
   do_cleanups (cleanup);
 
   if (!any_found)
diff --git a/gdb/probe.h b/gdb/probe.h
index 96be016..13a8b61 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -25,88 +25,94 @@
 DEF_VEC_P (const_char_ptr);
 
 struct linespec_result;
-enum ui_align;
 
 /* Operations associated with a probe.  */
 
 struct probe_ops
   {
-    /* Method responsible for verifying if the linespec provided is a valid
-       linespec for a probe breakpoint.  It should return 1 if it is, or zero
-       if it is not.  It also should update the pointer passed in order to
-       discard the breakpoint option associated with this linespec.  For
-       example, if the option is `-probe', and the linespec provided is
-       `-probe abc', the function should return 1 and set the string pointer
-       to `abc'.  */
+    /* Method responsible for verifying if LINESPECP is a valid linespec for
+       a probe breakpoint.  It should return 1 if it is, or zero if it is not.
+       It also should update LINESPECP in order to discard the breakpoint
+       option associated with this linespec.  For example, if the option is
+       `-probe', and the LINESPECP is `-probe abc', the function should
+       return 1 and set LINESPECP to `abc'.  */
 
-    int (*is_linespec) (const char **);
+    int (*is_linespec) (const char **linespecp);
 
-    /* Function that should fill the `VEC (probe_p) **' argument with
-       known probes from the objfile specified.  */
+    /* Function that should fill PROBES with known probes from OBJFILE.  */
 
-    void (*get_probes) (VEC (probe_p) **, struct objfile *);
+    void (*get_probes) (VEC (probe_p) **probes, struct objfile *objfile);
 
-    /* Function used to relocate a probe's addresses according to some
-       `CORE_ADDR' delta provided.  */
+    /* Function used to relocate addresses from PROBE according to some DELTA
+       provided.  */
 
-    void (*relocate) (struct probe *, CORE_ADDR);
+    void (*relocate) (struct probe *probe, CORE_ADDR delta);
 
-    /* Return the number of arguments of this probe.  */
+    /* Return the number of arguments of PROBE.  */
 
     unsigned (*get_probe_argument_count) (struct probe *probe,
 					  struct objfile *objfile);
 
-    /* Evaluate the Nth argument from the probe, returning a value
-       corresponding to it.  The argument number is represented by the
-       last function argument.  */
+    /* Evaluate the Nth argument from the PROBE, returning a value
+       corresponding to it.  The argument number is represented N.  */
 
-    struct value *(*evaluate_probe_argument) (struct probe *, struct objfile *,
-					      unsigned);
+    struct value *(*evaluate_probe_argument) (struct probe *probe,
+					      struct objfile *objfile,
+					      unsigned n);
 
-    /* Compile the Nth argument of the probe to an agent expression.
-       The argument number is represented by the last function argument.  */
+    /* Compile the Nth argument of the PROBE to an agent expression.
+       The argument number is represented by N.  */
 
-    void (*compile_to_ax) (struct probe *, struct objfile *,
-			   struct agent_expr *, struct axs_value *,
-			   unsigned);
+    void (*compile_to_ax) (struct probe *probe, struct objfile *objfile,
+			   struct agent_expr *aexpr,
+			   struct axs_value *axs_value, unsigned n);
 
-    /* Set the semaphore associated with the probe.  This function only makes
+    /* Set the semaphore associated with the PROBE.  This function only makes
        sense if the probe has a concept of semaphore associated to a
        probe.  */
 
     void (*set_semaphore) (struct probe *probe, struct gdbarch *gdbarch);
 
-    /* Clear the semaphore associated with the probe.  This function only
+    /* Clear the semaphore associated with the PROBE.  This function only
        makes sense if the probe has a concept of semaphore associated to
        a probe.  */
 
     void (*clear_semaphore) (struct probe *probe, struct gdbarch *gdbarch);
 
-    /* Function called to destroy a probe's specific data.  This function
-       shall not free the probe itself.  */
+    /* Function called to destroy PROBE's specific data.  This function
+       shall not free PROBE itself.  */
 
-    void (*destroy) (struct probe *);
+    void (*destroy) (struct probe *probe);
 
     /* Function responsible for providing the extra fields that will be
-       printed in the `info probes' command.  It should fill the
-       `VEC (const_char_ptr) **' with whatever extra fields it needs.
-       If the backend doesn't need to print extra fields, it can set this
-       method to NULL.  */
-
-    void (*gen_ui_out_table_header) (VEC (const_char_ptr) **);
-
-    /* Function that will provide a `VEC (const_char_ptr) **' containing
-       the values of the extra fields to be printed for the specified probe
-       and objfile.  If the backend implements the `gen_ui_out_table_header',
-       then it should implement this method as well.  The backend should also
-       guarantee that the order and the number of values in the vector is


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


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

only message in thread, other threads:[~2012-04-20 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-20 23:06 [SCM] archer-sergiodj-stap-patches: Addressing more comments from Jan, part N sergiodj

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