public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap-patches: Improving the passing of header names for `info probes' command.
@ 2012-04-22  5:21 sergiodj
  0 siblings, 0 replies; only message in thread
From: sergiodj @ 2012-04-22  5:21 UTC (permalink / raw)
  To: archer-commits

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

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

- Log -----------------------------------------------------------------
commit 96bc29f8567c7b5c0cafe0fcffad2c409025b349
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Sun Apr 22 02:20:31 2012 -0300

    Improving the passing of header names for `info probes' command.

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

Summary of changes:
 gdb/probe.c      |   53 +++++++++++++++++++++++++----------------------------
 gdb/probe.h      |   35 ++++++++++++++++++++++-------------
 gdb/stap-probe.c |   10 +++++++---
 3 files changed, 54 insertions(+), 44 deletions(-)

First 500 lines of diff:
diff --git a/gdb/probe.c b/gdb/probe.c
index 4b49c0c..4e1b6a0 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -371,9 +371,10 @@ gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
 {
   /* `headings' refers to the names of the columns when printing `info
      probes'.  */
-  VEC (const_char_ptr) *headings = NULL;
+  VEC (info_probe_column_s) *headings = NULL;
   struct cleanup *c;
-  const char *internal_field_name;
+  info_probe_column_s *column;
+  size_t headings_size;
   int ix;
 
   gdb_assert (p != NULL);
@@ -385,21 +386,18 @@ gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
   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);
+  c = make_cleanup (VEC_cleanup (info_probe_column_s), &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);
+  headings_size = VEC_length (info_probe_column_s, headings);
 
   for (ix = 0;
-       VEC_iterate (const_char_ptr, headings, ix, internal_field_name);
-       ix += 2)
+       VEC_iterate (info_probe_column_s, headings, ix, column);
+       ++ix)
     {
       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);
+      size_t size_max = strlen (column->print_name);
 
       for (jx = 0; VEC_iterate (probe_and_objfile_s, probes, jx, entry); ++jx)
 	{
@@ -417,8 +415,8 @@ gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
 	  p->gen_info_probes_table_values (entry->probe, entry->objfile,
 					   &probe_fields);
 
-	  gdb_assert (VEC_length (const_char_ptr, headings) ==
-		      VEC_length (const_char_ptr, probe_fields) * 2);
+	  gdb_assert (VEC_length (const_char_ptr, probe_fields)
+		      == headings_size);
 
 	  for (kx = 0; VEC_iterate (const_char_ptr, probe_fields, kx, val);
 	       ++kx)
@@ -435,7 +433,7 @@ gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
 	}
 
       ui_out_table_header (current_uiout, size_max, ui_left,
-			   internal_field_name, field_name);
+			   column->field_name, column->print_name);
     }
 
   do_cleanups (c);
@@ -447,12 +445,13 @@ gen_ui_out_table_header_info (VEC (probe_and_objfile_s) *probes,
 static void
 print_ui_out_info (probe_and_objfile_s *entry)
 {
-  const char *internal_field_name;
   int ix;
   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;
+  VEC (const_char_ptr) *values = NULL;
+  VEC (info_probe_column_s) *headings = NULL;
+  info_probe_column_s *column;
   struct cleanup *c;
 
   gdb_assert (entry != NULL);
@@ -466,26 +465,26 @@ print_ui_out_info (probe_and_objfile_s *entry)
   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);
+  c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings);
   make_cleanup (VEC_cleanup (const_char_ptr), &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, headings)
-	      == VEC_length (const_char_ptr, values) * 2);
+  gdb_assert (VEC_length (info_probe_column_s, headings)
+	      == VEC_length (const_char_ptr, values));
 
   for (ix = 0;
-       VEC_iterate (const_char_ptr, headings, ix, internal_field_name);
-       ix += 2)
+       VEC_iterate (info_probe_column_s, headings, ix, column);
+       ++ix)
     {
       const char *val = VEC_index (const_char_ptr, values, j++);
 
       if (val == NULL)
-	ui_out_field_skip (current_uiout, internal_field_name);
+	ui_out_field_skip (current_uiout, column->field_name);
       else
-	ui_out_field_string (current_uiout, internal_field_name, val);
+	ui_out_field_string (current_uiout, column->field_name, val);
     }
 
   do_cleanups (c);
@@ -497,23 +496,21 @@ print_ui_out_info (probe_and_objfile_s *entry)
 static int
 get_number_extra_fields (const struct probe_ops *pops)
 {
-  VEC (const_char_ptr) *headings = NULL;
+  VEC (info_probe_column_s) *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);
+  c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings);
   pops->gen_info_probes_table_header (&headings);
 
-  n = VEC_length (const_char_ptr, headings);
-
-  gdb_assert (n % 2 == 0);
+  n = VEC_length (info_probe_column_s, headings);
 
   do_cleanups (c);
 
-  return n / 2;
+  return n;
 }
 
 /* See comment in probe.h.  */
diff --git a/gdb/probe.h b/gdb/probe.h
index 13a8b61..9a91cae 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -26,6 +26,24 @@ DEF_VEC_P (const_char_ptr);
 
 struct linespec_result;
 
+/* Structure useful for passing the header names in the method
+   `gen_ui_out_table_header'.  */
+
+struct info_probe_column
+  {
+    /* The internal name of the field.  This string cannot be capitalized nor
+       localized, e.g., "extra_field".  */
+
+    const char *field_name;
+
+    /* The field name to be printed in the `info probes' command.  This
+       string can be capitalized and localized, e.g., _("Extra Field").  */
+    const char *print_name;
+  };
+
+typedef struct info_probe_column info_probe_column_s;
+DEF_VEC_O (info_probe_column_s);
+
 /* Operations associated with a probe.  */
 
 struct probe_ops
@@ -85,20 +103,11 @@ struct probe_ops
     void (*destroy) (struct probe *probe);
 
     /* Function responsible for providing the extra fields that will be
-       printed in the `info probes' command.  It should fill HEADINGS
+       printed in the `info probes' command.  It should fill HEADS
        with whatever extra fields it needs.  If the backend doesn't need
-       to print extra fields, it can set this method to NULL.
-
-       It is mandatory that this function fill the HEADINGS argument by
-       putting two strings for each new extra field to be printed.  The
-       first string shall represent the internal name of the field,
-       which cannot be capitalized nor localized, e.g., _("field_extra").
-       The second string shall represent the printed name of the column,
-       and it could be capitalized and localized, e.g., _("Field Extra").
-       Thus, the vector filled by this method will have twice the size
-       of the vector returned by `gen_info_probes_table_values'.  */
-
-    void (*gen_info_probes_table_header) (VEC (const_char_ptr) **headings);
+       to print extra fields, it can set this method to NULL.  */
+
+    void (*gen_info_probes_table_header) (VEC (info_probe_column_s) **heads);
 
     /* Function that will fill VALUES with the values of the extra fields
        to be printed for PROBE  and OBJFILE.  If the backend implements
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 2ade331..13ba281 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1449,10 +1449,14 @@ stap_probe_is_linespec (const char **linespecp)
 }
 
 static void
-stap_gen_info_probes_table_header (VEC (const_char_ptr) **headings)
+stap_gen_info_probes_table_header (VEC (info_probe_column_s) **heads)
 {
-  VEC_safe_push (const_char_ptr, *headings, "semaphore");
-  VEC_safe_push (const_char_ptr, *headings, _("Semaphore"));
+  info_probe_column_s stap_probe_column;
+
+  stap_probe_column.field_name = "semaphore";
+  stap_probe_column.print_name = _("Semaphore");
+
+  VEC_safe_push (info_probe_column_s, *heads, &stap_probe_column);
 }
 
 static void


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


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

only message in thread, other threads:[~2012-04-22  5:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-22  5:21 [SCM] archer-sergiodj-stap-patches: Improving the passing of header names for `info probes' command 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).