1 /* Output generating routines for GDB.
3 Copyright (C) 1999-2016 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/>. */
24 #include "expression.h" /* For language.h */
28 /* table header structures */
34 enum ui_align alignment
;
37 struct ui_out_hdr
*next
;
40 /* Maintain a stack so that the info applicable to the inner most list
41 is always available. Stack/nested level 0 is reserved for the
44 enum { MAX_UI_OUT_LEVELS
= 8 };
48 /* Count each field; the first element is for non-list fields. */
50 /* The type of this level. */
51 enum ui_out_type type
;
54 /* Define uiout->level vector types and operations. */
55 typedef struct ui_out_level
*ui_out_level_p
;
56 DEF_VEC_P (ui_out_level_p
);
58 /* Tables are special. Maintain a separate structure that tracks
59 their state. At present an output can only contain a single table
60 but that restriction might eventually be lifted. */
64 /* If on, a table is being generated. */
67 /* If on, the body of a table is being generated. If off, the table
68 header is being generated. */
71 /* The level at which each entry of the table is to be found. A row
72 (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
73 above that of the table. */
76 /* Number of table columns (as specified in the table_begin call). */
79 /* String identifying the table (as specified in the table_begin
83 /* Points to the first table header (if any). */
84 struct ui_out_hdr
*header_first
;
86 /* Points to the last table header (if any). */
87 struct ui_out_hdr
*header_last
;
89 /* Points to header of NEXT column to format. */
90 struct ui_out_hdr
*header_next
;
95 /* The ui_out structure */
96 /* Any change here requires a corresponding one in the initialization
97 of the default uiout, which is statically initialized. */
102 /* Specific implementation of ui-out. */
103 const struct ui_out_impl
*impl
;
109 /* Vector to store and track the ui-out levels. */
110 VEC (ui_out_level_p
) *levels
;
112 /* A table, if any. At present only a single table is supported. */
113 struct ui_out_table table
;
116 /* The current (inner most) level. */
117 static struct ui_out_level
*
118 current_level (struct ui_out
*uiout
)
120 return VEC_index (ui_out_level_p
, uiout
->levels
, uiout
->level
);
123 /* Create a new level, of TYPE. Return the new level's index. */
125 push_level (struct ui_out
*uiout
,
126 enum ui_out_type type
,
129 struct ui_out_level
*current
;
132 current
= XNEW (struct ui_out_level
);
133 current
->field_count
= 0;
134 current
->type
= type
;
135 VEC_safe_push (ui_out_level_p
, uiout
->levels
, current
);
139 /* Discard the current level, return the discarded level's index.
140 TYPE is the type of the level being discarded. */
142 pop_level (struct ui_out
*uiout
,
143 enum ui_out_type type
)
145 struct ui_out_level
*current
;
147 /* We had better not underflow the buffer. */
148 gdb_assert (uiout
->level
> 0);
149 gdb_assert (current_level (uiout
)->type
== type
);
150 current
= VEC_pop (ui_out_level_p
, uiout
->levels
);
153 return uiout
->level
+ 1;
157 /* These are the default implementation functions. */
159 static void default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
160 int nr_rows
, const char *tblid
);
161 static void default_table_body (struct ui_out
*uiout
);
162 static void default_table_end (struct ui_out
*uiout
);
163 static void default_table_header (struct ui_out
*uiout
, int width
,
164 enum ui_align alig
, const char *col_name
,
166 static void default_begin (struct ui_out
*uiout
,
167 enum ui_out_type type
,
168 int level
, const char *id
);
169 static void default_end (struct ui_out
*uiout
,
170 enum ui_out_type type
,
172 static void default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
176 static void default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
178 const char *fldname
);
179 static void default_field_string (struct ui_out
*uiout
, int fldno
, int width
,
183 static void default_field_fmt (struct ui_out
*uiout
, int fldno
,
184 int width
, enum ui_align align
,
187 va_list args
) ATTRIBUTE_PRINTF (6, 0);
188 static void default_spaces (struct ui_out
*uiout
, int numspaces
);
189 static void default_text (struct ui_out
*uiout
, const char *string
);
190 static void default_message (struct ui_out
*uiout
, int verbosity
,
192 va_list args
) ATTRIBUTE_PRINTF (3, 0);
193 static void default_wrap_hint (struct ui_out
*uiout
, char *identstring
);
194 static void default_flush (struct ui_out
*uiout
);
195 static void default_data_destroy (struct ui_out
*uiout
);
197 /* This is the default ui-out implementation functions vector. */
199 const struct ui_out_impl default_ui_out_impl
=
204 default_table_header
,
209 default_field_string
,
217 default_data_destroy
,
218 0, /* Does not need MI hacks. */
221 /* The default ui_out */
223 struct ui_out def_uiout
=
226 &default_ui_out_impl
, /* impl */
229 /* Pointer to current ui_out */
230 /* FIXME: This should not be a global, but something passed down from main.c
233 struct ui_out
*current_uiout
= &def_uiout
;
235 /* These are the interfaces to implementation functions. */
237 static void uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
238 int nr_rows
, const char *tblid
);
239 static void uo_table_body (struct ui_out
*uiout
);
240 static void uo_table_end (struct ui_out
*uiout
);
241 static void uo_table_header (struct ui_out
*uiout
, int width
,
242 enum ui_align align
, const char *col_name
,
244 static void uo_begin (struct ui_out
*uiout
,
245 enum ui_out_type type
,
246 int level
, const char *id
);
247 static void uo_end (struct ui_out
*uiout
,
248 enum ui_out_type type
,
250 static void uo_field_int (struct ui_out
*uiout
, int fldno
, int width
,
251 enum ui_align align
, const char *fldname
, int value
);
252 static void uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
253 enum ui_align align
, const char *fldname
);
254 static void uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
255 enum ui_align align
, const char *fldname
,
256 const char *format
, va_list args
)
257 ATTRIBUTE_PRINTF (6, 0);
258 static void uo_spaces (struct ui_out
*uiout
, int numspaces
);
259 static void uo_text (struct ui_out
*uiout
, const char *string
);
260 static void uo_message (struct ui_out
*uiout
, int verbosity
,
261 const char *format
, va_list args
)
262 ATTRIBUTE_PRINTF (3, 0);
263 static void uo_wrap_hint (struct ui_out
*uiout
, char *identstring
);
264 static void uo_flush (struct ui_out
*uiout
);
265 static int uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
);
266 static void uo_data_destroy (struct ui_out
*uiout
);
268 /* Prototypes for local functions */
270 extern void _initialize_ui_out (void);
271 static void append_header_to_list (struct ui_out
*uiout
, int width
,
272 enum ui_align alignment
, const char *col_name
,
274 static int get_next_header (struct ui_out
*uiout
, int *colno
, int *width
,
275 enum ui_align
*alignment
, char **colhdr
);
276 static void clear_header_list (struct ui_out
*uiout
);
277 static void clear_table (struct ui_out
*uiout
);
278 static void verify_field (struct ui_out
*uiout
, int *fldno
, int *width
,
279 enum ui_align
*align
);
281 /* exported functions (ui_out API) */
283 /* Mark beginning of a table. */
286 ui_out_table_begin (struct ui_out
*uiout
, int nbrofcols
,
290 if (uiout
->table
.flag
)
291 internal_error (__FILE__
, __LINE__
,
292 _("tables cannot be nested; table_begin found before \
293 previous table_end."));
295 uiout
->table
.flag
= 1;
296 uiout
->table
.body_flag
= 0;
297 uiout
->table
.entry_level
= uiout
->level
+ 1;
298 uiout
->table
.columns
= nbrofcols
;
300 uiout
->table
.id
= xstrdup (tblid
);
302 uiout
->table
.id
= NULL
;
303 clear_header_list (uiout
);
305 uo_table_begin (uiout
, nbrofcols
, nr_rows
, uiout
->table
.id
);
309 ui_out_table_body (struct ui_out
*uiout
)
311 if (!uiout
->table
.flag
)
312 internal_error (__FILE__
, __LINE__
,
313 _("table_body outside a table is not valid; it must be \
314 after a table_begin and before a table_end."));
315 if (uiout
->table
.body_flag
)
316 internal_error (__FILE__
, __LINE__
,
317 _("extra table_body call not allowed; there must be \
318 only one table_body after a table_begin and before a table_end."));
319 if (uiout
->table
.header_next
->colno
!= uiout
->table
.columns
)
320 internal_error (__FILE__
, __LINE__
,
321 _("number of headers differ from number of table \
324 uiout
->table
.body_flag
= 1;
325 uiout
->table
.header_next
= uiout
->table
.header_first
;
327 uo_table_body (uiout
);
331 ui_out_table_end (struct ui_out
*uiout
)
333 if (!uiout
->table
.flag
)
334 internal_error (__FILE__
, __LINE__
,
335 _("misplaced table_end or missing table_begin."));
337 uiout
->table
.entry_level
= 0;
338 uiout
->table
.body_flag
= 0;
339 uiout
->table
.flag
= 0;
341 uo_table_end (uiout
);
346 ui_out_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
347 const char *col_name
,
350 if (!uiout
->table
.flag
|| uiout
->table
.body_flag
)
351 internal_error (__FILE__
, __LINE__
,
352 _("table header must be specified after table_begin \
353 and before table_body."));
355 append_header_to_list (uiout
, width
, alignment
, col_name
, colhdr
);
357 uo_table_header (uiout
, width
, alignment
, col_name
, colhdr
);
361 do_cleanup_table_end (void *data
)
363 struct ui_out
*ui_out
= (struct ui_out
*) data
;
365 ui_out_table_end (ui_out
);
369 make_cleanup_ui_out_table_begin_end (struct ui_out
*ui_out
, int nr_cols
,
370 int nr_rows
, const char *tblid
)
372 ui_out_table_begin (ui_out
, nr_cols
, nr_rows
, tblid
);
373 return make_cleanup (do_cleanup_table_end
, ui_out
);
377 ui_out_begin (struct ui_out
*uiout
,
378 enum ui_out_type type
,
383 if (uiout
->table
.flag
&& !uiout
->table
.body_flag
)
384 internal_error (__FILE__
, __LINE__
,
385 _("table header or table_body expected; lists must be \
386 specified after table_body."));
388 /* Be careful to verify the ``field'' before the new tuple/list is
389 pushed onto the stack. That way the containing list/table/row is
390 verified and not the newly created tuple/list. This verification
391 is needed (at least) for the case where a table row entry
392 contains either a tuple/list. For that case bookkeeping such as
393 updating the column count or advancing to the next heading still
394 needs to be performed. */
400 verify_field (uiout
, &fldno
, &width
, &align
);
403 new_level
= push_level (uiout
, type
, id
);
405 /* If the push puts us at the same level as a table row entry, we've
406 got a new table row. Put the header pointer back to the start. */
407 if (uiout
->table
.body_flag
408 && uiout
->table
.entry_level
== new_level
)
409 uiout
->table
.header_next
= uiout
->table
.header_first
;
411 uo_begin (uiout
, type
, new_level
, id
);
415 ui_out_end (struct ui_out
*uiout
,
416 enum ui_out_type type
)
418 int old_level
= pop_level (uiout
, type
);
420 uo_end (uiout
, type
, old_level
);
423 struct ui_out_end_cleanup_data
425 struct ui_out
*uiout
;
426 enum ui_out_type type
;
430 do_cleanup_end (void *data
)
432 struct ui_out_end_cleanup_data
*end_cleanup_data
433 = (struct ui_out_end_cleanup_data
*) data
;
435 ui_out_end (end_cleanup_data
->uiout
, end_cleanup_data
->type
);
436 xfree (end_cleanup_data
);
439 static struct cleanup
*
440 make_cleanup_ui_out_end (struct ui_out
*uiout
,
441 enum ui_out_type type
)
443 struct ui_out_end_cleanup_data
*end_cleanup_data
;
445 end_cleanup_data
= XNEW (struct ui_out_end_cleanup_data
);
446 end_cleanup_data
->uiout
= uiout
;
447 end_cleanup_data
->type
= type
;
448 return make_cleanup (do_cleanup_end
, end_cleanup_data
);
452 make_cleanup_ui_out_tuple_begin_end (struct ui_out
*uiout
,
455 ui_out_begin (uiout
, ui_out_type_tuple
, id
);
456 return make_cleanup_ui_out_end (uiout
, ui_out_type_tuple
);
460 make_cleanup_ui_out_list_begin_end (struct ui_out
*uiout
,
463 ui_out_begin (uiout
, ui_out_type_list
, id
);
464 return make_cleanup_ui_out_end (uiout
, ui_out_type_list
);
468 ui_out_field_int (struct ui_out
*uiout
,
476 verify_field (uiout
, &fldno
, &width
, &align
);
478 uo_field_int (uiout
, fldno
, width
, align
, fldname
, value
);
482 ui_out_field_fmt_int (struct ui_out
*uiout
,
484 enum ui_align input_align
,
492 verify_field (uiout
, &fldno
, &width
, &align
);
494 uo_field_int (uiout
, fldno
, input_width
, input_align
, fldname
, value
);
497 /* Documented in ui-out.h. */
500 ui_out_field_core_addr (struct ui_out
*uiout
,
502 struct gdbarch
*gdbarch
,
505 ui_out_field_string (uiout
, fldname
,
506 print_core_address (gdbarch
, address
));
510 ui_out_field_stream (struct ui_out
*uiout
,
512 struct ui_file
*stream
)
515 char *buffer
= ui_file_xstrdup (stream
, &length
);
516 struct cleanup
*old_cleanup
= make_cleanup (xfree
, buffer
);
519 ui_out_field_string (uiout
, fldname
, buffer
);
521 ui_out_field_skip (uiout
, fldname
);
522 ui_file_rewind (stream
);
523 do_cleanups (old_cleanup
);
526 /* Used to omit a field. */
529 ui_out_field_skip (struct ui_out
*uiout
,
536 verify_field (uiout
, &fldno
, &width
, &align
);
538 uo_field_skip (uiout
, fldno
, width
, align
, fldname
);
542 ui_out_field_string (struct ui_out
*uiout
,
550 verify_field (uiout
, &fldno
, &width
, &align
);
552 uo_field_string (uiout
, fldno
, width
, align
, fldname
, string
);
557 ui_out_field_fmt (struct ui_out
*uiout
,
559 const char *format
, ...)
566 /* Will not align, but has to call anyway. */
567 verify_field (uiout
, &fldno
, &width
, &align
);
569 va_start (args
, format
);
571 uo_field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
577 ui_out_spaces (struct ui_out
*uiout
, int numspaces
)
579 uo_spaces (uiout
, numspaces
);
583 ui_out_text (struct ui_out
*uiout
,
586 uo_text (uiout
, string
);
590 ui_out_message (struct ui_out
*uiout
, int verbosity
,
591 const char *format
,...)
595 va_start (args
, format
);
596 uo_message (uiout
, verbosity
, format
, args
);
601 ui_out_wrap_hint (struct ui_out
*uiout
, char *identstring
)
603 uo_wrap_hint (uiout
, identstring
);
607 ui_out_flush (struct ui_out
*uiout
)
613 ui_out_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
615 return uo_redirect (uiout
, outstream
);
618 /* Set the flags specified by the mask given. */
620 ui_out_set_flags (struct ui_out
*uiout
, int mask
)
622 int oldflags
= uiout
->flags
;
624 uiout
->flags
|= mask
;
628 /* Clear the flags specified by the mask given. */
630 ui_out_clear_flags (struct ui_out
*uiout
, int mask
)
632 int oldflags
= uiout
->flags
;
634 uiout
->flags
&= ~mask
;
638 /* Test the flags against the mask given. */
640 ui_out_test_flags (struct ui_out
*uiout
, int mask
)
642 return (uiout
->flags
& mask
);
645 /* Obtain the current verbosity level (as stablished by the
646 'set verbositylevel' command. */
649 ui_out_get_verblvl (struct ui_out
*uiout
)
651 /* FIXME: not implemented yet. */
656 ui_out_is_mi_like_p (struct ui_out
*uiout
)
658 return uiout
->impl
->is_mi_like_p
;
661 /* Default gdb-out hook functions. */
664 default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
671 default_table_body (struct ui_out
*uiout
)
676 default_table_end (struct ui_out
*uiout
)
681 default_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
682 const char *col_name
,
688 default_begin (struct ui_out
*uiout
,
689 enum ui_out_type type
,
696 default_end (struct ui_out
*uiout
,
697 enum ui_out_type type
,
703 default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
705 const char *fldname
, int value
)
710 default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
711 enum ui_align align
, const char *fldname
)
716 default_field_string (struct ui_out
*uiout
,
726 default_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
735 default_spaces (struct ui_out
*uiout
, int numspaces
)
740 default_text (struct ui_out
*uiout
, const char *string
)
745 default_message (struct ui_out
*uiout
, int verbosity
,
752 default_wrap_hint (struct ui_out
*uiout
, char *identstring
)
757 default_flush (struct ui_out
*uiout
)
762 default_data_destroy (struct ui_out
*uiout
)
766 /* Interface to the implementation functions. */
769 uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
773 if (!uiout
->impl
->table_begin
)
775 uiout
->impl
->table_begin (uiout
, nbrofcols
, nr_rows
, tblid
);
779 uo_table_body (struct ui_out
*uiout
)
781 if (!uiout
->impl
->table_body
)
783 uiout
->impl
->table_body (uiout
);
787 uo_table_end (struct ui_out
*uiout
)
789 if (!uiout
->impl
->table_end
)
791 uiout
->impl
->table_end (uiout
);
795 uo_table_header (struct ui_out
*uiout
, int width
, enum ui_align align
,
796 const char *col_name
,
799 if (!uiout
->impl
->table_header
)
801 uiout
->impl
->table_header (uiout
, width
, align
, col_name
, colhdr
);
804 /* Clear the table associated with UIOUT. */
807 clear_table (struct ui_out
*uiout
)
809 xfree (uiout
->table
.id
);
810 uiout
->table
.id
= NULL
;
811 clear_header_list (uiout
);
815 uo_begin (struct ui_out
*uiout
,
816 enum ui_out_type type
,
820 if (uiout
->impl
->begin
== NULL
)
822 uiout
->impl
->begin (uiout
, type
, level
, id
);
826 uo_end (struct ui_out
*uiout
,
827 enum ui_out_type type
,
830 if (uiout
->impl
->end
== NULL
)
832 uiout
->impl
->end (uiout
, type
, level
);
836 uo_field_int (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
840 if (!uiout
->impl
->field_int
)
842 uiout
->impl
->field_int (uiout
, fldno
, width
, align
, fldname
, value
);
846 uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
849 if (!uiout
->impl
->field_skip
)
851 uiout
->impl
->field_skip (uiout
, fldno
, width
, align
, fldname
);
855 uo_field_string (struct ui_out
*uiout
, int fldno
, int width
,
860 if (!uiout
->impl
->field_string
)
862 uiout
->impl
->field_string (uiout
, fldno
, width
, align
, fldname
, string
);
866 uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
871 if (!uiout
->impl
->field_fmt
)
873 uiout
->impl
->field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
877 uo_spaces (struct ui_out
*uiout
, int numspaces
)
879 if (!uiout
->impl
->spaces
)
881 uiout
->impl
->spaces (uiout
, numspaces
);
885 uo_text (struct ui_out
*uiout
,
888 if (!uiout
->impl
->text
)
890 uiout
->impl
->text (uiout
, string
);
894 uo_message (struct ui_out
*uiout
, int verbosity
,
898 if (!uiout
->impl
->message
)
900 uiout
->impl
->message (uiout
, verbosity
, format
, args
);
904 uo_wrap_hint (struct ui_out
*uiout
, char *identstring
)
906 if (!uiout
->impl
->wrap_hint
)
908 uiout
->impl
->wrap_hint (uiout
, identstring
);
912 uo_flush (struct ui_out
*uiout
)
914 if (!uiout
->impl
->flush
)
916 uiout
->impl
->flush (uiout
);
920 uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
922 if (!uiout
->impl
->redirect
)
924 uiout
->impl
->redirect (uiout
, outstream
);
929 uo_data_destroy (struct ui_out
*uiout
)
931 if (!uiout
->impl
->data_destroy
)
934 uiout
->impl
->data_destroy (uiout
);
937 /* local functions */
939 /* List of column headers manipulation routines. */
942 clear_header_list (struct ui_out
*uiout
)
944 while (uiout
->table
.header_first
!= NULL
)
946 uiout
->table
.header_next
= uiout
->table
.header_first
;
947 uiout
->table
.header_first
= uiout
->table
.header_first
->next
;
948 xfree (uiout
->table
.header_next
->colhdr
);
949 xfree (uiout
->table
.header_next
->col_name
);
950 xfree (uiout
->table
.header_next
);
952 gdb_assert (uiout
->table
.header_first
== NULL
);
953 uiout
->table
.header_last
= NULL
;
954 uiout
->table
.header_next
= NULL
;
958 append_header_to_list (struct ui_out
*uiout
,
960 enum ui_align alignment
,
961 const char *col_name
,
964 struct ui_out_hdr
*temphdr
;
966 temphdr
= XNEW (struct ui_out_hdr
);
967 temphdr
->width
= width
;
968 temphdr
->alignment
= alignment
;
969 /* We have to copy the column title as the original may be an
972 temphdr
->colhdr
= xstrdup (colhdr
);
974 temphdr
->colhdr
= NULL
;
976 if (col_name
!= NULL
)
977 temphdr
->col_name
= xstrdup (col_name
);
978 else if (colhdr
!= NULL
)
979 temphdr
->col_name
= xstrdup (colhdr
);
981 temphdr
->col_name
= NULL
;
983 temphdr
->next
= NULL
;
984 if (uiout
->table
.header_first
== NULL
)
987 uiout
->table
.header_first
= temphdr
;
988 uiout
->table
.header_last
= temphdr
;
992 temphdr
->colno
= uiout
->table
.header_last
->colno
+ 1;
993 uiout
->table
.header_last
->next
= temphdr
;
994 uiout
->table
.header_last
= temphdr
;
996 uiout
->table
.header_next
= uiout
->table
.header_last
;
999 /* Extract the format information for the NEXT header and advance
1000 the header pointer. Return 0 if there was no next header. */
1003 get_next_header (struct ui_out
*uiout
,
1006 enum ui_align
*alignment
,
1009 /* There may be no headers at all or we may have used all columns. */
1010 if (uiout
->table
.header_next
== NULL
)
1012 *colno
= uiout
->table
.header_next
->colno
;
1013 *width
= uiout
->table
.header_next
->width
;
1014 *alignment
= uiout
->table
.header_next
->alignment
;
1015 *colhdr
= uiout
->table
.header_next
->colhdr
;
1016 /* Advance the header pointer to the next entry. */
1017 uiout
->table
.header_next
= uiout
->table
.header_next
->next
;
1022 /* Verify that the field/tuple/list is correctly positioned. Return
1023 the field number and corresponding alignment (if
1024 available/applicable). */
1027 verify_field (struct ui_out
*uiout
, int *fldno
, int *width
,
1028 enum ui_align
*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
.id
= NULL
;
1118 uiout
->table
.header_first
= NULL
;
1119 uiout
->table
.header_last
= NULL
;
1120 uiout
->table
.header_next
= NULL
;
1124 /* Free UIOUT and the memory areas it references. */
1127 ui_out_destroy (struct ui_out
*uiout
)
1130 struct ui_out_level
*current
;
1132 /* Make sure that all levels are freed in the case where levels have
1133 been pushed, but not popped before the ui_out object is
1136 VEC_iterate (ui_out_level_p
, uiout
->levels
, i
, current
);
1140 VEC_free (ui_out_level_p
, uiout
->levels
);
1141 uo_data_destroy (uiout
);
1142 clear_table (uiout
);
1146 /* Standard gdb initialization hook. */
1149 _initialize_ui_out (void)
1151 /* nothing needs to be done */