GDB (API)
|
00001 /* Output generating routines for GDB. 00002 00003 Copyright (C) 1999-2013 Free Software Foundation, Inc. 00004 00005 Contributed by Cygnus Solutions. 00006 Written by Fernando Nasser for Cygnus. 00007 00008 This file is part of GDB. 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00022 00023 #ifndef UI_OUT_H 00024 #define UI_OUT_H 1 00025 00026 /* The ui_out structure */ 00027 00028 struct ui_out; 00029 struct ui_file; 00030 00031 /* the current ui_out */ 00032 00033 /* FIXME: This should not be a global but something passed down from main.c 00034 or top.c. */ 00035 extern struct ui_out *current_uiout; 00036 00037 /* alignment enum */ 00038 enum ui_align 00039 { 00040 ui_left = -1, 00041 ui_center, 00042 ui_right, 00043 ui_noalign 00044 }; 00045 00046 /* flags enum */ 00047 enum ui_flags 00048 { 00049 ui_from_tty = 1, 00050 ui_source_list = 2 00051 }; 00052 00053 00054 /* Prototypes for ui-out API. */ 00055 00056 /* A result is a recursive data structure consisting of lists and 00057 tuples. */ 00058 00059 enum ui_out_type 00060 { 00061 ui_out_type_tuple, 00062 ui_out_type_list 00063 }; 00064 00065 extern void ui_out_begin (struct ui_out *uiout, 00066 enum ui_out_type level_type, 00067 const char *id); 00068 00069 extern void ui_out_end (struct ui_out *uiout, enum ui_out_type type); 00070 00071 extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout, 00072 enum ui_out_type level_type, 00073 const char *id); 00074 00075 /* A table can be considered a special tuple/list combination with the 00076 implied structure: ``table = { hdr = { header, ... } , body = [ { 00077 field, ... }, ... ] }''. If NR_ROWS is negative then there is at 00078 least one row. */ 00079 extern void ui_out_table_header (struct ui_out *uiout, int width, 00080 enum ui_align align, const char *col_name, 00081 const char *colhdr); 00082 00083 extern void ui_out_table_body (struct ui_out *uiout); 00084 00085 extern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, 00086 int nr_cols, 00087 int nr_rows, 00088 const char *tblid); 00089 /* Compatibility wrappers. */ 00090 00091 extern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, 00092 const char *id); 00093 00094 extern struct cleanup *make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, 00095 const char *id); 00096 00097 extern void ui_out_field_int (struct ui_out *uiout, const char *fldname, 00098 int value); 00099 00100 extern void ui_out_field_fmt_int (struct ui_out *uiout, int width, 00101 enum ui_align align, const char *fldname, 00102 int value); 00103 00104 /* Output a field containing an address. */ 00105 00106 extern void ui_out_field_core_addr (struct ui_out *uiout, const char *fldname, 00107 struct gdbarch *gdbarch, CORE_ADDR address); 00108 00109 extern void ui_out_field_string (struct ui_out * uiout, const char *fldname, 00110 const char *string); 00111 00112 extern void ui_out_field_stream (struct ui_out *uiout, const char *fldname, 00113 struct ui_file *stream); 00114 00115 extern void ui_out_field_fmt (struct ui_out *uiout, const char *fldname, 00116 const char *format, ...) 00117 ATTRIBUTE_PRINTF (3, 4); 00118 00119 extern void ui_out_field_skip (struct ui_out *uiout, const char *fldname); 00120 00121 extern void ui_out_spaces (struct ui_out *uiout, int numspaces); 00122 00123 extern void ui_out_text (struct ui_out *uiout, const char *string); 00124 00125 extern void ui_out_message (struct ui_out *uiout, int verbosity, 00126 const char *format, ...) 00127 ATTRIBUTE_PRINTF (3, 4); 00128 00129 extern void ui_out_wrap_hint (struct ui_out *uiout, char *identstring); 00130 00131 extern void ui_out_flush (struct ui_out *uiout); 00132 00133 extern int ui_out_set_flags (struct ui_out *uiout, int mask); 00134 00135 extern int ui_out_clear_flags (struct ui_out *uiout, int mask); 00136 00137 extern int ui_out_get_verblvl (struct ui_out *uiout); 00138 00139 extern int ui_out_test_flags (struct ui_out *uiout, int mask); 00140 00141 extern int ui_out_query_field (struct ui_out *uiout, int colno, 00142 int *width, int *alignment, char **col_name); 00143 00144 /* HACK: Code in GDB is currently checking to see the type of ui_out 00145 builder when determining which output to produce. This function is 00146 a hack to encapsulate that test. Once GDB manages to separate the 00147 CLI/MI from the core of GDB the problem should just go away .... */ 00148 00149 extern int ui_out_is_mi_like_p (struct ui_out *uiout); 00150 00151 /* From here on we have things that are only needed by implementation 00152 routines and main.c. We should pehaps have a separate file for that, 00153 like a ui-out-impl.h file. */ 00154 00155 /* User Interface Output Implementation Function Table */ 00156 00157 /* Type definition of all implementation functions. */ 00158 00159 typedef void (table_begin_ftype) (struct ui_out * uiout, 00160 int nbrofcols, int nr_rows, 00161 const char *tblid); 00162 typedef void (table_body_ftype) (struct ui_out * uiout); 00163 typedef void (table_end_ftype) (struct ui_out * uiout); 00164 typedef void (table_header_ftype) (struct ui_out * uiout, int width, 00165 enum ui_align align, const char *col_name, 00166 const char *colhdr); 00167 /* Note: level 0 is the top-level so LEVEL is always greater than 00168 zero. */ 00169 typedef void (ui_out_begin_ftype) (struct ui_out *uiout, 00170 enum ui_out_type type, 00171 int level, const char *id); 00172 typedef void (ui_out_end_ftype) (struct ui_out *uiout, 00173 enum ui_out_type type, 00174 int level); 00175 typedef void (field_int_ftype) (struct ui_out * uiout, int fldno, int width, 00176 enum ui_align align, 00177 const char *fldname, int value); 00178 typedef void (field_skip_ftype) (struct ui_out * uiout, int fldno, int width, 00179 enum ui_align align, 00180 const char *fldname); 00181 typedef void (field_string_ftype) (struct ui_out * uiout, int fldno, int width, 00182 enum ui_align align, 00183 const char *fldname, 00184 const char *string); 00185 typedef void (field_fmt_ftype) (struct ui_out * uiout, int fldno, int width, 00186 enum ui_align align, 00187 const char *fldname, 00188 const char *format, 00189 va_list args) ATTRIBUTE_FPTR_PRINTF(6,0); 00190 typedef void (spaces_ftype) (struct ui_out * uiout, int numspaces); 00191 typedef void (text_ftype) (struct ui_out * uiout, 00192 const char *string); 00193 typedef void (message_ftype) (struct ui_out * uiout, int verbosity, 00194 const char *format, va_list args) 00195 ATTRIBUTE_FPTR_PRINTF(3,0); 00196 typedef void (wrap_hint_ftype) (struct ui_out * uiout, char *identstring); 00197 typedef void (flush_ftype) (struct ui_out * uiout); 00198 typedef int (redirect_ftype) (struct ui_out * uiout, 00199 struct ui_file * outstream); 00200 typedef void (data_destroy_ftype) (struct ui_out *uiout); 00201 00202 /* ui-out-impl */ 00203 00204 /* IMPORTANT: If you change this structure, make sure to change the default 00205 initialization in ui-out.c. */ 00206 00207 struct ui_out_impl 00208 { 00209 table_begin_ftype *table_begin; 00210 table_body_ftype *table_body; 00211 table_end_ftype *table_end; 00212 table_header_ftype *table_header; 00213 ui_out_begin_ftype *begin; 00214 ui_out_end_ftype *end; 00215 field_int_ftype *field_int; 00216 field_skip_ftype *field_skip; 00217 field_string_ftype *field_string; 00218 field_fmt_ftype *field_fmt; 00219 spaces_ftype *spaces; 00220 text_ftype *text; 00221 message_ftype *message; 00222 wrap_hint_ftype *wrap_hint; 00223 flush_ftype *flush; 00224 redirect_ftype *redirect; 00225 data_destroy_ftype *data_destroy; 00226 int is_mi_like_p; 00227 }; 00228 00229 extern void *ui_out_data (struct ui_out *uiout); 00230 00231 extern void uo_field_string (struct ui_out *uiout, int fldno, int width, 00232 enum ui_align align, const char *fldname, 00233 const char *string); 00234 00235 /* Create a ui_out object */ 00236 00237 extern struct ui_out *ui_out_new (struct ui_out_impl *impl, 00238 void *data, 00239 int flags); 00240 00241 /* Destroy a ui_out object. */ 00242 00243 extern void ui_out_destroy (struct ui_out *uiout); 00244 00245 /* Redirect the ouptut of a ui_out object temporarily. */ 00246 00247 extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream); 00248 00249 #endif /* UI_OUT_H */