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