1 /* Output generating routines for GDB.
3 Copyright 1999, 2000, 2001, 2002 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 2 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, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
26 #include "gdb_string.h"
27 #include "expression.h" /* For language.h */
30 #include "gdb_assert.h"
32 /* table header structures */
41 struct ui_out_hdr
*next
;
44 /* Maintain a stack so that the info applicable to the inner most list
45 is always available. Stack/nested level 0 is reserved for the
48 enum { MAX_UI_OUT_LEVELS
= 6 };
52 /* Count each field; the first element is for non-list fields */
54 /* The type of this level. */
55 enum ui_out_type type
;
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 struct ui_out_impl
*impl
;
104 struct ui_out_data
*data
;
106 /* Sub structure tracking the ui-out depth. */
108 struct ui_out_level levels
[MAX_UI_OUT_LEVELS
];
110 /* A table, if any. At present only a single table is supported. */
111 struct ui_out_table table
;
114 /* The current (inner most) level. */
115 static struct ui_out_level
*
116 current_level (struct ui_out
*uiout
)
118 return &uiout
->levels
[uiout
->level
];
121 /* Create a new level, of TYPE. Return the new level's index. */
123 push_level (struct ui_out
*uiout
,
124 enum ui_out_type type
,
127 struct ui_out_level
*current
;
128 /* We had better not overflow the buffer. */
130 gdb_assert (uiout
->level
>= 0 && uiout
->level
< MAX_UI_OUT_LEVELS
);
131 current
= current_level (uiout
);
132 current
->field_count
= 0;
133 current
->type
= type
;
137 /* Discard the current level, return the discarded level's index.
138 TYPE is the type of the level being discarded. */
140 pop_level (struct ui_out
*uiout
,
141 enum ui_out_type type
)
143 /* We had better not underflow the buffer. */
144 gdb_assert (uiout
->level
> 0 && uiout
->level
< MAX_UI_OUT_LEVELS
);
145 gdb_assert (current_level (uiout
)->type
== type
);
147 return uiout
->level
+ 1;
151 /* These are the default implementation functions */
153 static void default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
154 int nr_rows
, const char *tblid
);
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
,
158 enum ui_align alig
, const char *col_name
,
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
,
166 static void default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
170 static void default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
172 const char *fldname
);
173 static void default_field_string (struct ui_out
*uiout
, int fldno
, int width
,
177 static void default_field_fmt (struct ui_out
*uiout
, int fldno
,
178 int width
, enum ui_align align
,
182 static void default_spaces (struct ui_out
*uiout
, int numspaces
);
183 static void default_text (struct ui_out
*uiout
, const char *string
);
184 static void default_message (struct ui_out
*uiout
, int verbosity
,
187 static void default_wrap_hint (struct ui_out
*uiout
, char *identstring
);
188 static void default_flush (struct ui_out
*uiout
);
190 /* This is the default ui-out implementation functions vector */
192 struct ui_out_impl default_ui_out_impl
=
197 default_table_header
,
202 default_field_string
,
209 0, /* Does not need MI hacks. */
212 /* The default ui_out */
214 struct ui_out def_uiout
=
217 &default_ui_out_impl
, /* impl */
220 /* Pointer to current ui_out */
221 /* FIXME: This should not be a global, but something passed down from main.c
224 struct ui_out
*uiout
= &def_uiout
;
226 /* These are the interfaces to implementation functions */
228 static void uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
229 int nr_rows
, const char *tblid
);
230 static void uo_table_body (struct ui_out
*uiout
);
231 static void uo_table_end (struct ui_out
*uiout
);
232 static void uo_table_header (struct ui_out
*uiout
, int width
,
233 enum ui_align align
, const char *col_name
,
235 static void uo_begin (struct ui_out
*uiout
,
236 enum ui_out_type type
,
237 int level
, const char *id
);
238 static void uo_end (struct ui_out
*uiout
,
239 enum ui_out_type type
,
241 static void uo_field_int (struct ui_out
*uiout
, int fldno
, int width
,
242 enum ui_align align
, const char *fldname
, int value
);
243 static void uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
244 enum ui_align align
, const char *fldname
);
245 static void uo_field_string (struct ui_out
*uiout
, int fldno
, int width
,
246 enum ui_align align
, const char *fldname
,
248 static void uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
249 enum ui_align align
, const char *fldname
,
250 const char *format
, va_list args
);
251 static void uo_spaces (struct ui_out
*uiout
, int numspaces
);
252 static void uo_text (struct ui_out
*uiout
, const char *string
);
253 static void uo_message (struct ui_out
*uiout
, int verbosity
,
254 const char *format
, va_list args
);
255 static void uo_wrap_hint (struct ui_out
*uiout
, char *identstring
);
256 static void uo_flush (struct ui_out
*uiout
);
258 /* Prototypes for local functions */
260 extern void _initialize_ui_out (void);
261 static void append_header_to_list (struct ui_out
*uiout
, int width
,
262 int alignment
, const char *col_name
,
264 static int get_next_header (struct ui_out
*uiout
, int *colno
, int *width
,
265 int *alignment
, char **colhdr
);
266 static void clear_header_list (struct ui_out
*uiout
);
267 static void verify_field (struct ui_out
*uiout
, int *fldno
, int *width
,
270 static void init_ui_out_state (struct ui_out
*uiout
);
272 /* exported functions (ui_out API) */
274 /* Mark beginning of a table */
277 ui_out_table_begin (struct ui_out
*uiout
, int nbrofcols
,
281 if (uiout
->table
.flag
)
282 internal_error (__FILE__
, __LINE__
,
283 "tables cannot be nested; table_begin found before \
284 previous table_end.");
286 uiout
->table
.flag
= 1;
287 uiout
->table
.body_flag
= 0;
288 uiout
->table
.entry_level
= uiout
->level
+ 1;
289 uiout
->table
.columns
= nbrofcols
;
291 uiout
->table
.id
= xstrdup (tblid
);
293 uiout
->table
.id
= NULL
;
294 clear_header_list (uiout
);
296 uo_table_begin (uiout
, nbrofcols
, nr_rows
, uiout
->table
.id
);
300 ui_out_table_body (struct ui_out
*uiout
)
302 if (!uiout
->table
.flag
)
303 internal_error (__FILE__
, __LINE__
,
304 "table_body outside a table is not valid; it must be \
305 after a table_begin and before a table_end.");
306 if (uiout
->table
.body_flag
)
307 internal_error (__FILE__
, __LINE__
,
308 "extra table_body call not allowed; there must be \
309 only one table_body after a table_begin and before a table_end.");
310 if (uiout
->table
.header_next
->colno
!= uiout
->table
.columns
)
311 internal_error (__FILE__
, __LINE__
,
312 "number of headers differ from number of table \
315 uiout
->table
.body_flag
= 1;
316 uiout
->table
.header_next
= uiout
->table
.header_first
;
318 uo_table_body (uiout
);
322 ui_out_table_end (struct ui_out
*uiout
)
324 if (!uiout
->table
.flag
)
325 internal_error (__FILE__
, __LINE__
,
326 "misplaced table_end or missing table_begin.");
328 uiout
->table
.entry_level
= 0;
329 uiout
->table
.body_flag
= 0;
330 uiout
->table
.flag
= 0;
332 uo_table_end (uiout
);
335 xfree (uiout
->table
.id
);
336 clear_header_list (uiout
);
340 ui_out_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
341 const char *col_name
,
344 if (!uiout
->table
.flag
|| uiout
->table
.body_flag
)
345 internal_error (__FILE__
, __LINE__
,
346 "table header must be specified after table_begin \
347 and before table_body.");
349 append_header_to_list (uiout
, width
, alignment
, col_name
, colhdr
);
351 uo_table_header (uiout
, width
, alignment
, col_name
, colhdr
);
355 do_cleanup_table_end (void *data
)
357 struct ui_out
*ui_out
= data
;
359 ui_out_table_end (ui_out
);
363 make_cleanup_ui_out_table_begin_end (struct ui_out
*ui_out
, int nr_cols
,
364 int nr_rows
, const char *tblid
)
366 ui_out_table_begin (ui_out
, nr_cols
, nr_rows
, tblid
);
367 return make_cleanup (do_cleanup_table_end
, ui_out
);
371 ui_out_begin (struct ui_out
*uiout
,
372 enum ui_out_type type
,
376 if (uiout
->table
.flag
&& !uiout
->table
.body_flag
)
377 internal_error (__FILE__
, __LINE__
,
378 "table header or table_body expected; lists must be \
379 specified after table_body.");
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. */
392 verify_field (uiout
, &fldno
, &width
, &align
);
395 new_level
= push_level (uiout
, type
, id
);
397 /* If the push puts us at the same level as a table row entry, we've
398 got a new table row. Put the header pointer back to the start. */
399 if (uiout
->table
.body_flag
400 && uiout
->table
.entry_level
== new_level
)
401 uiout
->table
.header_next
= uiout
->table
.header_first
;
403 uo_begin (uiout
, type
, new_level
, id
);
407 ui_out_end (struct ui_out
*uiout
,
408 enum ui_out_type type
)
410 int old_level
= pop_level (uiout
, type
);
411 uo_end (uiout
, type
, old_level
);
414 struct ui_out_end_cleanup_data
416 struct ui_out
*uiout
;
417 enum ui_out_type type
;
421 do_cleanup_end (void *data
)
423 struct ui_out_end_cleanup_data
*end_cleanup_data
= data
;
424 ui_out_end (end_cleanup_data
->uiout
, end_cleanup_data
->type
);
425 xfree (end_cleanup_data
);
428 static struct cleanup
*
429 make_cleanup_ui_out_end (struct ui_out
*uiout
,
430 enum ui_out_type type
)
432 struct ui_out_end_cleanup_data
*end_cleanup_data
;
433 end_cleanup_data
= XMALLOC (struct ui_out_end_cleanup_data
);
434 end_cleanup_data
->uiout
= uiout
;
435 end_cleanup_data
->type
= type
;
436 return make_cleanup (do_cleanup_end
, end_cleanup_data
);
440 make_cleanup_ui_out_begin_end (struct ui_out
*uiout
,
441 enum ui_out_type type
,
444 ui_out_begin (uiout
, type
, id
);
445 return make_cleanup_ui_out_end (uiout
, type
);
449 make_cleanup_ui_out_tuple_begin_end (struct ui_out
*uiout
,
452 ui_out_begin (uiout
, ui_out_type_tuple
, id
);
453 return make_cleanup_ui_out_end (uiout
, ui_out_type_tuple
);
457 make_cleanup_ui_out_list_begin_end (struct ui_out
*uiout
,
460 ui_out_begin (uiout
, ui_out_type_list
, id
);
461 return make_cleanup_ui_out_end (uiout
, ui_out_type_list
);
465 ui_out_field_int (struct ui_out
*uiout
,
472 struct ui_out_level
*current
= current_level (uiout
);
474 verify_field (uiout
, &fldno
, &width
, &align
);
476 uo_field_int (uiout
, fldno
, width
, align
, fldname
, value
);
480 ui_out_field_fmt_int (struct ui_out
*uiout
,
482 enum ui_align input_align
,
489 struct ui_out_level
*current
= current_level (uiout
);
491 verify_field (uiout
, &fldno
, &width
, &align
);
493 uo_field_int (uiout
, fldno
, input_width
, input_align
, fldname
, value
);
497 ui_out_field_core_addr (struct ui_out
*uiout
,
503 /* FIXME: cagney/2002-05-03: Need local_address_string() function
504 that returns the language localized string formatted to a width
505 based on TARGET_ADDR_BIT. */
506 /* print_address_numeric (address, 1, local_stream); */
507 if (TARGET_ADDR_BIT
<= 32)
508 strcpy (addstr
, local_hex_string_custom (address
, "08l"));
510 strcpy (addstr
, local_hex_string_custom (address
, "016l"));
512 ui_out_field_string (uiout
, fldname
, addstr
);
516 ui_out_field_stream (struct ui_out
*uiout
,
518 struct ui_stream
*buf
)
521 char *buffer
= ui_file_xstrdup (buf
->stream
, &length
);
522 struct cleanup
*old_cleanup
= make_cleanup (xfree
, buffer
);
524 ui_out_field_string (uiout
, fldname
, buffer
);
526 ui_out_field_skip (uiout
, fldname
);
527 ui_file_rewind (buf
->stream
);
528 do_cleanups (old_cleanup
);
531 /* used to ommit a field */
534 ui_out_field_skip (struct ui_out
*uiout
,
541 verify_field (uiout
, &fldno
, &width
, &align
);
543 uo_field_skip (uiout
, fldno
, width
, align
, fldname
);
547 ui_out_field_string (struct ui_out
*uiout
,
555 verify_field (uiout
, &fldno
, &width
, &align
);
557 uo_field_string (uiout
, fldno
, width
, align
, fldname
, string
);
562 ui_out_field_fmt (struct ui_out
*uiout
,
564 const char *format
, ...)
571 /* will not align, but has to call anyway */
572 verify_field (uiout
, &fldno
, &width
, &align
);
574 va_start (args
, format
);
576 uo_field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
582 ui_out_spaces (struct ui_out
*uiout
, int numspaces
)
584 uo_spaces (uiout
, numspaces
);
588 ui_out_text (struct ui_out
*uiout
,
591 uo_text (uiout
, string
);
595 ui_out_message (struct ui_out
*uiout
, int verbosity
,
596 const char *format
,...)
600 va_start (args
, format
);
602 uo_message (uiout
, verbosity
, format
, args
);
608 ui_out_stream_new (struct ui_out
*uiout
)
610 struct ui_stream
*tempbuf
;
612 tempbuf
= XMALLOC (struct ui_stream
);
613 tempbuf
->uiout
= uiout
;
614 tempbuf
->stream
= mem_fileopen ();
619 ui_out_stream_delete (struct ui_stream
*buf
)
621 ui_file_delete (buf
->stream
);
626 do_stream_delete (void *buf
)
628 ui_out_stream_delete (buf
);
632 make_cleanup_ui_out_stream_delete (struct ui_stream
*buf
)
634 return make_cleanup (do_stream_delete
, buf
);
639 ui_out_wrap_hint (struct ui_out
*uiout
, char *identstring
)
641 uo_wrap_hint (uiout
, identstring
);
645 ui_out_flush (struct ui_out
*uiout
)
650 /* set the flags specified by the mask given */
652 ui_out_set_flags (struct ui_out
*uiout
, int mask
)
654 int oldflags
= uiout
->flags
;
656 uiout
->flags
|= mask
;
661 /* clear the flags specified by the mask given */
663 ui_out_clear_flags (struct ui_out
*uiout
, int mask
)
665 int oldflags
= uiout
->flags
;
667 uiout
->flags
&= ~mask
;
672 /* test the flags against the mask given */
674 ui_out_test_flags (struct ui_out
*uiout
, int mask
)
676 return (uiout
->flags
& mask
);
679 /* obtain the current verbosity level (as stablished by the
680 'set verbositylevel' command */
683 ui_out_get_verblvl (struct ui_out
*uiout
)
685 /* FIXME: not implemented yet */
691 ui_out_result_begin (struct ui_out
*uiout
, char *class)
696 ui_out_result_end (struct ui_out
*uiout
)
701 ui_out_info_begin (struct ui_out
*uiout
, char *class)
706 ui_out_info_end (struct ui_out
*uiout
)
711 ui_out_notify_begin (struct ui_out
*uiout
, char *class)
716 ui_out_notify_end (struct ui_out
*uiout
)
721 ui_out_error_begin (struct ui_out
*uiout
, char *class)
726 ui_out_error_end (struct ui_out
*uiout
)
733 gdb_error (ui_out
* uiout
, int severity
, char *format
,...)
739 gdb_query (struct ui_out
*uiout
, int qflags
, char *qprompt
)
745 ui_out_is_mi_like_p (struct ui_out
*uiout
)
747 return uiout
->impl
->is_mi_like_p
;
750 /* default gdb-out hook functions */
753 default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
760 default_table_body (struct ui_out
*uiout
)
765 default_table_end (struct ui_out
*uiout
)
770 default_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
771 const char *col_name
,
777 default_begin (struct ui_out
*uiout
,
778 enum ui_out_type type
,
785 default_end (struct ui_out
*uiout
,
786 enum ui_out_type type
,
792 default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
794 const char *fldname
, int value
)
799 default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
800 enum ui_align align
, const char *fldname
)
805 default_field_string (struct ui_out
*uiout
,
815 default_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
824 default_spaces (struct ui_out
*uiout
, int numspaces
)
829 default_text (struct ui_out
*uiout
, const char *string
)
834 default_message (struct ui_out
*uiout
, int verbosity
,
841 default_wrap_hint (struct ui_out
*uiout
, char *identstring
)
846 default_flush (struct ui_out
*uiout
)
850 /* Interface to the implementation functions */
853 uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
857 if (!uiout
->impl
->table_begin
)
859 uiout
->impl
->table_begin (uiout
, nbrofcols
, nr_rows
, tblid
);
863 uo_table_body (struct ui_out
*uiout
)
865 if (!uiout
->impl
->table_body
)
867 uiout
->impl
->table_body (uiout
);
871 uo_table_end (struct ui_out
*uiout
)
873 if (!uiout
->impl
->table_end
)
875 uiout
->impl
->table_end (uiout
);
879 uo_table_header (struct ui_out
*uiout
, int width
, enum ui_align align
,
880 const char *col_name
,
883 if (!uiout
->impl
->table_header
)
885 uiout
->impl
->table_header (uiout
, width
, align
, col_name
, colhdr
);
889 uo_begin (struct ui_out
*uiout
,
890 enum ui_out_type type
,
894 if (uiout
->impl
->begin
== NULL
)
896 uiout
->impl
->begin (uiout
, type
, level
, id
);
900 uo_end (struct ui_out
*uiout
,
901 enum ui_out_type type
,
904 if (uiout
->impl
->end
== NULL
)
906 uiout
->impl
->end (uiout
, type
, level
);
910 uo_field_int (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
914 if (!uiout
->impl
->field_int
)
916 uiout
->impl
->field_int (uiout
, fldno
, width
, align
, fldname
, value
);
920 uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
923 if (!uiout
->impl
->field_skip
)
925 uiout
->impl
->field_skip (uiout
, fldno
, width
, align
, fldname
);
929 uo_field_string (struct ui_out
*uiout
, int fldno
, int width
,
934 if (!uiout
->impl
->field_string
)
936 uiout
->impl
->field_string (uiout
, fldno
, width
, align
, fldname
, string
);
940 uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
945 if (!uiout
->impl
->field_fmt
)
947 uiout
->impl
->field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
951 uo_spaces (struct ui_out
*uiout
, int numspaces
)
953 if (!uiout
->impl
->spaces
)
955 uiout
->impl
->spaces (uiout
, numspaces
);
959 uo_text (struct ui_out
*uiout
,
962 if (!uiout
->impl
->text
)
964 uiout
->impl
->text (uiout
, string
);
968 uo_message (struct ui_out
*uiout
, int verbosity
,
972 if (!uiout
->impl
->message
)
974 uiout
->impl
->message (uiout
, verbosity
, format
, args
);
978 uo_wrap_hint (struct ui_out
*uiout
, char *identstring
)
980 if (!uiout
->impl
->wrap_hint
)
982 uiout
->impl
->wrap_hint (uiout
, identstring
);
986 uo_flush (struct ui_out
*uiout
)
988 if (!uiout
->impl
->flush
)
990 uiout
->impl
->flush (uiout
);
993 /* local functions */
995 /* list of column headers manipulation routines */
998 clear_header_list (struct ui_out
*uiout
)
1000 while (uiout
->table
.header_first
!= NULL
)
1002 uiout
->table
.header_next
= uiout
->table
.header_first
;
1003 uiout
->table
.header_first
= uiout
->table
.header_first
->next
;
1004 if (uiout
->table
.header_next
->colhdr
!= NULL
)
1005 xfree (uiout
->table
.header_next
->colhdr
);
1006 xfree (uiout
->table
.header_next
);
1008 gdb_assert (uiout
->table
.header_first
== NULL
);
1009 uiout
->table
.header_last
= NULL
;
1010 uiout
->table
.header_next
= NULL
;
1014 append_header_to_list (struct ui_out
*uiout
,
1017 const char *col_name
,
1020 struct ui_out_hdr
*temphdr
;
1022 temphdr
= XMALLOC (struct ui_out_hdr
);
1023 temphdr
->width
= width
;
1024 temphdr
->alignment
= alignment
;
1025 /* we have to copy the column title as the original may be an automatic */
1027 temphdr
->colhdr
= xstrdup (colhdr
);
1029 temphdr
->colhdr
= NULL
;
1030 if (col_name
!= NULL
)
1031 temphdr
->col_name
= xstrdup (colhdr
);
1033 temphdr
->col_name
= xstrdup (colhdr
);
1034 temphdr
->next
= NULL
;
1035 if (uiout
->table
.header_first
== NULL
)
1038 uiout
->table
.header_first
= temphdr
;
1039 uiout
->table
.header_last
= temphdr
;
1043 temphdr
->colno
= uiout
->table
.header_last
->colno
+ 1;
1044 uiout
->table
.header_last
->next
= temphdr
;
1045 uiout
->table
.header_last
= temphdr
;
1047 uiout
->table
.header_next
= uiout
->table
.header_last
;
1050 /* Extract the format information for the NEXT header and and advance
1051 the header pointer. Return 0 if there was no next header. */
1054 get_next_header (struct ui_out
*uiout
,
1060 /* There may be no headers at all or we may have used all columns. */
1061 if (uiout
->table
.header_next
== NULL
)
1063 *colno
= uiout
->table
.header_next
->colno
;
1064 *width
= uiout
->table
.header_next
->width
;
1065 *alignment
= uiout
->table
.header_next
->alignment
;
1066 *colhdr
= uiout
->table
.header_next
->colhdr
;
1067 /* Advance the header pointer to the next entry. */
1068 uiout
->table
.header_next
= uiout
->table
.header_next
->next
;
1073 /* Verify that the field/tuple/list is correctly positioned. Return
1074 the field number and corresponding alignment (if
1075 available/applicable). */
1078 verify_field (struct ui_out
*uiout
, int *fldno
, int *width
, int *align
)
1080 struct ui_out_level
*current
= current_level (uiout
);
1083 if (uiout
->table
.flag
)
1085 if (!uiout
->table
.body_flag
)
1086 internal_error (__FILE__
, __LINE__
,
1087 "table_body missing; table fields must be \
1088 specified after table_body and inside a list.");
1089 /* NOTE: cagney/2001-12-08: There was a check here to ensure
1090 that this code was only executed when uiout->level was
1091 greater than zero. That no longer applies - this code is run
1092 before each table row tuple is started and at that point the
1096 current
->field_count
+= 1;
1098 if (uiout
->table
.body_flag
1099 && uiout
->table
.entry_level
== uiout
->level
1100 && get_next_header (uiout
, fldno
, width
, align
, &text
))
1102 if (*fldno
!= current
->field_count
)
1103 internal_error (__FILE__
, __LINE__
,
1104 "ui-out internal error in handling headers.");
1109 *align
= ui_noalign
;
1110 *fldno
= current
->field_count
;
1115 /* access to ui_out format private members */
1118 ui_out_get_field_separator (struct ui_out
*uiout
)
1122 /* Access to ui-out members data */
1124 struct ui_out_data
*
1125 ui_out_data (struct ui_out
*uiout
)
1130 /* initalize private members at startup */
1133 ui_out_new (struct ui_out_impl
*impl
,
1134 struct ui_out_data
*data
,
1137 struct ui_out
*uiout
= XMALLOC (struct ui_out
);
1140 uiout
->flags
= flags
;
1141 uiout
->table
.flag
= 0;
1142 uiout
->table
.body_flag
= 0;
1144 memset (uiout
->levels
, 0, sizeof (uiout
->levels
));
1145 uiout
->table
.header_first
= NULL
;
1146 uiout
->table
.header_last
= NULL
;
1147 uiout
->table
.header_next
= NULL
;
1151 /* standard gdb initialization hook */
1154 _initialize_ui_out (void)
1156 /* nothing needs to be done */