]>
Commit | Line | Data |
---|---|---|
8b93c638 | 1 | /* Output generating routines for GDB. |
349c5d5f | 2 | |
0fb0cc75 | 3 | Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009 |
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 | ||
a3edc55b | 47 | enum { MAX_UI_OUT_LEVELS = 6 }; |
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; | |
103 | struct ui_out_data *data; | |
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, | |
bee0189a | 180 | va_list args) ATTR_FORMAT (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, | |
bee0189a | 185 | va_list args) ATTR_FORMAT (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_string (struct ui_out *uiout, int fldno, int width, |
88379baf AC |
246 | enum ui_align align, const char *fldname, |
247 | const char *string); | |
8b93c638 | 248 | static void uo_field_fmt (struct ui_out *uiout, int fldno, int width, |
88379baf | 249 | enum ui_align align, const char *fldname, |
bee0189a DJ |
250 | const char *format, va_list args) |
251 | ATTR_FORMAT (printf, 6, 0); | |
8b93c638 | 252 | static void uo_spaces (struct ui_out *uiout, int numspaces); |
88379baf | 253 | static void uo_text (struct ui_out *uiout, const char *string); |
8b93c638 | 254 | static void uo_message (struct ui_out *uiout, int verbosity, |
bee0189a DJ |
255 | const char *format, va_list args) |
256 | ATTR_FORMAT (printf, 3, 0); | |
8b93c638 JM |
257 | static void uo_wrap_hint (struct ui_out *uiout, char *identstring); |
258 | static void uo_flush (struct ui_out *uiout); | |
0fac0b41 | 259 | static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream); |
8b93c638 JM |
260 | |
261 | /* Prototypes for local functions */ | |
262 | ||
263 | extern void _initialize_ui_out (void); | |
88379baf | 264 | static void append_header_to_list (struct ui_out *uiout, int width, |
b25959ec AC |
265 | int alignment, const char *col_name, |
266 | const char *colhdr); | |
bafdd3b3 | 267 | static int get_next_header (struct ui_out *uiout, int *colno, int *width, |
8b93c638 JM |
268 | int *alignment, char **colhdr); |
269 | static void clear_header_list (struct ui_out *uiout); | |
a6c47c14 AC |
270 | static void verify_field (struct ui_out *uiout, int *fldno, int *width, |
271 | int *align); | |
8b93c638 | 272 | |
8b93c638 JM |
273 | /* exported functions (ui_out API) */ |
274 | ||
275 | /* Mark beginning of a table */ | |
276 | ||
3b31d625 | 277 | static void |
88379baf | 278 | ui_out_table_begin (struct ui_out *uiout, int nbrofcols, |
d63f1d40 | 279 | int nr_rows, |
88379baf | 280 | const char *tblid) |
8b93c638 | 281 | { |
bafdd3b3 | 282 | if (uiout->table.flag) |
8e65ff28 | 283 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
284 | _("tables cannot be nested; table_begin found before \ |
285 | previous table_end.")); | |
8b93c638 | 286 | |
bafdd3b3 AC |
287 | uiout->table.flag = 1; |
288 | uiout->table.body_flag = 0; | |
a6c47c14 | 289 | uiout->table.entry_level = uiout->level + 1; |
bafdd3b3 | 290 | uiout->table.columns = nbrofcols; |
8b93c638 | 291 | if (tblid != NULL) |
bafdd3b3 | 292 | uiout->table.id = xstrdup (tblid); |
8b93c638 | 293 | else |
bafdd3b3 | 294 | uiout->table.id = NULL; |
8b93c638 JM |
295 | clear_header_list (uiout); |
296 | ||
bafdd3b3 | 297 | uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id); |
8b93c638 JM |
298 | } |
299 | ||
300 | void | |
fba45db2 | 301 | ui_out_table_body (struct ui_out *uiout) |
8b93c638 | 302 | { |
bafdd3b3 | 303 | if (!uiout->table.flag) |
8e65ff28 | 304 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
305 | _("table_body outside a table is not valid; it must be \ |
306 | after a table_begin and before a table_end.")); | |
bafdd3b3 | 307 | if (uiout->table.body_flag) |
8e65ff28 | 308 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
309 | _("extra table_body call not allowed; there must be \ |
310 | only one table_body after a table_begin and before a table_end.")); | |
bafdd3b3 | 311 | if (uiout->table.header_next->colno != uiout->table.columns) |
8e65ff28 | 312 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
313 | _("number of headers differ from number of table \ |
314 | columns.")); | |
8b93c638 | 315 | |
bafdd3b3 AC |
316 | uiout->table.body_flag = 1; |
317 | uiout->table.header_next = uiout->table.header_first; | |
8b93c638 JM |
318 | |
319 | uo_table_body (uiout); | |
320 | } | |
321 | ||
3b31d625 | 322 | static void |
fba45db2 | 323 | ui_out_table_end (struct ui_out *uiout) |
8b93c638 | 324 | { |
bafdd3b3 | 325 | if (!uiout->table.flag) |
8e65ff28 | 326 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 327 | _("misplaced table_end or missing table_begin.")); |
8b93c638 | 328 | |
a6c47c14 | 329 | uiout->table.entry_level = 0; |
bafdd3b3 AC |
330 | uiout->table.body_flag = 0; |
331 | uiout->table.flag = 0; | |
8b93c638 JM |
332 | |
333 | uo_table_end (uiout); | |
334 | ||
bafdd3b3 AC |
335 | if (uiout->table.id) |
336 | xfree (uiout->table.id); | |
8b93c638 JM |
337 | clear_header_list (uiout); |
338 | } | |
339 | ||
340 | void | |
fba45db2 | 341 | ui_out_table_header (struct ui_out *uiout, int width, enum ui_align alignment, |
b25959ec | 342 | const char *col_name, |
88379baf | 343 | const char *colhdr) |
8b93c638 | 344 | { |
bafdd3b3 | 345 | if (!uiout->table.flag || uiout->table.body_flag) |
8e65ff28 | 346 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
347 | _("table header must be specified after table_begin \ |
348 | and before table_body.")); | |
8b93c638 | 349 | |
b25959ec | 350 | append_header_to_list (uiout, width, alignment, col_name, colhdr); |
8b93c638 | 351 | |
b25959ec | 352 | uo_table_header (uiout, width, alignment, col_name, colhdr); |
8b93c638 JM |
353 | } |
354 | ||
3b31d625 EZ |
355 | static void |
356 | do_cleanup_table_end (void *data) | |
357 | { | |
358 | struct ui_out *ui_out = data; | |
359 | ||
360 | ui_out_table_end (ui_out); | |
361 | } | |
362 | ||
363 | struct cleanup * | |
364 | make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols, | |
365 | int nr_rows, const char *tblid) | |
366 | { | |
367 | ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid); | |
368 | return make_cleanup (do_cleanup_table_end, ui_out); | |
369 | } | |
370 | ||
8b93c638 | 371 | void |
631ec795 AC |
372 | ui_out_begin (struct ui_out *uiout, |
373 | enum ui_out_type type, | |
374 | const char *id) | |
8b93c638 | 375 | { |
80f49b30 | 376 | int new_level; |
bafdd3b3 | 377 | if (uiout->table.flag && !uiout->table.body_flag) |
8e65ff28 | 378 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
379 | _("table header or table_body expected; lists must be \ |
380 | specified after table_body.")); | |
a6c47c14 AC |
381 | |
382 | /* Be careful to verify the ``field'' before the new tuple/list is | |
383 | pushed onto the stack. That way the containing list/table/row is | |
384 | verified and not the newly created tuple/list. This verification | |
385 | is needed (at least) for the case where a table row entry | |
386 | contains either a tuple/list. For that case bookkeeping such as | |
387 | updating the column count or advancing to the next heading still | |
388 | needs to be performed. */ | |
389 | { | |
390 | int fldno; | |
391 | int width; | |
392 | int align; | |
393 | verify_field (uiout, &fldno, &width, &align); | |
394 | } | |
395 | ||
631ec795 | 396 | new_level = push_level (uiout, type, id); |
a6c47c14 AC |
397 | |
398 | /* If the push puts us at the same level as a table row entry, we've | |
399 | got a new table row. Put the header pointer back to the start. */ | |
400 | if (uiout->table.body_flag | |
401 | && uiout->table.entry_level == new_level) | |
bafdd3b3 | 402 | uiout->table.header_next = uiout->table.header_first; |
a6c47c14 | 403 | |
631ec795 AC |
404 | uo_begin (uiout, type, new_level, id); |
405 | } | |
406 | ||
631ec795 AC |
407 | void |
408 | ui_out_end (struct ui_out *uiout, | |
409 | enum ui_out_type type) | |
410 | { | |
411 | int old_level = pop_level (uiout, type); | |
412 | uo_end (uiout, type, old_level); | |
8b93c638 JM |
413 | } |
414 | ||
127431f9 AC |
415 | struct ui_out_end_cleanup_data |
416 | { | |
417 | struct ui_out *uiout; | |
418 | enum ui_out_type type; | |
419 | }; | |
420 | ||
e6e0bfab | 421 | static void |
127431f9 AC |
422 | do_cleanup_end (void *data) |
423 | { | |
424 | struct ui_out_end_cleanup_data *end_cleanup_data = data; | |
425 | ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type); | |
426 | xfree (end_cleanup_data); | |
427 | } | |
428 | ||
429 | static struct cleanup * | |
430 | make_cleanup_ui_out_end (struct ui_out *uiout, | |
431 | enum ui_out_type type) | |
432 | { | |
433 | struct ui_out_end_cleanup_data *end_cleanup_data; | |
434 | end_cleanup_data = XMALLOC (struct ui_out_end_cleanup_data); | |
435 | end_cleanup_data->uiout = uiout; | |
436 | end_cleanup_data->type = type; | |
437 | return make_cleanup (do_cleanup_end, end_cleanup_data); | |
438 | } | |
439 | ||
e6e0bfab | 440 | struct cleanup * |
666547aa AC |
441 | make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, |
442 | const char *id) | |
443 | { | |
3b31d625 | 444 | ui_out_begin (uiout, ui_out_type_tuple, id); |
666547aa AC |
445 | return make_cleanup_ui_out_end (uiout, ui_out_type_tuple); |
446 | } | |
447 | ||
448 | struct cleanup * | |
6b28c186 AC |
449 | make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, |
450 | const char *id) | |
e6e0bfab | 451 | { |
3b31d625 | 452 | ui_out_begin (uiout, ui_out_type_list, id); |
127431f9 | 453 | return make_cleanup_ui_out_end (uiout, ui_out_type_list); |
e6e0bfab MK |
454 | } |
455 | ||
8b93c638 | 456 | void |
88379baf AC |
457 | ui_out_field_int (struct ui_out *uiout, |
458 | const char *fldname, | |
459 | int value) | |
8b93c638 JM |
460 | { |
461 | int fldno; | |
462 | int width; | |
463 | int align; | |
80f49b30 | 464 | struct ui_out_level *current = current_level (uiout); |
8b93c638 | 465 | |
a6c47c14 | 466 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
467 | |
468 | uo_field_int (uiout, fldno, width, align, fldname, value); | |
469 | } | |
470 | ||
52c6a6ac JJ |
471 | void |
472 | ui_out_field_fmt_int (struct ui_out *uiout, | |
473 | int input_width, | |
474 | enum ui_align input_align, | |
475 | const char *fldname, | |
476 | int value) | |
477 | { | |
478 | int fldno; | |
479 | int width; | |
480 | int align; | |
481 | struct ui_out_level *current = current_level (uiout); | |
482 | ||
483 | verify_field (uiout, &fldno, &width, &align); | |
484 | ||
485 | uo_field_int (uiout, fldno, input_width, input_align, fldname, value); | |
486 | } | |
487 | ||
8b93c638 | 488 | void |
88379baf AC |
489 | ui_out_field_core_addr (struct ui_out *uiout, |
490 | const char *fldname, | |
491 | CORE_ADDR address) | |
8b93c638 JM |
492 | { |
493 | char addstr[20]; | |
17a912b6 | 494 | int addr_bit = gdbarch_addr_bit (current_gdbarch); |
a72d8a8e | 495 | |
a72d8a8e MR |
496 | if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) |
497 | address &= ((CORE_ADDR) 1 << addr_bit) - 1; | |
8b93c638 | 498 | |
535c96ce AC |
499 | /* FIXME: cagney/2002-05-03: Need local_address_string() function |
500 | that returns the language localized string formatted to a width | |
17a912b6 | 501 | based on gdbarch_addr_bit. */ |
a72d8a8e | 502 | if (addr_bit <= 32) |
bb599908 | 503 | strcpy (addstr, hex_string_custom (address, 8)); |
535c96ce | 504 | else |
bb599908 | 505 | strcpy (addstr, hex_string_custom (address, 16)); |
8b93c638 JM |
506 | |
507 | ui_out_field_string (uiout, fldname, addstr); | |
508 | } | |
509 | ||
510 | void | |
88379baf AC |
511 | ui_out_field_stream (struct ui_out *uiout, |
512 | const char *fldname, | |
513 | struct ui_stream *buf) | |
8b93c638 JM |
514 | { |
515 | long length; | |
516 | char *buffer = ui_file_xstrdup (buf->stream, &length); | |
b8c9b27d | 517 | struct cleanup *old_cleanup = make_cleanup (xfree, buffer); |
8b93c638 JM |
518 | if (length > 0) |
519 | ui_out_field_string (uiout, fldname, buffer); | |
520 | else | |
521 | ui_out_field_skip (uiout, fldname); | |
522 | ui_file_rewind (buf->stream); | |
523 | do_cleanups (old_cleanup); | |
524 | } | |
525 | ||
526 | /* used to ommit a field */ | |
527 | ||
528 | void | |
88379baf AC |
529 | ui_out_field_skip (struct ui_out *uiout, |
530 | const char *fldname) | |
8b93c638 JM |
531 | { |
532 | int fldno; | |
533 | int width; | |
534 | int align; | |
8b93c638 | 535 | |
a6c47c14 | 536 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
537 | |
538 | uo_field_skip (uiout, fldno, width, align, fldname); | |
539 | } | |
540 | ||
541 | void | |
542 | ui_out_field_string (struct ui_out *uiout, | |
88379baf | 543 | const char *fldname, |
8b93c638 JM |
544 | const char *string) |
545 | { | |
546 | int fldno; | |
547 | int width; | |
548 | int align; | |
8b93c638 | 549 | |
a6c47c14 | 550 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
551 | |
552 | uo_field_string (uiout, fldno, width, align, fldname, string); | |
553 | } | |
554 | ||
555 | /* VARARGS */ | |
556 | void | |
88379baf AC |
557 | ui_out_field_fmt (struct ui_out *uiout, |
558 | const char *fldname, | |
559 | const char *format, ...) | |
8b93c638 JM |
560 | { |
561 | va_list args; | |
562 | int fldno; | |
563 | int width; | |
564 | int align; | |
8b93c638 JM |
565 | |
566 | /* will not align, but has to call anyway */ | |
a6c47c14 | 567 | verify_field (uiout, &fldno, &width, &align); |
8b93c638 JM |
568 | |
569 | va_start (args, format); | |
570 | ||
571 | uo_field_fmt (uiout, fldno, width, align, fldname, format, args); | |
572 | ||
573 | va_end (args); | |
574 | } | |
575 | ||
576 | void | |
fba45db2 | 577 | ui_out_spaces (struct ui_out *uiout, int numspaces) |
8b93c638 JM |
578 | { |
579 | uo_spaces (uiout, numspaces); | |
580 | } | |
581 | ||
582 | void | |
88379baf AC |
583 | ui_out_text (struct ui_out *uiout, |
584 | const char *string) | |
8b93c638 JM |
585 | { |
586 | uo_text (uiout, string); | |
587 | } | |
588 | ||
589 | void | |
88379baf AC |
590 | ui_out_message (struct ui_out *uiout, int verbosity, |
591 | const char *format,...) | |
8b93c638 JM |
592 | { |
593 | va_list args; | |
594 | ||
595 | va_start (args, format); | |
596 | ||
597 | uo_message (uiout, verbosity, format, args); | |
598 | ||
599 | va_end (args); | |
600 | } | |
601 | ||
602 | struct ui_stream * | |
fba45db2 | 603 | ui_out_stream_new (struct ui_out *uiout) |
8b93c638 JM |
604 | { |
605 | struct ui_stream *tempbuf; | |
606 | ||
607 | tempbuf = XMALLOC (struct ui_stream); | |
608 | tempbuf->uiout = uiout; | |
609 | tempbuf->stream = mem_fileopen (); | |
610 | return tempbuf; | |
611 | } | |
612 | ||
613 | void | |
fba45db2 | 614 | ui_out_stream_delete (struct ui_stream *buf) |
8b93c638 JM |
615 | { |
616 | ui_file_delete (buf->stream); | |
b8c9b27d | 617 | xfree (buf); |
8b93c638 JM |
618 | } |
619 | ||
620 | static void | |
621 | do_stream_delete (void *buf) | |
622 | { | |
623 | ui_out_stream_delete (buf); | |
624 | } | |
625 | ||
626 | struct cleanup * | |
627 | make_cleanup_ui_out_stream_delete (struct ui_stream *buf) | |
628 | { | |
629 | return make_cleanup (do_stream_delete, buf); | |
630 | } | |
631 | ||
632 | ||
633 | void | |
fba45db2 | 634 | ui_out_wrap_hint (struct ui_out *uiout, char *identstring) |
8b93c638 JM |
635 | { |
636 | uo_wrap_hint (uiout, identstring); | |
637 | } | |
638 | ||
639 | void | |
fba45db2 | 640 | ui_out_flush (struct ui_out *uiout) |
8b93c638 JM |
641 | { |
642 | uo_flush (uiout); | |
643 | } | |
644 | ||
0fac0b41 DJ |
645 | int |
646 | ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream) | |
647 | { | |
648 | return uo_redirect (uiout, outstream); | |
649 | } | |
650 | ||
8b93c638 JM |
651 | /* set the flags specified by the mask given */ |
652 | int | |
fba45db2 | 653 | ui_out_set_flags (struct ui_out *uiout, int mask) |
8b93c638 | 654 | { |
5bfb05ca | 655 | int oldflags = uiout->flags; |
8b93c638 | 656 | |
b8d86de3 | 657 | uiout->flags |= mask; |
8b93c638 JM |
658 | |
659 | return oldflags; | |
660 | } | |
661 | ||
662 | /* clear the flags specified by the mask given */ | |
663 | int | |
fba45db2 | 664 | ui_out_clear_flags (struct ui_out *uiout, int mask) |
8b93c638 | 665 | { |
5bfb05ca | 666 | int oldflags = uiout->flags; |
8b93c638 JM |
667 | |
668 | uiout->flags &= ~mask; | |
669 | ||
670 | return oldflags; | |
671 | } | |
672 | ||
673 | /* test the flags against the mask given */ | |
674 | int | |
fba45db2 | 675 | ui_out_test_flags (struct ui_out *uiout, int mask) |
8b93c638 JM |
676 | { |
677 | return (uiout->flags & mask); | |
678 | } | |
679 | ||
680 | /* obtain the current verbosity level (as stablished by the | |
681 | 'set verbositylevel' command */ | |
682 | ||
683 | int | |
fba45db2 | 684 | ui_out_get_verblvl (struct ui_out *uiout) |
8b93c638 JM |
685 | { |
686 | /* FIXME: not implemented yet */ | |
687 | return 0; | |
688 | } | |
689 | ||
690 | #if 0 | |
691 | void | |
fba45db2 | 692 | ui_out_result_begin (struct ui_out *uiout, char *class) |
8b93c638 JM |
693 | { |
694 | } | |
695 | ||
696 | void | |
fba45db2 | 697 | ui_out_result_end (struct ui_out *uiout) |
8b93c638 JM |
698 | { |
699 | } | |
700 | ||
701 | void | |
fba45db2 | 702 | ui_out_info_begin (struct ui_out *uiout, char *class) |
8b93c638 JM |
703 | { |
704 | } | |
705 | ||
706 | void | |
fba45db2 | 707 | ui_out_info_end (struct ui_out *uiout) |
8b93c638 JM |
708 | { |
709 | } | |
710 | ||
711 | void | |
fba45db2 | 712 | ui_out_notify_begin (struct ui_out *uiout, char *class) |
8b93c638 JM |
713 | { |
714 | } | |
715 | ||
716 | void | |
fba45db2 | 717 | ui_out_notify_end (struct ui_out *uiout) |
8b93c638 JM |
718 | { |
719 | } | |
720 | ||
721 | void | |
fba45db2 | 722 | ui_out_error_begin (struct ui_out *uiout, char *class) |
8b93c638 JM |
723 | { |
724 | } | |
725 | ||
726 | void | |
fba45db2 | 727 | ui_out_error_end (struct ui_out *uiout) |
8b93c638 JM |
728 | { |
729 | } | |
730 | #endif | |
731 | ||
732 | #if 0 | |
733 | void | |
734 | gdb_error (ui_out * uiout, int severity, char *format,...) | |
735 | { | |
736 | va_list args; | |
737 | } | |
738 | ||
739 | void | |
10689f25 | 740 | gdb_query (struct ui_out *uiout, int qflags, char *qprompt) |
8b93c638 JM |
741 | { |
742 | } | |
743 | #endif | |
744 | ||
9dc5e2a9 AC |
745 | int |
746 | ui_out_is_mi_like_p (struct ui_out *uiout) | |
747 | { | |
748 | return uiout->impl->is_mi_like_p; | |
749 | } | |
750 | ||
8b93c638 JM |
751 | /* default gdb-out hook functions */ |
752 | ||
753 | static void | |
d63f1d40 AC |
754 | default_table_begin (struct ui_out *uiout, int nbrofcols, |
755 | int nr_rows, | |
756 | const char *tblid) | |
8b93c638 JM |
757 | { |
758 | } | |
759 | ||
760 | static void | |
fba45db2 | 761 | default_table_body (struct ui_out *uiout) |
8b93c638 JM |
762 | { |
763 | } | |
764 | ||
765 | static void | |
fba45db2 | 766 | default_table_end (struct ui_out *uiout) |
8b93c638 JM |
767 | { |
768 | } | |
769 | ||
770 | static void | |
fba45db2 | 771 | default_table_header (struct ui_out *uiout, int width, enum ui_align alignment, |
b25959ec | 772 | const char *col_name, |
e2e11a41 | 773 | const char *colhdr) |
8b93c638 JM |
774 | { |
775 | } | |
776 | ||
777 | static void | |
631ec795 AC |
778 | default_begin (struct ui_out *uiout, |
779 | enum ui_out_type type, | |
780 | int level, | |
781 | const char *id) | |
8b93c638 JM |
782 | { |
783 | } | |
784 | ||
785 | static void | |
631ec795 AC |
786 | default_end (struct ui_out *uiout, |
787 | enum ui_out_type type, | |
788 | int level) | |
8b93c638 JM |
789 | { |
790 | } | |
791 | ||
792 | static void | |
fba45db2 | 793 | default_field_int (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
794 | enum ui_align align, |
795 | const char *fldname, int value) | |
8b93c638 JM |
796 | { |
797 | } | |
798 | ||
799 | static void | |
fba45db2 | 800 | default_field_skip (struct ui_out *uiout, int fldno, int width, |
e2e11a41 | 801 | enum ui_align align, const char *fldname) |
8b93c638 JM |
802 | { |
803 | } | |
804 | ||
805 | static void | |
806 | default_field_string (struct ui_out *uiout, | |
807 | int fldno, | |
808 | int width, | |
809 | enum ui_align align, | |
e2e11a41 | 810 | const char *fldname, |
8b93c638 JM |
811 | const char *string) |
812 | { | |
813 | } | |
814 | ||
815 | static void | |
fba45db2 | 816 | default_field_fmt (struct ui_out *uiout, int fldno, int width, |
e2e11a41 AC |
817 | enum ui_align align, |
818 | const char *fldname, | |
819 | const char *format, | |
fba45db2 | 820 | va_list args) |
8b93c638 JM |
821 | { |
822 | } | |
823 | ||
824 | static void | |
fba45db2 | 825 | default_spaces (struct ui_out *uiout, int numspaces) |
8b93c638 JM |
826 | { |
827 | } | |
828 | ||
829 | static void | |
e2e11a41 | 830 | default_text (struct ui_out *uiout, const char *string) |
8b93c638 JM |
831 | { |
832 | } | |
833 | ||
834 | static void | |
e2e11a41 AC |
835 | default_message (struct ui_out *uiout, int verbosity, |
836 | const char *format, | |
fba45db2 | 837 | va_list args) |
8b93c638 JM |
838 | { |
839 | } | |
840 | ||
841 | static void | |
fba45db2 | 842 | default_wrap_hint (struct ui_out *uiout, char *identstring) |
8b93c638 JM |
843 | { |
844 | } | |
845 | ||
846 | static void | |
fba45db2 | 847 | default_flush (struct ui_out *uiout) |
8b93c638 JM |
848 | { |
849 | } | |
850 | ||
851 | /* Interface to the implementation functions */ | |
852 | ||
853 | void | |
88379baf | 854 | uo_table_begin (struct ui_out *uiout, int nbrofcols, |
d63f1d40 | 855 | int nr_rows, |
88379baf | 856 | const char *tblid) |
8b93c638 JM |
857 | { |
858 | if (!uiout->impl->table_begin) | |
859 | return; | |
d63f1d40 | 860 | uiout->impl->table_begin (uiout, nbrofcols, nr_rows, tblid); |
8b93c638 JM |
861 | } |
862 | ||
863 | void | |
864 | uo_table_body (struct ui_out *uiout) | |
865 | { | |
866 | if (!uiout->impl->table_body) | |
867 | return; | |
868 | uiout->impl->table_body (uiout); | |
869 | } | |
870 | ||
871 | void | |
872 | uo_table_end (struct ui_out *uiout) | |
873 | { | |
874 | if (!uiout->impl->table_end) | |
875 | return; | |
876 | uiout->impl->table_end (uiout); | |
877 | } | |
878 | ||
879 | void | |
88379baf | 880 | uo_table_header (struct ui_out *uiout, int width, enum ui_align align, |
b25959ec | 881 | const char *col_name, |
88379baf | 882 | const char *colhdr) |
8b93c638 JM |
883 | { |
884 | if (!uiout->impl->table_header) | |
885 | return; | |
b25959ec | 886 | uiout->impl->table_header (uiout, width, align, col_name, colhdr); |
8b93c638 JM |
887 | } |
888 | ||
889 | void | |
631ec795 AC |
890 | uo_begin (struct ui_out *uiout, |
891 | enum ui_out_type type, | |
892 | int level, | |
893 | const char *id) | |
8b93c638 | 894 | { |
631ec795 | 895 | if (uiout->impl->begin == NULL) |
8b93c638 | 896 | return; |
631ec795 | 897 | uiout->impl->begin (uiout, type, level, id); |
8b93c638 JM |
898 | } |
899 | ||
900 | void | |
631ec795 AC |
901 | uo_end (struct ui_out *uiout, |
902 | enum ui_out_type type, | |
903 | int level) | |
8b93c638 | 904 | { |
631ec795 | 905 | if (uiout->impl->end == NULL) |
8b93c638 | 906 | return; |
631ec795 | 907 | uiout->impl->end (uiout, type, level); |
8b93c638 JM |
908 | } |
909 | ||
910 | void | |
88379baf AC |
911 | uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
912 | const char *fldname, | |
913 | int value) | |
8b93c638 JM |
914 | { |
915 | if (!uiout->impl->field_int) | |
916 | return; | |
917 | uiout->impl->field_int (uiout, fldno, width, align, fldname, value); | |
918 | } | |
919 | ||
920 | void | |
88379baf AC |
921 | uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
922 | const char *fldname) | |
8b93c638 JM |
923 | { |
924 | if (!uiout->impl->field_skip) | |
925 | return; | |
926 | uiout->impl->field_skip (uiout, fldno, width, align, fldname); | |
927 | } | |
928 | ||
929 | void | |
930 | uo_field_string (struct ui_out *uiout, int fldno, int width, | |
88379baf AC |
931 | enum ui_align align, |
932 | const char *fldname, | |
933 | const char *string) | |
8b93c638 JM |
934 | { |
935 | if (!uiout->impl->field_string) | |
936 | return; | |
937 | uiout->impl->field_string (uiout, fldno, width, align, fldname, string); | |
938 | } | |
939 | ||
940 | void | |
88379baf AC |
941 | uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align, |
942 | const char *fldname, | |
943 | const char *format, | |
944 | va_list args) | |
8b93c638 JM |
945 | { |
946 | if (!uiout->impl->field_fmt) | |
947 | return; | |
948 | uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args); | |
949 | } | |
950 | ||
951 | void | |
952 | uo_spaces (struct ui_out *uiout, int numspaces) | |
953 | { | |
954 | if (!uiout->impl->spaces) | |
955 | return; | |
956 | uiout->impl->spaces (uiout, numspaces); | |
957 | } | |
958 | ||
959 | void | |
88379baf AC |
960 | uo_text (struct ui_out *uiout, |
961 | const char *string) | |
8b93c638 JM |
962 | { |
963 | if (!uiout->impl->text) | |
964 | return; | |
965 | uiout->impl->text (uiout, string); | |
966 | } | |
967 | ||
968 | void | |
88379baf AC |
969 | uo_message (struct ui_out *uiout, int verbosity, |
970 | const char *format, | |
971 | va_list args) | |
8b93c638 JM |
972 | { |
973 | if (!uiout->impl->message) | |
974 | return; | |
975 | uiout->impl->message (uiout, verbosity, format, args); | |
976 | } | |
977 | ||
978 | void | |
979 | uo_wrap_hint (struct ui_out *uiout, char *identstring) | |
980 | { | |
981 | if (!uiout->impl->wrap_hint) | |
982 | return; | |
983 | uiout->impl->wrap_hint (uiout, identstring); | |
984 | } | |
985 | ||
986 | void | |
987 | uo_flush (struct ui_out *uiout) | |
988 | { | |
989 | if (!uiout->impl->flush) | |
990 | return; | |
991 | uiout->impl->flush (uiout); | |
992 | } | |
993 | ||
0fac0b41 DJ |
994 | int |
995 | uo_redirect (struct ui_out *uiout, struct ui_file *outstream) | |
996 | { | |
997 | if (!uiout->impl->redirect) | |
998 | return -1; | |
999 | uiout->impl->redirect (uiout, outstream); | |
1000 | return 0; | |
1001 | } | |
1002 | ||
8b93c638 JM |
1003 | /* local functions */ |
1004 | ||
1005 | /* list of column headers manipulation routines */ | |
1006 | ||
1007 | static void | |
fba45db2 | 1008 | clear_header_list (struct ui_out *uiout) |
8b93c638 | 1009 | { |
bafdd3b3 | 1010 | while (uiout->table.header_first != NULL) |
8b93c638 | 1011 | { |
bafdd3b3 AC |
1012 | uiout->table.header_next = uiout->table.header_first; |
1013 | uiout->table.header_first = uiout->table.header_first->next; | |
1014 | if (uiout->table.header_next->colhdr != NULL) | |
1015 | xfree (uiout->table.header_next->colhdr); | |
1016 | xfree (uiout->table.header_next); | |
8b93c638 | 1017 | } |
bafdd3b3 AC |
1018 | gdb_assert (uiout->table.header_first == NULL); |
1019 | uiout->table.header_last = NULL; | |
1020 | uiout->table.header_next = NULL; | |
8b93c638 JM |
1021 | } |
1022 | ||
1023 | static void | |
1024 | append_header_to_list (struct ui_out *uiout, | |
1025 | int width, | |
1026 | int alignment, | |
b25959ec | 1027 | const char *col_name, |
88379baf | 1028 | const char *colhdr) |
8b93c638 JM |
1029 | { |
1030 | struct ui_out_hdr *temphdr; | |
1031 | ||
1032 | temphdr = XMALLOC (struct ui_out_hdr); | |
1033 | temphdr->width = width; | |
1034 | temphdr->alignment = alignment; | |
44db85f8 MS |
1035 | /* We have to copy the column title as the original may be an |
1036 | automatic. */ | |
8b93c638 | 1037 | if (colhdr != NULL) |
b25959ec AC |
1038 | temphdr->colhdr = xstrdup (colhdr); |
1039 | else | |
1040 | temphdr->colhdr = NULL; | |
44db85f8 | 1041 | |
b25959ec | 1042 | if (col_name != NULL) |
44db85f8 MS |
1043 | temphdr->col_name = xstrdup (col_name); |
1044 | else if (colhdr != NULL) | |
b25959ec AC |
1045 | temphdr->col_name = xstrdup (colhdr); |
1046 | else | |
44db85f8 MS |
1047 | temphdr->col_name = NULL; |
1048 | ||
8b93c638 | 1049 | temphdr->next = NULL; |
bafdd3b3 | 1050 | if (uiout->table.header_first == NULL) |
8b93c638 JM |
1051 | { |
1052 | temphdr->colno = 1; | |
bafdd3b3 AC |
1053 | uiout->table.header_first = temphdr; |
1054 | uiout->table.header_last = temphdr; | |
8b93c638 JM |
1055 | } |
1056 | else | |
1057 | { | |
bafdd3b3 AC |
1058 | temphdr->colno = uiout->table.header_last->colno + 1; |
1059 | uiout->table.header_last->next = temphdr; | |
1060 | uiout->table.header_last = temphdr; | |
8b93c638 | 1061 | } |
bafdd3b3 | 1062 | uiout->table.header_next = uiout->table.header_last; |
8b93c638 JM |
1063 | } |
1064 | ||
bafdd3b3 AC |
1065 | /* Extract the format information for the NEXT header and and advance |
1066 | the header pointer. Return 0 if there was no next header. */ | |
8b93c638 JM |
1067 | |
1068 | static int | |
bafdd3b3 | 1069 | get_next_header (struct ui_out *uiout, |
8b93c638 JM |
1070 | int *colno, |
1071 | int *width, | |
1072 | int *alignment, | |
1073 | char **colhdr) | |
1074 | { | |
bafdd3b3 AC |
1075 | /* There may be no headers at all or we may have used all columns. */ |
1076 | if (uiout->table.header_next == NULL) | |
8b93c638 | 1077 | return 0; |
bafdd3b3 AC |
1078 | *colno = uiout->table.header_next->colno; |
1079 | *width = uiout->table.header_next->width; | |
1080 | *alignment = uiout->table.header_next->alignment; | |
1081 | *colhdr = uiout->table.header_next->colhdr; | |
1082 | /* Advance the header pointer to the next entry. */ | |
1083 | uiout->table.header_next = uiout->table.header_next->next; | |
8b93c638 JM |
1084 | return 1; |
1085 | } | |
1086 | ||
a6c47c14 AC |
1087 | |
1088 | /* Verify that the field/tuple/list is correctly positioned. Return | |
1089 | the field number and corresponding alignment (if | |
1090 | available/applicable). */ | |
8b93c638 JM |
1091 | |
1092 | static void | |
a6c47c14 | 1093 | verify_field (struct ui_out *uiout, int *fldno, int *width, int *align) |
8b93c638 | 1094 | { |
a6c47c14 AC |
1095 | struct ui_out_level *current = current_level (uiout); |
1096 | char *text; | |
1097 | ||
bafdd3b3 | 1098 | if (uiout->table.flag) |
8b93c638 | 1099 | { |
bafdd3b3 | 1100 | if (!uiout->table.body_flag) |
8e65ff28 | 1101 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 AC |
1102 | _("table_body missing; table fields must be \ |
1103 | specified after table_body and inside a list.")); | |
a6c47c14 AC |
1104 | /* NOTE: cagney/2001-12-08: There was a check here to ensure |
1105 | that this code was only executed when uiout->level was | |
1106 | greater than zero. That no longer applies - this code is run | |
1107 | before each table row tuple is started and at that point the | |
1108 | level is zero. */ | |
8b93c638 | 1109 | } |
8b93c638 | 1110 | |
a6c47c14 | 1111 | current->field_count += 1; |
8b93c638 | 1112 | |
a6c47c14 AC |
1113 | if (uiout->table.body_flag |
1114 | && uiout->table.entry_level == uiout->level | |
1115 | && get_next_header (uiout, fldno, width, align, &text)) | |
8b93c638 | 1116 | { |
a6c47c14 | 1117 | if (*fldno != current->field_count) |
8e65ff28 | 1118 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 1119 | _("ui-out internal error in handling headers.")); |
8b93c638 JM |
1120 | } |
1121 | else | |
1122 | { | |
1123 | *width = 0; | |
1124 | *align = ui_noalign; | |
a6c47c14 | 1125 | *fldno = current->field_count; |
8b93c638 JM |
1126 | } |
1127 | } | |
1128 | ||
a6c47c14 | 1129 | |
8b93c638 JM |
1130 | /* access to ui_out format private members */ |
1131 | ||
1132 | void | |
fba45db2 | 1133 | ui_out_get_field_separator (struct ui_out *uiout) |
8b93c638 JM |
1134 | { |
1135 | } | |
1136 | ||
1137 | /* Access to ui-out members data */ | |
1138 | ||
1139 | struct ui_out_data * | |
1140 | ui_out_data (struct ui_out *uiout) | |
1141 | { | |
1142 | return uiout->data; | |
1143 | } | |
1144 | ||
1145 | /* initalize private members at startup */ | |
1146 | ||
1147 | struct ui_out * | |
1148 | ui_out_new (struct ui_out_impl *impl, | |
1149 | struct ui_out_data *data, | |
1150 | int flags) | |
1151 | { | |
1152 | struct ui_out *uiout = XMALLOC (struct ui_out); | |
1153 | uiout->data = data; | |
1154 | uiout->impl = impl; | |
1155 | uiout->flags = flags; | |
bafdd3b3 AC |
1156 | uiout->table.flag = 0; |
1157 | uiout->table.body_flag = 0; | |
80f49b30 AC |
1158 | uiout->level = 0; |
1159 | memset (uiout->levels, 0, sizeof (uiout->levels)); | |
bafdd3b3 AC |
1160 | uiout->table.header_first = NULL; |
1161 | uiout->table.header_last = NULL; | |
1162 | uiout->table.header_next = NULL; | |
8b93c638 JM |
1163 | return uiout; |
1164 | } | |
1165 | ||
1166 | /* standard gdb initialization hook */ | |
1167 | ||
1168 | void | |
fba45db2 | 1169 | _initialize_ui_out (void) |
8b93c638 JM |
1170 | { |
1171 | /* nothing needs to be done */ | |
1172 | } |