arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / python / py-uiout.h
blob5f8c53052cb7681b574140faf18795e371d65a93
1 /* Python implementation of ui_out
3 Copyright (C) 2023-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef GDB_PYTHON_PY_UIOUT_H
21 #define GDB_PYTHON_PY_UIOUT_H
23 #include "python-internal.h"
24 #include "ui-out.h"
26 /* A ui_out subclass that creates a Python object based on the data
27 that is passed in. */
29 class py_ui_out : public ui_out
31 public:
33 py_ui_out ()
34 : ui_out (fix_multi_location_breakpoint_output
35 | fix_breakpoint_script_output)
37 do_begin (ui_out_type_tuple, nullptr);
40 bool can_emit_style_escape () const override
41 { return false; }
43 bool do_is_mi_like_p () const override
44 { return true; }
46 /* Return the Python object that was created. If a Python error
47 occurred during the processing, set the Python error and return
48 nullptr. */
49 gdbpy_ref<> result ()
51 if (m_error.has_value ())
53 m_error->restore ();
54 return nullptr;
56 return std::move (current ().obj);
59 ui_file *current_stream () const override
60 { return nullptr; }
62 protected:
64 void do_progress_end () override { }
65 void do_progress_start () override { }
66 void do_progress_notify (const std::string &, const char *, double, double)
67 override
68 { }
70 void do_table_begin (int nbrofcols, int nr_rows, const char *tblid) override
72 do_begin (ui_out_type_list, tblid);
74 void do_table_body () override
75 { }
76 void do_table_end () override
78 do_end (ui_out_type_list);
80 void do_table_header (int width, ui_align align,
81 const std::string &col_name,
82 const std::string &col_hdr) override
83 { }
85 void do_begin (ui_out_type type, const char *id) override;
86 void do_end (ui_out_type type) override;
88 void do_field_signed (int fldno, int width, ui_align align,
89 const char *fldname, LONGEST value,
90 const ui_file_style &style) override;
91 void do_field_unsigned (int fldno, int width, ui_align align,
92 const char *fldname, ULONGEST value) override;
94 void do_field_skip (int fldno, int width, ui_align align,
95 const char *fldname) override
96 { }
98 void do_field_string (int fldno, int width, ui_align align,
99 const char *fldname, const char *string,
100 const ui_file_style &style) override;
101 void do_field_fmt (int fldno, int width, ui_align align,
102 const char *fldname, const ui_file_style &style,
103 const char *format, va_list args) override
104 ATTRIBUTE_PRINTF (7, 0);
106 void do_spaces (int numspaces) override
109 void do_text (const char *string) override
112 void do_message (const ui_file_style &style,
113 const char *format, va_list args)
114 override ATTRIBUTE_PRINTF (3,0)
117 void do_wrap_hint (int indent) override
120 void do_flush () override
123 void do_redirect (struct ui_file *outstream) override
126 private:
128 /* When constructing Python objects, this class keeps a stack of
129 objects being constructed. Each such object has this type. */
130 struct object_desc
132 /* Name of the field (or empty for lists) that this object will
133 eventually become. */
134 std::string field_name;
135 /* The object under construction. */
136 gdbpy_ref<> obj;
137 /* The type of structure being created. Note that tables are
138 treated as lists here. */
139 ui_out_type type;
142 /* The stack of objects being created. */
143 std::vector<object_desc> m_objects;
145 /* If an error occurred, this holds the exception information for
146 use by the 'release' method. */
147 std::optional<gdbpy_err_fetch> m_error;
149 /* Return a reference to the object under construction. */
150 object_desc &current ()
151 { return m_objects.back (); }
153 /* Add a new field to the current object under construction. */
154 void add_field (const char *name, const gdbpy_ref<> &obj);
157 #endif /* GDB_PYTHON_PY_UIOUT_H */