/* Routines for handling XML generic OS data provided by target.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "vec.h"
#include "xml-support.h"
#include "osdata.h"
-#include <string.h>
#include "ui-out.h"
#include "gdbcmd.h"
const struct gdb_xml_element *element,
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
- struct osdata_parsing_data *data = user_data;
+ struct osdata_parsing_data *data = (struct osdata_parsing_data *) user_data;
char *type;
struct osdata *osdata;
if (data->osdata)
gdb_xml_error (parser, _("Seen more than on osdata element"));
- type = xml_find_attribute (attributes, "type")->value;
+ type = (char *) xml_find_attribute (attributes, "type")->value;
osdata = XCNEW (struct osdata);
osdata->type = xstrdup (type);
data->osdata = osdata;
const struct gdb_xml_element *element,
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
- struct osdata_parsing_data *data = user_data;
+ struct osdata_parsing_data *data = (struct osdata_parsing_data *) user_data;
struct osdata_item item = { NULL };
VEC_safe_push (osdata_item_s, data->osdata->items, &item);
const struct gdb_xml_element *element,
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
- struct osdata_parsing_data *data = user_data;
- const char *name = xml_find_attribute (attributes, "name")->value;
+ struct osdata_parsing_data *data = (struct osdata_parsing_data *) user_data;
+ const char *name
+ = (const char *) xml_find_attribute (attributes, "name")->value;
data->property_name = xstrdup (name);
}
const struct gdb_xml_element *element,
void *user_data, const char *body_text)
{
- struct osdata_parsing_data *data = user_data;
+ struct osdata_parsing_data *data = (struct osdata_parsing_data *) user_data;
struct osdata *osdata = data->osdata;
struct osdata_item *item = VEC_last (osdata_item_s, osdata->items);
struct osdata_column *col = VEC_safe_push (osdata_column_s,
static void
clear_parsing_data (void *p)
{
- struct osdata_parsing_data *data = p;
+ struct osdata_parsing_data *data = (struct osdata_parsing_data *) p;
osdata_free (data->osdata);
data->osdata = NULL;
static void
osdata_free_cleanup (void *arg)
{
- struct osdata *osdata = arg;
+ struct osdata *osdata = (struct osdata *) arg;
osdata_free (osdata);
}
}
void
-info_osdata_command (char *type, int from_tty)
+info_osdata (const char *type)
{
struct ui_out *uiout = current_uiout;
struct osdata *osdata = NULL;
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))
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))
+ if (*type == '\0' && !uiout->is_mi_like_p ())
{
struct osdata_column *col;
int ix;
continue;
snprintf (col_name, 32, "col%d", ix);
- ui_out_table_header (uiout, 10, ui_left,
+ uiout->table_header (10, ui_left,
col_name, col->name);
}
}
- ui_out_table_body (uiout);
+ uiout->table_body ();
if (nrows != 0)
{
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);
- ui_out_field_string (uiout, col_name, col->value);
- }
-
- do_cleanups (old_chain);
+ snprintf (col_name, 32, "col%d", ix_cols);
+ uiout->field_string (col_name, col->value);
+ }
+ }
- ui_out_text (uiout, "\n");
+ uiout->text ("\n");
}
}
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