PR22067, x86 check_relocs invalid read
[deliverable/binutils-gdb.git] / gdb / osdata.c
index 25e3cce6f1e463767bc6cd9ffec605a60d81fc6f..5458e2fc3b9d424a99db3be4293afbb8f3122926 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines for handling XML generic OS data provided by target.
 
-   Copyright (C) 2008-2016 Free Software Foundation, Inc.
+   Copyright (C) 2008-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -287,7 +287,7 @@ get_osdata_column (struct osdata_item *item, const char *name)
 }
 
 void
-info_osdata_command (char *type, int from_tty)
+info_osdata (const char *type)
 {
   struct ui_out *uiout = current_uiout;
   struct osdata *osdata = NULL;
@@ -297,12 +297,15 @@ info_osdata_command (char *type, int from_tty)
   int nrows;
   int col_to_skip = -1;
 
+  if (type == NULL)
+    type = "";
+
   osdata = get_osdata (type);
   old_chain = make_cleanup_osdata_free (osdata);
 
   nrows = VEC_length (osdata_item_s, osdata->items);
 
-  if (!type && nrows == 0)
+  if (*type == '\0' && nrows == 0)
     error (_("Available types of OS data not reported."));
   
   if (!VEC_empty (osdata_item_s, osdata->items))
@@ -315,7 +318,7 @@ info_osdata_command (char *type, int from_tty)
         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 && !uiout->is_mi_like_p ())
+      if (*type == '\0' && !uiout->is_mi_like_p ())
        {
          struct osdata_column *col;
          int ix;
@@ -334,8 +337,7 @@ info_osdata_command (char *type, int from_tty)
        }
     }
 
-  make_cleanup_ui_out_table_begin_end (uiout, ncols, nrows,
-                                      "OSDataTable");
+  ui_out_emit_table table_emitter (uiout, ncols, nrows, "OSDataTable");
 
   /* With no columns/items, we just output an empty table, but we
      still output the table.  This matters for MI.  */
@@ -378,27 +380,26 @@ info_osdata_command (char *type, int from_tty)
                        ix_items, item);
           ix_items++)
        {
-         struct cleanup *old_chain;
          int ix_cols;
          struct osdata_column *col;
 
-         old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "item");
+        {
+          ui_out_emit_tuple tuple_emitter (uiout, "item");
 
-         for (ix_cols = 0;
-              VEC_iterate (osdata_column_s, item->columns,
-                           ix_cols, col);
-              ix_cols++)
-          {
-            char col_name[32];
+          for (ix_cols = 0;
+               VEC_iterate (osdata_column_s, item->columns,
+                            ix_cols, col);
+               ix_cols++)
+            {
+              char col_name[32];
 
-            if (ix_cols == col_to_skip)
-              continue;
+              if (ix_cols == col_to_skip)
+                continue;
 
-            snprintf (col_name, 32, "col%d", ix_cols);
-            uiout->field_string (col_name, col->value);
-          }
-        
-         do_cleanups (old_chain);
+              snprintf (col_name, 32, "col%d", ix_cols);
+              uiout->field_string (col_name, col->value);
+            }
+        }
 
          uiout->text ("\n");
        }
@@ -407,6 +408,12 @@ info_osdata_command (char *type, int from_tty)
   do_cleanups (old_chain);
 }
 
+static void
+info_osdata_command (char *arg, int from_tty)
+{
+  info_osdata (arg);
+}
+
 extern initialize_file_ftype _initialize_osdata; /* -Wmissing-prototypes */
 
 void
This page took 0.02498 seconds and 4 git commands to generate.