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