valprint.h revision 1.8 1 1.1 christos /* Declarations for value printing routines for GDB, the GNU debugger.
2 1.1 christos
3 1.8 christos Copyright (C) 1986-2019 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #ifndef VALPRINT_H
21 1.1 christos #define VALPRINT_H
22 1.1 christos
23 1.1 christos /* This is used to pass formatting options to various value-printing
24 1.1 christos functions. */
25 1.1 christos struct value_print_options
26 1.1 christos {
27 1.1 christos /* Pretty-formatting control. */
28 1.1 christos enum val_prettyformat prettyformat;
29 1.1 christos
30 1.1 christos /* Controls pretty formatting of arrays. */
31 1.1 christos int prettyformat_arrays;
32 1.1 christos
33 1.1 christos /* Controls pretty formatting of structures. */
34 1.1 christos int prettyformat_structs;
35 1.1 christos
36 1.1 christos /* Controls printing of virtual tables. */
37 1.1 christos int vtblprint;
38 1.1 christos
39 1.1 christos /* Controls printing of nested unions. */
40 1.1 christos int unionprint;
41 1.1 christos
42 1.1 christos /* Controls printing of addresses. */
43 1.1 christos int addressprint;
44 1.1 christos
45 1.1 christos /* Controls looking up an object's derived type using what we find
46 1.1 christos in its vtables. */
47 1.1 christos int objectprint;
48 1.1 christos
49 1.1 christos /* Maximum number of chars to print for a string pointer value or vector
50 1.1 christos contents, or UINT_MAX for no limit. Note that "set print elements 0"
51 1.1 christos stores UINT_MAX in print_max, which displays in a show command as
52 1.1 christos "unlimited". */
53 1.1 christos unsigned int print_max;
54 1.1 christos
55 1.1 christos /* Print repeat counts if there are more than this many repetitions
56 1.1 christos of an element in an array. */
57 1.1 christos unsigned int repeat_count_threshold;
58 1.1 christos
59 1.1 christos /* The global output format letter. */
60 1.1 christos int output_format;
61 1.1 christos
62 1.1 christos /* The current format letter. This is set locally for a given call,
63 1.1 christos e.g. when the user passes a format to "print". */
64 1.1 christos int format;
65 1.1 christos
66 1.1 christos /* Stop printing at null character? */
67 1.1 christos int stop_print_at_null;
68 1.1 christos
69 1.1 christos /* True if we should print the index of each element when printing
70 1.1 christos an array. */
71 1.1 christos int print_array_indexes;
72 1.1 christos
73 1.1 christos /* If nonzero, then dereference references, otherwise just print
74 1.1 christos them like pointers. */
75 1.1 christos int deref_ref;
76 1.1 christos
77 1.1 christos /* If nonzero, print static fields. */
78 1.1 christos int static_field_print;
79 1.1 christos
80 1.7 christos /* If nonzero, print static fields for Pascal. FIXME: C++ has a
81 1.7 christos flag, why not share with Pascal too? */
82 1.1 christos int pascal_static_field_print;
83 1.1 christos
84 1.1 christos /* If non-zero don't do Python pretty-printing. */
85 1.1 christos int raw;
86 1.1 christos
87 1.1 christos /* If nonzero, print the value in "summary" form.
88 1.1 christos If raw and summary are both non-zero, don't print non-scalar values
89 1.1 christos ("..." is printed instead). */
90 1.1 christos int summary;
91 1.1 christos
92 1.1 christos /* If nonzero, when printing a pointer, print the symbol to which it
93 1.1 christos points, if any. */
94 1.1 christos int symbol_print;
95 1.1 christos };
96 1.1 christos
97 1.1 christos /* The global print options set by the user. In general this should
98 1.1 christos not be directly accessed, except by set/show commands. Ordinary
99 1.1 christos code should call get_user_print_options instead. */
100 1.1 christos extern struct value_print_options user_print_options;
101 1.1 christos
102 1.1 christos /* Initialize *OPTS to be a copy of the user print options. */
103 1.1 christos extern void get_user_print_options (struct value_print_options *opts);
104 1.1 christos
105 1.1 christos /* Initialize *OPTS to be a copy of the user print options, but with
106 1.1 christos pretty-formatting disabled. */
107 1.1 christos extern void get_no_prettyformat_print_options (struct value_print_options *);
108 1.1 christos
109 1.1 christos /* Initialize *OPTS to be a copy of the user print options, but using
110 1.1 christos FORMAT as the formatting option. */
111 1.1 christos extern void get_formatted_print_options (struct value_print_options *opts,
112 1.1 christos char format);
113 1.1 christos
114 1.1 christos extern void maybe_print_array_index (struct type *index_type, LONGEST index,
115 1.1 christos struct ui_file *stream,
116 1.1 christos const struct value_print_options *);
117 1.1 christos
118 1.7 christos extern void val_print_array_elements (struct type *, LONGEST,
119 1.1 christos CORE_ADDR, struct ui_file *, int,
120 1.7 christos struct value *,
121 1.1 christos const struct value_print_options *,
122 1.1 christos unsigned int);
123 1.1 christos
124 1.1 christos extern void val_print_scalar_formatted (struct type *,
125 1.7 christos LONGEST,
126 1.7 christos struct value *,
127 1.1 christos const struct value_print_options *,
128 1.1 christos int,
129 1.1 christos struct ui_file *);
130 1.1 christos
131 1.1 christos extern void print_binary_chars (struct ui_file *, const gdb_byte *,
132 1.8 christos unsigned int, enum bfd_endian, bool);
133 1.1 christos
134 1.1 christos extern void print_octal_chars (struct ui_file *, const gdb_byte *,
135 1.1 christos unsigned int, enum bfd_endian);
136 1.1 christos
137 1.1 christos extern void print_decimal_chars (struct ui_file *, const gdb_byte *,
138 1.8 christos unsigned int, bool, enum bfd_endian);
139 1.1 christos
140 1.1 christos extern void print_hex_chars (struct ui_file *, const gdb_byte *,
141 1.8 christos unsigned int, enum bfd_endian, bool);
142 1.1 christos
143 1.1 christos extern void print_char_chars (struct ui_file *, struct type *,
144 1.1 christos const gdb_byte *, unsigned int, enum bfd_endian);
145 1.1 christos
146 1.1 christos extern void print_function_pointer_address (const struct value_print_options *options,
147 1.1 christos struct gdbarch *gdbarch,
148 1.1 christos CORE_ADDR address,
149 1.1 christos struct ui_file *stream);
150 1.1 christos
151 1.1 christos extern int read_string (CORE_ADDR addr, int len, int width,
152 1.1 christos unsigned int fetchlimit,
153 1.8 christos enum bfd_endian byte_order,
154 1.8 christos gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
155 1.1 christos int *bytes_read);
156 1.1 christos
157 1.1 christos extern void val_print_optimized_out (const struct value *val,
158 1.1 christos struct ui_file *stream);
159 1.1 christos
160 1.1 christos /* Prints "<not saved>" to STREAM. */
161 1.1 christos extern void val_print_not_saved (struct ui_file *stream);
162 1.1 christos
163 1.1 christos extern void val_print_unavailable (struct ui_file *stream);
164 1.1 christos
165 1.1 christos extern void val_print_invalid_address (struct ui_file *stream);
166 1.1 christos
167 1.1 christos /* An instance of this is passed to generic_val_print and describes
168 1.1 christos some language-specific ways to print things. */
169 1.1 christos
170 1.1 christos struct generic_val_print_decorations
171 1.1 christos {
172 1.1 christos /* Printing complex numbers: what to print before, between the
173 1.1 christos elements, and after. */
174 1.1 christos
175 1.1 christos const char *complex_prefix;
176 1.1 christos const char *complex_infix;
177 1.1 christos const char *complex_suffix;
178 1.1 christos
179 1.1 christos /* Boolean true and false. */
180 1.1 christos
181 1.1 christos const char *true_name;
182 1.1 christos const char *false_name;
183 1.1 christos
184 1.1 christos /* What to print when we see TYPE_CODE_VOID. */
185 1.1 christos
186 1.1 christos const char *void_name;
187 1.6 christos
188 1.6 christos /* Array start and end strings. */
189 1.6 christos const char *array_start;
190 1.6 christos const char *array_end;
191 1.1 christos };
192 1.1 christos
193 1.1 christos
194 1.7 christos extern void generic_val_print (struct type *type,
195 1.1 christos int embedded_offset, CORE_ADDR address,
196 1.1 christos struct ui_file *stream, int recurse,
197 1.7 christos struct value *original_value,
198 1.1 christos const struct value_print_options *options,
199 1.1 christos const struct generic_val_print_decorations *);
200 1.1 christos
201 1.1 christos extern void generic_emit_char (int c, struct type *type, struct ui_file *stream,
202 1.1 christos int quoter, const char *encoding);
203 1.1 christos
204 1.1 christos extern void generic_printstr (struct ui_file *stream, struct type *type,
205 1.1 christos const gdb_byte *string, unsigned int length,
206 1.1 christos const char *encoding, int force_ellipses,
207 1.1 christos int quote_char, int c_style_terminator,
208 1.1 christos const struct value_print_options *options);
209 1.1 christos
210 1.1 christos /* Run the "output" command. ARGS and FROM_TTY are the usual
211 1.1 christos arguments passed to all command implementations, except ARGS is
212 1.1 christos const. */
213 1.1 christos
214 1.8 christos extern void output_command (const char *args, int from_tty);
215 1.1 christos
216 1.1 christos extern int val_print_scalar_type_p (struct type *type);
217 1.1 christos
218 1.5 christos struct format_data
219 1.5 christos {
220 1.5 christos int count;
221 1.5 christos char format;
222 1.5 christos char size;
223 1.5 christos
224 1.5 christos /* True if the value should be printed raw -- that is, bypassing
225 1.5 christos python-based formatters. */
226 1.5 christos unsigned char raw;
227 1.5 christos };
228 1.5 christos
229 1.5 christos extern void print_command_parse_format (const char **expp, const char *cmdname,
230 1.5 christos struct format_data *fmtp);
231 1.5 christos extern void print_value (struct value *val, const struct format_data *fmtp);
232 1.5 christos
233 1.8 christos /* Given an address ADDR return all the elements needed to print the
234 1.8 christos address in a symbolic form. NAME can be mangled or not depending
235 1.8 christos on DO_DEMANGLE (and also on the asm_demangle global variable,
236 1.8 christos manipulated via ''set print asm-demangle''). Return 0 in case of
237 1.8 christos success, when all the info in the OUT paramters is valid. Return 1
238 1.8 christos otherwise. */
239 1.8 christos
240 1.8 christos extern int build_address_symbolic (struct gdbarch *,
241 1.8 christos CORE_ADDR addr,
242 1.8 christos int do_demangle,
243 1.8 christos std::string *name,
244 1.8 christos int *offset,
245 1.8 christos std::string *filename,
246 1.8 christos int *line,
247 1.8 christos int *unmapped);
248 1.8 christos
249 1.1 christos #endif
250