| OLD | NEW |
| 1 /* Routines for handling XML generic OS data provided by target. | 1 /* Routines for handling XML generic OS data provided by target. |
| 2 | 2 |
| 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 for (ix_cols = 0; | 281 for (ix_cols = 0; |
| 282 VEC_iterate (osdata_column_s, item->columns, | 282 VEC_iterate (osdata_column_s, item->columns, |
| 283 ix_cols, col); | 283 ix_cols, col); |
| 284 ix_cols++) | 284 ix_cols++) |
| 285 if (strcmp (col->name, name) == 0) | 285 if (strcmp (col->name, name) == 0) |
| 286 return col->value; | 286 return col->value; |
| 287 | 287 |
| 288 return NULL; | 288 return NULL; |
| 289 } | 289 } |
| 290 | 290 |
| 291 static void | 291 void |
| 292 info_osdata_command (char *type, int from_tty) | 292 info_osdata_command (char *type, int from_tty) |
| 293 { | 293 { |
| 294 struct ui_out *uiout = current_uiout; | 294 struct ui_out *uiout = current_uiout; |
| 295 struct osdata *osdata = NULL; | 295 struct osdata *osdata = NULL; |
| 296 struct osdata_item *last = NULL; | 296 struct osdata_item *last = NULL; |
| 297 struct cleanup *old_chain; | 297 struct cleanup *old_chain; |
| 298 int ncols = 0; | 298 int ncols = 0; |
| 299 int nrows; | 299 int nrows; |
| 300 int col_to_skip = -1; |
| 300 | 301 |
| 301 osdata = get_osdata (type); | 302 osdata = get_osdata (type); |
| 302 old_chain = make_cleanup_osdata_free (osdata); | 303 old_chain = make_cleanup_osdata_free (osdata); |
| 303 | 304 |
| 304 nrows = VEC_length (osdata_item_s, osdata->items); | 305 nrows = VEC_length (osdata_item_s, osdata->items); |
| 305 | 306 |
| 306 if (!type && nrows == 0) | 307 if (!type && nrows == 0) |
| 307 error (_("Available types of OS data not reported.")); | 308 error (_("Available types of OS data not reported.")); |
| 308 | 309 |
| 309 if (!VEC_empty (osdata_item_s, osdata->items)) | 310 if (!VEC_empty (osdata_item_s, osdata->items)) |
| 310 { | 311 { |
| 311 last = VEC_last (osdata_item_s, osdata->items); | 312 last = VEC_last (osdata_item_s, osdata->items); |
| 312 if (last->columns) | 313 if (last->columns) |
| 313 ncols = VEC_length (osdata_column_s, last->columns); | 314 ncols = VEC_length (osdata_column_s, last->columns); |
| 315 |
| 316 /* As a special case, scan the listing of available data types |
| 317 for a column named "Title", and only include it with MI |
| 318 output; this column's normal use is for titles for interface |
| 319 elements like menus, and it clutters up CLI output. */ |
| 320 if (!type && !ui_out_is_mi_like_p (uiout)) |
| 321 { |
| 322 struct osdata_column *col; |
| 323 int ix; |
| 324 |
| 325 for (ix = 0; |
| 326 VEC_iterate (osdata_column_s, last->columns, ix, col); |
| 327 ix++) |
| 328 { |
| 329 if (strcmp (col->name, "Title") == 0) |
| 330 col_to_skip = ix; |
| 331 } |
| 332 /* Be sure to reduce the total column count, otherwise |
| 333 internal errors ensue. */ |
| 334 if (col_to_skip >= 0) |
| 335 --ncols; |
| 336 } |
| 314 } | 337 } |
| 315 | 338 |
| 316 make_cleanup_ui_out_table_begin_end (uiout, ncols, nrows, | 339 make_cleanup_ui_out_table_begin_end (uiout, ncols, nrows, |
| 317 "OSDataTable"); | 340 "OSDataTable"); |
| 318 | 341 |
| 319 /* With no columns/items, we just output an empty table, but we | 342 /* With no columns/items, we just output an empty table, but we |
| 320 still output the table. This matters for MI. */ | 343 still output the table. This matters for MI. */ |
| 321 if (ncols == 0) | 344 if (ncols == 0) |
| 322 { | 345 { |
| 323 do_cleanups (old_chain); | 346 do_cleanups (old_chain); |
| 324 return; | 347 return; |
| 325 } | 348 } |
| 326 | 349 |
| 327 if (last && last->columns) | 350 if (last && last->columns) |
| 328 { | 351 { |
| 329 struct osdata_column *col; | 352 struct osdata_column *col; |
| 330 int ix; | 353 int ix; |
| 331 | 354 |
| 332 for (ix = 0; | 355 for (ix = 0; |
| 333 VEC_iterate (osdata_column_s, last->columns, | 356 VEC_iterate (osdata_column_s, last->columns, |
| 334 ix, col); | 357 ix, col); |
| 335 ix++) | 358 ix++) |
| 336 { | 359 { |
| 337 char col_name[32]; | 360 char col_name[32]; |
| 338 » | 361 |
| 362 » if (ix == col_to_skip) |
| 363 » continue; |
| 364 |
| 339 snprintf (col_name, 32, "col%d", ix); | 365 snprintf (col_name, 32, "col%d", ix); |
| 340 ui_out_table_header (uiout, 10, ui_left, | 366 ui_out_table_header (uiout, 10, ui_left, |
| 341 col_name, col->name); | 367 col_name, col->name); |
| 342 } | 368 } |
| 343 } | 369 } |
| 344 | 370 |
| 345 ui_out_table_body (uiout); | 371 ui_out_table_body (uiout); |
| 346 | 372 |
| 347 if (nrows != 0) | 373 if (nrows != 0) |
| 348 { | 374 { |
| 349 struct osdata_item *item; | 375 struct osdata_item *item; |
| 350 int ix_items; | 376 int ix_items; |
| 351 | 377 |
| 352 for (ix_items = 0; | 378 for (ix_items = 0; |
| 353 VEC_iterate (osdata_item_s, osdata->items, | 379 VEC_iterate (osdata_item_s, osdata->items, |
| 354 ix_items, item); | 380 ix_items, item); |
| 355 ix_items++) | 381 ix_items++) |
| 356 { | 382 { |
| 357 struct cleanup *old_chain; | 383 struct cleanup *old_chain; |
| 358 struct ui_stream *stb; | |
| 359 int ix_cols; | 384 int ix_cols; |
| 360 struct osdata_column *col; | 385 struct osdata_column *col; |
| 361 | 386 |
| 362 stb = ui_out_stream_new (uiout); | 387 old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "item"); |
| 363 old_chain = make_cleanup_ui_out_stream_delete (stb); | |
| 364 make_cleanup_ui_out_tuple_begin_end (uiout, "item"); | |
| 365 | 388 |
| 366 for (ix_cols = 0; | 389 for (ix_cols = 0; |
| 367 VEC_iterate (osdata_column_s, item->columns, | 390 VEC_iterate (osdata_column_s, item->columns, |
| 368 ix_cols, col); | 391 ix_cols, col); |
| 369 ix_cols++) | 392 ix_cols++) |
| 370 { | 393 { |
| 371 char col_name[32]; | 394 char col_name[32]; |
| 372 » | 395 |
| 396 » if (ix_cols == col_to_skip) |
| 397 » continue; |
| 398 |
| 373 snprintf (col_name, 32, "col%d", ix_cols); | 399 snprintf (col_name, 32, "col%d", ix_cols); |
| 374 ui_out_field_string (uiout, col_name, col->value); | 400 ui_out_field_string (uiout, col_name, col->value); |
| 375 } | 401 } |
| 376 | 402 |
| 377 do_cleanups (old_chain); | 403 do_cleanups (old_chain); |
| 378 | 404 |
| 379 ui_out_text (uiout, "\n"); | 405 ui_out_text (uiout, "\n"); |
| 380 } | 406 } |
| 381 } | 407 } |
| 382 | 408 |
| 383 do_cleanups (old_chain); | 409 do_cleanups (old_chain); |
| 384 } | 410 } |
| 385 | 411 |
| 386 extern initialize_file_ftype _initialize_osdata; /* -Wmissing-prototypes */ | 412 extern initialize_file_ftype _initialize_osdata; /* -Wmissing-prototypes */ |
| 387 | 413 |
| 388 void | 414 void |
| 389 _initialize_osdata (void) | 415 _initialize_osdata (void) |
| 390 { | 416 { |
| 391 add_info ("os", info_osdata_command, | 417 add_info ("os", info_osdata_command, |
| 392 _("Show OS data ARG.")); | 418 _("Show OS data ARG.")); |
| 393 } | 419 } |
| OLD | NEW |