1 /* Output generating routines for GDB.
3 Copyright (C) 1999-2014 Free Software Foundation, Inc.
5 Contributed by Cygnus Solutions.
6 Written by Fernando Nasser for Cygnus.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "expression.h" /* For language.h */
28 #include "gdb_assert.h"
30 /* table header structures */
39 struct ui_out_hdr
*next
;
42 /* Maintain a stack so that the info applicable to the inner most list
43 is always available. Stack/nested level 0 is reserved for the
46 enum { MAX_UI_OUT_LEVELS
= 8 };
50 /* Count each field; the first element is for non-list fields. */
52 /* The type of this level. */
53 enum ui_out_type type
;
56 /* Define uiout->level vector types and operations. */
57 typedef struct ui_out_level
*ui_out_level_p
;
58 DEF_VEC_P (ui_out_level_p
);
60 /* Tables are special. Maintain a separate structure that tracks
61 their state. At present an output can only contain a single table
62 but that restriction might eventually be lifted. */
66 /* If on, a table is being generated. */
69 /* If on, the body of a table is being generated. If off, the table
70 header is being generated. */
73 /* The level at which each entry of the table is to be found. A row
74 (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
75 above that of the table. */
78 /* Number of table columns (as specified in the table_begin call). */
81 /* String identifying the table (as specified in the table_begin
85 /* Points to the first table header (if any). */
86 struct ui_out_hdr
*header_first
;
88 /* Points to the last table header (if any). */
89 struct ui_out_hdr
*header_last
;
91 /* Points to header of NEXT column to format. */
92 struct ui_out_hdr
*header_next
;
97 /* The ui_out structure */
98 /* Any change here requires a corresponding one in the initialization
99 of the default uiout, which is statically initialized. */
104 /* Specific implementation of ui-out. */
105 const struct ui_out_impl
*impl
;
111 /* Vector to store and track the ui-out levels. */
112 VEC (ui_out_level_p
) *levels
;
114 /* A table, if any. At present only a single table is supported. */
115 struct ui_out_table table
;
118 /* The current (inner most) level. */
119 static struct ui_out_level
*
120 current_level (struct ui_out
*uiout
)
122 return VEC_index (ui_out_level_p
, uiout
->levels
, uiout
->level
);
125 /* Create a new level, of TYPE. Return the new level's index. */
127 push_level (struct ui_out
*uiout
,
128 enum ui_out_type type
,
131 struct ui_out_level
*current
;
134 current
= XNEW (struct ui_out_level
);
135 current
->field_count
= 0;
136 current
->type
= type
;
137 VEC_safe_push (ui_out_level_p
, uiout
->levels
, current
);
141 /* Discard the current level, return the discarded level's index.
142 TYPE is the type of the level being discarded. */
144 pop_level (struct ui_out
*uiout
,
145 enum ui_out_type type
)
147 struct ui_out_level
*current
;
149 /* We had better not underflow the buffer. */
150 gdb_assert (uiout
->level
> 0);
151 gdb_assert (current_level (uiout
)->type
== type
);
152 current
= VEC_pop (ui_out_level_p
, uiout
->levels
);
155 return uiout
->level
+ 1;
159 /* These are the default implementation functions. */
161 static void default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
162 int nr_rows
, const char *tblid
);
163 static void default_table_body (struct ui_out
*uiout
);
164 static void default_table_end (struct ui_out
*uiout
);
165 static void default_table_header (struct ui_out
*uiout
, int width
,
166 enum ui_align alig
, const char *col_name
,
168 static void default_begin (struct ui_out
*uiout
,
169 enum ui_out_type type
,
170 int level
, const char *id
);
171 static void default_end (struct ui_out
*uiout
,
172 enum ui_out_type type
,
174 static void default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
178 static void default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
180 const char *fldname
);
181 static void default_field_string (struct ui_out
*uiout
, int fldno
, int width
,
185 static void default_field_fmt (struct ui_out
*uiout
, int fldno
,
186 int width
, enum ui_align align
,
189 va_list args
) ATTRIBUTE_PRINTF (6, 0);
190 static void default_spaces (struct ui_out
*uiout
, int numspaces
);
191 static void default_text (struct ui_out
*uiout
, const char *string
);
192 static void default_message (struct ui_out
*uiout
, int verbosity
,
194 va_list args
) ATTRIBUTE_PRINTF (3, 0);
195 static void default_wrap_hint (struct ui_out
*uiout
, char *identstring
);
196 static void default_flush (struct ui_out
*uiout
);
197 static void default_data_destroy (struct ui_out
*uiout
);
199 /* This is the default ui-out implementation functions vector. */
201 const struct ui_out_impl default_ui_out_impl
=
206 default_table_header
,
211 default_field_string
,
219 default_data_destroy
,
220 0, /* Does not need MI hacks. */
223 /* The default ui_out */
225 struct ui_out def_uiout
=
228 &default_ui_out_impl
, /* impl */
231 /* Pointer to current ui_out */
232 /* FIXME: This should not be a global, but something passed down from main.c
235 struct ui_out
*current_uiout
= &def_uiout
;
237 /* These are the interfaces to implementation functions. */
239 static void uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
240 int nr_rows
, const char *tblid
);
241 static void uo_table_body (struct ui_out
*uiout
);
242 static void uo_table_end (struct ui_out
*uiout
);
243 static void uo_table_header (struct ui_out
*uiout
, int width
,
244 enum ui_align align
, const char *col_name
,
246 static void uo_begin (struct ui_out
*uiout
,
247 enum ui_out_type type
,
248 int level
, const char *id
);
249 static void uo_end (struct ui_out
*uiout
,
250 enum ui_out_type type
,
252 static void uo_field_int (struct ui_out
*uiout
, int fldno
, int width
,
253 enum ui_align align
, const char *fldname
, int value
);
254 static void uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
255 enum ui_align align
, const char *fldname
);
256 static void uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
257 enum ui_align align
, const char *fldname
,
258 const char *format
, va_list args
)
259 ATTRIBUTE_PRINTF (6, 0);
260 static void uo_spaces (struct ui_out
*uiout
, int numspaces
);
261 static void uo_text (struct ui_out
*uiout
, const char *string
);
262 static void uo_message (struct ui_out
*uiout
, int verbosity
,
263 const char *format
, va_list args
)
264 ATTRIBUTE_PRINTF (3, 0);
265 static void uo_wrap_hint (struct ui_out
*uiout
, char *identstring
);
266 static void uo_flush (struct ui_out
*uiout
);
267 static int uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
);
268 static void uo_data_destroy (struct ui_out
*uiout
);
270 /* Prototypes for local functions */
272 extern void _initialize_ui_out (void);
273 static void append_header_to_list (struct ui_out
*uiout
, int width
,
274 int alignment
, const char *col_name
,
276 static int get_next_header (struct ui_out
*uiout
, int *colno
, int *width
,
277 int *alignment
, char **colhdr
);
278 static void clear_header_list (struct ui_out
*uiout
);
279 static void clear_table (struct ui_out
*uiout
);
280 static void verify_field (struct ui_out
*uiout
, int *fldno
, int *width
,
283 /* exported functions (ui_out API) */
285 /* Mark beginning of a table. */
288 ui_out_table_begin (struct ui_out
*uiout
, int nbrofcols
,
292 if (uiout
->table
.flag
)
293 internal_error (__FILE__
, __LINE__
,
294 _("tables cannot be nested; table_begin found before \
295 previous table_end."));
297 uiout
->table
.flag
= 1;
298 uiout
->table
.body_flag
= 0;
299 uiout
->table
.entry_level
= uiout
->level
+ 1;
300 uiout
->table
.columns
= nbrofcols
;
302 uiout
->table
.id
= xstrdup (tblid
);
304 uiout
->table
.id
= NULL
;
305 clear_header_list (uiout
);
307 uo_table_begin (uiout
, nbrofcols
, nr_rows
, uiout
->table
.id
);
311 ui_out_table_body (struct ui_out
*uiout
)
313 if (!uiout
->table
.flag
)
314 internal_error (__FILE__
, __LINE__
,
315 _("table_body outside a table is not valid; it must be \
316 after a table_begin and before a table_end."));
317 if (uiout
->table
.body_flag
)
318 internal_error (__FILE__
, __LINE__
,
319 _("extra table_body call not allowed; there must be \
320 only one table_body after a table_begin and before a table_end."));
321 if (uiout
->table
.header_next
->colno
!= uiout
->table
.columns
)
322 internal_error (__FILE__
, __LINE__
,
323 _("number of headers differ from number of table \
326 uiout
->table
.body_flag
= 1;
327 uiout
->table
.header_next
= uiout
->table
.header_first
;
329 uo_table_body (uiout
);
333 ui_out_table_end (struct ui_out
*uiout
)
335 if (!uiout
->table
.flag
)
336 internal_error (__FILE__
, __LINE__
,
337 _("misplaced table_end or missing table_begin."));
339 uiout
->table
.entry_level
= 0;
340 uiout
->table
.body_flag
= 0;
341 uiout
->table
.flag
= 0;
343 uo_table_end (uiout
);
348 ui_out_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
349 const char *col_name
,
352 if (!uiout
->table
.flag
|| uiout
->table
.body_flag
)
353 internal_error (__FILE__
, __LINE__
,
354 _("table header must be specified after table_begin \
355 and before table_body."));
357 append_header_to_list (uiout
, width
, alignment
, col_name
, colhdr
);
359 uo_table_header (uiout
, width
, alignment
, col_name
, colhdr
);
363 do_cleanup_table_end (void *data
)
365 struct ui_out
*ui_out
= data
;
367 ui_out_table_end (ui_out
);
371 make_cleanup_ui_out_table_begin_end (struct ui_out
*ui_out
, int nr_cols
,
372 int nr_rows
, const char *tblid
)
374 ui_out_table_begin (ui_out
, nr_cols
, nr_rows
, tblid
);
375 return make_cleanup (do_cleanup_table_end
, ui_out
);
379 ui_out_begin (struct ui_out
*uiout
,
380 enum ui_out_type type
,
385 if (uiout
->table
.flag
&& !uiout
->table
.body_flag
)
386 internal_error (__FILE__
, __LINE__
,
387 _("table header or table_body expected; lists must be \
388 specified after table_body."));
390 /* Be careful to verify the ``field'' before the new tuple/list is
391 pushed onto the stack. That way the containing list/table/row is
392 verified and not the newly created tuple/list. This verification
393 is needed (at least) for the case where a table row entry
394 contains either a tuple/list. For that case bookkeeping such as
395 updating the column count or advancing to the next heading still
396 needs to be performed. */
402 verify_field (uiout
, &fldno
, &width
, &align
);
405 new_level
= push_level (uiout
, type
, id
);
407 /* If the push puts us at the same level as a table row entry, we've
408 got a new table row. Put the header pointer back to the start. */
409 if (uiout
->table
.body_flag
410 && uiout
->table
.entry_level
== new_level
)
411 uiout
->table
.header_next
= uiout
->table
.header_first
;
413 uo_begin (uiout
, type
, new_level
, id
);
417 ui_out_end (struct ui_out
*uiout
,
418 enum ui_out_type type
)
420 int old_level
= pop_level (uiout
, type
);
422 uo_end (uiout
, type
, old_level
);
425 struct ui_out_end_cleanup_data
427 struct ui_out
*uiout
;
428 enum ui_out_type type
;
432 do_cleanup_end (void *data
)
434 struct ui_out_end_cleanup_data
*end_cleanup_data
= data
;
436 ui_out_end (end_cleanup_data
->uiout
, end_cleanup_data
->type
);
437 xfree (end_cleanup_data
);
440 static struct cleanup
*
441 make_cleanup_ui_out_end (struct ui_out
*uiout
,
442 enum ui_out_type type
)
444 struct ui_out_end_cleanup_data
*end_cleanup_data
;
446 end_cleanup_data
= XNEW (struct ui_out_end_cleanup_data
);
447 end_cleanup_data
->uiout
= uiout
;
448 end_cleanup_data
->type
= type
;
449 return make_cleanup (do_cleanup_end
, end_cleanup_data
);
453 make_cleanup_ui_out_tuple_begin_end (struct ui_out
*uiout
,
456 ui_out_begin (uiout
, ui_out_type_tuple
, id
);
457 return make_cleanup_ui_out_end (uiout
, ui_out_type_tuple
);
461 make_cleanup_ui_out_list_begin_end (struct ui_out
*uiout
,
464 ui_out_begin (uiout
, ui_out_type_list
, id
);
465 return make_cleanup_ui_out_end (uiout
, ui_out_type_list
);
469 ui_out_field_int (struct ui_out
*uiout
,
477 verify_field (uiout
, &fldno
, &width
, &align
);
479 uo_field_int (uiout
, fldno
, width
, align
, fldname
, value
);
483 ui_out_field_fmt_int (struct ui_out
*uiout
,
485 enum ui_align input_align
,
493 verify_field (uiout
, &fldno
, &width
, &align
);
495 uo_field_int (uiout
, fldno
, input_width
, input_align
, fldname
, value
);
498 /* Documented in ui-out.h. */
501 ui_out_field_core_addr (struct ui_out
*uiout
,
503 struct gdbarch
*gdbarch
,
506 ui_out_field_string (uiout
, fldname
,
507 print_core_address (gdbarch
, address
));
511 ui_out_field_stream (struct ui_out
*uiout
,
513 struct ui_file
*stream
)
516 char *buffer
= ui_file_xstrdup (stream
, &length
);
517 struct cleanup
*old_cleanup
= make_cleanup (xfree
, buffer
);
520 ui_out_field_string (uiout
, fldname
, buffer
);
522 ui_out_field_skip (uiout
, fldname
);
523 ui_file_rewind (stream
);
524 do_cleanups (old_cleanup
);
527 /* Used to omit a field. */
530 ui_out_field_skip (struct ui_out
*uiout
,
537 verify_field (uiout
, &fldno
, &width
, &align
);
539 uo_field_skip (uiout
, fldno
, width
, align
, fldname
);
543 ui_out_field_string (struct ui_out
*uiout
,
551 verify_field (uiout
, &fldno
, &width
, &align
);
553 uo_field_string (uiout
, fldno
, width
, align
, fldname
, string
);
558 ui_out_field_fmt (struct ui_out
*uiout
,
560 const char *format
, ...)
567 /* Will not align, but has to call anyway. */
568 verify_field (uiout
, &fldno
, &width
, &align
);
570 va_start (args
, format
);
572 uo_field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
578 ui_out_spaces (struct ui_out
*uiout
, int numspaces
)
580 uo_spaces (uiout
, numspaces
);
584 ui_out_text (struct ui_out
*uiout
,
587 uo_text (uiout
, string
);
591 ui_out_message (struct ui_out
*uiout
, int verbosity
,
592 const char *format
,...)
596 va_start (args
, format
);
597 uo_message (uiout
, verbosity
, format
, args
);
602 ui_out_wrap_hint (struct ui_out
*uiout
, char *identstring
)
604 uo_wrap_hint (uiout
, identstring
);
608 ui_out_flush (struct ui_out
*uiout
)
614 ui_out_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
616 return uo_redirect (uiout
, outstream
);
619 /* Set the flags specified by the mask given. */
621 ui_out_set_flags (struct ui_out
*uiout
, int mask
)
623 int oldflags
= uiout
->flags
;
625 uiout
->flags
|= mask
;
629 /* Clear the flags specified by the mask given. */
631 ui_out_clear_flags (struct ui_out
*uiout
, int mask
)
633 int oldflags
= uiout
->flags
;
635 uiout
->flags
&= ~mask
;
639 /* Test the flags against the mask given. */
641 ui_out_test_flags (struct ui_out
*uiout
, int mask
)
643 return (uiout
->flags
& mask
);
646 /* Obtain the current verbosity level (as stablished by the
647 'set verbositylevel' command. */
650 ui_out_get_verblvl (struct ui_out
*uiout
)
652 /* FIXME: not implemented yet. */
657 ui_out_is_mi_like_p (struct ui_out
*uiout
)
659 return uiout
->impl
->is_mi_like_p
;
662 /* Default gdb-out hook functions. */
665 default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
672 default_table_body (struct ui_out
*uiout
)
677 default_table_end (struct ui_out
*uiout
)
682 default_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
683 const char *col_name
,
689 default_begin (struct ui_out
*uiout
,
690 enum ui_out_type type
,
697 default_end (struct ui_out
*uiout
,
698 enum ui_out_type type
,
704 default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
706 const char *fldname
, int value
)
711 default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
712 enum ui_align align
, const char *fldname
)
717 default_field_string (struct ui_out
*uiout
,
727 default_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
736 default_spaces (struct ui_out
*uiout
, int numspaces
)
741 default_text (struct ui_out
*uiout
, const char *string
)
746 default_message (struct ui_out
*uiout
, int verbosity
,
753 default_wrap_hint (struct ui_out
*uiout
, char *identstring
)
758 default_flush (struct ui_out
*uiout
)
763 default_data_destroy (struct ui_out
*uiout
)
767 /* Interface to the implementation functions. */
770 uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
774 if (!uiout
->impl
->table_begin
)
776 uiout
->impl
->table_begin (uiout
, nbrofcols
, nr_rows
, tblid
);
780 uo_table_body (struct ui_out
*uiout
)
782 if (!uiout
->impl
->table_body
)
784 uiout
->impl
->table_body (uiout
);
788 uo_table_end (struct ui_out
*uiout
)
790 if (!uiout
->impl
->table_end
)
792 uiout
->impl
->table_end (uiout
);
796 uo_table_header (struct ui_out
*uiout
, int width
, enum ui_align align
,
797 const char *col_name
,
800 if (!uiout
->impl
->table_header
)
802 uiout
->impl
->table_header (uiout
, width
, align
, col_name
, colhdr
);
805 /* Clear the table associated with UIOUT. */
808 clear_table (struct ui_out
*uiout
)
811 xfree (uiout
->table
.id
);
812 clear_header_list (uiout
);
816 uo_begin (struct ui_out
*uiout
,
817 enum ui_out_type type
,
821 if (uiout
->impl
->begin
== NULL
)
823 uiout
->impl
->begin (uiout
, type
, level
, id
);
827 uo_end (struct ui_out
*uiout
,
828 enum ui_out_type type
,
831 if (uiout
->impl
->end
== NULL
)
833 uiout
->impl
->end (uiout
, type
, level
);
837 uo_field_int (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
841 if (!uiout
->impl
->field_int
)
843 uiout
->impl
->field_int (uiout
, fldno
, width
, align
, fldname
, value
);
847 uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
850 if (!uiout
->impl
->field_skip
)
852 uiout
->impl
->field_skip (uiout
, fldno
, width
, align
, fldname
);
856 uo_field_string (struct ui_out
*uiout
, int fldno
, int width
,
861 if (!uiout
->impl
->field_string
)
863 uiout
->impl
->field_string (uiout
, fldno
, width
, align
, fldname
, string
);
867 uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
872 if (!uiout
->impl
->field_fmt
)
874 uiout
->impl
->field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
878 uo_spaces (struct ui_out
*uiout
, int numspaces
)
880 if (!uiout
->impl
->spaces
)
882 uiout
->impl
->spaces (uiout
, numspaces
);
886 uo_text (struct ui_out
*uiout
,
889 if (!uiout
->impl
->text
)
891 uiout
->impl
->text (uiout
, string
);
895 uo_message (struct ui_out
*uiout
, int verbosity
,
899 if (!uiout
->impl
->message
)
901 uiout
->impl
->message (uiout
, verbosity
, format
, args
);
905 uo_wrap_hint (struct ui_out
*uiout
, char *identstring
)
907 if (!uiout
->impl
->wrap_hint
)
909 uiout
->impl
->wrap_hint (uiout
, identstring
);
913 uo_flush (struct ui_out
*uiout
)
915 if (!uiout
->impl
->flush
)
917 uiout
->impl
->flush (uiout
);
921 uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
923 if (!uiout
->impl
->redirect
)
925 uiout
->impl
->redirect (uiout
, outstream
);
930 uo_data_destroy (struct ui_out
*uiout
)
932 if (!uiout
->impl
->data_destroy
)
935 uiout
->impl
->data_destroy (uiout
);
938 /* local functions */
940 /* List of column headers manipulation routines. */
943 clear_header_list (struct ui_out
*uiout
)
945 while (uiout
->table
.header_first
!= NULL
)
947 uiout
->table
.header_next
= uiout
->table
.header_first
;
948 uiout
->table
.header_first
= uiout
->table
.header_first
->next
;
949 xfree (uiout
->table
.header_next
->colhdr
);
950 xfree (uiout
->table
.header_next
->col_name
);
951 xfree (uiout
->table
.header_next
);
953 gdb_assert (uiout
->table
.header_first
== NULL
);
954 uiout
->table
.header_last
= NULL
;
955 uiout
->table
.header_next
= NULL
;
959 append_header_to_list (struct ui_out
*uiout
,
962 const char *col_name
,
965 struct ui_out_hdr
*temphdr
;
967 temphdr
= XNEW (struct ui_out_hdr
);
968 temphdr
->width
= width
;
969 temphdr
->alignment
= alignment
;
970 /* We have to copy the column title as the original may be an
973 temphdr
->colhdr
= xstrdup (colhdr
);
975 temphdr
->colhdr
= NULL
;
977 if (col_name
!= NULL
)
978 temphdr
->col_name
= xstrdup (col_name
);
979 else if (colhdr
!= NULL
)
980 temphdr
->col_name
= xstrdup (colhdr
);
982 temphdr
->col_name
= NULL
;
984 temphdr
->next
= NULL
;
985 if (uiout
->table
.header_first
== NULL
)
988 uiout
->table
.header_first
= temphdr
;
989 uiout
->table
.header_last
= temphdr
;
993 temphdr
->colno
= uiout
->table
.header_last
->colno
+ 1;
994 uiout
->table
.header_last
->next
= temphdr
;
995 uiout
->table
.header_last
= temphdr
;
997 uiout
->table
.header_next
= uiout
->table
.header_last
;
1000 /* Extract the format information for the NEXT header and advance
1001 the header pointer. Return 0 if there was no next header. */
1004 get_next_header (struct ui_out
*uiout
,
1010 /* There may be no headers at all or we may have used all columns. */
1011 if (uiout
->table
.header_next
== NULL
)
1013 *colno
= uiout
->table
.header_next
->colno
;
1014 *width
= uiout
->table
.header_next
->width
;
1015 *alignment
= uiout
->table
.header_next
->alignment
;
1016 *colhdr
= uiout
->table
.header_next
->colhdr
;
1017 /* Advance the header pointer to the next entry. */
1018 uiout
->table
.header_next
= uiout
->table
.header_next
->next
;
1023 /* Verify that the field/tuple/list is correctly positioned. Return
1024 the field number and corresponding alignment (if
1025 available/applicable). */
1028 verify_field (struct ui_out
*uiout
, int *fldno
, int *width
, int *align
)
1030 struct ui_out_level
*current
= current_level (uiout
);
1033 if (uiout
->table
.flag
)
1035 if (!uiout
->table
.body_flag
)
1036 internal_error (__FILE__
, __LINE__
,
1037 _("table_body missing; table fields must be \
1038 specified after table_body and inside a list."));
1039 /* NOTE: cagney/2001-12-08: There was a check here to ensure
1040 that this code was only executed when uiout->level was
1041 greater than zero. That no longer applies - this code is run
1042 before each table row tuple is started and at that point the
1046 current
->field_count
+= 1;
1048 if (uiout
->table
.body_flag
1049 && uiout
->table
.entry_level
== uiout
->level
1050 && get_next_header (uiout
, fldno
, width
, align
, &text
))
1052 if (*fldno
!= current
->field_count
)
1053 internal_error (__FILE__
, __LINE__
,
1054 _("ui-out internal error in handling headers."));
1059 *align
= ui_noalign
;
1060 *fldno
= current
->field_count
;
1065 /* Access to ui-out members data. */
1068 ui_out_data (struct ui_out
*uiout
)
1073 /* Access table field parameters. */
1075 ui_out_query_field (struct ui_out
*uiout
, int colno
,
1076 int *width
, int *alignment
, char **col_name
)
1078 struct ui_out_hdr
*hdr
;
1080 if (!uiout
->table
.flag
)
1083 for (hdr
= uiout
->table
.header_first
; hdr
; hdr
= hdr
->next
)
1084 if (hdr
->colno
== colno
)
1086 *width
= hdr
->width
;
1087 *alignment
= hdr
->alignment
;
1088 *col_name
= hdr
->col_name
;
1095 /* Initalize private members at startup. */
1098 ui_out_new (const struct ui_out_impl
*impl
, void *data
,
1101 struct ui_out
*uiout
= XNEW (struct ui_out
);
1102 struct ui_out_level
*current
= XNEW (struct ui_out_level
);
1106 uiout
->flags
= flags
;
1107 uiout
->table
.flag
= 0;
1108 uiout
->table
.body_flag
= 0;
1110 uiout
->levels
= NULL
;
1112 /* Create uiout->level 0, the default level. */
1113 current
->type
= ui_out_type_tuple
;
1114 current
->field_count
= 0;
1115 VEC_safe_push (ui_out_level_p
, uiout
->levels
, current
);
1117 uiout
->table
.header_first
= NULL
;
1118 uiout
->table
.header_last
= NULL
;
1119 uiout
->table
.header_next
= NULL
;
1123 /* Free UIOUT and the memory areas it references. */
1126 ui_out_destroy (struct ui_out
*uiout
)
1129 struct ui_out_level
*current
;
1131 /* Make sure that all levels are freed in the case where levels have
1132 been pushed, but not popped before the ui_out object is
1135 VEC_iterate (ui_out_level_p
, uiout
->levels
, i
, current
);
1139 VEC_free (ui_out_level_p
, uiout
->levels
);
1140 uo_data_destroy (uiout
);
1141 clear_table (uiout
);
1145 /* Standard gdb initialization hook. */
1148 _initialize_ui_out (void)
1150 /* nothing needs to be done */