Bump GDB's version number to 15.0.91.DATE-git.
[binutils-gdb.git] / gdb / expprint.c
blob2d8bccd60c6598d9662045571b18ea42b9afdc32
1 /* Print in infix form a struct expression.
3 Copyright (C) 1986-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 #include "symtab.h"
21 #include "gdbtypes.h"
22 #include "expression.h"
23 #include "value.h"
24 #include "language.h"
25 #include "parser-defs.h"
26 #include "user-regs.h"
27 #include "target.h"
28 #include "block.h"
29 #include "objfiles.h"
30 #include "valprint.h"
31 #include "cli/cli-style.h"
32 #include "c-lang.h"
33 #include "expop.h"
34 #include "ada-exp.h"
36 #include <ctype.h>
38 /* Meant to be used in debug sessions, so don't export it in a header file. */
39 extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
41 /* Print EXP. */
43 void
44 ATTRIBUTE_USED
45 debug_exp (struct expression *exp)
47 exp->dump (gdb_stdlog);
48 gdb_flush (gdb_stdlog);
51 namespace expr
54 bool
55 check_objfile (const struct block *block, struct objfile *objfile)
57 return check_objfile (block->objfile (), objfile);
60 void
61 dump_for_expression (struct ui_file *stream, int depth, enum exp_opcode op)
63 gdb_printf (stream, _("%*sOperation: "), depth, "");
65 switch (op)
67 default:
68 gdb_printf (stream, "<unknown %d>", op);
69 break;
71 #define OP(name) \
72 case name: \
73 gdb_puts (#name, stream); \
74 break;
75 #include "std-operator.def"
76 #undef OP
79 gdb_puts ("\n", stream);
82 void
83 dump_for_expression (struct ui_file *stream, int depth, const std::string &str)
85 gdb_printf (stream, _("%*sString: %s\n"), depth, "", str.c_str ());
88 void
89 dump_for_expression (struct ui_file *stream, int depth, struct type *type)
91 gdb_printf (stream, _("%*sType: "), depth, "");
92 type_print (type, nullptr, stream, 0);
93 gdb_printf (stream, "\n");
96 void
97 dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr)
99 gdb_printf (stream, _("%*sConstant: %s\n"), depth, "",
100 core_addr_to_string (addr));
103 void
104 dump_for_expression (struct ui_file *stream, int depth, const gdb_mpz &val)
106 gdb_printf (stream, _("%*sConstant: %s\n"), depth, "", val.str ().c_str ());
109 void
110 dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar)
112 gdb_printf (stream, _("%*sInternalvar: $%s\n"), depth, "",
113 internalvar_name (ivar));
116 void
117 dump_for_expression (struct ui_file *stream, int depth, symbol *sym)
119 gdb_printf (stream, _("%*sSymbol: %s\n"), depth, "",
120 sym->print_name ());
121 dump_for_expression (stream, depth + 1, sym->type ());
124 void
125 dump_for_expression (struct ui_file *stream, int depth,
126 bound_minimal_symbol msym)
128 gdb_printf (stream, _("%*sMinsym %s in objfile %s\n"), depth, "",
129 msym.minsym->print_name (), objfile_name (msym.objfile));
132 void
133 dump_for_expression (struct ui_file *stream, int depth, const block *bl)
135 gdb_printf (stream, _("%*sBlock: %p\n"), depth, "", bl);
138 void
139 dump_for_expression (struct ui_file *stream, int depth,
140 const block_symbol &sym)
142 gdb_printf (stream, _("%*sBlock symbol:\n"), depth, "");
143 dump_for_expression (stream, depth + 1, sym.symbol);
144 dump_for_expression (stream, depth + 1, sym.block);
147 void
148 dump_for_expression (struct ui_file *stream, int depth,
149 type_instance_flags flags)
151 gdb_printf (stream, _("%*sType flags: "), depth, "");
152 if (flags & TYPE_INSTANCE_FLAG_CONST)
153 gdb_puts ("const ", stream);
154 if (flags & TYPE_INSTANCE_FLAG_VOLATILE)
155 gdb_puts ("volatile", stream);
156 gdb_printf (stream, "\n");
159 void
160 dump_for_expression (struct ui_file *stream, int depth,
161 enum c_string_type_values flags)
163 gdb_printf (stream, _("%*sC string flags: "), depth, "");
164 switch (flags & ~C_CHAR)
166 case C_WIDE_STRING:
167 gdb_puts (_("wide "), stream);
168 break;
169 case C_STRING_16:
170 gdb_puts (_("u16 "), stream);
171 break;
172 case C_STRING_32:
173 gdb_puts (_("u32 "), stream);
174 break;
175 default:
176 gdb_puts (_("ordinary "), stream);
177 break;
180 if ((flags & C_CHAR) != 0)
181 gdb_puts (_("char"), stream);
182 else
183 gdb_puts (_("string"), stream);
184 gdb_puts ("\n", stream);
187 void
188 dump_for_expression (struct ui_file *stream, int depth,
189 enum range_flag flags)
191 gdb_printf (stream, _("%*sRange:"), depth, "");
192 if ((flags & RANGE_LOW_BOUND_DEFAULT) != 0)
193 gdb_puts (_("low-default "), stream);
194 if ((flags & RANGE_HIGH_BOUND_DEFAULT) != 0)
195 gdb_puts (_("high-default "), stream);
196 if ((flags & RANGE_HIGH_BOUND_EXCLUSIVE) != 0)
197 gdb_puts (_("high-exclusive "), stream);
198 if ((flags & RANGE_HAS_STRIDE) != 0)
199 gdb_puts (_("has-stride"), stream);
200 gdb_printf (stream, "\n");
203 void
204 dump_for_expression (struct ui_file *stream, int depth,
205 const std::unique_ptr<ada_component> &comp)
207 comp->dump (stream, depth);
210 void
211 float_const_operation::dump (struct ui_file *stream, int depth) const
213 gdb_printf (stream, _("%*sFloat: "), depth, "");
214 print_floating (m_data.data (), m_type, stream);
215 gdb_printf (stream, "\n");
218 } /* namespace expr */