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