1 /* Output generating routines for GDB.
3 Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 Contributed by Cygnus Solutions.
7 Written by Fernando Nasser for Cygnus.
9 This file is part of GDB.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
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.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "gdb_string.h"
26 #include "expression.h" /* For language.h */
29 #include "gdb_assert.h"
31 /* table header structures */
40 struct ui_out_hdr
*next
;
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
47 enum { MAX_UI_OUT_LEVELS
= 8 };
51 /* Count each field; the first element is for non-list fields */
53 /* The type of this level. */
54 enum ui_out_type type
;
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. */
63 /* If on, a table is being generated. */
66 /* If on, the body of a table is being generated. If off, the table
67 header is being generated. */
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. */
75 /* Number of table columns (as specified in the table_begin call). */
78 /* String identifying the table (as specified in the table_begin
82 /* Points to the first table header (if any). */
83 struct ui_out_hdr
*header_first
;
85 /* Points to the last table header (if any). */
86 struct ui_out_hdr
*header_last
;
88 /* Points to header of NEXT column to format. */
89 struct ui_out_hdr
*header_next
;
94 /* The ui_out structure */
95 /* Any change here requires a corresponding one in the initialization
96 of the default uiout, which is statically initialized */
101 /* specific implementation of ui-out */
102 struct ui_out_impl
*impl
;
105 /* Sub structure tracking the ui-out depth. */
107 struct ui_out_level levels
[MAX_UI_OUT_LEVELS
];
109 /* A table, if any. At present only a single table is supported. */
110 struct ui_out_table table
;
113 /* The current (inner most) level. */
114 static struct ui_out_level
*
115 current_level (struct ui_out
*uiout
)
117 return &uiout
->levels
[uiout
->level
];
120 /* Create a new level, of TYPE. Return the new level's index. */
122 push_level (struct ui_out
*uiout
,
123 enum ui_out_type type
,
126 struct ui_out_level
*current
;
127 /* We had better not overflow the buffer. */
129 gdb_assert (uiout
->level
>= 0 && uiout
->level
< MAX_UI_OUT_LEVELS
);
130 current
= current_level (uiout
);
131 current
->field_count
= 0;
132 current
->type
= type
;
136 /* Discard the current level, return the discarded level's index.
137 TYPE is the type of the level being discarded. */
139 pop_level (struct ui_out
*uiout
,
140 enum ui_out_type type
)
142 /* We had better not underflow the buffer. */
143 gdb_assert (uiout
->level
> 0 && uiout
->level
< MAX_UI_OUT_LEVELS
);
144 gdb_assert (current_level (uiout
)->type
== type
);
146 return uiout
->level
+ 1;
150 /* These are the default implementation functions */
152 static void default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
153 int nr_rows
, const char *tblid
);
154 static void default_table_body (struct ui_out
*uiout
);
155 static void default_table_end (struct ui_out
*uiout
);
156 static void default_table_header (struct ui_out
*uiout
, int width
,
157 enum ui_align alig
, const char *col_name
,
159 static void default_begin (struct ui_out
*uiout
,
160 enum ui_out_type type
,
161 int level
, const char *id
);
162 static void default_end (struct ui_out
*uiout
,
163 enum ui_out_type type
,
165 static void default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
169 static void default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
171 const char *fldname
);
172 static void default_field_string (struct ui_out
*uiout
, int fldno
, int width
,
176 static void default_field_fmt (struct ui_out
*uiout
, int fldno
,
177 int width
, enum ui_align align
,
180 va_list args
) ATTR_FORMAT (printf
, 6, 0);
181 static void default_spaces (struct ui_out
*uiout
, int numspaces
);
182 static void default_text (struct ui_out
*uiout
, const char *string
);
183 static void default_message (struct ui_out
*uiout
, int verbosity
,
185 va_list args
) ATTR_FORMAT (printf
, 3, 0);
186 static void default_wrap_hint (struct ui_out
*uiout
, char *identstring
);
187 static void default_flush (struct ui_out
*uiout
);
189 /* This is the default ui-out implementation functions vector */
191 struct ui_out_impl default_ui_out_impl
=
196 default_table_header
,
201 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_fmt (struct ui_out
*uiout
, int fldno
, int width
,
246 enum ui_align align
, const char *fldname
,
247 const char *format
, va_list args
)
248 ATTR_FORMAT (printf
, 6, 0);
249 static void uo_spaces (struct ui_out
*uiout
, int numspaces
);
250 static void uo_text (struct ui_out
*uiout
, const char *string
);
251 static void uo_message (struct ui_out
*uiout
, int verbosity
,
252 const char *format
, va_list args
)
253 ATTR_FORMAT (printf
, 3, 0);
254 static void uo_wrap_hint (struct ui_out
*uiout
, char *identstring
);
255 static void uo_flush (struct ui_out
*uiout
);
256 static int uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
);
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 /* exported functions (ui_out API) */
272 /* Mark beginning of a table */
275 ui_out_table_begin (struct ui_out
*uiout
, int nbrofcols
,
279 if (uiout
->table
.flag
)
280 internal_error (__FILE__
, __LINE__
,
281 _("tables cannot be nested; table_begin found before \
282 previous table_end."));
284 uiout
->table
.flag
= 1;
285 uiout
->table
.body_flag
= 0;
286 uiout
->table
.entry_level
= uiout
->level
+ 1;
287 uiout
->table
.columns
= nbrofcols
;
289 uiout
->table
.id
= xstrdup (tblid
);
291 uiout
->table
.id
= NULL
;
292 clear_header_list (uiout
);
294 uo_table_begin (uiout
, nbrofcols
, nr_rows
, uiout
->table
.id
);
298 ui_out_table_body (struct ui_out
*uiout
)
300 if (!uiout
->table
.flag
)
301 internal_error (__FILE__
, __LINE__
,
302 _("table_body outside a table is not valid; it must be \
303 after a table_begin and before a table_end."));
304 if (uiout
->table
.body_flag
)
305 internal_error (__FILE__
, __LINE__
,
306 _("extra table_body call not allowed; there must be \
307 only one table_body after a table_begin and before a table_end."));
308 if (uiout
->table
.header_next
->colno
!= uiout
->table
.columns
)
309 internal_error (__FILE__
, __LINE__
,
310 _("number of headers differ from number of table \
313 uiout
->table
.body_flag
= 1;
314 uiout
->table
.header_next
= uiout
->table
.header_first
;
316 uo_table_body (uiout
);
320 ui_out_table_end (struct ui_out
*uiout
)
322 if (!uiout
->table
.flag
)
323 internal_error (__FILE__
, __LINE__
,
324 _("misplaced table_end or missing table_begin."));
326 uiout
->table
.entry_level
= 0;
327 uiout
->table
.body_flag
= 0;
328 uiout
->table
.flag
= 0;
330 uo_table_end (uiout
);
333 xfree (uiout
->table
.id
);
334 clear_header_list (uiout
);
338 ui_out_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
339 const char *col_name
,
342 if (!uiout
->table
.flag
|| uiout
->table
.body_flag
)
343 internal_error (__FILE__
, __LINE__
,
344 _("table header must be specified after table_begin \
345 and before table_body."));
347 append_header_to_list (uiout
, width
, alignment
, col_name
, colhdr
);
349 uo_table_header (uiout
, width
, alignment
, col_name
, colhdr
);
353 do_cleanup_table_end (void *data
)
355 struct ui_out
*ui_out
= data
;
357 ui_out_table_end (ui_out
);
361 make_cleanup_ui_out_table_begin_end (struct ui_out
*ui_out
, int nr_cols
,
362 int nr_rows
, const char *tblid
)
364 ui_out_table_begin (ui_out
, nr_cols
, nr_rows
, tblid
);
365 return make_cleanup (do_cleanup_table_end
, ui_out
);
369 ui_out_begin (struct ui_out
*uiout
,
370 enum ui_out_type type
,
374 if (uiout
->table
.flag
&& !uiout
->table
.body_flag
)
375 internal_error (__FILE__
, __LINE__
,
376 _("table header or table_body expected; lists must be \
377 specified after table_body."));
379 /* Be careful to verify the ``field'' before the new tuple/list is
380 pushed onto the stack. That way the containing list/table/row is
381 verified and not the newly created tuple/list. This verification
382 is needed (at least) for the case where a table row entry
383 contains either a tuple/list. For that case bookkeeping such as
384 updating the column count or advancing to the next heading still
385 needs to be performed. */
390 verify_field (uiout
, &fldno
, &width
, &align
);
393 new_level
= push_level (uiout
, type
, id
);
395 /* If the push puts us at the same level as a table row entry, we've
396 got a new table row. Put the header pointer back to the start. */
397 if (uiout
->table
.body_flag
398 && uiout
->table
.entry_level
== new_level
)
399 uiout
->table
.header_next
= uiout
->table
.header_first
;
401 uo_begin (uiout
, type
, new_level
, id
);
405 ui_out_end (struct ui_out
*uiout
,
406 enum ui_out_type type
)
408 int old_level
= pop_level (uiout
, type
);
409 uo_end (uiout
, type
, old_level
);
412 struct ui_out_end_cleanup_data
414 struct ui_out
*uiout
;
415 enum ui_out_type type
;
419 do_cleanup_end (void *data
)
421 struct ui_out_end_cleanup_data
*end_cleanup_data
= data
;
422 ui_out_end (end_cleanup_data
->uiout
, end_cleanup_data
->type
);
423 xfree (end_cleanup_data
);
426 static struct cleanup
*
427 make_cleanup_ui_out_end (struct ui_out
*uiout
,
428 enum ui_out_type type
)
430 struct ui_out_end_cleanup_data
*end_cleanup_data
;
431 end_cleanup_data
= XMALLOC (struct ui_out_end_cleanup_data
);
432 end_cleanup_data
->uiout
= uiout
;
433 end_cleanup_data
->type
= type
;
434 return make_cleanup (do_cleanup_end
, end_cleanup_data
);
438 make_cleanup_ui_out_tuple_begin_end (struct ui_out
*uiout
,
441 ui_out_begin (uiout
, ui_out_type_tuple
, id
);
442 return make_cleanup_ui_out_end (uiout
, ui_out_type_tuple
);
446 make_cleanup_ui_out_list_begin_end (struct ui_out
*uiout
,
449 ui_out_begin (uiout
, ui_out_type_list
, id
);
450 return make_cleanup_ui_out_end (uiout
, ui_out_type_list
);
454 ui_out_field_int (struct ui_out
*uiout
,
461 struct ui_out_level
*current
= current_level (uiout
);
463 verify_field (uiout
, &fldno
, &width
, &align
);
465 uo_field_int (uiout
, fldno
, width
, align
, fldname
, value
);
469 ui_out_field_fmt_int (struct ui_out
*uiout
,
471 enum ui_align input_align
,
478 struct ui_out_level
*current
= current_level (uiout
);
480 verify_field (uiout
, &fldno
, &width
, &align
);
482 uo_field_int (uiout
, fldno
, input_width
, input_align
, fldname
, value
);
486 ui_out_field_core_addr (struct ui_out
*uiout
,
488 struct gdbarch
*gdbarch
,
492 int addr_bit
= gdbarch_addr_bit (gdbarch
);
494 if (addr_bit
< (sizeof (CORE_ADDR
) * HOST_CHAR_BIT
))
495 address
&= ((CORE_ADDR
) 1 << addr_bit
) - 1;
497 /* FIXME: cagney/2002-05-03: Need local_address_string() function
498 that returns the language localized string formatted to a width
499 based on gdbarch_addr_bit. */
501 strcpy (addstr
, hex_string_custom (address
, 8));
503 strcpy (addstr
, hex_string_custom (address
, 16));
505 ui_out_field_string (uiout
, fldname
, addstr
);
509 ui_out_field_stream (struct ui_out
*uiout
,
511 struct ui_stream
*buf
)
514 char *buffer
= ui_file_xstrdup (buf
->stream
, &length
);
515 struct cleanup
*old_cleanup
= make_cleanup (xfree
, buffer
);
517 ui_out_field_string (uiout
, fldname
, buffer
);
519 ui_out_field_skip (uiout
, fldname
);
520 ui_file_rewind (buf
->stream
);
521 do_cleanups (old_cleanup
);
524 /* used to ommit a field */
527 ui_out_field_skip (struct ui_out
*uiout
,
534 verify_field (uiout
, &fldno
, &width
, &align
);
536 uo_field_skip (uiout
, fldno
, width
, align
, fldname
);
540 ui_out_field_string (struct ui_out
*uiout
,
548 verify_field (uiout
, &fldno
, &width
, &align
);
550 uo_field_string (uiout
, fldno
, width
, align
, fldname
, string
);
555 ui_out_field_fmt (struct ui_out
*uiout
,
557 const char *format
, ...)
564 /* will not align, but has to call anyway */
565 verify_field (uiout
, &fldno
, &width
, &align
);
567 va_start (args
, format
);
569 uo_field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
575 ui_out_spaces (struct ui_out
*uiout
, int numspaces
)
577 uo_spaces (uiout
, numspaces
);
581 ui_out_text (struct ui_out
*uiout
,
584 uo_text (uiout
, string
);
588 ui_out_message (struct ui_out
*uiout
, int verbosity
,
589 const char *format
,...)
593 va_start (args
, format
);
595 uo_message (uiout
, verbosity
, format
, args
);
601 ui_out_stream_new (struct ui_out
*uiout
)
603 struct ui_stream
*tempbuf
;
605 tempbuf
= XMALLOC (struct ui_stream
);
606 tempbuf
->uiout
= uiout
;
607 tempbuf
->stream
= mem_fileopen ();
612 ui_out_stream_delete (struct ui_stream
*buf
)
614 ui_file_delete (buf
->stream
);
619 do_stream_delete (void *buf
)
621 ui_out_stream_delete (buf
);
625 make_cleanup_ui_out_stream_delete (struct ui_stream
*buf
)
627 return make_cleanup (do_stream_delete
, buf
);
632 ui_out_wrap_hint (struct ui_out
*uiout
, char *identstring
)
634 uo_wrap_hint (uiout
, identstring
);
638 ui_out_flush (struct ui_out
*uiout
)
644 ui_out_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
646 return uo_redirect (uiout
, outstream
);
649 /* set the flags specified by the mask given */
651 ui_out_set_flags (struct ui_out
*uiout
, int mask
)
653 int oldflags
= uiout
->flags
;
655 uiout
->flags
|= mask
;
660 /* clear the flags specified by the mask given */
662 ui_out_clear_flags (struct ui_out
*uiout
, int mask
)
664 int oldflags
= uiout
->flags
;
666 uiout
->flags
&= ~mask
;
671 /* test the flags against the mask given */
673 ui_out_test_flags (struct ui_out
*uiout
, int mask
)
675 return (uiout
->flags
& mask
);
678 /* obtain the current verbosity level (as stablished by the
679 'set verbositylevel' command */
682 ui_out_get_verblvl (struct ui_out
*uiout
)
684 /* FIXME: not implemented yet */
690 ui_out_result_begin (struct ui_out
*uiout
, char *class)
695 ui_out_result_end (struct ui_out
*uiout
)
700 ui_out_info_begin (struct ui_out
*uiout
, char *class)
705 ui_out_info_end (struct ui_out
*uiout
)
710 ui_out_notify_begin (struct ui_out
*uiout
, char *class)
715 ui_out_notify_end (struct ui_out
*uiout
)
720 ui_out_error_begin (struct ui_out
*uiout
, char *class)
725 ui_out_error_end (struct ui_out
*uiout
)
732 gdb_error (ui_out
* uiout
, int severity
, char *format
,...)
738 gdb_query (struct ui_out
*uiout
, int qflags
, char *qprompt
)
744 ui_out_is_mi_like_p (struct ui_out
*uiout
)
746 return uiout
->impl
->is_mi_like_p
;
749 /* default gdb-out hook functions */
752 default_table_begin (struct ui_out
*uiout
, int nbrofcols
,
759 default_table_body (struct ui_out
*uiout
)
764 default_table_end (struct ui_out
*uiout
)
769 default_table_header (struct ui_out
*uiout
, int width
, enum ui_align alignment
,
770 const char *col_name
,
776 default_begin (struct ui_out
*uiout
,
777 enum ui_out_type type
,
784 default_end (struct ui_out
*uiout
,
785 enum ui_out_type type
,
791 default_field_int (struct ui_out
*uiout
, int fldno
, int width
,
793 const char *fldname
, int value
)
798 default_field_skip (struct ui_out
*uiout
, int fldno
, int width
,
799 enum ui_align align
, const char *fldname
)
804 default_field_string (struct ui_out
*uiout
,
814 default_field_fmt (struct ui_out
*uiout
, int fldno
, int width
,
823 default_spaces (struct ui_out
*uiout
, int numspaces
)
828 default_text (struct ui_out
*uiout
, const char *string
)
833 default_message (struct ui_out
*uiout
, int verbosity
,
840 default_wrap_hint (struct ui_out
*uiout
, char *identstring
)
845 default_flush (struct ui_out
*uiout
)
849 /* Interface to the implementation functions */
852 uo_table_begin (struct ui_out
*uiout
, int nbrofcols
,
856 if (!uiout
->impl
->table_begin
)
858 uiout
->impl
->table_begin (uiout
, nbrofcols
, nr_rows
, tblid
);
862 uo_table_body (struct ui_out
*uiout
)
864 if (!uiout
->impl
->table_body
)
866 uiout
->impl
->table_body (uiout
);
870 uo_table_end (struct ui_out
*uiout
)
872 if (!uiout
->impl
->table_end
)
874 uiout
->impl
->table_end (uiout
);
878 uo_table_header (struct ui_out
*uiout
, int width
, enum ui_align align
,
879 const char *col_name
,
882 if (!uiout
->impl
->table_header
)
884 uiout
->impl
->table_header (uiout
, width
, align
, col_name
, colhdr
);
888 uo_begin (struct ui_out
*uiout
,
889 enum ui_out_type type
,
893 if (uiout
->impl
->begin
== NULL
)
895 uiout
->impl
->begin (uiout
, type
, level
, id
);
899 uo_end (struct ui_out
*uiout
,
900 enum ui_out_type type
,
903 if (uiout
->impl
->end
== NULL
)
905 uiout
->impl
->end (uiout
, type
, level
);
909 uo_field_int (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
913 if (!uiout
->impl
->field_int
)
915 uiout
->impl
->field_int (uiout
, fldno
, width
, align
, fldname
, value
);
919 uo_field_skip (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
922 if (!uiout
->impl
->field_skip
)
924 uiout
->impl
->field_skip (uiout
, fldno
, width
, align
, fldname
);
928 uo_field_string (struct ui_out
*uiout
, int fldno
, int width
,
933 if (!uiout
->impl
->field_string
)
935 uiout
->impl
->field_string (uiout
, fldno
, width
, align
, fldname
, string
);
939 uo_field_fmt (struct ui_out
*uiout
, int fldno
, int width
, enum ui_align align
,
944 if (!uiout
->impl
->field_fmt
)
946 uiout
->impl
->field_fmt (uiout
, fldno
, width
, align
, fldname
, format
, args
);
950 uo_spaces (struct ui_out
*uiout
, int numspaces
)
952 if (!uiout
->impl
->spaces
)
954 uiout
->impl
->spaces (uiout
, numspaces
);
958 uo_text (struct ui_out
*uiout
,
961 if (!uiout
->impl
->text
)
963 uiout
->impl
->text (uiout
, string
);
967 uo_message (struct ui_out
*uiout
, int verbosity
,
971 if (!uiout
->impl
->message
)
973 uiout
->impl
->message (uiout
, verbosity
, format
, args
);
977 uo_wrap_hint (struct ui_out
*uiout
, char *identstring
)
979 if (!uiout
->impl
->wrap_hint
)
981 uiout
->impl
->wrap_hint (uiout
, identstring
);
985 uo_flush (struct ui_out
*uiout
)
987 if (!uiout
->impl
->flush
)
989 uiout
->impl
->flush (uiout
);
993 uo_redirect (struct ui_out
*uiout
, struct ui_file
*outstream
)
995 if (!uiout
->impl
->redirect
)
997 uiout
->impl
->redirect (uiout
, outstream
);
1001 /* local functions */
1003 /* list of column headers manipulation routines */
1006 clear_header_list (struct ui_out
*uiout
)
1008 while (uiout
->table
.header_first
!= NULL
)
1010 uiout
->table
.header_next
= uiout
->table
.header_first
;
1011 uiout
->table
.header_first
= uiout
->table
.header_first
->next
;
1012 if (uiout
->table
.header_next
->colhdr
!= NULL
)
1013 xfree (uiout
->table
.header_next
->colhdr
);
1014 xfree (uiout
->table
.header_next
);
1016 gdb_assert (uiout
->table
.header_first
== NULL
);
1017 uiout
->table
.header_last
= NULL
;
1018 uiout
->table
.header_next
= NULL
;
1022 append_header_to_list (struct ui_out
*uiout
,
1025 const char *col_name
,
1028 struct ui_out_hdr
*temphdr
;
1030 temphdr
= XMALLOC (struct ui_out_hdr
);
1031 temphdr
->width
= width
;
1032 temphdr
->alignment
= alignment
;
1033 /* We have to copy the column title as the original may be an
1036 temphdr
->colhdr
= xstrdup (colhdr
);
1038 temphdr
->colhdr
= NULL
;
1040 if (col_name
!= NULL
)
1041 temphdr
->col_name
= xstrdup (col_name
);
1042 else if (colhdr
!= NULL
)
1043 temphdr
->col_name
= xstrdup (colhdr
);
1045 temphdr
->col_name
= NULL
;
1047 temphdr
->next
= NULL
;
1048 if (uiout
->table
.header_first
== NULL
)
1051 uiout
->table
.header_first
= temphdr
;
1052 uiout
->table
.header_last
= temphdr
;
1056 temphdr
->colno
= uiout
->table
.header_last
->colno
+ 1;
1057 uiout
->table
.header_last
->next
= temphdr
;
1058 uiout
->table
.header_last
= temphdr
;
1060 uiout
->table
.header_next
= uiout
->table
.header_last
;
1063 /* Extract the format information for the NEXT header and and advance
1064 the header pointer. Return 0 if there was no next header. */
1067 get_next_header (struct ui_out
*uiout
,
1073 /* There may be no headers at all or we may have used all columns. */
1074 if (uiout
->table
.header_next
== NULL
)
1076 *colno
= uiout
->table
.header_next
->colno
;
1077 *width
= uiout
->table
.header_next
->width
;
1078 *alignment
= uiout
->table
.header_next
->alignment
;
1079 *colhdr
= uiout
->table
.header_next
->colhdr
;
1080 /* Advance the header pointer to the next entry. */
1081 uiout
->table
.header_next
= uiout
->table
.header_next
->next
;
1086 /* Verify that the field/tuple/list is correctly positioned. Return
1087 the field number and corresponding alignment (if
1088 available/applicable). */
1091 verify_field (struct ui_out
*uiout
, int *fldno
, int *width
, int *align
)
1093 struct ui_out_level
*current
= current_level (uiout
);
1096 if (uiout
->table
.flag
)
1098 if (!uiout
->table
.body_flag
)
1099 internal_error (__FILE__
, __LINE__
,
1100 _("table_body missing; table fields must be \
1101 specified after table_body and inside a list."));
1102 /* NOTE: cagney/2001-12-08: There was a check here to ensure
1103 that this code was only executed when uiout->level was
1104 greater than zero. That no longer applies - this code is run
1105 before each table row tuple is started and at that point the
1109 current
->field_count
+= 1;
1111 if (uiout
->table
.body_flag
1112 && uiout
->table
.entry_level
== uiout
->level
1113 && get_next_header (uiout
, fldno
, width
, align
, &text
))
1115 if (*fldno
!= current
->field_count
)
1116 internal_error (__FILE__
, __LINE__
,
1117 _("ui-out internal error in handling headers."));
1122 *align
= ui_noalign
;
1123 *fldno
= current
->field_count
;
1128 /* access to ui_out format private members */
1131 ui_out_get_field_separator (struct ui_out
*uiout
)
1135 /* Access to ui-out members data */
1138 ui_out_data (struct ui_out
*uiout
)
1143 /* initalize private members at startup */
1146 ui_out_new (struct ui_out_impl
*impl
, void *data
,
1149 struct ui_out
*uiout
= XMALLOC (struct ui_out
);
1152 uiout
->flags
= flags
;
1153 uiout
->table
.flag
= 0;
1154 uiout
->table
.body_flag
= 0;
1156 memset (uiout
->levels
, 0, sizeof (uiout
->levels
));
1157 uiout
->table
.header_first
= NULL
;
1158 uiout
->table
.header_last
= NULL
;
1159 uiout
->table
.header_next
= NULL
;
1163 /* standard gdb initialization hook */
1166 _initialize_ui_out (void)
1168 /* nothing needs to be done */