]>
Commit | Line | Data |
---|---|---|
8b93c638 | 1 | /* Output generating routines for GDB. |
349c5d5f | 2 | |
32d0add0 | 3 | Copyright (C) 1999-2015 Free Software Foundation, Inc. |
349c5d5f | 4 | |
8b93c638 JM |
5 | Contributed by Cygnus Solutions. |
6 | Written by Fernando Nasser for Cygnus. | |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 12 | the Free Software Foundation; either version 3 of the License, or |
8b93c638 JM |
13 | (at your option) any later version. |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8b93c638 JM |
22 | |
23 | #include "defs.h" | |
8b93c638 JM |
24 | #include "expression.h" /* For language.h */ |
25 | #include "language.h" | |
26 | #include "ui-out.h" | |
27 | ||
8b93c638 JM |
28 | /* table header structures */ |
29 | ||
30 | struct ui_out_hdr | |
31 | { | |
32 | int colno; | |
33 | int width; | |
34 | int alignment; | |
b25959ec | 35 | char *col_name; |
8b93c638 JM |
36 | char *colhdr; |
37 | struct ui_out_hdr *next; | |
38 | }; | |
39 | ||
80f49b30 AC |
40 | /* Maintain a stack so that the info applicable to the inner most list |
41 | is always available. Stack/nested level 0 is reserved for the | |
581e13c1 | 42 | top-level result. */ |
80f49b30 | 43 | |
dc146f7c | 44 | enum { MAX_UI_OUT_LEVELS = 8 }; |
80f49b30 AC |
45 | |
46 | struct ui_out_level | |
47 | { | |
581e13c1 | 48 | /* Count each field; the first element is for non-list fields. */ |
80f49b30 | 49 | int field_count; |
581e13c1 | 50 | /* The type of this level. */ |
631ec795 | 51 | enum ui_out_type type; |
80f49b30 AC |
52 | }; |
53 | ||
54eb231c PM |
54 | /* Define uiout->level vector types and operations. */ |
55 | typedef struct ui_out_level *ui_out_level_p; | |
56 | DEF_VEC_P (ui_out_level_p); | |
57 | ||
bafdd3b3 AC |
58 | /* Tables are special. Maintain a separate structure that tracks |
59 | their state. At present an output can only contain a single table | |
60 | but that restriction might eventually be lifted. */ | |
61 | ||
62 | struct ui_out_table | |
63 | { | |
64 | /* If on, a table is being generated. */ | |
65 | int flag; | |
66 | ||
67 | /* If on, the body of a table is being generated. If off, the table | |
68 | header is being generated. */ | |
69 | int body_flag; | |
70 | ||
a6c47c14 AC |
71 | /* The level at which each entry of the table is to be found. A row |
72 | (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one | |
73 | above that of the table. */ | |
74 | int entry_level; | |
75 | ||
bafdd3b3 AC |
76 | /* Number of table columns (as specified in the table_begin call). */ |
77 | int columns; | |
78 | ||
79 | /* String identifying the table (as specified in the table_begin | |
80 | call). */ | |
81 | char *id; | |
82 | ||
83 | /* Points to the first table header (if any). */ | |
84 | struct ui_out_hdr *header_first; | |
85 | ||
86 | /* Points to the last table header (if any). */ | |
87 | struct ui_out_hdr *header_last; | |
88 | ||
89 | /* Points to header of NEXT column to format. */ | |
90 | struct ui_out_hdr *header_next; | |
91 | ||
92 | }; | |
93 | ||
94 | ||
8b93c638 JM |
95 | /* The ui_out structure */ |
96 | /* Any change here requires a corresponding one in the initialization | |
581e13c1 | 97 | of the default uiout, which is statically initialized. */ |
8b93c638 JM |
98 | |
99 | struct ui_out | |
100 | { | |
101 | int flags; | |
581e13c1 | 102 | /* Specific implementation of ui-out. */ |
89de4da4 | 103 | const struct ui_out_impl *impl; |
0a8fce9a | 104 | void *data; |
8b93c638 | 105 | |
54eb231c | 106 | /* Current level. */ |
80f49b30 | 107 | int level; |
54eb231c PM |
108 | |
109 | /* Vector to store and track the ui-out levels. */ | |
110 | VEC (ui_out_level_p) *levels; | |
8b93c638 | 111 | |
bafdd3b3 AC |
112 | /* A table, if any. At present only a single table is supported. */ |
113 | struct ui_out_table table; | |
8b93c638 JM |
114 | }; |
115 | ||
581e13c1 | 116 | /* The current (inner most) level. */ |
80f49b30 AC |
117 | static struct ui_out_level * |
118 | current_level (struct ui_out *uiout) | |
119 | { | |
54eb231c | 120 | return VEC_index (ui_out_level_p, uiout->levels, uiout->level); |
80f49b30 AC |
121 | } |
122 | ||
581e13c1 | 123 | /* Create a new level, of TYPE. Return the new level's index. */ |
80f49b30 AC |
124 | static int |
125 | push_level (struct ui_out *uiout, | |
631ec795 | 126 | enum ui_out_type type, |
80f49b30 AC |
127 | const char *id) |
128 | { | |
129 | struct ui_out_level *current; | |
5d502164 | 130 | |
80f49b30 | 131 | uiout->level++; |
70ba0933 | 132 | current = XNEW (struct ui_out_level); |
80f49b30 | 133 | current->field_count = 0; |
631ec795 | 134 | current->type = type; |
54eb231c | 135 | VEC_safe_push (ui_out_level_p, uiout->levels, current); |
80f49b30 AC |
136 | return uiout->level; |
137 | } | |
138 | ||
139 | /* Discard the current level, return the discarded level's index. | |
581e13c1 | 140 | TYPE is the type of the level being discarded. */ |
80f49b30 | 141 | static int |
631ec795 AC |
142 | pop_level (struct ui_out *uiout, |
143 | enum ui_out_type type) | |
80f49b30 | 144 | { |
54eb231c PM |
145 | struct ui_out_level *current; |
146 | ||
581e13c1 | 147 | /* We had better not underflow the buffer. */ |
54eb231c | 148 | gdb_assert (uiout->level > 0); |
631ec795 | 149 | gdb_assert (current_level (uiout)->type == type); |
54eb231c PM |
150 | current = VEC_pop (ui_out_level_p, uiout->levels); |
151 | xfree (current); | |
80f49b30 AC |
152 | uiout->level--; |
153 | return uiout->level + 1; | |
154 | } | |
155 | ||
156 | ||
581e13c1 | 157 | /* These are the default implementation functions. */ |
8b93c638 JM |
158 | |
159 | static void default_table_begin (struct ui_out *uiout, int nbrofcols, | |
d63f1d40 | 160 | int nr_rows, const char *tblid); |
8b93c638 JM |
161 | static void default_table_body (struct ui_out *uiout); |
162 | static void default_table_end (struct ui_out *uiout); | |
163 | static void default_table_header (struct ui_out *uiout, int width, | |
b25959ec | 164 | enum ui_align alig, const char *col_name, |
e2e11a41 | 165 | const char *colhdr); |
631ec795 AC |
166 | static void default_begin (struct ui_out *uiout, |
167 | enum ui_out_type type, | |
168 | int level, const char *id); | |
169 | static void default_end (struct ui_out *uiout, | |
170 | enum ui_out_type type, | |
171 | int level); | |
8b93c638 | 172 | static void default_field_int (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
173 | enum ui_align alig, |
174 | const char *fldname, | |
175 | int value); | |
8b93c638 | 176 | static void default_field_skip (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
177 | enum ui_align alig, |
178 | const char *fldname); | |
8b93c638 | 179 | static void default_field_string (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
180 | enum ui_align align, |
181 | const char *fldname, | |
8b93c638 JM |
182 | const char *string); |
183 | static void default_field_fmt (struct ui_out *uiout, int fldno, | |
184 | int width, enum ui_align align, | |
e2e11a41 AC |
185 | const char *fldname, |
186 | const char *format, | |
a0b31db1 | 187 | va_list args) ATTRIBUTE_PRINTF (6, 0); |
8b93c638 | 188 | static void default_spaces (struct ui_out *uiout, int numspaces); |
e2e11a41 AC |
189 | static void default_text (struct ui_out *uiout, const char *string); |
190 | static void default_message (struct ui_out *uiout, int verbosity, | |
191 | const char *format, | |
a0b31db1 | 192 | va_list args) ATTRIBUTE_PRINTF (3, 0); |
8b93c638 JM |
193 | static void default_wrap_hint (struct ui_out *uiout, char *identstring); |
194 | static void default_flush (struct ui_out *uiout); | |
b65a2bd9 | 195 | static void default_data_destroy (struct ui_out *uiout); |
8b93c638 | 196 | |
581e13c1 | 197 | /* This is the default ui-out implementation functions vector. */ |
8b93c638 | 198 | |
89de4da4 | 199 | const struct ui_out_impl default_ui_out_impl = |
8b93c638 JM |
200 | { |
201 | default_table_begin, | |
202 | default_table_body, | |
203 | default_table_end, | |
204 | default_table_header, | |
631ec795 AC |
205 | default_begin, |
206 | default_end, | |
8b93c638 JM |
207 | default_field_int, |
208 | default_field_skip, | |
209 | default_field_string, | |
210 | default_field_fmt, | |
211 | default_spaces, | |
212 | default_text, | |
213 | default_message, | |
214 | default_wrap_hint, | |
9dc5e2a9 | 215 | default_flush, |
0fac0b41 | 216 | NULL, |
b65a2bd9 | 217 | default_data_destroy, |
9dc5e2a9 | 218 | 0, /* Does not need MI hacks. */ |
8b93c638 JM |
219 | }; |
220 | ||
221 | /* The default ui_out */ | |
222 | ||
223 | struct ui_out def_uiout = | |
224 | { | |
225 | 0, /* flags */ | |
226 | &default_ui_out_impl, /* impl */ | |
227 | }; | |
228 | ||
229 | /* Pointer to current ui_out */ | |
230 | /* FIXME: This should not be a global, but something passed down from main.c | |
581e13c1 | 231 | or top.c. */ |
8b93c638 | 232 | |
79a45e25 | 233 | struct ui_out *current_uiout = &def_uiout; |
8b93c638 | 234 | |
581e13c1 | 235 | /* These are the interfaces to implementation functions. */ |
8b93c638 | 236 | |
88379baf | 237 | static void uo_table_begin (struct ui_out *uiout, int nbrofcols, |
d63f1d40 | 238 | int nr_rows, const char *tblid); |
8b93c638 JM |
239 | static void uo_table_body (struct ui_out *uiout); |
240 | static void uo_table_end (struct ui_out *uiout); | |
241 | static void uo_table_header (struct ui_out *uiout, int width, | |
b25959ec AC |
242 | enum ui_align align, const char *col_name, |
243 | const char *colhdr); | |
631ec795 AC |
244 | static void uo_begin (struct ui_out *uiout, |
245 | enum ui_out_type type, | |
246 | int level, const char *id); | |
247 | static void uo_end (struct ui_out *uiout, | |
248 | enum ui_out_type type, | |
249 | int level); | |
8b93c638 | 250 | static void uo_field_int (struct ui_out *uiout, int fldno, int width, |
88379baf | 251 | enum ui_align align, const char *fldname, int value); |
8b93c638 | 252 | static void uo_field_skip (struct ui_out *uiout, int fldno, int width, |
88379baf | 253 | enum ui_align align, const char *fldname); |
8b93c638 | 254 | static void uo_field_fmt (struct ui_out *uiout, int fldno, int width, |
88379baf | 255 | enum ui_align align, const char *fldname, |
bee0189a | 256 | const char *format, va_list args) |
a0b31db1 | 257 | ATTRIBUTE_PRINTF (6, 0); |
8b93c638 | 258 | static void uo_spaces (struct ui_out *uiout, int numspaces); |
88379baf | 259 | static void uo_text (struct ui_out *uiout, const char *string); |
8b93c638 | 260 | static void uo_message (struct ui_out *uiout, int verbosity, |
bee0189a | 261 | const char *format, va_list args) |
a0b31db1 | 262 | ATTRIBUTE_PRINTF (3, 0); |
8b93c638 JM |
263 | static void uo_wrap_hint (struct ui_out *uiout, char *identstring); |
264 | static void uo_flush (struct ui_out *uiout); | |
0fac0b41 | 265 | static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream); |
b65a2bd9 | 266 | static void uo_data_destroy (struct ui_out *uiout); |
8b93c638 JM |
267 | |
268 | /* Prototypes for local functions */ | |
269 | ||
270 | extern void _initialize_ui_out (void); | |
88379baf | 271 | static void append_header_to_list (struct ui_out *uiout, int width, |
b25959ec AC |
272 | int alignment, const char *col_name, |
273 | const char *colhdr); | |
bafdd3b3 | 274 | static int get_next_header (struct ui_out *uiout, int *colno, int *width, |
8b93c638 JM |
275 | int *alignment, char **colhdr); |
276 | static void clear_header_list (struct ui_out *uiout); | |
b65a2bd9 | 277 | static void clear_table (struct ui_out *uiout); |
a6c47c14 AC |
278 | static void verify_field (struct ui_out *uiout, int *fldno, int *width, |
279 | int *align); | |
8b93c638 | 280 | |
8b93c638 JM |
281 | /* exported functions (ui_out API) */ |
282 | ||
581e13c1 | 283 | /* Mark beginning of a table. */ |
8b93c638 | 284 | |
3b31d625 | 285 | static void |
88379baf | 286 | ui_out_table_begin (struct ui_out *uiout, int nbrofcols, |
d63f1d40 | 287 | int nr_rows, |
88379baf | 288 | const char *tblid) |
8b93c638 | 289 | { |
bafdd3b3 | 290 | if (uiout->table.flag) |
8e65ff28 | 291 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
292 | _("tables cannot be nested; table_begin found before \ |
293 | previous table_end.")); | |
8b93c638 | 294 | |
bafdd3b3 AC |
295 | uiout->table.flag = 1; |
296 | uiout->table.body_flag = 0; | |
a6c47c14 | 297 | uiout->table.entry_level = uiout->level + 1; |
bafdd3b3 | 298 | uiout->table.columns = nbrofcols; |
8b93c638 | 299 | if (tblid != NULL) |
bafdd3b3 | 300 | uiout->table.id = xstrdup (tblid); |
8b93c638 | 301 | else |
bafdd3b3 | 302 | uiout->table.id = NULL; |
8b93c638 JM |
303 | clear_header_list (uiout); |
304 | ||
bafdd3b3 | 305 | uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id); |
8b93c638 JM |
306 | } |
307 | ||
308 | void | |
fba45db2 | 309 | ui_out_table_body (struct ui_out *uiout) |
8b93c638 | 310 | { |
bafdd3b3 | 311 | if (!uiout->table.flag) |
8e65ff28 | 312 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
313 | _("table_body outside a table is not valid; it must be \ |
314 | after a table_begin and before a table_end.")); | |
bafdd3b3 | 315 | if (uiout->table.body_flag) |
8e65ff28 | 316 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
317 | _("extra table_body call not allowed; there must be \ |
318 | only one table_body after a table_begin and before a table_end.")); | |
bafdd3b3 | 319 | if (uiout->table.header_next->colno != uiout->table.columns) |
8e65ff28 | 320 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
321 | _("number of headers differ from number of table \ |
322 | columns.")); | |
8b93c638 | 323 | |
bafdd3b3 AC |
324 | uiout->table.body_flag = 1; |
325 | uiout->table.header_next = uiout->table.header_first; | |
8b93c638 JM |
326 | |
327 | uo_table_body (uiout); | |
328 | } | |
329 | ||
3b31d625 | 330 | static void |
fba45db2 | 331 | ui_out_table_end (struct ui_out *uiout) |
8b93c638 | 332 | { |
bafdd3b3 | 333 | if (!uiout->table.flag) |
8e65ff28 | 334 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 335 | _("misplaced table_end or missing table_begin.")); |
8b93c638 | 336 | |
a6c47c14 | 337 | uiout->table.entry_level = 0; |
bafdd3b3 AC |
338 | uiout->table.body_flag = 0; |
339 | uiout->table.flag = 0; | |
8b93c638 JM |
340 | |
341 | uo_table_end (uiout); | |
b65a2bd9 | 342 | clear_table (uiout); |
8b93c638 JM |
343 | } |
344 | ||
345 | void | |
fba45db2 | 346 | ui_out_table_header (struct ui_out *uiout, int width, enum ui_align alignment, |
b25959ec | 347 | const char *col_name, |
88379baf | 348 | const char *colhdr) |
8b93c638 | 349 | { |
bafdd3b3 | 350 | if (!uiout->table.flag || uiout->table.body_flag) |
8e65ff28 | 351 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
352 | _("table header must be specified after table_begin \ |
353 | and before table_body.")); | |
8b93c638 | 354 | |
b25959ec | 355 | append_header_to_list (uiout, width, alignment, col_name, colhdr); |
8b93c638 | 356 | |
b25959ec | 357 | uo_table_header (uiout, width, alignment, col_name, colhdr); |
8b93c638 JM |
358 | } |
359 | ||
3b31d625 EZ |
360 | static void |
361 | do_cleanup_table_end (void *data) | |
362 | { | |
363 | struct ui_out *ui_out = data; | |
364 | ||
365 | ui_out_table_end (ui_out); | |
366 | } | |
367 | ||
368 | struct cleanup * | |
369 | make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols, | |
370 | int nr_rows, const char *tblid) | |
371 | { | |
372 | ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid); | |
373 | return make_cleanup (do_cleanup_table_end, ui_out); | |
374 | } | |
375 | ||
8b93c638 | 376 | void |
631ec795 AC |
377 | ui_out_begin (struct ui_out *uiout, |
378 | enum ui_out_type type, | |
379 | const char *id) | |
8b93c638 | 380 | { |
80f49b30 | 381 | int new_level; |
5d502164 | 382 | |
bafdd3b3 | 383 | if (uiout->table.flag && !uiout->table.body_flag) |
8e65ff28 | 384 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
385 | _("table header or table_body expected; lists must be \ |
386 | specified after table_body.")); | |
a6c47c14 AC |
387 | |
388 | /* Be careful to verify the ``field'' before the new tuple/list is | |
389 | pushed onto the stack. That way the containing list/table/row is | |
390 | verified and not the newly created tuple/list. This verification | |
391 | is needed (at least) for the case where a table row entry | |
392 | contains either a tuple/list. For that case bookkeeping such as | |
393 | updating the column count or advancing to the next heading still | |
394 | needs to be performed. */ | |
395 | { | |
396 | int fldno; | |
397 | int width; | |
398 | int align; | |
5d502164 | 399 | |
a6c47c14 AC |
400 | verify_field (uiout, &fldno, &width, &align); |
401 | } | |
402 | ||
631ec795 | 403 | new_level = push_level (uiout, type, id); |
a6c47c14 AC |
404 | |
405 | /* If the push puts us at the same level as a table row entry, we've | |
406 | got a new table row. Put the header pointer back to the start. */ | |
407 | if (uiout->table.body_flag | |
408 | && uiout->table.entry_level == new_level) | |
bafdd3b3 | 409 | uiout->table.header_next = uiout->table.header_first; |
a6c47c14 | 410 | |
631ec795 AC |
411 | uo_begin (uiout, type, new_level, id); |
412 | } | |
413 | ||
631ec795 AC |
414 | void |
415 | ui_out_end (struct ui_out *uiout, | |
416 | enum ui_out_type type) | |
417 | { | |
418 | int old_level = pop_level (uiout, type); | |
5d502164 | 419 | |
631ec795 | 420 | uo_end (uiout, type, old_level); |
8b93c638 JM |
421 | } |
422 | ||
127431f9 AC |
423 | struct ui_out_end_cleanup_data |
424 | { | |
425 | struct ui_out *uiout; | |
426 | enum ui_out_type type; | |
427 | }; | |
428 | ||
e6e0bfab | 429 | static void |
127431f9 AC |
430 | do_cleanup_end (void *data) |
431 | { | |
432 | struct ui_out_end_cleanup_data *end_cleanup_data = data; | |
5d502164 | 433 | |
127431f9 AC |
434 | ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type); |
435 | xfree (end_cleanup_data); | |
436 | } | |
437 | ||
438 | static struct cleanup * | |
439 | make_cleanup_ui_out_end (struct ui_out *uiout, | |
440 | enum ui_out_type type) | |
441 | { | |
442 | struct ui_out_end_cleanup_data *end_cleanup_data; | |
5d502164 | 443 | |
70ba0933 | 444 | end_cleanup_data = XNEW (struct ui_out_end_cleanup_data); |
127431f9 AC |
445 | end_cleanup_data->uiout = uiout; |
446 | end_cleanup_data->type = type; | |
447 | return make_cleanup (do_cleanup_end, end_cleanup_data); | |
448 | } | |
449 | ||
e6e0bfab | 450 | struct cleanup * |
666547aa AC |
451 | make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, |
452 | const char *id) | |
453 | { | |
3b31d625 | 454 | ui_out_begin (uiout, ui_out_type_tuple, id); |
666547aa AC |
455 | return make_cleanup_ui_out_end (uiout, ui_out_type_tuple); |
456 | } | |
457 | ||
458 | struct cleanup * | |
6b28c186 AC |
459 | make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, |
460 | const char *id) | |
e6e0bfab | 461 | { |
3b31d625 | 462 | ui_out_begin (uiout, ui_out_type_list, id); |
127431f9 | 463 | return make_cleanup_ui_out_end (uiout, ui_out_type_list); |
e6e0bfab MK |
464 | } |
465 | ||
8b93c638 | 466 | void |
88379baf AC |
467 | ui_out_field_int (struct ui_out *uiout, |
468 | const char *fldname, | |
469 | int value) | |
8b93c638 JM |
470 | { |
471 | int fldno; | |
472 | int width; | |
473 | int align; | |
474 | ||
a6c47c14 | 475 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
476 | |
477 | uo_field_int (uiout, fldno, width, align, fldname, value); | |
478 | } | |
479 | ||
52c6a6ac JJ |
480 | void |
481 | ui_out_field_fmt_int (struct ui_out *uiout, | |
482 | int input_width, | |
483 | enum ui_align input_align, | |
484 | const char *fldname, | |
485 | int value) | |
486 | { | |
487 | int fldno; | |
488 | int width; | |
489 | int align; | |
52c6a6ac JJ |
490 | |
491 | verify_field (uiout, &fldno, &width, &align); | |
492 | ||
493 | uo_field_int (uiout, fldno, input_width, input_align, fldname, value); | |
494 | } | |
495 | ||
15230f37 TJB |
496 | /* Documented in ui-out.h. */ |
497 | ||
8b93c638 | 498 | void |
88379baf AC |
499 | ui_out_field_core_addr (struct ui_out *uiout, |
500 | const char *fldname, | |
5af949e3 | 501 | struct gdbarch *gdbarch, |
88379baf | 502 | CORE_ADDR address) |
8b93c638 | 503 | { |
f1310107 TJB |
504 | ui_out_field_string (uiout, fldname, |
505 | print_core_address (gdbarch, address)); | |
8b93c638 JM |
506 | } |
507 | ||
508 | void | |
88379baf AC |
509 | ui_out_field_stream (struct ui_out *uiout, |
510 | const char *fldname, | |
f99d8bf4 | 511 | struct ui_file *stream) |
8b93c638 JM |
512 | { |
513 | long length; | |
f99d8bf4 | 514 | char *buffer = ui_file_xstrdup (stream, &length); |
b8c9b27d | 515 | struct cleanup *old_cleanup = make_cleanup (xfree, buffer); |
5d502164 | 516 | |
8b93c638 JM |
517 | if (length > 0) |
518 | ui_out_field_string (uiout, fldname, buffer); | |
519 | else | |
520 | ui_out_field_skip (uiout, fldname); | |
f99d8bf4 | 521 | ui_file_rewind (stream); |
8b93c638 JM |
522 | do_cleanups (old_cleanup); |
523 | } | |
524 | ||
581e13c1 | 525 | /* Used to omit a field. */ |
8b93c638 JM |
526 | |
527 | void | |
88379baf AC |
528 | ui_out_field_skip (struct ui_out *uiout, |
529 | const char *fldname) | |
8b93c638 JM |
530 | { |
531 | int fldno; | |
532 | int width; | |
533 | int align; | |
8b93c638 | 534 | |
a6c47c14 | 535 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
536 | |
537 | uo_field_skip (uiout, fldno, width, align, fldname); | |
538 | } | |
539 | ||
540 | void | |
541 | ui_out_field_string (struct ui_out *uiout, | |
88379baf | 542 | const char *fldname, |
8b93c638 JM |
543 | const char *string) |
544 | { | |
545 | int fldno; | |
546 | int width; | |
547 | int align; | |
8b93c638 | 548 | |
a6c47c14 | 549 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
550 | |
551 | uo_field_string (uiout, fldno, width, align, fldname, string); | |
552 | } | |
553 | ||
554 | /* VARARGS */ | |
555 | void | |
88379baf AC |
556 | ui_out_field_fmt (struct ui_out *uiout, |
557 | const char *fldname, | |
558 | const char *format, ...) | |
8b93c638 JM |
559 | { |
560 | va_list args; | |
561 | int fldno; | |
562 | int width; | |
563 | int align; | |
8b93c638 | 564 | |
581e13c1 | 565 | /* Will not align, but has to call anyway. */ |
a6c47c14 | 566 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
567 | |
568 | va_start (args, format); | |
569 | ||
570 | uo_field_fmt (uiout, fldno, width, align, fldname, format, args); | |
571 | ||
572 | va_end (args); | |
573 | } | |
574 | ||
575 | void | |
fba45db2 | 576 | ui_out_spaces (struct ui_out *uiout, int numspaces) |
8b93c638 JM |
577 | { |
578 | uo_spaces (uiout, numspaces); | |
579 | } | |
580 | ||
581 | void | |
88379baf AC |
582 | ui_out_text (struct ui_out *uiout, |
583 | const char *string) | |
8b93c638 JM |
584 | { |
585 | uo_text (uiout, string); | |
586 | } | |
587 | ||
588 | void | |
88379baf AC |
589 | ui_out_message (struct ui_out *uiout, int verbosity, |
590 | const char *format,...) | |
8b93c638 JM |
591 | { |
592 | va_list args; | |
593 | ||
594 | va_start (args, format); | |
8b93c638 | 595 | uo_message (uiout, verbosity, format, args); |
8b93c638 JM |
596 | va_end (args); |
597 | } | |
598 | ||
8b93c638 | 599 | void |
fba45db2 | 600 | ui_out_wrap_hint (struct ui_out *uiout, char *identstring) |
8b93c638 JM |
601 | { |
602 | uo_wrap_hint (uiout, identstring); | |
603 | } | |
604 | ||
605 | void | |
fba45db2 | 606 | ui_out_flush (struct ui_out *uiout) |
8b93c638 JM |
607 | { |
608 | uo_flush (uiout); | |
609 | } | |
610 | ||
0fac0b41 DJ |
611 | int |
612 | ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream) | |
613 | { | |
614 | return uo_redirect (uiout, outstream); | |
615 | } | |
616 | ||
581e13c1 | 617 | /* Set the flags specified by the mask given. */ |
8b93c638 | 618 | int |
fba45db2 | 619 | ui_out_set_flags (struct ui_out *uiout, int mask) |
8b93c638 | 620 | { |
5bfb05ca | 621 | int oldflags = uiout->flags; |
8b93c638 | 622 | |
b8d86de3 | 623 | uiout->flags |= mask; |
8b93c638 JM |
624 | return oldflags; |
625 | } | |
626 | ||
581e13c1 | 627 | /* Clear the flags specified by the mask given. */ |
8b93c638 | 628 | int |
fba45db2 | 629 | ui_out_clear_flags (struct ui_out *uiout, int mask) |
8b93c638 | 630 | { |
5bfb05ca | 631 | int oldflags = uiout->flags; |
8b93c638 JM |
632 | |
633 | uiout->flags &= ~mask; | |
8b93c638 JM |
634 | return oldflags; |
635 | } | |
636 | ||
581e13c1 | 637 | /* Test the flags against the mask given. */ |
8b93c638 | 638 | int |
fba45db2 | 639 | ui_out_test_flags (struct ui_out *uiout, int mask) |
8b93c638 JM |
640 | { |
641 | return (uiout->flags & mask); | |
642 | } | |
643 | ||
581e13c1 MS |
644 | /* Obtain the current verbosity level (as stablished by the |
645 | 'set verbositylevel' command. */ | |
8b93c638 JM |
646 | |
647 | int | |
fba45db2 | 648 | ui_out_get_verblvl (struct ui_out *uiout) |
8b93c638 | 649 | { |
581e13c1 | 650 | /* FIXME: not implemented yet. */ |
8b93c638 JM |
651 | return 0; |
652 | } | |
653 | ||
9dc5e2a9 AC |
654 | int |
655 | ui_out_is_mi_like_p (struct ui_out *uiout) | |
656 | { | |
657 | return uiout->impl->is_mi_like_p; | |
658 | } | |
659 | ||
581e13c1 | 660 | /* Default gdb-out hook functions. */ |
8b93c638 JM |
661 | |
662 | static void | |
d63f1d40 AC |
663 | default_table_begin (struct ui_out *uiout, int nbrofcols, |
664 | int nr_rows, | |
665 | const char *tblid) | |
8b93c638 JM |
666 | { |
667 | } | |
668 | ||
669 | static void | |
fba45db2 | 670 | default_table_body (struct ui_out *uiout) |
8b93c638 JM |
671 | { |
672 | } | |
673 | ||
674 | static void | |
fba45db2 | 675 | default_table_end (struct ui_out *uiout) |
8b93c638 JM |
676 | { |
677 | } | |
678 | ||
679 | static void | |
fba45db2 | 680 | default_table_header (struct ui_out *uiout, int width, enum ui_align alignment, |
b25959ec | 681 | const char *col_name, |
e2e11a41 | 682 | const char *colhdr) |
8b93c638 JM |
683 | { |
684 | } | |
685 | ||
686 | static void | |
631ec795 AC |
687 | default_begin (struct ui_out *uiout, |
688 | enum ui_out_type type, | |
689 | int level, | |
690 | const char *id) | |
8b93c638 JM |
691 | { |
692 | } | |
693 | ||
694 | static void | |
631ec795 AC |
695 | default_end (struct ui_out *uiout, |
696 | enum ui_out_type type, | |
697 | int level) | |
8b93c638 JM |
698 | { |
699 | } | |
700 | ||
701 | static void | |
fba45db2 | 702 | default_field_int (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
703 | enum ui_align align, |
704 | const char *fldname, int value) | |
8b93c638 JM |
705 | { |
706 | } | |
707 | ||
708 | static void | |
fba45db2 | 709 | default_field_skip (struct ui_out *uiout, int fldno, int width, |
e2e11a41 | 710 | enum ui_align align, const char *fldname) |
8b93c638 JM |
711 | { |
712 | } | |
713 | ||
714 | static void | |
715 | default_field_string (struct ui_out *uiout, | |
716 | int fldno, | |
717 | int width, | |
718 | enum ui_align align, | |
e2e11a41 | 719 | const char *fldname, |
8b93c638 JM |
720 | const char *string) |
721 | { | |
722 | } | |
723 | ||
724 | static void | |
fba45db2 | 725 | default_field_fmt (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
726 | enum ui_align align, |
727 | const char *fldname, | |
728 | const char *format, | |
fba45db2 | 729 | va_list args) |
8b93c638 JM |
730 | { |
731 | } | |
732 | ||
733 | static void | |
fba45db2 | 734 | default_spaces (struct ui_out *uiout, int numspaces) |
8b93c638 JM |
735 | { |
736 | } | |
737 | ||
738 | static void | |
e2e11a41 | 739 | default_text (struct ui_out *uiout, const char *string) |
8b93c638 JM |
740 | { |
741 | } | |
742 | ||
743 | static void | |
e2e11a41 AC |
744 | default_message (struct ui_out *uiout, int verbosity, |
745 | const char *format, | |
fba45db2 | 746 | va_list args) |
8b93c638 JM |
747 | { |
748 | } | |
749 | ||
750 | static void | |
fba45db2 | 751 | default_wrap_hint (struct ui_out *uiout, char *identstring) |
8b93c638 JM |
752 | { |
753 | } | |
754 | ||
755 | static void | |
fba45db2 | 756 | default_flush (struct ui_out *uiout) |
8b93c638 JM |
757 | { |
758 | } | |
759 | ||
b65a2bd9 SCR |
760 | static void |
761 | default_data_destroy (struct ui_out *uiout) | |
762 | { | |
763 | } | |
764 | ||
581e13c1 | 765 | /* Interface to the implementation functions. */ |
8b93c638 JM |
766 | |
767 | void | |
88379baf | 768 | uo_table_begin (struct ui_out *uiout, int nbrofcols, |
d63f1d40 | 769 | int nr_rows, |
88379baf | 770 | const char *tblid) |
8b93c638 JM |
771 | { |
772 | if (!uiout->impl->table_begin) | |
773 | return; | |
d63f1d40 | 774 | uiout->impl->table_begin (uiout, nbrofcols, nr_rows, tblid); |
8b93c638 JM |
775 | } |
776 | ||
777 | void | |
778 | uo_table_body (struct ui_out *uiout) | |
779 | { | |
780 | if (!uiout->impl->table_body) | |
781 | return; | |
782 | uiout->impl->table_body (uiout); | |
783 | } | |
784 | ||
785 | void | |
786 | uo_table_end (struct ui_out *uiout) | |
787 | { | |
788 | if (!uiout->impl->table_end) | |
789 | return; | |
790 | uiout->impl->table_end (uiout); | |
791 | } | |
792 | ||
793 | void | |
88379baf | 794 | uo_table_header (struct ui_out *uiout, int width, enum ui_align align, |
b25959ec | 795 | const char *col_name, |
88379baf | 796 | const char *colhdr) |
8b93c638 JM |
797 | { |
798 | if (!uiout->impl->table_header) | |
799 | return; | |
b25959ec | 800 | uiout->impl->table_header (uiout, width, align, col_name, colhdr); |
8b93c638 JM |
801 | } |
802 | ||
b65a2bd9 SCR |
803 | /* Clear the table associated with UIOUT. */ |
804 | ||
805 | static void | |
806 | clear_table (struct ui_out *uiout) | |
807 | { | |
9c1fcd01 TT |
808 | xfree (uiout->table.id); |
809 | uiout->table.id = NULL; | |
b65a2bd9 SCR |
810 | clear_header_list (uiout); |
811 | } | |
812 | ||
8b93c638 | 813 | void |
631ec795 AC |
814 | uo_begin (struct ui_out *uiout, |
815 | enum ui_out_type type, | |
816 | int level, | |
817 | const char *id) | |
8b93c638 | 818 | { |
631ec795 | 819 | if (uiout->impl->begin == NULL) |
8b93c638 | 820 | return; |
631ec795 | 821 | uiout->impl->begin (uiout, type, level, id); |
8b93c638 JM |
822 | } |
823 | ||
824 | void | |
631ec795 AC |
825 | uo_end (struct ui_out *uiout, |
826 | enum ui_out_type type, | |
827 | int level) | |
8b93c638 | 828 | { |
631ec795 | 829 | if (uiout->impl->end == NULL) |
8b93c638 | 830 | return; |
631ec795 | 831 | uiout->impl->end (uiout, type, level); |
8b93c638 JM |
832 | } |
833 | ||
834 | void | |
88379baf AC |
835 | uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
836 | const char *fldname, | |
837 | int value) | |
8b93c638 JM |
838 | { |
839 | if (!uiout->impl->field_int) | |
840 | return; | |
841 | uiout->impl->field_int (uiout, fldno, width, align, fldname, value); | |
842 | } | |
843 | ||
844 | void | |
88379baf AC |
845 | uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
846 | const char *fldname) | |
8b93c638 JM |
847 | { |
848 | if (!uiout->impl->field_skip) | |
849 | return; | |
850 | uiout->impl->field_skip (uiout, fldno, width, align, fldname); | |
851 | } | |
852 | ||
853 | void | |
854 | uo_field_string (struct ui_out *uiout, int fldno, int width, | |
88379baf AC |
855 | enum ui_align align, |
856 | const char *fldname, | |
857 | const char *string) | |
8b93c638 JM |
858 | { |
859 | if (!uiout->impl->field_string) | |
860 | return; | |
861 | uiout->impl->field_string (uiout, fldno, width, align, fldname, string); | |
862 | } | |
863 | ||
864 | void | |
88379baf AC |
865 | uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
866 | const char *fldname, | |
867 | const char *format, | |
868 | va_list args) | |
8b93c638 JM |
869 | { |
870 | if (!uiout->impl->field_fmt) | |
871 | return; | |
872 | uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args); | |
873 | } | |
874 | ||
875 | void | |
876 | uo_spaces (struct ui_out *uiout, int numspaces) | |
877 | { | |
878 | if (!uiout->impl->spaces) | |
879 | return; | |
880 | uiout->impl->spaces (uiout, numspaces); | |
881 | } | |
882 | ||
883 | void | |
88379baf AC |
884 | uo_text (struct ui_out *uiout, |
885 | const char *string) | |
8b93c638 JM |
886 | { |
887 | if (!uiout->impl->text) | |
888 | return; | |
889 | uiout->impl->text (uiout, string); | |
890 | } | |
891 | ||
892 | void | |
88379baf AC |
893 | uo_message (struct ui_out *uiout, int verbosity, |
894 | const char *format, | |
895 | va_list args) | |
8b93c638 JM |
896 | { |
897 | if (!uiout->impl->message) | |
898 | return; | |
899 | uiout->impl->message (uiout, verbosity, format, args); | |
900 | } | |
901 | ||
902 | void | |
903 | uo_wrap_hint (struct ui_out *uiout, char *identstring) | |
904 | { | |
905 | if (!uiout->impl->wrap_hint) | |
906 | return; | |
907 | uiout->impl->wrap_hint (uiout, identstring); | |
908 | } | |
909 | ||
910 | void | |
911 | uo_flush (struct ui_out *uiout) | |
912 | { | |
913 | if (!uiout->impl->flush) | |
914 | return; | |
915 | uiout->impl->flush (uiout); | |
916 | } | |
917 | ||
0fac0b41 DJ |
918 | int |
919 | uo_redirect (struct ui_out *uiout, struct ui_file *outstream) | |
920 | { | |
921 | if (!uiout->impl->redirect) | |
922 | return -1; | |
923 | uiout->impl->redirect (uiout, outstream); | |
924 | return 0; | |
925 | } | |
926 | ||
b65a2bd9 SCR |
927 | void |
928 | uo_data_destroy (struct ui_out *uiout) | |
929 | { | |
930 | if (!uiout->impl->data_destroy) | |
931 | return; | |
932 | ||
933 | uiout->impl->data_destroy (uiout); | |
934 | } | |
935 | ||
8b93c638 JM |
936 | /* local functions */ |
937 | ||
581e13c1 | 938 | /* List of column headers manipulation routines. */ |
8b93c638 JM |
939 | |
940 | static void | |
fba45db2 | 941 | clear_header_list (struct ui_out *uiout) |
8b93c638 | 942 | { |
bafdd3b3 | 943 | while (uiout->table.header_first != NULL) |
8b93c638 | 944 | { |
bafdd3b3 AC |
945 | uiout->table.header_next = uiout->table.header_first; |
946 | uiout->table.header_first = uiout->table.header_first->next; | |
71bdabee KS |
947 | xfree (uiout->table.header_next->colhdr); |
948 | xfree (uiout->table.header_next->col_name); | |
bafdd3b3 | 949 | xfree (uiout->table.header_next); |
8b93c638 | 950 | } |
bafdd3b3 AC |
951 | gdb_assert (uiout->table.header_first == NULL); |
952 | uiout->table.header_last = NULL; | |
953 | uiout->table.header_next = NULL; | |
8b93c638 JM |
954 | } |
955 | ||
956 | static void | |
957 | append_header_to_list (struct ui_out *uiout, | |
958 | int width, | |
959 | int alignment, | |
b25959ec | 960 | const char *col_name, |
88379baf | 961 | const char *colhdr) |
8b93c638 JM |
962 | { |
963 | struct ui_out_hdr *temphdr; | |
964 | ||
70ba0933 | 965 | temphdr = XNEW (struct ui_out_hdr); |
8b93c638 JM |
966 | temphdr->width = width; |
967 | temphdr->alignment = alignment; | |
44db85f8 MS |
968 | /* We have to copy the column title as the original may be an |
969 | automatic. */ | |
8b93c638 | 970 | if (colhdr != NULL) |
b25959ec AC |
971 | temphdr->colhdr = xstrdup (colhdr); |
972 | else | |
973 | temphdr->colhdr = NULL; | |
44db85f8 | 974 | |
b25959ec | 975 | if (col_name != NULL) |
44db85f8 MS |
976 | temphdr->col_name = xstrdup (col_name); |
977 | else if (colhdr != NULL) | |
b25959ec AC |
978 | temphdr->col_name = xstrdup (colhdr); |
979 | else | |
44db85f8 MS |
980 | temphdr->col_name = NULL; |
981 | ||
8b93c638 | 982 | temphdr->next = NULL; |
bafdd3b3 | 983 | if (uiout->table.header_first == NULL) |
8b93c638 JM |
984 | { |
985 | temphdr->colno = 1; | |
bafdd3b3 AC |
986 | uiout->table.header_first = temphdr; |
987 | uiout->table.header_last = temphdr; | |
8b93c638 JM |
988 | } |
989 | else | |
990 | { | |
bafdd3b3 AC |
991 | temphdr->colno = uiout->table.header_last->colno + 1; |
992 | uiout->table.header_last->next = temphdr; | |
993 | uiout->table.header_last = temphdr; | |
8b93c638 | 994 | } |
bafdd3b3 | 995 | uiout->table.header_next = uiout->table.header_last; |
8b93c638 JM |
996 | } |
997 | ||
7a9dd1b2 | 998 | /* Extract the format information for the NEXT header and advance |
bafdd3b3 | 999 | the header pointer. Return 0 if there was no next header. */ |
8b93c638 JM |
1000 | |
1001 | static int | |
bafdd3b3 | 1002 | get_next_header (struct ui_out *uiout, |
8b93c638 JM |
1003 | int *colno, |
1004 | int *width, | |
1005 | int *alignment, | |
1006 | char **colhdr) | |
1007 | { | |
bafdd3b3 AC |
1008 | /* There may be no headers at all or we may have used all columns. */ |
1009 | if (uiout->table.header_next == NULL) | |
8b93c638 | 1010 | return 0; |
bafdd3b3 AC |
1011 | *colno = uiout->table.header_next->colno; |
1012 | *width = uiout->table.header_next->width; | |
1013 | *alignment = uiout->table.header_next->alignment; | |
1014 | *colhdr = uiout->table.header_next->colhdr; | |
1015 | /* Advance the header pointer to the next entry. */ | |
1016 | uiout->table.header_next = uiout->table.header_next->next; | |
8b93c638 JM |
1017 | return 1; |
1018 | } | |
1019 | ||
a6c47c14 AC |
1020 | |
1021 | /* Verify that the field/tuple/list is correctly positioned. Return | |
1022 | the field number and corresponding alignment (if | |
1023 | available/applicable). */ | |
8b93c638 JM |
1024 | |
1025 | static void | |
a6c47c14 | 1026 | verify_field (struct ui_out *uiout, int *fldno, int *width, int *align) |
8b93c638 | 1027 | { |
a6c47c14 AC |
1028 | struct ui_out_level *current = current_level (uiout); |
1029 | char *text; | |
1030 | ||
bafdd3b3 | 1031 | if (uiout->table.flag) |
8b93c638 | 1032 | { |
bafdd3b3 | 1033 | if (!uiout->table.body_flag) |
8e65ff28 | 1034 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
1035 | _("table_body missing; table fields must be \ |
1036 | specified after table_body and inside a list.")); | |
a6c47c14 AC |
1037 | /* NOTE: cagney/2001-12-08: There was a check here to ensure |
1038 | that this code was only executed when uiout->level was | |
1039 | greater than zero. That no longer applies - this code is run | |
1040 | before each table row tuple is started and at that point the | |
1041 | level is zero. */ | |
8b93c638 | 1042 | } |
8b93c638 | 1043 | |
a6c47c14 | 1044 | current->field_count += 1; |
8b93c638 | 1045 | |
a6c47c14 AC |
1046 | if (uiout->table.body_flag |
1047 | && uiout->table.entry_level == uiout->level | |
1048 | && get_next_header (uiout, fldno, width, align, &text)) | |
8b93c638 | 1049 | { |
a6c47c14 | 1050 | if (*fldno != current->field_count) |
8e65ff28 | 1051 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 1052 | _("ui-out internal error in handling headers.")); |
8b93c638 JM |
1053 | } |
1054 | else | |
1055 | { | |
1056 | *width = 0; | |
1057 | *align = ui_noalign; | |
a6c47c14 | 1058 | *fldno = current->field_count; |
8b93c638 JM |
1059 | } |
1060 | } | |
1061 | ||
a6c47c14 | 1062 | |
581e13c1 | 1063 | /* Access to ui-out members data. */ |
8b93c638 | 1064 | |
0a8fce9a | 1065 | void * |
8b93c638 JM |
1066 | ui_out_data (struct ui_out *uiout) |
1067 | { | |
1068 | return uiout->data; | |
1069 | } | |
1070 | ||
170b53b2 UW |
1071 | /* Access table field parameters. */ |
1072 | int | |
1073 | ui_out_query_field (struct ui_out *uiout, int colno, | |
1074 | int *width, int *alignment, char **col_name) | |
1075 | { | |
1076 | struct ui_out_hdr *hdr; | |
1077 | ||
1078 | if (!uiout->table.flag) | |
1079 | return 0; | |
1080 | ||
1081 | for (hdr = uiout->table.header_first; hdr; hdr = hdr->next) | |
1082 | if (hdr->colno == colno) | |
1083 | { | |
1084 | *width = hdr->width; | |
1085 | *alignment = hdr->alignment; | |
1086 | *col_name = hdr->col_name; | |
1087 | return 1; | |
1088 | } | |
1089 | ||
1090 | return 0; | |
1091 | } | |
1092 | ||
581e13c1 | 1093 | /* Initalize private members at startup. */ |
8b93c638 JM |
1094 | |
1095 | struct ui_out * | |
89de4da4 | 1096 | ui_out_new (const struct ui_out_impl *impl, void *data, |
8b93c638 JM |
1097 | int flags) |
1098 | { | |
70ba0933 TT |
1099 | struct ui_out *uiout = XNEW (struct ui_out); |
1100 | struct ui_out_level *current = XNEW (struct ui_out_level); | |
5d502164 | 1101 | |
8b93c638 JM |
1102 | uiout->data = data; |
1103 | uiout->impl = impl; | |
1104 | uiout->flags = flags; | |
bafdd3b3 AC |
1105 | uiout->table.flag = 0; |
1106 | uiout->table.body_flag = 0; | |
80f49b30 | 1107 | uiout->level = 0; |
54eb231c PM |
1108 | uiout->levels = NULL; |
1109 | ||
1110 | /* Create uiout->level 0, the default level. */ | |
1111 | current->type = ui_out_type_tuple; | |
1112 | current->field_count = 0; | |
1113 | VEC_safe_push (ui_out_level_p, uiout->levels, current); | |
1114 | ||
9c1fcd01 | 1115 | uiout->table.id = NULL; |
bafdd3b3 AC |
1116 | uiout->table.header_first = NULL; |
1117 | uiout->table.header_last = NULL; | |
1118 | uiout->table.header_next = NULL; | |
8b93c638 JM |
1119 | return uiout; |
1120 | } | |
1121 | ||
b65a2bd9 SCR |
1122 | /* Free UIOUT and the memory areas it references. */ |
1123 | ||
1124 | void | |
1125 | ui_out_destroy (struct ui_out *uiout) | |
1126 | { | |
54eb231c PM |
1127 | int i; |
1128 | struct ui_out_level *current; | |
1129 | ||
1130 | /* Make sure that all levels are freed in the case where levels have | |
1131 | been pushed, but not popped before the ui_out object is | |
1132 | destroyed. */ | |
1133 | for (i = 0; | |
1134 | VEC_iterate (ui_out_level_p, uiout->levels, i, current); | |
1135 | ++i) | |
1136 | xfree (current); | |
1137 | ||
1138 | VEC_free (ui_out_level_p, uiout->levels); | |
b65a2bd9 SCR |
1139 | uo_data_destroy (uiout); |
1140 | clear_table (uiout); | |
1141 | xfree (uiout); | |
1142 | } | |
1143 | ||
581e13c1 | 1144 | /* Standard gdb initialization hook. */ |
8b93c638 JM |
1145 | |
1146 | void | |
fba45db2 | 1147 | _initialize_ui_out (void) |
8b93c638 JM |
1148 | { |
1149 | /* nothing needs to be done */ | |
1150 | } |