xref: /dflybsd-src/contrib/gdb-7/gdb/ui-out.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Output generating routines for GDB.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1999-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    Contributed by Cygnus Solutions.
65796c8dcSSimon Schubert    Written by Fernando Nasser for Cygnus.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This file is part of GDB.
95796c8dcSSimon Schubert 
105796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
115796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
125796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
135796c8dcSSimon Schubert    (at your option) any later version.
145796c8dcSSimon Schubert 
155796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
165796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
175796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
185796c8dcSSimon Schubert    GNU General Public License for more details.
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
215796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #ifndef UI_OUT_H
245796c8dcSSimon Schubert #define UI_OUT_H 1
255796c8dcSSimon Schubert 
265796c8dcSSimon Schubert /* The ui_out structure */
275796c8dcSSimon Schubert 
285796c8dcSSimon Schubert struct ui_out;
295796c8dcSSimon Schubert struct ui_file;
305796c8dcSSimon Schubert 
315796c8dcSSimon Schubert /* the current ui_out */
325796c8dcSSimon Schubert 
335796c8dcSSimon Schubert /* FIXME: This should not be a global but something passed down from main.c
34c50c785cSJohn Marino    or top.c.  */
35a45ae5f8SJohn Marino extern struct ui_out *current_uiout;
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert /* alignment enum */
385796c8dcSSimon Schubert enum ui_align
395796c8dcSSimon Schubert   {
405796c8dcSSimon Schubert     ui_left = -1,
415796c8dcSSimon Schubert     ui_center,
425796c8dcSSimon Schubert     ui_right,
435796c8dcSSimon Schubert     ui_noalign
445796c8dcSSimon Schubert   };
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert /* flags enum */
475796c8dcSSimon Schubert enum ui_flags
485796c8dcSSimon Schubert   {
495796c8dcSSimon Schubert     ui_from_tty = 1,
505796c8dcSSimon Schubert     ui_source_list = 2
515796c8dcSSimon Schubert   };
525796c8dcSSimon Schubert 
535796c8dcSSimon Schubert 
545796c8dcSSimon Schubert /* Prototypes for ui-out API.  */
555796c8dcSSimon Schubert 
565796c8dcSSimon Schubert /* A result is a recursive data structure consisting of lists and
575796c8dcSSimon Schubert    tuples.  */
585796c8dcSSimon Schubert 
595796c8dcSSimon Schubert enum ui_out_type
605796c8dcSSimon Schubert   {
615796c8dcSSimon Schubert     ui_out_type_tuple,
625796c8dcSSimon Schubert     ui_out_type_list
635796c8dcSSimon Schubert   };
645796c8dcSSimon Schubert 
655796c8dcSSimon Schubert extern void ui_out_begin (struct ui_out *uiout,
665796c8dcSSimon Schubert 			  enum ui_out_type level_type,
675796c8dcSSimon Schubert 			  const char *id);
685796c8dcSSimon Schubert 
695796c8dcSSimon Schubert extern void ui_out_end (struct ui_out *uiout, enum ui_out_type type);
705796c8dcSSimon Schubert 
715796c8dcSSimon Schubert extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout,
725796c8dcSSimon Schubert 						 enum ui_out_type level_type,
735796c8dcSSimon Schubert 						 const char *id);
745796c8dcSSimon Schubert 
755796c8dcSSimon Schubert /* A table can be considered a special tuple/list combination with the
765796c8dcSSimon Schubert    implied structure: ``table = { hdr = { header, ... } , body = [ {
775796c8dcSSimon Schubert    field, ... }, ... ] }''.  If NR_ROWS is negative then there is at
785796c8dcSSimon Schubert    least one row.  */
795796c8dcSSimon Schubert extern void ui_out_table_header (struct ui_out *uiout, int width,
805796c8dcSSimon Schubert 				 enum ui_align align, const char *col_name,
815796c8dcSSimon Schubert 				 const char *colhdr);
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert extern void ui_out_table_body (struct ui_out *uiout);
845796c8dcSSimon Schubert 
855796c8dcSSimon Schubert extern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out,
865796c8dcSSimon Schubert                                                             int nr_cols,
875796c8dcSSimon Schubert 							    int nr_rows,
885796c8dcSSimon Schubert 							    const char *tblid);
895796c8dcSSimon Schubert /* Compatibility wrappers.  */
905796c8dcSSimon Schubert 
915796c8dcSSimon Schubert extern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
925796c8dcSSimon Schubert 							   const char *id);
935796c8dcSSimon Schubert 
945796c8dcSSimon Schubert extern struct cleanup *make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
955796c8dcSSimon Schubert 							    const char *id);
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert extern void ui_out_field_int (struct ui_out *uiout, const char *fldname,
985796c8dcSSimon Schubert 			      int value);
995796c8dcSSimon Schubert 
1005796c8dcSSimon Schubert extern void ui_out_field_fmt_int (struct ui_out *uiout, int width,
1015796c8dcSSimon Schubert 				  enum ui_align align, const char *fldname,
1025796c8dcSSimon Schubert 		 		  int value);
1035796c8dcSSimon Schubert 
104a45ae5f8SJohn Marino /* Output a field containing an address.  */
105a45ae5f8SJohn Marino 
1065796c8dcSSimon Schubert extern void ui_out_field_core_addr (struct ui_out *uiout, const char *fldname,
1075796c8dcSSimon Schubert 				    struct gdbarch *gdbarch, CORE_ADDR address);
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert extern void ui_out_field_string (struct ui_out * uiout, const char *fldname,
1105796c8dcSSimon Schubert 				 const char *string);
1115796c8dcSSimon Schubert 
1125796c8dcSSimon Schubert extern void ui_out_field_stream (struct ui_out *uiout, const char *fldname,
113*ef5ccd6cSJohn Marino 				 struct ui_file *stream);
1145796c8dcSSimon Schubert 
1155796c8dcSSimon Schubert extern void ui_out_field_fmt (struct ui_out *uiout, const char *fldname,
1165796c8dcSSimon Schubert 			      const char *format, ...)
117cf7f2e2dSJohn Marino      ATTRIBUTE_PRINTF (3, 4);
1185796c8dcSSimon Schubert 
1195796c8dcSSimon Schubert extern void ui_out_field_skip (struct ui_out *uiout, const char *fldname);
1205796c8dcSSimon Schubert 
1215796c8dcSSimon Schubert extern void ui_out_spaces (struct ui_out *uiout, int numspaces);
1225796c8dcSSimon Schubert 
1235796c8dcSSimon Schubert extern void ui_out_text (struct ui_out *uiout, const char *string);
1245796c8dcSSimon Schubert 
1255796c8dcSSimon Schubert extern void ui_out_message (struct ui_out *uiout, int verbosity,
1265796c8dcSSimon Schubert 			    const char *format, ...)
127cf7f2e2dSJohn Marino      ATTRIBUTE_PRINTF (3, 4);
1285796c8dcSSimon Schubert 
1295796c8dcSSimon Schubert extern void ui_out_wrap_hint (struct ui_out *uiout, char *identstring);
1305796c8dcSSimon Schubert 
1315796c8dcSSimon Schubert extern void ui_out_flush (struct ui_out *uiout);
1325796c8dcSSimon Schubert 
1335796c8dcSSimon Schubert extern int ui_out_set_flags (struct ui_out *uiout, int mask);
1345796c8dcSSimon Schubert 
1355796c8dcSSimon Schubert extern int ui_out_clear_flags (struct ui_out *uiout, int mask);
1365796c8dcSSimon Schubert 
1375796c8dcSSimon Schubert extern int ui_out_get_verblvl (struct ui_out *uiout);
1385796c8dcSSimon Schubert 
1395796c8dcSSimon Schubert extern int ui_out_test_flags (struct ui_out *uiout, int mask);
1405796c8dcSSimon Schubert 
141c50c785cSJohn Marino extern int ui_out_query_field (struct ui_out *uiout, int colno,
142c50c785cSJohn Marino 			       int *width, int *alignment, char **col_name);
143c50c785cSJohn Marino 
1445796c8dcSSimon Schubert /* HACK: Code in GDB is currently checking to see the type of ui_out
1455796c8dcSSimon Schubert    builder when determining which output to produce.  This function is
1465796c8dcSSimon Schubert    a hack to encapsulate that test.  Once GDB manages to separate the
1475796c8dcSSimon Schubert    CLI/MI from the core of GDB the problem should just go away ....  */
1485796c8dcSSimon Schubert 
1495796c8dcSSimon Schubert extern int ui_out_is_mi_like_p (struct ui_out *uiout);
1505796c8dcSSimon Schubert 
1515796c8dcSSimon Schubert /* From here on we have things that are only needed by implementation
1525796c8dcSSimon Schubert    routines and main.c.   We should pehaps have a separate file for that,
153c50c785cSJohn Marino    like a  ui-out-impl.h  file.  */
1545796c8dcSSimon Schubert 
1555796c8dcSSimon Schubert /* User Interface Output Implementation Function Table */
1565796c8dcSSimon Schubert 
1575796c8dcSSimon Schubert /* Type definition of all implementation functions.  */
1585796c8dcSSimon Schubert 
1595796c8dcSSimon Schubert typedef void (table_begin_ftype) (struct ui_out * uiout,
1605796c8dcSSimon Schubert 				  int nbrofcols, int nr_rows,
1615796c8dcSSimon Schubert 				  const char *tblid);
1625796c8dcSSimon Schubert typedef void (table_body_ftype) (struct ui_out * uiout);
1635796c8dcSSimon Schubert typedef void (table_end_ftype) (struct ui_out * uiout);
1645796c8dcSSimon Schubert typedef void (table_header_ftype) (struct ui_out * uiout, int width,
1655796c8dcSSimon Schubert 				   enum ui_align align, const char *col_name,
1665796c8dcSSimon Schubert 				   const char *colhdr);
1675796c8dcSSimon Schubert /* Note: level 0 is the top-level so LEVEL is always greater than
1685796c8dcSSimon Schubert    zero.  */
1695796c8dcSSimon Schubert typedef void (ui_out_begin_ftype) (struct ui_out *uiout,
1705796c8dcSSimon Schubert 				   enum ui_out_type type,
1715796c8dcSSimon Schubert 				   int level, const char *id);
1725796c8dcSSimon Schubert typedef void (ui_out_end_ftype) (struct ui_out *uiout,
1735796c8dcSSimon Schubert 				 enum ui_out_type type,
1745796c8dcSSimon Schubert 				 int level);
1755796c8dcSSimon Schubert typedef void (field_int_ftype) (struct ui_out * uiout, int fldno, int width,
1765796c8dcSSimon Schubert 				enum ui_align align,
1775796c8dcSSimon Schubert 				const char *fldname, int value);
1785796c8dcSSimon Schubert typedef void (field_skip_ftype) (struct ui_out * uiout, int fldno, int width,
1795796c8dcSSimon Schubert 				 enum ui_align align,
1805796c8dcSSimon Schubert 				 const char *fldname);
1815796c8dcSSimon Schubert typedef void (field_string_ftype) (struct ui_out * uiout, int fldno, int width,
1825796c8dcSSimon Schubert 				   enum ui_align align,
1835796c8dcSSimon Schubert 				   const char *fldname,
1845796c8dcSSimon Schubert 				   const char *string);
1855796c8dcSSimon Schubert typedef void (field_fmt_ftype) (struct ui_out * uiout, int fldno, int width,
1865796c8dcSSimon Schubert 				enum ui_align align,
1875796c8dcSSimon Schubert 				const char *fldname,
1885796c8dcSSimon Schubert 				const char *format,
1895796c8dcSSimon Schubert 				va_list args) ATTRIBUTE_FPTR_PRINTF(6,0);
1905796c8dcSSimon Schubert typedef void (spaces_ftype) (struct ui_out * uiout, int numspaces);
1915796c8dcSSimon Schubert typedef void (text_ftype) (struct ui_out * uiout,
1925796c8dcSSimon Schubert 			   const char *string);
1935796c8dcSSimon Schubert typedef void (message_ftype) (struct ui_out * uiout, int verbosity,
1945796c8dcSSimon Schubert 			      const char *format, va_list args)
1955796c8dcSSimon Schubert      ATTRIBUTE_FPTR_PRINTF(3,0);
1965796c8dcSSimon Schubert typedef void (wrap_hint_ftype) (struct ui_out * uiout, char *identstring);
1975796c8dcSSimon Schubert typedef void (flush_ftype) (struct ui_out * uiout);
1985796c8dcSSimon Schubert typedef int (redirect_ftype) (struct ui_out * uiout,
1995796c8dcSSimon Schubert 			      struct ui_file * outstream);
200*ef5ccd6cSJohn Marino typedef void (data_destroy_ftype) (struct ui_out *uiout);
2015796c8dcSSimon Schubert 
2025796c8dcSSimon Schubert /* ui-out-impl */
2035796c8dcSSimon Schubert 
2045796c8dcSSimon Schubert /* IMPORTANT: If you change this structure, make sure to change the default
205c50c785cSJohn Marino    initialization in ui-out.c.  */
2065796c8dcSSimon Schubert 
2075796c8dcSSimon Schubert struct ui_out_impl
2085796c8dcSSimon Schubert   {
2095796c8dcSSimon Schubert     table_begin_ftype *table_begin;
2105796c8dcSSimon Schubert     table_body_ftype *table_body;
2115796c8dcSSimon Schubert     table_end_ftype *table_end;
2125796c8dcSSimon Schubert     table_header_ftype *table_header;
2135796c8dcSSimon Schubert     ui_out_begin_ftype *begin;
2145796c8dcSSimon Schubert     ui_out_end_ftype *end;
2155796c8dcSSimon Schubert     field_int_ftype *field_int;
2165796c8dcSSimon Schubert     field_skip_ftype *field_skip;
2175796c8dcSSimon Schubert     field_string_ftype *field_string;
2185796c8dcSSimon Schubert     field_fmt_ftype *field_fmt;
2195796c8dcSSimon Schubert     spaces_ftype *spaces;
2205796c8dcSSimon Schubert     text_ftype *text;
2215796c8dcSSimon Schubert     message_ftype *message;
2225796c8dcSSimon Schubert     wrap_hint_ftype *wrap_hint;
2235796c8dcSSimon Schubert     flush_ftype *flush;
2245796c8dcSSimon Schubert     redirect_ftype *redirect;
225*ef5ccd6cSJohn Marino     data_destroy_ftype *data_destroy;
2265796c8dcSSimon Schubert     int is_mi_like_p;
2275796c8dcSSimon Schubert   };
2285796c8dcSSimon Schubert 
229cf7f2e2dSJohn Marino extern void *ui_out_data (struct ui_out *uiout);
2305796c8dcSSimon Schubert 
231cf7f2e2dSJohn Marino extern void uo_field_string (struct ui_out *uiout, int fldno, int width,
232cf7f2e2dSJohn Marino 			     enum ui_align align, const char *fldname,
233cf7f2e2dSJohn Marino 			     const char *string);
2345796c8dcSSimon Schubert 
2355796c8dcSSimon Schubert /* Create a ui_out object */
2365796c8dcSSimon Schubert 
2375796c8dcSSimon Schubert extern struct ui_out *ui_out_new (struct ui_out_impl *impl,
238cf7f2e2dSJohn Marino 				  void *data,
2395796c8dcSSimon Schubert 				  int flags);
2405796c8dcSSimon Schubert 
241*ef5ccd6cSJohn Marino /* Destroy a ui_out object.  */
242*ef5ccd6cSJohn Marino 
243*ef5ccd6cSJohn Marino extern void ui_out_destroy (struct ui_out *uiout);
244*ef5ccd6cSJohn Marino 
2455796c8dcSSimon Schubert /* Redirect the ouptut of a ui_out object temporarily.  */
2465796c8dcSSimon Schubert 
2475796c8dcSSimon Schubert extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream);
2485796c8dcSSimon Schubert 
2495796c8dcSSimon Schubert #endif /* UI_OUT_H */
250