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