[PATCH 12/57][Arm][GAS] Add support for MVE instructions: vaddlv and vaddv
[binutils-gdb.git] / gdb / ui-out.h
blob9eba70eedac646911e137348298fbc27d41ec048
1 /* Output generating routines for GDB.
3 Copyright (C) 1999-2019 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 3 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, see <http://www.gnu.org/licenses/>. */
23 #ifndef UI_OUT_H
24 #define UI_OUT_H 1
26 #include <vector>
28 #include "common/enum-flags.h"
30 class ui_out_level;
31 class ui_out_table;
32 struct ui_file;
34 /* the current ui_out */
36 /* FIXME: This should not be a global but something passed down from main.c
37 or top.c. */
38 extern struct ui_out **current_ui_current_uiout_ptr (void);
39 #define current_uiout (*current_ui_current_uiout_ptr ())
41 /* alignment enum */
42 enum ui_align
44 ui_left = -1,
45 ui_center,
46 ui_right,
47 ui_noalign
50 /* flags enum */
51 enum ui_out_flag
53 ui_source_list = (1 << 0),
54 fix_multi_location_breakpoint_output = (1 << 1),
57 DEF_ENUM_FLAGS_TYPE (ui_out_flag, ui_out_flags);
59 /* Prototypes for ui-out API. */
61 /* A result is a recursive data structure consisting of lists and
62 tuples. */
64 enum ui_out_type
66 ui_out_type_tuple,
67 ui_out_type_list
70 /* Possible kinds of styling. */
72 enum class ui_out_style_kind
74 /* The default (plain) style. */
75 DEFAULT,
76 /* File name. */
77 FILE,
78 /* Function name. */
79 FUNCTION,
80 /* Variable name. */
81 VARIABLE,
82 /* Address. */
83 ADDRESS
86 class ui_out
88 public:
90 explicit ui_out (ui_out_flags flags = 0);
91 virtual ~ui_out ();
93 void push_level (ui_out_type type);
94 void pop_level (ui_out_type type);
96 /* A table can be considered a special tuple/list combination with the
97 implied structure: ``table = { hdr = { header, ... } , body = [ {
98 field, ... }, ... ] }''. If NR_ROWS is negative then there is at
99 least one row. */
101 void table_begin (int nr_cols, int nr_rows, const std::string &tblid);
102 void table_header (int width, ui_align align, const std::string &col_name,
103 const std::string &col_hdr);
104 void table_body ();
105 void table_end ();
107 void begin (ui_out_type type, const char *id);
108 void end (ui_out_type type);
110 void field_int (const char *fldname, int value);
111 void field_fmt_int (int width, ui_align align, const char *fldname,
112 int value);
113 void field_core_addr (const char *fldname, struct gdbarch *gdbarch,
114 CORE_ADDR address);
115 void field_string (const char *fldname, const char *string,
116 ui_out_style_kind style = ui_out_style_kind::DEFAULT);
117 void field_string (const char *fldname, const std::string &string);
118 void field_stream (const char *fldname, string_file &stream,
119 ui_out_style_kind style = ui_out_style_kind::DEFAULT);
120 void field_skip (const char *fldname);
121 void field_fmt (const char *fldname, const char *format, ...)
122 ATTRIBUTE_PRINTF (3, 4);
124 void spaces (int numspaces);
125 void text (const char *string);
126 void message (const char *format, ...) ATTRIBUTE_PRINTF (2, 3);
127 void wrap_hint (const char *identstring);
129 void flush ();
131 /* Redirect the output of a ui_out object temporarily. */
132 void redirect (ui_file *outstream);
134 ui_out_flags test_flags (ui_out_flags mask);
136 /* HACK: Code in GDB is currently checking to see the type of ui_out
137 builder when determining which output to produce. This function is
138 a hack to encapsulate that test. Once GDB manages to separate the
139 CLI/MI from the core of GDB the problem should just go away .... */
141 bool is_mi_like_p () const;
143 bool query_table_field (int colno, int *width, int *alignment,
144 const char **col_name);
146 protected:
148 virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
149 = 0;
150 virtual void do_table_body () = 0;
151 virtual void do_table_end () = 0;
152 virtual void do_table_header (int width, ui_align align,
153 const std::string &col_name,
154 const std::string &col_hdr) = 0;
156 virtual void do_begin (ui_out_type type, const char *id) = 0;
157 virtual void do_end (ui_out_type type) = 0;
158 virtual void do_field_int (int fldno, int width, ui_align align,
159 const char *fldname, int value) = 0;
160 virtual void do_field_skip (int fldno, int width, ui_align align,
161 const char *fldname) = 0;
162 virtual void do_field_string (int fldno, int width, ui_align align,
163 const char *fldname, const char *string,
164 ui_out_style_kind style) = 0;
165 virtual void do_field_fmt (int fldno, int width, ui_align align,
166 const char *fldname, const char *format,
167 va_list args)
168 ATTRIBUTE_PRINTF (6,0) = 0;
169 virtual void do_spaces (int numspaces) = 0;
170 virtual void do_text (const char *string) = 0;
171 virtual void do_message (const char *format, va_list args)
172 ATTRIBUTE_PRINTF (2,0) = 0;
173 virtual void do_wrap_hint (const char *identstring) = 0;
174 virtual void do_flush () = 0;
175 virtual void do_redirect (struct ui_file *outstream) = 0;
177 /* Set as not MI-like by default. It is overridden in subclasses if
178 necessary. */
180 virtual bool do_is_mi_like_p () const
181 { return false; }
183 private:
185 ui_out_flags m_flags;
187 /* Vector to store and track the ui-out levels. */
188 std::vector<std::unique_ptr<ui_out_level>> m_levels;
190 /* A table, if any. At present only a single table is supported. */
191 std::unique_ptr<ui_out_table> m_table_up;
193 void verify_field (int *fldno, int *width, ui_align *align);
195 int level () const;
196 ui_out_level *current_level () const;
199 /* Start a new tuple or list on construction, and end it on
200 destruction. Normally this is used via the typedefs
201 ui_out_emit_tuple and ui_out_emit_list. */
202 template<ui_out_type Type>
203 class ui_out_emit_type
205 public:
207 ui_out_emit_type (struct ui_out *uiout, const char *id)
208 : m_uiout (uiout)
210 uiout->begin (Type, id);
213 ~ui_out_emit_type ()
215 m_uiout->end (Type);
218 DISABLE_COPY_AND_ASSIGN (ui_out_emit_type<Type>);
220 private:
222 struct ui_out *m_uiout;
225 typedef ui_out_emit_type<ui_out_type_tuple> ui_out_emit_tuple;
226 typedef ui_out_emit_type<ui_out_type_list> ui_out_emit_list;
228 /* Start a new table on construction, and end the table on
229 destruction. */
230 class ui_out_emit_table
232 public:
234 ui_out_emit_table (struct ui_out *uiout, int nr_cols, int nr_rows,
235 const char *tblid)
236 : m_uiout (uiout)
238 m_uiout->table_begin (nr_cols, nr_rows, tblid);
241 ~ui_out_emit_table ()
243 m_uiout->table_end ();
246 ui_out_emit_table (const ui_out_emit_table &) = delete;
247 ui_out_emit_table &operator= (const ui_out_emit_table &) = delete;
249 private:
251 struct ui_out *m_uiout;
254 /* On destruction, pop the last redirection by calling the uiout's
255 redirect method with a NULL parameter. */
256 class ui_out_redirect_pop
258 public:
260 ui_out_redirect_pop (ui_out *uiout)
261 : m_uiout (uiout)
265 ~ui_out_redirect_pop ()
267 m_uiout->redirect (NULL);
270 ui_out_redirect_pop (const ui_out_redirect_pop &) = delete;
271 ui_out_redirect_pop &operator= (const ui_out_redirect_pop &) = delete;
273 private:
274 struct ui_out *m_uiout;
277 #endif /* UI_OUT_H */