* osdata.c (info_osdata_command): Filter out "Title" columns
authorStan Shebs <shebs@codesourcery.com>
Thu, 28 Jun 2012 23:44:26 +0000 (23:44 +0000)
committerStan Shebs <shebs@codesourcery.com>
Thu, 28 Jun 2012 23:44:26 +0000 (23:44 +0000)
from non-MI uses.
* common/linux-osdata.c (struct osdata_type): Add title field.
(osdata_table): Add titles to each entry.
(linux_command_xfer_osdata): Add a column for title data.

* gdb.texinfo (Miscellaneous GDB/MI Commands): Update -info-os
example, add note about title column.

gdb/ChangeLog
gdb/common/linux-osdata.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/osdata.c

index ad9b710ef80465d8c503a1363f3c53e463bb2f9f..0239a303113bde39873fa29a6cc65a26b9e5708a 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-28  Stan Shebs  <stan@codesourcery.com>
+
+       * osdata.c (info_osdata_command): Filter out "Title" columns
+       from non-MI uses.
+       * common/linux-osdata.c (struct osdata_type): Add title field.
+       (osdata_table): Add titles to each entry.
+       (linux_command_xfer_osdata): Add a column for title data.
+
 2012-06-28  Stan Shebs  <stan@codesourcery.com>
 
        Make logging work for MI.
index 1086d10ac344df43384cfb3a7b93461bc712378b..6488963c0fcea7c854a103a89b78531684cb6743 100644 (file)
@@ -1543,26 +1543,27 @@ linux_xfer_osdata_modules (gdb_byte *readbuf,
 
 struct osdata_type {
   char *type;
+  char *title;
   char *description;
   LONGEST (*getter) (gdb_byte *readbuf, ULONGEST offset, LONGEST len);
 } osdata_table[] = {
-  { "processes", "Listing of all processes",
+  { "processes", "Processes", "Listing of all processes",
     linux_xfer_osdata_processes },
-  { "procgroups", "Listing of all process groups",
+  { "procgroups", "Process groups", "Listing of all process groups",
     linux_xfer_osdata_processgroups },
-  { "threads", "Listing of all threads",
+  { "threads", "Threads", "Listing of all threads",
     linux_xfer_osdata_threads },
-  { "files", "Listing of all file descriptors",
+  { "files", "File descriptors", "Listing of all file descriptors",
     linux_xfer_osdata_fds },
-  { "sockets", "Listing of all internet-domain sockets",
+  { "sockets", "Sockets", "Listing of all internet-domain sockets",
     linux_xfer_osdata_isockets },
-  { "shm", "Listing of all shared-memory regions",
+  { "shm", "Shared-memory regions", "Listing of all shared-memory regions",
     linux_xfer_osdata_shm },
-  { "semaphores", "Listing of all semaphores",
+  { "semaphores", "Semaphores", "Listing of all semaphores",
     linux_xfer_osdata_sem },
-  { "msg", "Listing of all message queues",
+  { "msg", "Message queues", "Listing of all message queues",
     linux_xfer_osdata_msg },
-  { "modules", "Listing of all loaded kernel modules",
+  { "modules", "Kernel modules", "Listing of all loaded kernel modules",
     linux_xfer_osdata_modules },
   { NULL, NULL, NULL }
 };
@@ -1594,9 +1595,11 @@ linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf,
                               "<item>"
                               "<column name=\"Type\">%s</column>"
                               "<column name=\"Description\">%s</column>"
+                              "<column name=\"Title\">%s</column>"
                               "</item>",
                               osdata_table[i].type,
-                              osdata_table[i].description);
+                              osdata_table[i].description,
+                              osdata_table[i].title);
 
          buffer_grow_str0 (&buffer, "</osdata>\n");
          buf = buffer_finish (&buffer);
index b1ebf98ec26c894b251b55c88203d0ccf9d3f777..10bc9e801d217543160d29e22ff7210ebabe802e 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-28  Stan Shebs  <stan@codesourcery.com>
+
+       * gdb.texinfo (Miscellaneous GDB/MI Commands): Update -info-os
+       example, add note about title column.
+
 2012-06-26  Siva Chandra Reddy  <sivachandra@google.com>
 
        * gdb.texinfo (Symbol Tables In Python): Add description about
index a2c91678fc4336c09269c98f8053fd187a0e0af6..9884566a869cbf9c0894631d651ab4b48e7774c2 100644 (file)
@@ -32665,18 +32665,28 @@ like this:
 @smallexample
 @value{GDBP}
 -info-os
-^done,OSDataTable=@{nr_rows="9",nr_cols="2",
+^done,OSDataTable=@{nr_rows="9",nr_cols="3",
 hdr=[@{width="10",alignment="-1",col_name="col0",colhdr="Type"@},
-     @{width="10",alignment="-1",col_name="col1",colhdr="Description"@}],
-body=[item=@{col0="processes",col1="Listing of all processes"@},
-      item=@{col0="procgroups",col1="Listing of all process groups"@},
-      item=@{col0="threads",col1="Listing of all threads"@},
-      item=@{col0="files",col1="Listing of all file descriptors"@},
-      item=@{col0="sockets",col1="Listing of all internet-domain sockets"@},
-      item=@{col0="shm",col1="Listing of all shared-memory regions"@},
-      item=@{col0="semaphores",col1="Listing of all semaphores"@},
-      item=@{col0="msg",col1="Listing of all message queues"@},
-      item=@{col0="modules",col1="Listing of all loaded kernel modules"@}]@}
+     @{width="10",alignment="-1",col_name="col1",colhdr="Description"@},
+     @{width="10",alignment="-1",col_name="col2",colhdr="Title"@}],
+body=[item=@{col0="processes",col1="Listing of all processes",
+            col2="Processes"@},
+      item=@{col0="procgroups",col1="Listing of all process groups",
+            col2="Process groups"@},
+      item=@{col0="threads",col1="Listing of all threads",
+            col2="Threads"@},
+      item=@{col0="files",col1="Listing of all file descriptors",
+            col2="File descriptors"@},
+      item=@{col0="sockets",col1="Listing of all internet-domain sockets",
+            col2="Sockets"@},
+      item=@{col0="shm",col1="Listing of all shared-memory regions",
+            col2="Shared-memory regions"@},
+      item=@{col0="semaphores",col1="Listing of all semaphores",
+            col2="Semaphores"@},
+      item=@{col0="msg",col1="Listing of all message queues",
+            col2="Message queues"@},
+      item=@{col0="modules",col1="Listing of all loaded kernel modules",
+            col2="Kernel modules"@}]@}
 @value{GDBP}
 -info-os processes
 ^done,OSDataTable=@{nr_rows="190",nr_cols="4",
@@ -32693,6 +32703,12 @@ body=[item=@{col0="1",col1="root",col2="/sbin/init",col3="0"@},
 (gdb)
 @end smallexample
 
+(Note that the MI output here includes a @code{"Title"} column that
+does not appear in command-line @code{info os}; this column is useful
+for MI clients that want to enumerate the types of data, such as in a
+popup menu, but is needless clutter on the command line, and
+@code{info os} omits it.)
+
 @subheading The @code{-add-inferior} Command
 @findex -add-inferior
 
index 066d47fa56fc53a6d6ad59bda2580a02af2072ce..8776022843b74328bf435225150df1aad3140c86 100644 (file)
@@ -297,6 +297,7 @@ info_osdata_command (char *type, int from_tty)
   struct cleanup *old_chain;
   int ncols = 0;
   int nrows;
+  int col_to_skip = -1;
 
   osdata = get_osdata (type);
   old_chain = make_cleanup_osdata_free (osdata);
@@ -311,6 +312,28 @@ info_osdata_command (char *type, int from_tty)
       last = VEC_last (osdata_item_s, osdata->items);
       if (last->columns)
         ncols = VEC_length (osdata_column_s, last->columns);
+
+      /* As a special case, scan the listing of available data types
+        for a column named "Title", and only include it with MI
+        output; this column's normal use is for titles for interface
+        elements like menus, and it clutters up CLI output.  */
+      if (!type && !ui_out_is_mi_like_p (uiout))
+       {
+         struct osdata_column *col;
+         int ix;
+
+         for (ix = 0;
+              VEC_iterate (osdata_column_s, last->columns, ix, col);
+              ix++)
+           {
+             if (strcmp (col->name, "Title") == 0)
+               col_to_skip = ix;
+           }
+         /* Be sure to reduce the total column count, otherwise
+            internal errors ensue.  */
+         if (col_to_skip >= 0)
+           --ncols;
+       }
     }
 
   make_cleanup_ui_out_table_begin_end (uiout, ncols, nrows,
@@ -335,7 +358,10 @@ info_osdata_command (char *type, int from_tty)
           ix++)
        {
          char col_name[32];
-         
+
+         if (ix == col_to_skip)
+           continue;
+
          snprintf (col_name, 32, "col%d", ix);
          ui_out_table_header (uiout, 10, ui_left,
                               col_name, col->name);
@@ -366,7 +392,10 @@ info_osdata_command (char *type, int from_tty)
               ix_cols++)
           {
             char col_name[32];
-            
+
+            if (ix_cols == col_to_skip)
+              continue;
+
             snprintf (col_name, 32, "col%d", ix_cols);
             ui_out_field_string (uiout, col_name, col->value);
           }