GDB (xrefs)
Loading...
Searching...
No Matches
valprint.c
Go to the documentation of this file.
1/* Print values for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "symtab.h"
22#include "gdbtypes.h"
23#include "value.h"
24#include "gdbcore.h"
25#include "gdbcmd.h"
26#include "target.h"
27#include "language.h"
28#include "annotate.h"
29#include "valprint.h"
30#include "target-float.h"
31#include "extension.h"
32#include "ada-lang.h"
33#include "gdbsupport/gdb_obstack.h"
34#include "charset.h"
35#include "typeprint.h"
36#include <ctype.h>
37#include <algorithm>
38#include "gdbsupport/byte-vector.h"
39#include "cli/cli-option.h"
40#include "gdbarch.h"
41#include "cli/cli-style.h"
42#include "count-one-bits.h"
43#include "c-lang.h"
44#include "cp-abi.h"
45#include "inferior.h"
46#include "gdbsupport/selftest.h"
47#include "selftest-arch.h"
48
49/* Maximum number of wchars returned from wchar_iterate. */
50#define MAX_WCHARS 4
51
52/* A convenience macro to compute the size of a wchar_t buffer containing X
53 characters. */
54#define WCHAR_BUFLEN(X) ((X) * sizeof (gdb_wchar_t))
55
56/* Character buffer size saved while iterating over wchars. */
57#define WCHAR_BUFLEN_MAX WCHAR_BUFLEN (MAX_WCHARS)
58
59/* A structure to encapsulate state information from iterated
60 character conversions. */
62{
63 /* The number of characters converted. */
65
66 /* The result of the conversion. See charset.h for more. */
68
69 /* The (saved) converted character(s). */
71
72 /* The first converted target byte. */
73 const gdb_byte *buf;
74
75 /* The number of bytes converted. */
76 size_t buflen;
77
78 /* How many times this character(s) is repeated. */
80};
81
82/* Command lists for set/show print raw. */
85
86/* Prototypes for local functions */
87
88static void set_input_radix_1 (int, unsigned);
89
90static void set_output_radix_1 (int, unsigned);
91
92static void val_print_type_code_flags (struct type *type,
93 struct value *original_value,
94 int embedded_offset,
95 struct ui_file *stream);
96
97#define PRINT_MAX_DEFAULT 200 /* Start print_max off at this value. */
98#define PRINT_MAX_DEPTH_DEFAULT 20 /* Start print_max_depth off at this value. */
99
101{
102 Val_prettyformat_default, /* prettyformat */
103 0, /* prettyformat_arrays */
104 0, /* prettyformat_structs */
105 0, /* vtblprint */
106 1, /* unionprint */
107 1, /* addressprint */
108 false, /* nibblesprint */
109 0, /* objectprint */
110 PRINT_MAX_DEFAULT, /* print_max */
111 10, /* repeat_count_threshold */
112 0, /* output_format */
113 0, /* format */
114 1, /* memory_tag_violations */
115 0, /* stop_print_at_null */
116 0, /* print_array_indexes */
117 0, /* deref_ref */
118 1, /* static_field_print */
119 1, /* pascal_static_field_print */
120 0, /* raw */
121 0, /* summary */
122 1, /* symbol_print */
123 PRINT_MAX_DEPTH_DEFAULT, /* max_depth */
124};
125
126/* Initialize *OPTS to be a copy of the user print options. */
127void
129{
130 *opts = user_print_options;
131}
132
133/* Initialize *OPTS to be a copy of the user print options, but with
134 pretty-formatting disabled. */
135void
137{
138 *opts = user_print_options;
139 opts->prettyformat = Val_no_prettyformat;
140}
141
142/* Initialize *OPTS to be a copy of the user print options, but using
143 FORMAT as the formatting option. */
144void
146 char format)
147{
148 *opts = user_print_options;
149 opts->format = format;
150}
151
152static void
153show_print_max (struct ui_file *file, int from_tty,
154 struct cmd_list_element *c, const char *value)
155{
156 gdb_printf (file,
157 _("Limit on string chars or array "
158 "elements to print is %s.\n"),
159 value);
160}
161
162
163/* Default input and output radixes, and output format letter. */
164
165unsigned input_radix = 10;
166static void
167show_input_radix (struct ui_file *file, int from_tty,
168 struct cmd_list_element *c, const char *value)
169{
170 gdb_printf (file,
171 _("Default input radix for entering numbers is %s.\n"),
172 value);
173}
174
175unsigned output_radix = 10;
176static void
177show_output_radix (struct ui_file *file, int from_tty,
178 struct cmd_list_element *c, const char *value)
179{
180 gdb_printf (file,
181 _("Default output radix for printing of values is %s.\n"),
182 value);
183}
184
185/* By default we print arrays without printing the index of each element in
186 the array. This behavior can be changed by setting PRINT_ARRAY_INDEXES. */
187
188static void
189show_print_array_indexes (struct ui_file *file, int from_tty,
190 struct cmd_list_element *c, const char *value)
191{
192 gdb_printf (file, _("Printing of array indexes is %s.\n"), value);
193}
194
195/* Print repeat counts if there are more than this many repetitions of an
196 element in an array. Referenced by the low level language dependent
197 print routines. */
198
199static void
200show_repeat_count_threshold (struct ui_file *file, int from_tty,
201 struct cmd_list_element *c, const char *value)
202{
203 gdb_printf (file, _("Threshold for repeated print elements is %s.\n"),
204 value);
205}
206
207/* If nonzero, prints memory tag violations for pointers. */
208
209static void
210show_memory_tag_violations (struct ui_file *file, int from_tty,
211 struct cmd_list_element *c, const char *value)
212{
213 gdb_printf (file,
214 _("Printing of memory tag violations is %s.\n"),
215 value);
216}
217
218/* If nonzero, stops printing of char arrays at first null. */
219
220static void
221show_stop_print_at_null (struct ui_file *file, int from_tty,
222 struct cmd_list_element *c, const char *value)
223{
224 gdb_printf (file,
225 _("Printing of char arrays to stop "
226 "at first null char is %s.\n"),
227 value);
228}
229
230/* Controls pretty printing of structures. */
231
232static void
233show_prettyformat_structs (struct ui_file *file, int from_tty,
234 struct cmd_list_element *c, const char *value)
235{
236 gdb_printf (file, _("Pretty formatting of structures is %s.\n"), value);
237}
238
239/* Controls pretty printing of arrays. */
240
241static void
242show_prettyformat_arrays (struct ui_file *file, int from_tty,
243 struct cmd_list_element *c, const char *value)
244{
245 gdb_printf (file, _("Pretty formatting of arrays is %s.\n"), value);
246}
247
248/* If nonzero, causes unions inside structures or other unions to be
249 printed. */
250
251static void
252show_unionprint (struct ui_file *file, int from_tty,
253 struct cmd_list_element *c, const char *value)
254{
255 gdb_printf (file,
256 _("Printing of unions interior to structures is %s.\n"),
257 value);
258}
259
260/* Controls the format of printing binary values. */
261
262static void
263show_nibbles (struct ui_file *file, int from_tty,
264 struct cmd_list_element *c, const char *value)
265{
266 gdb_printf (file,
267 _("Printing binary values in groups is %s.\n"),
268 value);
269}
270
271/* If nonzero, causes machine addresses to be printed in certain contexts. */
272
273static void
274show_addressprint (struct ui_file *file, int from_tty,
275 struct cmd_list_element *c, const char *value)
276{
277 gdb_printf (file, _("Printing of addresses is %s.\n"), value);
278}
279
280static void
281show_symbol_print (struct ui_file *file, int from_tty,
282 struct cmd_list_element *c, const char *value)
283{
284 gdb_printf (file,
285 _("Printing of symbols when printing pointers is %s.\n"),
286 value);
287}
288
289
290
291/* A helper function for val_print. When printing in "summary" mode,
292 we want to print scalar arguments, but not aggregate arguments.
293 This function distinguishes between the two. */
294
295int
297{
299 while (TYPE_IS_REFERENCE (type))
300 {
301 type = type->target_type ();
303 }
304 switch (type->code ())
305 {
306 case TYPE_CODE_ARRAY:
307 case TYPE_CODE_STRUCT:
308 case TYPE_CODE_UNION:
309 case TYPE_CODE_SET:
310 case TYPE_CODE_STRING:
311 return 0;
312 default:
313 return 1;
314 }
315}
316
317/* A helper function for val_print. When printing with limited depth we
318 want to print string and scalar arguments, but not aggregate arguments.
319 This function distinguishes between the two. */
320
321static bool
323 const struct language_defn *language)
324{
326 || language->is_string_type_p (type));
327}
328
329/* See valprint.h. */
330
331int
333 struct type *type,
334 LONGEST embedded_offset,
335 const struct value *val)
336{
338
340 {
342 return 0;
343 }
344
346 {
348 return 0;
349 }
350
351 if (type->code () != TYPE_CODE_UNION
352 && type->code () != TYPE_CODE_STRUCT
353 && type->code () != TYPE_CODE_ARRAY)
354 {
356 TARGET_CHAR_BIT * embedded_offset,
357 TARGET_CHAR_BIT * type->length ()))
358 {
359 val_print_optimized_out (val, stream);
360 return 0;
361 }
362
363 if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset,
364 TARGET_CHAR_BIT * type->length ()))
365 {
366 const int is_ref = type->code () == TYPE_CODE_REF;
367 int ref_is_addressable = 0;
368
369 if (is_ref)
370 {
371 const struct value *deref_val = coerce_ref_if_computed (val);
372
373 if (deref_val != NULL)
374 ref_is_addressable = value_lval_const (deref_val) == lval_memory;
375 }
376
377 if (!is_ref || !ref_is_addressable)
378 fputs_styled (_("<synthetic pointer>"), metadata_style.style (),
379 stream);
380
381 /* C++ references should be valid even if they're synthetic. */
382 return is_ref;
383 }
384
386 {
387 val_print_unavailable (stream);
388 return 0;
389 }
390 }
391
392 return 1;
393}
394
395void
396val_print_optimized_out (const struct value *val, struct ui_file *stream)
397{
398 if (val != NULL && value_lval_const (val) == lval_register)
399 val_print_not_saved (stream);
400 else
401 fprintf_styled (stream, metadata_style.style (), _("<optimized out>"));
402}
403
404void
406{
407 fprintf_styled (stream, metadata_style.style (), _("<not saved>"));
408}
409
410void
412{
413 fprintf_styled (stream, metadata_style.style (), _("<unavailable>"));
414}
415
416void
418{
419 fprintf_styled (stream, metadata_style.style (), _("<invalid address>"));
420}
421
422/* Print a pointer based on the type of its target.
423
424 Arguments to this functions are roughly the same as those in
425 generic_val_print. A difference is that ADDRESS is the address to print,
426 with embedded_offset already added. ELTTYPE represents
427 the pointed type after check_typedef. */
428
429static void
430print_unpacked_pointer (struct type *type, struct type *elttype,
431 CORE_ADDR address, struct ui_file *stream,
432 const struct value_print_options *options)
433{
434 struct gdbarch *gdbarch = type->arch ();
435
436 if (elttype->code () == TYPE_CODE_FUNC)
437 {
438 /* Try to print what function it points to. */
439 print_function_pointer_address (options, gdbarch, address, stream);
440 return;
441 }
442
443 if (options->symbol_print)
444 print_address_demangle (options, gdbarch, address, stream, demangle);
445 else if (options->addressprint)
446 gdb_puts (paddress (gdbarch, address), stream);
447}
448
449/* generic_val_print helper for TYPE_CODE_ARRAY. */
450
451static void
453 struct ui_file *stream, int recurse,
454 const struct value_print_options *options,
455 const struct
457{
458 struct type *type = check_typedef (value_type (val));
459 struct type *unresolved_elttype = type->target_type ();
460 struct type *elttype = check_typedef (unresolved_elttype);
461
462 if (type->length () > 0 && unresolved_elttype->length () > 0)
463 {
464 LONGEST low_bound, high_bound;
465
466 if (!get_array_bounds (type, &low_bound, &high_bound))
467 error (_("Could not determine the array high bound"));
468
469 gdb_puts (decorations->array_start, stream);
470 value_print_array_elements (val, stream, recurse, options, 0);
471 gdb_puts (decorations->array_end, stream);
472 }
473 else
474 {
475 /* Array of unspecified length: treat like pointer to first elt. */
477 stream, options);
478 }
479
480}
481
482/* generic_value_print helper for TYPE_CODE_PTR. */
483
484static void
485generic_value_print_ptr (struct value *val, struct ui_file *stream,
486 const struct value_print_options *options)
487{
488
489 if (options->format && options->format != 's')
490 value_print_scalar_formatted (val, options, 0, stream);
491 else
492 {
493 struct type *type = check_typedef (value_type (val));
494 struct type *elttype = check_typedef (type->target_type ());
495 const gdb_byte *valaddr = value_contents_for_printing (val).data ();
496 CORE_ADDR addr = unpack_pointer (type, valaddr);
497
498 print_unpacked_pointer (type, elttype, addr, stream, options);
499 }
500}
501
502
503/* Print '@' followed by the address contained in ADDRESS_BUFFER. */
504
505static void
506print_ref_address (struct type *type, const gdb_byte *address_buffer,
507 int embedded_offset, struct ui_file *stream)
508{
509 struct gdbarch *gdbarch = type->arch ();
510
511 if (address_buffer != NULL)
512 {
513 CORE_ADDR address
514 = extract_typed_address (address_buffer + embedded_offset, type);
515
516 gdb_printf (stream, "@");
517 gdb_puts (paddress (gdbarch, address), stream);
518 }
519 /* Else: we have a non-addressable value, such as a DW_AT_const_value. */
520}
521
522/* If VAL is addressable, return the value contents buffer of a value that
523 represents a pointer to VAL. Otherwise return NULL. */
524
525static const gdb_byte *
527{
528 gdb_assert (deref_val != NULL);
529
530 if (value_lval_const (deref_val) == lval_memory)
531 return value_contents_for_printing_const (value_addr (deref_val)).data ();
532 else
533 {
534 /* We have a non-addressable value, such as a DW_AT_const_value. */
535 return NULL;
536 }
537}
538
539/* generic_val_print helper for TYPE_CODE_{RVALUE_,}REF. */
540
541static void
543 int embedded_offset, struct ui_file *stream, int recurse,
544 struct value *original_value,
545 const struct value_print_options *options)
546{
547 struct type *elttype = check_typedef (type->target_type ());
548 struct value *deref_val = NULL;
549 const int value_is_synthetic
550 = value_bits_synthetic_pointer (original_value,
551 TARGET_CHAR_BIT * embedded_offset,
552 TARGET_CHAR_BIT * type->length ());
553 const int must_coerce_ref = ((options->addressprint && value_is_synthetic)
554 || options->deref_ref);
555 const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF;
556 const gdb_byte *valaddr = value_contents_for_printing (original_value).data ();
557
558 if (must_coerce_ref && type_is_defined)
559 {
560 deref_val = coerce_ref_if_computed (original_value);
561
562 if (deref_val != NULL)
563 {
564 /* More complicated computed references are not supported. */
565 gdb_assert (embedded_offset == 0);
566 }
567 else
568 deref_val = value_at (type->target_type (),
569 unpack_pointer (type, valaddr + embedded_offset));
570 }
571 /* Else, original_value isn't a synthetic reference or we don't have to print
572 the reference's contents.
573
574 Notice that for references to TYPE_CODE_STRUCT, 'set print object on' will
575 cause original_value to be a not_lval instead of an lval_computed,
576 which will make value_bits_synthetic_pointer return false.
577 This happens because if options->objectprint is true, c_value_print will
578 overwrite original_value's contents with the result of coercing
579 the reference through value_addr, and then set its type back to
580 TYPE_CODE_REF. In that case we don't have to coerce the reference again;
581 we can simply treat it as non-synthetic and move on. */
582
583 if (options->addressprint)
584 {
585 const gdb_byte *address = (value_is_synthetic && type_is_defined
586 ? get_value_addr_contents (deref_val)
587 : valaddr);
588
590
591 if (options->deref_ref)
592 gdb_puts (": ", stream);
593 }
594
595 if (options->deref_ref)
596 {
597 if (type_is_defined)
598 common_val_print (deref_val, stream, recurse, options,
600 else
601 gdb_puts ("???", stream);
602 }
603}
604
605/* Helper function for generic_val_print_enum.
606 This is also used to print enums in TYPE_CODE_FLAGS values. */
607
608static void
609generic_val_print_enum_1 (struct type *type, LONGEST val,
610 struct ui_file *stream)
611{
612 unsigned int i;
613 unsigned int len;
614
615 len = type->num_fields ();
616 for (i = 0; i < len; i++)
617 {
618 QUIT;
619 if (val == type->field (i).loc_enumval ())
620 {
621 break;
622 }
623 }
624 if (i < len)
625 {
627 stream);
628 }
629 else if (type->is_flag_enum ())
630 {
631 int first = 1;
632
633 /* We have a "flag" enum, so we try to decompose it into pieces as
634 appropriate. The enum may have multiple enumerators representing
635 the same bit, in which case we choose to only print the first one
636 we find. */
637 for (i = 0; i < len; ++i)
638 {
639 QUIT;
640
641 ULONGEST enumval = type->field (i).loc_enumval ();
642 int nbits = count_one_bits_ll (enumval);
643
644 gdb_assert (nbits == 0 || nbits == 1);
645
646 if ((val & enumval) != 0)
647 {
648 if (first)
649 {
650 gdb_puts ("(", stream);
651 first = 0;
652 }
653 else
654 gdb_puts (" | ", stream);
655
656 val &= ~type->field (i).loc_enumval ();
657 fputs_styled (type->field (i).name (),
658 variable_name_style.style (), stream);
659 }
660 }
661
662 if (val != 0)
663 {
664 /* There are leftover bits, print them. */
665 if (first)
666 gdb_puts ("(", stream);
667 else
668 gdb_puts (" | ", stream);
669
670 gdb_puts ("unknown: 0x", stream);
671 print_longest (stream, 'x', 0, val);
672 gdb_puts (")", stream);
673 }
674 else if (first)
675 {
676 /* Nothing has been printed and the value is 0, the enum value must
677 have been 0. */
678 gdb_puts ("0", stream);
679 }
680 else
681 {
682 /* Something has been printed, close the parenthesis. */
683 gdb_puts (")", stream);
684 }
685 }
686 else
687 print_longest (stream, 'd', 0, val);
688}
689
690/* generic_val_print helper for TYPE_CODE_ENUM. */
691
692static void
694 int embedded_offset, struct ui_file *stream,
695 struct value *original_value,
696 const struct value_print_options *options)
697{
698 LONGEST val;
699 struct gdbarch *gdbarch = type->arch ();
701
702 gdb_assert (!options->format);
703
704 const gdb_byte *valaddr = value_contents_for_printing (original_value).data ();
705
706 val = unpack_long (type, valaddr + embedded_offset * unit_size);
707
708 generic_val_print_enum_1 (type, val, stream);
709}
710
711/* generic_val_print helper for TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
712
713static void
715 int embedded_offset, CORE_ADDR address,
716 struct ui_file *stream,
717 struct value *original_value,
718 const struct value_print_options *options)
719{
720 struct gdbarch *gdbarch = type->arch ();
721
722 gdb_assert (!options->format);
723
724 /* FIXME, we should consider, at least for ANSI C language,
725 eliminating the distinction made between FUNCs and POINTERs to
726 FUNCs. */
727 gdb_printf (stream, "{");
728 type_print (type, "", stream, -1);
729 gdb_printf (stream, "} ");
730 /* Try to print what function it points to, and its address. */
731 print_address_demangle (options, gdbarch, address, stream, demangle);
732}
733
734/* generic_value_print helper for TYPE_CODE_BOOL. */
735
736static void
738 (struct value *value, struct ui_file *stream,
739 const struct value_print_options *options,
740 const struct generic_val_print_decorations *decorations)
741{
742 if (options->format || options->output_format)
743 {
744 struct value_print_options opts = *options;
745 opts.format = (options->format ? options->format
746 : options->output_format);
747 value_print_scalar_formatted (value, &opts, 0, stream);
748 }
749 else
750 {
751 const gdb_byte *valaddr = value_contents_for_printing (value).data ();
752 struct type *type = check_typedef (value_type (value));
753 LONGEST val = unpack_long (type, valaddr);
754 if (val == 0)
755 gdb_puts (decorations->false_name, stream);
756 else if (val == 1)
757 gdb_puts (decorations->true_name, stream);
758 else
759 print_longest (stream, 'd', 0, val);
760 }
761}
762
763/* generic_value_print helper for TYPE_CODE_INT. */
764
765static void
766generic_value_print_int (struct value *val, struct ui_file *stream,
767 const struct value_print_options *options)
768{
769 struct value_print_options opts = *options;
770
771 opts.format = (options->format ? options->format
772 : options->output_format);
773 value_print_scalar_formatted (val, &opts, 0, stream);
774}
775
776/* generic_value_print helper for TYPE_CODE_CHAR. */
777
778static void
780 const struct value_print_options *options)
781{
782 if (options->format || options->output_format)
783 {
784 struct value_print_options opts = *options;
785
786 opts.format = (options->format ? options->format
787 : options->output_format);
788 value_print_scalar_formatted (value, &opts, 0, stream);
789 }
790 else
791 {
792 struct type *unresolved_type = value_type (value);
793 struct type *type = check_typedef (unresolved_type);
794 const gdb_byte *valaddr = value_contents_for_printing (value).data ();
795
796 LONGEST val = unpack_long (type, valaddr);
797 if (type->is_unsigned ())
798 gdb_printf (stream, "%u", (unsigned int) val);
799 else
800 gdb_printf (stream, "%d", (int) val);
801 gdb_puts (" ", stream);
802 current_language->printchar (val, unresolved_type, stream);
803 }
804}
805
806/* generic_val_print helper for TYPE_CODE_FLT and TYPE_CODE_DECFLOAT. */
807
808static void
809generic_val_print_float (struct type *type, struct ui_file *stream,
810 struct value *original_value,
811 const struct value_print_options *options)
812{
813 gdb_assert (!options->format);
814
815 const gdb_byte *valaddr = value_contents_for_printing (original_value).data ();
816
817 print_floating (valaddr, type, stream);
818}
819
820/* generic_val_print helper for TYPE_CODE_FIXED_POINT. */
821
822static void
823generic_val_print_fixed_point (struct value *val, struct ui_file *stream,
824 const struct value_print_options *options)
825{
826 if (options->format)
827 value_print_scalar_formatted (val, options, 0, stream);
828 else
829 {
830 struct type *type = value_type (val);
831
832 const gdb_byte *valaddr = value_contents_for_printing (val).data ();
833 gdb_mpf f;
834
835 f.read_fixed_point (gdb::make_array_view (valaddr, type->length ()),
838
839 const char *fmt = type->length () < 4 ? "%.11Fg" : "%.17Fg";
840 std::string str = gmp_string_printf (fmt, f.val);
841 gdb_printf (stream, "%s", str.c_str ());
842 }
843}
844
845/* generic_value_print helper for TYPE_CODE_COMPLEX. */
846
847static void
848generic_value_print_complex (struct value *val, struct ui_file *stream,
849 const struct value_print_options *options,
851 *decorations)
852{
853 gdb_printf (stream, "%s", decorations->complex_prefix);
854
855 struct value *real_part = value_real_part (val);
856 value_print_scalar_formatted (real_part, options, 0, stream);
857 gdb_printf (stream, "%s", decorations->complex_infix);
858
859 struct value *imag_part = value_imaginary_part (val);
860 value_print_scalar_formatted (imag_part, options, 0, stream);
861 gdb_printf (stream, "%s", decorations->complex_suffix);
862}
863
864/* generic_value_print helper for TYPE_CODE_MEMBERPTR. */
865
866static void
868 (struct value *val, struct ui_file *stream,
869 int recurse,
870 const struct value_print_options *options,
871 const struct generic_val_print_decorations *decorations)
872{
873 if (!options->format)
874 {
875 /* Member pointers are essentially specific to C++, and so if we
876 encounter one, we should print it according to C++ rules. */
877 struct type *type = check_typedef (value_type (val));
878 const gdb_byte *valaddr = value_contents_for_printing (val).data ();
879 cp_print_class_member (valaddr, type, stream, "&");
880 }
881 else
882 value_print_scalar_formatted (val, options, 0, stream);
883}
884
885/* See valprint.h. */
886
887void
888generic_value_print (struct value *val, struct ui_file *stream, int recurse,
889 const struct value_print_options *options,
890 const struct generic_val_print_decorations *decorations)
891{
892 struct type *type = value_type (val);
893
895
898
899 /* Widen a subrange to its target type, then use that type's
900 printer. */
901 while (type->code () == TYPE_CODE_RANGE)
902 {
904 val = value_cast (type, val);
905 }
906
907 switch (type->code ())
908 {
909 case TYPE_CODE_ARRAY:
910 generic_val_print_array (val, stream, recurse, options, decorations);
911 break;
912
913 case TYPE_CODE_MEMBERPTR:
914 generic_value_print_memberptr (val, stream, recurse, options,
915 decorations);
916 break;
917
918 case TYPE_CODE_PTR:
919 generic_value_print_ptr (val, stream, options);
920 break;
921
922 case TYPE_CODE_REF:
923 case TYPE_CODE_RVALUE_REF:
924 generic_val_print_ref (type, 0, stream, recurse,
925 val, options);
926 break;
927
928 case TYPE_CODE_ENUM:
929 if (options->format)
930 value_print_scalar_formatted (val, options, 0, stream);
931 else
932 generic_val_print_enum (type, 0, stream, val, options);
933 break;
934
935 case TYPE_CODE_FLAGS:
936 if (options->format)
937 value_print_scalar_formatted (val, options, 0, stream);
938 else
939 val_print_type_code_flags (type, val, 0, stream);
940 break;
941
942 case TYPE_CODE_FUNC:
943 case TYPE_CODE_METHOD:
944 if (options->format)
945 value_print_scalar_formatted (val, options, 0, stream);
946 else
947 generic_val_print_func (type, 0, value_address (val), stream,
948 val, options);
949 break;
950
951 case TYPE_CODE_BOOL:
952 generic_value_print_bool (val, stream, options, decorations);
953 break;
954
955 case TYPE_CODE_INT:
956 generic_value_print_int (val, stream, options);
957 break;
958
959 case TYPE_CODE_CHAR:
960 generic_value_print_char (val, stream, options);
961 break;
962
963 case TYPE_CODE_FLT:
964 case TYPE_CODE_DECFLOAT:
965 if (options->format)
966 value_print_scalar_formatted (val, options, 0, stream);
967 else
968 generic_val_print_float (type, stream, val, options);
969 break;
970
971 case TYPE_CODE_FIXED_POINT:
972 generic_val_print_fixed_point (val, stream, options);
973 break;
974
975 case TYPE_CODE_VOID:
976 gdb_puts (decorations->void_name, stream);
977 break;
978
979 case TYPE_CODE_ERROR:
980 gdb_printf (stream, "%s", TYPE_ERROR_NAME (type));
981 break;
982
983 case TYPE_CODE_UNDEF:
984 /* This happens (without TYPE_STUB set) on systems which don't use
985 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
986 and no complete type for struct foo in that file. */
987 fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
988 break;
989
990 case TYPE_CODE_COMPLEX:
991 generic_value_print_complex (val, stream, options, decorations);
992 break;
993
994 case TYPE_CODE_METHODPTR:
996 stream);
997 break;
998
999 case TYPE_CODE_UNION:
1000 case TYPE_CODE_STRUCT:
1001 default:
1002 error (_("Unhandled type code %d in symbol table."),
1003 type->code ());
1004 }
1005}
1006
1007/* Print using the given LANGUAGE the value VAL onto stream STREAM according
1008 to OPTIONS.
1009
1010 This is a preferable interface to val_print, above, because it uses
1011 GDB's value mechanism. */
1012
1013void
1014common_val_print (struct value *value, struct ui_file *stream, int recurse,
1015 const struct value_print_options *options,
1016 const struct language_defn *language)
1017{
1018 if (language->la_language == language_ada)
1019 /* The value might have a dynamic type, which would cause trouble
1020 below when trying to extract the value contents (since the value
1021 size is determined from the type size which is unknown). So
1022 get a fixed representation of our value. */
1024
1025 if (value_lazy (value))
1027
1028 struct value_print_options local_opts = *options;
1029 struct type *type = value_type (value);
1030 struct type *real_type = check_typedef (type);
1031
1032 if (local_opts.prettyformat == Val_prettyformat_default)
1033 local_opts.prettyformat = (local_opts.prettyformat_structs
1035
1036 QUIT;
1037
1038 /* Ensure that the type is complete and not just a stub. If the type is
1039 only a stub and we can't find and substitute its complete type, then
1040 print appropriate string and return. */
1041
1042 if (real_type->is_stub ())
1043 {
1044 fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
1045 return;
1046 }
1047
1048 if (!valprint_check_validity (stream, real_type, 0, value))
1049 return;
1050
1051 if (!options->raw)
1052 {
1053 if (apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
1054 language))
1055 return;
1056 }
1057
1058 /* Handle summary mode. If the value is a scalar, print it;
1059 otherwise, print an ellipsis. */
1060 if (options->summary && !val_print_scalar_type_p (type))
1061 {
1062 gdb_printf (stream, "...");
1063 return;
1064 }
1065
1066 /* If this value is too deep then don't print it. */
1068 && val_print_check_max_depth (stream, recurse, options, language))
1069 return;
1070
1071 try
1072 {
1073 language->value_print_inner (value, stream, recurse, &local_opts);
1074 }
1075 catch (const gdb_exception_error &except)
1076 {
1078 _("<error reading variable: %s>"), except.what ());
1079 }
1080}
1081
1082/* See valprint.h. */
1083
1084bool
1085val_print_check_max_depth (struct ui_file *stream, int recurse,
1086 const struct value_print_options *options,
1087 const struct language_defn *language)
1088{
1089 if (options->max_depth > -1 && recurse >= options->max_depth)
1090 {
1091 gdb_assert (language->struct_too_deep_ellipsis () != NULL);
1092 gdb_puts (language->struct_too_deep_ellipsis (), stream);
1093 return true;
1094 }
1095
1096 return false;
1097}
1098
1099/* Check whether the value VAL is printable. Return 1 if it is;
1100 return 0 and print an appropriate error message to STREAM according to
1101 OPTIONS if it is not. */
1102
1103static int
1104value_check_printable (struct value *val, struct ui_file *stream,
1105 const struct value_print_options *options)
1106{
1107 if (val == 0)
1108 {
1110 _("<address of value unknown>"));
1111 return 0;
1112 }
1113
1115 {
1116 if (options->summary && !val_print_scalar_type_p (value_type (val)))
1117 gdb_printf (stream, "...");
1118 else
1119 val_print_optimized_out (val, stream);
1120 return 0;
1121 }
1122
1124 {
1125 if (options->summary && !val_print_scalar_type_p (value_type (val)))
1126 gdb_printf (stream, "...");
1127 else
1128 val_print_unavailable (stream);
1129 return 0;
1130 }
1131
1132 if (value_type (val)->code () == TYPE_CODE_INTERNAL_FUNCTION)
1133 {
1135 _("<internal function %s>"),
1137 return 0;
1138 }
1139
1140 if (type_not_associated (value_type (val)))
1141 {
1142 val_print_not_associated (stream);
1143 return 0;
1144 }
1145
1146 if (type_not_allocated (value_type (val)))
1147 {
1148 val_print_not_allocated (stream);
1149 return 0;
1150 }
1151
1152 return 1;
1153}
1154
1155/* See valprint.h. */
1156
1157void
1158common_val_print_checked (struct value *val, struct ui_file *stream,
1159 int recurse,
1160 const struct value_print_options *options,
1161 const struct language_defn *language)
1162{
1163 if (!value_check_printable (val, stream, options))
1164 return;
1165 common_val_print (val, stream, recurse, options, language);
1166}
1167
1168/* Print on stream STREAM the value VAL according to OPTIONS. The value
1169 is printed using the current_language syntax. */
1170
1171void
1172value_print (struct value *val, struct ui_file *stream,
1173 const struct value_print_options *options)
1174{
1175 scoped_value_mark free_values;
1176
1177 if (!value_check_printable (val, stream, options))
1178 return;
1179
1180 if (!options->raw)
1181 {
1182 int r
1183 = apply_ext_lang_val_pretty_printer (val, stream, 0, options,
1185
1186 if (r)
1187 return;
1188 }
1189
1190 current_language->value_print (val, stream, options);
1191}
1192
1193/* Meant to be used in debug sessions, so don't export it in a header file. */
1194extern void ATTRIBUTE_UNUSED debug_val (struct value *val);
1195
1196/* Print VAL. */
1197
1198void ATTRIBUTE_UNUSED
1199debug_val (struct value *val)
1200{
1203}
1204
1205static void
1206val_print_type_code_flags (struct type *type, struct value *original_value,
1207 int embedded_offset, struct ui_file *stream)
1208{
1209 const gdb_byte *valaddr = (value_contents_for_printing (original_value).data ()
1210 + embedded_offset);
1211 ULONGEST val = unpack_long (type, valaddr);
1212 int field, nfields = type->num_fields ();
1213 struct gdbarch *gdbarch = type->arch ();
1214 struct type *bool_type = builtin_type (gdbarch)->builtin_bool;
1215
1216 gdb_puts ("[", stream);
1217 for (field = 0; field < nfields; field++)
1218 {
1219 if (type->field (field).name ()[0] != '\0')
1220 {
1221 struct type *field_type = type->field (field).type ();
1222
1223 if (field_type == bool_type
1224 /* We require boolean types here to be one bit wide. This is a
1225 problematic place to notify the user of an internal error
1226 though. Instead just fall through and print the field as an
1227 int. */
1228 && TYPE_FIELD_BITSIZE (type, field) == 1)
1229 {
1230 if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ()))
1232 (stream, " %ps",
1234 type->field (field).name ()));
1235 }
1236 else
1237 {
1238 unsigned field_len = TYPE_FIELD_BITSIZE (type, field);
1239 ULONGEST field_val = val >> type->field (field).loc_bitpos ();
1240
1241 if (field_len < sizeof (ULONGEST) * TARGET_CHAR_BIT)
1242 field_val &= ((ULONGEST) 1 << field_len) - 1;
1243 gdb_printf (stream, " %ps=",
1245 type->field (field).name ()));
1246 if (field_type->code () == TYPE_CODE_ENUM)
1247 generic_val_print_enum_1 (field_type, field_val, stream);
1248 else
1249 print_longest (stream, 'd', 0, field_val);
1250 }
1251 }
1252 }
1253 gdb_puts (" ]", stream);
1254}
1255
1256/* See valprint.h. */
1257
1258void
1260 const struct value_print_options *options,
1261 int size,
1262 struct ui_file *stream)
1263{
1264 struct type *type = check_typedef (value_type (val));
1265
1266 gdb_assert (val != NULL);
1267
1268 /* If we get here with a string format, try again without it. Go
1269 all the way back to the language printers, which may call us
1270 again. */
1271 if (options->format == 's')
1272 {
1273 struct value_print_options opts = *options;
1274 opts.format = 0;
1275 opts.deref_ref = 0;
1276 common_val_print (val, stream, 0, &opts, current_language);
1277 return;
1278 }
1279
1280 /* value_contents_for_printing fetches all VAL's contents. They are
1281 needed to check whether VAL is optimized-out or unavailable
1282 below. */
1283 const gdb_byte *valaddr = value_contents_for_printing (val).data ();
1284
1285 /* A scalar object that does not have all bits available can't be
1286 printed, because all bits contribute to its representation. */
1287 if (value_bits_any_optimized_out (val, 0,
1288 TARGET_CHAR_BIT * type->length ()))
1289 val_print_optimized_out (val, stream);
1290 else if (!value_bytes_available (val, 0, type->length ()))
1291 val_print_unavailable (stream);
1292 else
1293 print_scalar_formatted (valaddr, type, options, size, stream);
1294}
1295
1296/* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
1297 The raison d'etre of this function is to consolidate printing of
1298 LONG_LONG's into this one function. The format chars b,h,w,g are
1299 from print_scalar_formatted(). Numbers are printed using C
1300 format.
1301
1302 USE_C_FORMAT means to use C format in all cases. Without it,
1303 'o' and 'x' format do not include the standard C radix prefix
1304 (leading 0 or 0x).
1305
1306 Hilfinger/2004-09-09: USE_C_FORMAT was originally called USE_LOCAL
1307 and was intended to request formatting according to the current
1308 language and would be used for most integers that GDB prints. The
1309 exceptional cases were things like protocols where the format of
1310 the integer is a protocol thing, not a user-visible thing). The
1311 parameter remains to preserve the information of what things might
1312 be printed with language-specific format, should we ever resurrect
1313 that capability. */
1314
1315void
1316print_longest (struct ui_file *stream, int format, int use_c_format,
1317 LONGEST val_long)
1318{
1319 const char *val;
1320
1321 switch (format)
1322 {
1323 case 'd':
1324 val = int_string (val_long, 10, 1, 0, 1); break;
1325 case 'u':
1326 val = int_string (val_long, 10, 0, 0, 1); break;
1327 case 'x':
1328 val = int_string (val_long, 16, 0, 0, use_c_format); break;
1329 case 'b':
1330 val = int_string (val_long, 16, 0, 2, 1); break;
1331 case 'h':
1332 val = int_string (val_long, 16, 0, 4, 1); break;
1333 case 'w':
1334 val = int_string (val_long, 16, 0, 8, 1); break;
1335 case 'g':
1336 val = int_string (val_long, 16, 0, 16, 1); break;
1337 break;
1338 case 'o':
1339 val = int_string (val_long, 8, 0, 0, use_c_format); break;
1340 default:
1341 internal_error (_("failed internal consistency check"));
1342 }
1343 gdb_puts (val, stream);
1344}
1345
1346/* This used to be a macro, but I don't think it is called often enough
1347 to merit such treatment. */
1348/* Convert a LONGEST to an int. This is used in contexts (e.g. number of
1349 arguments to a function, number in a value history, register number, etc.)
1350 where the value must not be larger than can fit in an int. */
1351
1352int
1353longest_to_int (LONGEST arg)
1354{
1355 /* Let the compiler do the work. */
1356 int rtnval = (int) arg;
1357
1358 /* Check for overflows or underflows. */
1359 if (sizeof (LONGEST) > sizeof (int))
1360 {
1361 if (rtnval != arg)
1362 {
1363 error (_("Value out of range."));
1364 }
1365 }
1366 return (rtnval);
1367}
1368
1369/* Print a floating point value of floating-point type TYPE,
1370 pointed to in GDB by VALADDR, on STREAM. */
1371
1372void
1373print_floating (const gdb_byte *valaddr, struct type *type,
1374 struct ui_file *stream)
1375{
1376 std::string str = target_float_to_string (valaddr, type);
1377 gdb_puts (str.c_str (), stream);
1378}
1379
1380void
1381print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
1382 unsigned len, enum bfd_endian byte_order, bool zero_pad,
1383 const struct value_print_options *options)
1384{
1385 const gdb_byte *p;
1386 unsigned int i;
1387 int b;
1388 bool seen_a_one = false;
1389 const char *digit_separator = nullptr;
1390
1391 /* Declared "int" so it will be signed.
1392 This ensures that right shift will shift in zeros. */
1393
1394 const int mask = 0x080;
1395
1396 if (options->nibblesprint)
1397 digit_separator = current_language->get_digit_separator();
1398
1399 if (byte_order == BFD_ENDIAN_BIG)
1400 {
1401 for (p = valaddr;
1402 p < valaddr + len;
1403 p++)
1404 {
1405 /* Every byte has 8 binary characters; peel off
1406 and print from the MSB end. */
1407
1408 for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
1409 {
1410 if (options->nibblesprint && seen_a_one && i % 4 == 0)
1411 gdb_putc (*digit_separator, stream);
1412
1413 if (*p & (mask >> i))
1414 b = '1';
1415 else
1416 b = '0';
1417
1418 if (zero_pad || seen_a_one || b == '1')
1419 gdb_putc (b, stream);
1420 else if (options->nibblesprint)
1421 {
1422 if ((0xf0 & (mask >> i) && (*p & 0xf0))
1423 || (0x0f & (mask >> i) && (*p & 0x0f)))
1424 gdb_putc (b, stream);
1425 }
1426
1427 if (b == '1')
1428 seen_a_one = true;
1429 }
1430 }
1431 }
1432 else
1433 {
1434 for (p = valaddr + len - 1;
1435 p >= valaddr;
1436 p--)
1437 {
1438 for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
1439 {
1440 if (options->nibblesprint && seen_a_one && i % 4 == 0)
1441 gdb_putc (*digit_separator, stream);
1442
1443 if (*p & (mask >> i))
1444 b = '1';
1445 else
1446 b = '0';
1447
1448 if (zero_pad || seen_a_one || b == '1')
1449 gdb_putc (b, stream);
1450 else if (options->nibblesprint)
1451 {
1452 if ((0xf0 & (mask >> i) && (*p & 0xf0))
1453 || (0x0f & (mask >> i) && (*p & 0x0f)))
1454 gdb_putc (b, stream);
1455 }
1456
1457 if (b == '1')
1458 seen_a_one = true;
1459 }
1460 }
1461 }
1462
1463 /* When not zero-padding, ensure that something is printed when the
1464 input is 0. */
1465 if (!zero_pad && !seen_a_one)
1466 gdb_putc ('0', stream);
1467}
1468
1469/* A helper for print_octal_chars that emits a single octal digit,
1470 optionally suppressing it if is zero and updating SEEN_A_ONE. */
1471
1472static void
1473emit_octal_digit (struct ui_file *stream, bool *seen_a_one, int digit)
1474{
1475 if (*seen_a_one || digit != 0)
1476 gdb_printf (stream, "%o", digit);
1477 if (digit != 0)
1478 *seen_a_one = true;
1479}
1480
1481/* VALADDR points to an integer of LEN bytes.
1482 Print it in octal on stream or format it in buf. */
1483
1484void
1485print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
1486 unsigned len, enum bfd_endian byte_order)
1487{
1488 const gdb_byte *p;
1489 unsigned char octa1, octa2, octa3, carry;
1490 int cycle;
1491
1492 /* Octal is 3 bits, which doesn't fit. Yuk. So we have to track
1493 * the extra bits, which cycle every three bytes:
1494 *
1495 * Byte side: 0 1 2 3
1496 * | | | |
1497 * bit number 123 456 78 | 9 012 345 6 | 78 901 234 | 567 890 12 |
1498 *
1499 * Octal side: 0 1 carry 3 4 carry ...
1500 *
1501 * Cycle number: 0 1 2
1502 *
1503 * But of course we are printing from the high side, so we have to
1504 * figure out where in the cycle we are so that we end up with no
1505 * left over bits at the end.
1506 */
1507#define BITS_IN_OCTAL 3
1508#define HIGH_ZERO 0340
1509#define LOW_ZERO 0034
1510#define CARRY_ZERO 0003
1511 static_assert (HIGH_ZERO + LOW_ZERO + CARRY_ZERO == 0xff,
1512 "cycle zero constants are wrong");
1513#define HIGH_ONE 0200
1514#define MID_ONE 0160
1515#define LOW_ONE 0016
1516#define CARRY_ONE 0001
1517 static_assert (HIGH_ONE + MID_ONE + LOW_ONE + CARRY_ONE == 0xff,
1518 "cycle one constants are wrong");
1519#define HIGH_TWO 0300
1520#define MID_TWO 0070
1521#define LOW_TWO 0007
1522 static_assert (HIGH_TWO + MID_TWO + LOW_TWO == 0xff,
1523 "cycle two constants are wrong");
1524
1525 /* For 32 we start in cycle 2, with two bits and one bit carry;
1526 for 64 in cycle in cycle 1, with one bit and a two bit carry. */
1527
1528 cycle = (len * HOST_CHAR_BIT) % BITS_IN_OCTAL;
1529 carry = 0;
1530
1531 gdb_puts ("0", stream);
1532 bool seen_a_one = false;
1533 if (byte_order == BFD_ENDIAN_BIG)
1534 {
1535 for (p = valaddr;
1536 p < valaddr + len;
1537 p++)
1538 {
1539 switch (cycle)
1540 {
1541 case 0:
1542 /* No carry in, carry out two bits. */
1543
1544 octa1 = (HIGH_ZERO & *p) >> 5;
1545 octa2 = (LOW_ZERO & *p) >> 2;
1546 carry = (CARRY_ZERO & *p);
1547 emit_octal_digit (stream, &seen_a_one, octa1);
1548 emit_octal_digit (stream, &seen_a_one, octa2);
1549 break;
1550
1551 case 1:
1552 /* Carry in two bits, carry out one bit. */
1553
1554 octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
1555 octa2 = (MID_ONE & *p) >> 4;
1556 octa3 = (LOW_ONE & *p) >> 1;
1557 carry = (CARRY_ONE & *p);
1558 emit_octal_digit (stream, &seen_a_one, octa1);
1559 emit_octal_digit (stream, &seen_a_one, octa2);
1560 emit_octal_digit (stream, &seen_a_one, octa3);
1561 break;
1562
1563 case 2:
1564 /* Carry in one bit, no carry out. */
1565
1566 octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
1567 octa2 = (MID_TWO & *p) >> 3;
1568 octa3 = (LOW_TWO & *p);
1569 carry = 0;
1570 emit_octal_digit (stream, &seen_a_one, octa1);
1571 emit_octal_digit (stream, &seen_a_one, octa2);
1572 emit_octal_digit (stream, &seen_a_one, octa3);
1573 break;
1574
1575 default:
1576 error (_("Internal error in octal conversion;"));
1577 }
1578
1579 cycle++;
1580 cycle = cycle % BITS_IN_OCTAL;
1581 }
1582 }
1583 else
1584 {
1585 for (p = valaddr + len - 1;
1586 p >= valaddr;
1587 p--)
1588 {
1589 switch (cycle)
1590 {
1591 case 0:
1592 /* Carry out, no carry in */
1593
1594 octa1 = (HIGH_ZERO & *p) >> 5;
1595 octa2 = (LOW_ZERO & *p) >> 2;
1596 carry = (CARRY_ZERO & *p);
1597 emit_octal_digit (stream, &seen_a_one, octa1);
1598 emit_octal_digit (stream, &seen_a_one, octa2);
1599 break;
1600
1601 case 1:
1602 /* Carry in, carry out */
1603
1604 octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
1605 octa2 = (MID_ONE & *p) >> 4;
1606 octa3 = (LOW_ONE & *p) >> 1;
1607 carry = (CARRY_ONE & *p);
1608 emit_octal_digit (stream, &seen_a_one, octa1);
1609 emit_octal_digit (stream, &seen_a_one, octa2);
1610 emit_octal_digit (stream, &seen_a_one, octa3);
1611 break;
1612
1613 case 2:
1614 /* Carry in, no carry out */
1615
1616 octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
1617 octa2 = (MID_TWO & *p) >> 3;
1618 octa3 = (LOW_TWO & *p);
1619 carry = 0;
1620 emit_octal_digit (stream, &seen_a_one, octa1);
1621 emit_octal_digit (stream, &seen_a_one, octa2);
1622 emit_octal_digit (stream, &seen_a_one, octa3);
1623 break;
1624
1625 default:
1626 error (_("Internal error in octal conversion;"));
1627 }
1628
1629 cycle++;
1630 cycle = cycle % BITS_IN_OCTAL;
1631 }
1632 }
1633
1634}
1635
1636/* Possibly negate the integer represented by BYTES. It contains LEN
1637 bytes in the specified byte order. If the integer is negative,
1638 copy it into OUT_VEC, negate it, and return true. Otherwise, do
1639 nothing and return false. */
1640
1641static bool
1642maybe_negate_by_bytes (const gdb_byte *bytes, unsigned len,
1643 enum bfd_endian byte_order,
1644 gdb::byte_vector *out_vec)
1645{
1646 gdb_byte sign_byte;
1647 gdb_assert (len > 0);
1648 if (byte_order == BFD_ENDIAN_BIG)
1649 sign_byte = bytes[0];
1650 else
1651 sign_byte = bytes[len - 1];
1652 if ((sign_byte & 0x80) == 0)
1653 return false;
1654
1655 out_vec->resize (len);
1656
1657 /* Compute -x == 1 + ~x. */
1658 if (byte_order == BFD_ENDIAN_LITTLE)
1659 {
1660 unsigned carry = 1;
1661 for (unsigned i = 0; i < len; ++i)
1662 {
1663 unsigned tem = (0xff & ~bytes[i]) + carry;
1664 (*out_vec)[i] = tem & 0xff;
1665 carry = tem / 256;
1666 }
1667 }
1668 else
1669 {
1670 unsigned carry = 1;
1671 for (unsigned i = len; i > 0; --i)
1672 {
1673 unsigned tem = (0xff & ~bytes[i - 1]) + carry;
1674 (*out_vec)[i - 1] = tem & 0xff;
1675 carry = tem / 256;
1676 }
1677 }
1678
1679 return true;
1680}
1681
1682/* VALADDR points to an integer of LEN bytes.
1683 Print it in decimal on stream or format it in buf. */
1684
1685void
1686print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr,
1687 unsigned len, bool is_signed,
1688 enum bfd_endian byte_order)
1689{
1690#define TEN 10
1691#define CARRY_OUT( x ) ((x) / TEN) /* extend char to int */
1692#define CARRY_LEFT( x ) ((x) % TEN)
1693#define SHIFT( x ) ((x) << 4)
1694#define LOW_NIBBLE( x ) ( (x) & 0x00F)
1695#define HIGH_NIBBLE( x ) (((x) & 0x0F0) >> 4)
1696
1697 const gdb_byte *p;
1698 int carry;
1699 int decimal_len;
1700 int i, j, decimal_digits;
1701 int dummy;
1702 int flip;
1703
1704 gdb::byte_vector negated_bytes;
1705 if (is_signed
1706 && maybe_negate_by_bytes (valaddr, len, byte_order, &negated_bytes))
1707 {
1708 gdb_puts ("-", stream);
1709 valaddr = negated_bytes.data ();
1710 }
1711
1712 /* Base-ten number is less than twice as many digits
1713 as the base 16 number, which is 2 digits per byte. */
1714
1715 decimal_len = len * 2 * 2;
1716 std::vector<unsigned char> digits (decimal_len, 0);
1717
1718 /* Ok, we have an unknown number of bytes of data to be printed in
1719 * decimal.
1720 *
1721 * Given a hex number (in nibbles) as XYZ, we start by taking X and
1722 * decimalizing it as "x1 x2" in two decimal nibbles. Then we multiply
1723 * the nibbles by 16, add Y and re-decimalize. Repeat with Z.
1724 *
1725 * The trick is that "digits" holds a base-10 number, but sometimes
1726 * the individual digits are > 10.
1727 *
1728 * Outer loop is per nibble (hex digit) of input, from MSD end to
1729 * LSD end.
1730 */
1731 decimal_digits = 0; /* Number of decimal digits so far */
1732 p = (byte_order == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1;
1733 flip = 0;
1734 while ((byte_order == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr))
1735 {
1736 /*
1737 * Multiply current base-ten number by 16 in place.
1738 * Each digit was between 0 and 9, now is between
1739 * 0 and 144.
1740 */
1741 for (j = 0; j < decimal_digits; j++)
1742 {
1743 digits[j] = SHIFT (digits[j]);
1744 }
1745
1746 /* Take the next nibble off the input and add it to what
1747 * we've got in the LSB position. Bottom 'digit' is now
1748 * between 0 and 159.
1749 *
1750 * "flip" is used to run this loop twice for each byte.
1751 */
1752 if (flip == 0)
1753 {
1754 /* Take top nibble. */
1755
1756 digits[0] += HIGH_NIBBLE (*p);
1757 flip = 1;
1758 }
1759 else
1760 {
1761 /* Take low nibble and bump our pointer "p". */
1762
1763 digits[0] += LOW_NIBBLE (*p);
1764 if (byte_order == BFD_ENDIAN_BIG)
1765 p++;
1766 else
1767 p--;
1768 flip = 0;
1769 }
1770
1771 /* Re-decimalize. We have to do this often enough
1772 * that we don't overflow, but once per nibble is
1773 * overkill. Easier this way, though. Note that the
1774 * carry is often larger than 10 (e.g. max initial
1775 * carry out of lowest nibble is 15, could bubble all
1776 * the way up greater than 10). So we have to do
1777 * the carrying beyond the last current digit.
1778 */
1779 carry = 0;
1780 for (j = 0; j < decimal_len - 1; j++)
1781 {
1782 digits[j] += carry;
1783
1784 /* "/" won't handle an unsigned char with
1785 * a value that if signed would be negative.
1786 * So extend to longword int via "dummy".
1787 */
1788 dummy = digits[j];
1789 carry = CARRY_OUT (dummy);
1790 digits[j] = CARRY_LEFT (dummy);
1791
1792 if (j >= decimal_digits && carry == 0)
1793 {
1794 /*
1795 * All higher digits are 0 and we
1796 * no longer have a carry.
1797 *
1798 * Note: "j" is 0-based, "decimal_digits" is
1799 * 1-based.
1800 */
1801 decimal_digits = j + 1;
1802 break;
1803 }
1804 }
1805 }
1806
1807 /* Ok, now "digits" is the decimal representation, with
1808 the "decimal_digits" actual digits. Print! */
1809
1810 for (i = decimal_digits - 1; i > 0 && digits[i] == 0; --i)
1811 ;
1812
1813 for (; i >= 0; i--)
1814 {
1815 gdb_printf (stream, "%1d", digits[i]);
1816 }
1817}
1818
1819/* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */
1820
1821void
1822print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
1823 unsigned len, enum bfd_endian byte_order,
1824 bool zero_pad)
1825{
1826 const gdb_byte *p;
1827
1828 gdb_puts ("0x", stream);
1829 if (byte_order == BFD_ENDIAN_BIG)
1830 {
1831 p = valaddr;
1832
1833 if (!zero_pad)
1834 {
1835 /* Strip leading 0 bytes, but be sure to leave at least a
1836 single byte at the end. */
1837 for (; p < valaddr + len - 1 && !*p; ++p)
1838 ;
1839 }
1840
1841 const gdb_byte *first = p;
1842 for (;
1843 p < valaddr + len;
1844 p++)
1845 {
1846 /* When not zero-padding, use a different format for the
1847 very first byte printed. */
1848 if (!zero_pad && p == first)
1849 gdb_printf (stream, "%x", *p);
1850 else
1851 gdb_printf (stream, "%02x", *p);
1852 }
1853 }
1854 else
1855 {
1856 p = valaddr + len - 1;
1857
1858 if (!zero_pad)
1859 {
1860 /* Strip leading 0 bytes, but be sure to leave at least a
1861 single byte at the end. */
1862 for (; p >= valaddr + 1 && !*p; --p)
1863 ;
1864 }
1865
1866 const gdb_byte *first = p;
1867 for (;
1868 p >= valaddr;
1869 p--)
1870 {
1871 /* When not zero-padding, use a different format for the
1872 very first byte printed. */
1873 if (!zero_pad && p == first)
1874 gdb_printf (stream, "%x", *p);
1875 else
1876 gdb_printf (stream, "%02x", *p);
1877 }
1878 }
1879}
1880
1881/* Print function pointer with inferior address ADDRESS onto stdio
1882 stream STREAM. */
1883
1884void
1886 struct gdbarch *gdbarch,
1887 CORE_ADDR address,
1888 struct ui_file *stream)
1889{
1890 CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr
1891 (gdbarch, address, current_inferior ()->top_target ());
1892
1893 /* If the function pointer is represented by a description, print
1894 the address of the description. */
1895 if (options->addressprint && func_addr != address)
1896 {
1897 gdb_puts ("@", stream);
1898 gdb_puts (paddress (gdbarch, address), stream);
1899 gdb_puts (": ", stream);
1900 }
1901 print_address_demangle (options, gdbarch, func_addr, stream, demangle);
1902}
1903
1904
1905/* Print on STREAM using the given OPTIONS the index for the element
1906 at INDEX of an array whose index type is INDEX_TYPE. */
1907
1908void
1909maybe_print_array_index (struct type *index_type, LONGEST index,
1910 struct ui_file *stream,
1911 const struct value_print_options *options)
1912{
1913 if (!options->print_array_indexes)
1914 return;
1915
1916 current_language->print_array_index (index_type, index, stream, options);
1917}
1918
1919/* See valprint.h. */
1920
1921void
1922value_print_array_elements (struct value *val, struct ui_file *stream,
1923 int recurse,
1924 const struct value_print_options *options,
1925 unsigned int i)
1926{
1927 unsigned int things_printed = 0;
1928 unsigned len;
1929 struct type *elttype, *index_type;
1930 /* Position of the array element we are examining to see
1931 whether it is repeated. */
1932 unsigned int rep1;
1933 /* Number of repetitions we have detected so far. */
1934 unsigned int reps;
1935 LONGEST low_bound, high_bound;
1936
1937 struct type *type = check_typedef (value_type (val));
1938
1939 elttype = type->target_type ();
1940 unsigned bit_stride = type->bit_stride ();
1941 if (bit_stride == 0)
1942 bit_stride = 8 * check_typedef (elttype)->length ();
1944 if (index_type->code () == TYPE_CODE_RANGE)
1946
1947 if (get_array_bounds (type, &low_bound, &high_bound))
1948 {
1949 /* The array length should normally be HIGH_BOUND - LOW_BOUND +
1950 1. But we have to be a little extra careful, because some
1951 languages such as Ada allow LOW_BOUND to be greater than
1952 HIGH_BOUND for empty arrays. In that situation, the array
1953 length is just zero, not negative! */
1954 if (low_bound > high_bound)
1955 len = 0;
1956 else
1957 len = high_bound - low_bound + 1;
1958 }
1959 else
1960 {
1961 warning (_("unable to get bounds of array, assuming null array"));
1962 low_bound = 0;
1963 len = 0;
1964 }
1965
1966 annotate_array_section_begin (i, elttype);
1967
1968 for (; i < len && things_printed < options->print_max; i++)
1969 {
1970 scoped_value_mark free_values;
1971
1972 if (i != 0)
1973 {
1974 if (options->prettyformat_arrays)
1975 {
1976 gdb_printf (stream, ",\n");
1977 print_spaces (2 + 2 * recurse, stream);
1978 }
1979 else
1980 gdb_printf (stream, ", ");
1981 }
1982 else if (options->prettyformat_arrays)
1983 {
1984 gdb_printf (stream, "\n");
1985 print_spaces (2 + 2 * recurse, stream);
1986 }
1987 stream->wrap_here (2 + 2 * recurse);
1988 maybe_print_array_index (index_type, i + low_bound,
1989 stream, options);
1990
1991 struct value *element = value_from_component_bitsize (val, elttype,
1992 bit_stride * i,
1993 bit_stride);
1994 rep1 = i + 1;
1995 reps = 1;
1996 /* Only check for reps if repeat_count_threshold is not set to
1997 UINT_MAX (unlimited). */
1998 if (options->repeat_count_threshold < UINT_MAX)
1999 {
2000 while (rep1 < len)
2001 {
2002 struct value *rep_elt
2003 = value_from_component_bitsize (val, elttype,
2004 rep1 * bit_stride,
2005 bit_stride);
2006 if (!value_contents_eq (element, rep_elt))
2007 break;
2008 ++reps;
2009 ++rep1;
2010 }
2011 }
2012
2013 common_val_print (element, stream, recurse + 1, options,
2015
2016 if (reps > options->repeat_count_threshold)
2017 {
2018 annotate_elt_rep (reps);
2019 gdb_printf (stream, " %p[<repeats %u times>%p]",
2020 metadata_style.style ().ptr (), reps, nullptr);
2022
2023 i = rep1 - 1;
2024 things_printed += options->repeat_count_threshold;
2025 }
2026 else
2027 {
2028 annotate_elt ();
2029 things_printed++;
2030 }
2031 }
2033 if (i < len)
2034 gdb_printf (stream, "...");
2035 if (options->prettyformat_arrays)
2036 {
2037 gdb_printf (stream, "\n");
2038 print_spaces (2 * recurse, stream);
2039 }
2040}
2041
2042/* Return true if print_wchar can display W without resorting to a
2043 numeric escape, false otherwise. */
2044
2045static int
2047{
2048 return (gdb_iswprint (w)
2049 || w == LCST ('\a') || w == LCST ('\b')
2050 || w == LCST ('\f') || w == LCST ('\n')
2051 || w == LCST ('\r') || w == LCST ('\t')
2052 || w == LCST ('\v'));
2053}
2054
2055/* A helper function that converts the contents of STRING to wide
2056 characters and then appends them to OUTPUT. */
2057
2058static void
2059append_string_as_wide (const char *string,
2060 struct obstack *output)
2061{
2062 for (; *string; ++string)
2063 {
2064 gdb_wchar_t w = gdb_btowc (*string);
2065 obstack_grow (output, &w, sizeof (gdb_wchar_t));
2066 }
2067}
2068
2069/* Print a wide character W to OUTPUT. ORIG is a pointer to the
2070 original (target) bytes representing the character, ORIG_LEN is the
2071 number of valid bytes. WIDTH is the number of bytes in a base
2072 characters of the type. OUTPUT is an obstack to which wide
2073 characters are emitted. QUOTER is a (narrow) character indicating
2074 the style of quotes surrounding the character to be printed.
2075 NEED_ESCAPE is an in/out flag which is used to track numeric
2076 escapes across calls. */
2077
2078static void
2079print_wchar (gdb_wint_t w, const gdb_byte *orig,
2080 int orig_len, int width,
2081 enum bfd_endian byte_order,
2082 struct obstack *output,
2083 int quoter, bool *need_escapep)
2084{
2085 bool need_escape = *need_escapep;
2086
2087 *need_escapep = false;
2088
2089 /* If any additional cases are added to this switch block, then the
2090 function wchar_printable will likely need updating too. */
2091 switch (w)
2092 {
2093 case LCST ('\a'):
2094 obstack_grow_wstr (output, LCST ("\\a"));
2095 break;
2096 case LCST ('\b'):
2097 obstack_grow_wstr (output, LCST ("\\b"));
2098 break;
2099 case LCST ('\f'):
2100 obstack_grow_wstr (output, LCST ("\\f"));
2101 break;
2102 case LCST ('\n'):
2103 obstack_grow_wstr (output, LCST ("\\n"));
2104 break;
2105 case LCST ('\r'):
2106 obstack_grow_wstr (output, LCST ("\\r"));
2107 break;
2108 case LCST ('\t'):
2109 obstack_grow_wstr (output, LCST ("\\t"));
2110 break;
2111 case LCST ('\v'):
2112 obstack_grow_wstr (output, LCST ("\\v"));
2113 break;
2114 default:
2115 {
2116 if (gdb_iswprint (w) && !(need_escape && gdb_iswxdigit (w)))
2117 {
2118 gdb_wchar_t wchar = w;
2119
2120 if (w == gdb_btowc (quoter) || w == LCST ('\\'))
2121 obstack_grow_wstr (output, LCST ("\\"));
2122 obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
2123 }
2124 else
2125 {
2126 int i;
2127
2128 for (i = 0; i + width <= orig_len; i += width)
2129 {
2130 char octal[30];
2131 ULONGEST value;
2132
2133 value = extract_unsigned_integer (&orig[i], width,
2134 byte_order);
2135 /* If the value fits in 3 octal digits, print it that
2136 way. Otherwise, print it as a hex escape. */
2137 if (value <= 0777)
2138 {
2139 xsnprintf (octal, sizeof (octal), "\\%.3o",
2140 (int) (value & 0777));
2141 *need_escapep = false;
2142 }
2143 else
2144 {
2145 xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value);
2146 /* A hex escape might require the next character
2147 to be escaped, because, unlike with octal,
2148 hex escapes have no length limit. */
2149 *need_escapep = true;
2150 }
2151 append_string_as_wide (octal, output);
2152 }
2153 /* If we somehow have extra bytes, print them now. */
2154 while (i < orig_len)
2155 {
2156 char octal[5];
2157
2158 xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff);
2159 *need_escapep = false;
2160 append_string_as_wide (octal, output);
2161 ++i;
2162 }
2163 }
2164 break;
2165 }
2166 }
2167}
2168
2169/* Print the character C on STREAM as part of the contents of a
2170 literal string whose delimiter is QUOTER. ENCODING names the
2171 encoding of C. */
2172
2173void
2174generic_emit_char (int c, struct type *type, struct ui_file *stream,
2175 int quoter, const char *encoding)
2176{
2177 enum bfd_endian byte_order
2179 gdb_byte *c_buf;
2180 bool need_escape = false;
2181
2182 c_buf = (gdb_byte *) alloca (type->length ());
2183 pack_long (c_buf, type, c);
2184
2185 wchar_iterator iter (c_buf, type->length (), encoding, type->length ());
2186
2187 /* This holds the printable form of the wchar_t data. */
2188 auto_obstack wchar_buf;
2189
2190 while (1)
2191 {
2192 int num_chars;
2193 gdb_wchar_t *chars;
2194 const gdb_byte *buf;
2195 size_t buflen;
2196 int print_escape = 1;
2197 enum wchar_iterate_result result;
2198
2199 num_chars = iter.iterate (&result, &chars, &buf, &buflen);
2200 if (num_chars < 0)
2201 break;
2202 if (num_chars > 0)
2203 {
2204 /* If all characters are printable, print them. Otherwise,
2205 we're going to have to print an escape sequence. We
2206 check all characters because we want to print the target
2207 bytes in the escape sequence, and we don't know character
2208 boundaries there. */
2209 int i;
2210
2211 print_escape = 0;
2212 for (i = 0; i < num_chars; ++i)
2213 if (!wchar_printable (chars[i]))
2214 {
2215 print_escape = 1;
2216 break;
2217 }
2218
2219 if (!print_escape)
2220 {
2221 for (i = 0; i < num_chars; ++i)
2222 print_wchar (chars[i], buf, buflen,
2223 type->length (), byte_order,
2224 &wchar_buf, quoter, &need_escape);
2225 }
2226 }
2227
2228 /* This handles the NUM_CHARS == 0 case as well. */
2229 if (print_escape)
2230 print_wchar (gdb_WEOF, buf, buflen, type->length (),
2231 byte_order, &wchar_buf, quoter, &need_escape);
2232 }
2233
2234 /* The output in the host encoding. */
2235 auto_obstack output;
2236
2238 (gdb_byte *) obstack_base (&wchar_buf),
2239 obstack_object_size (&wchar_buf),
2240 sizeof (gdb_wchar_t), &output, translit_char);
2241 obstack_1grow (&output, '\0');
2242
2243 gdb_puts ((const char *) obstack_base (&output), stream);
2244}
2245
2246/* Return the repeat count of the next character/byte in ITER,
2247 storing the result in VEC. */
2248
2249static int
2251 std::vector<converted_character> *vec)
2252{
2253 struct converted_character *current;
2254
2255 if (vec->empty ())
2256 {
2257 struct converted_character tmp;
2259
2260 tmp.num_chars
2261 = iter->iterate (&tmp.result, &chars, &tmp.buf, &tmp.buflen);
2262 if (tmp.num_chars > 0)
2263 {
2264 gdb_assert (tmp.num_chars < MAX_WCHARS);
2265 memcpy (tmp.chars, chars, tmp.num_chars * sizeof (gdb_wchar_t));
2266 }
2267 vec->push_back (tmp);
2268 }
2269
2270 current = &vec->back ();
2271
2272 /* Count repeated characters or bytes. */
2273 current->repeat_count = 1;
2274 if (current->num_chars == -1)
2275 {
2276 /* EOF */
2277 return -1;
2278 }
2279 else
2280 {
2282 struct converted_character d;
2283 int repeat;
2284
2285 d.repeat_count = 0;
2286
2287 while (1)
2288 {
2289 /* Get the next character. */
2290 d.num_chars = iter->iterate (&d.result, &chars, &d.buf, &d.buflen);
2291
2292 /* If a character was successfully converted, save the character
2293 into the converted character. */
2294 if (d.num_chars > 0)
2295 {
2296 gdb_assert (d.num_chars < MAX_WCHARS);
2297 memcpy (d.chars, chars, WCHAR_BUFLEN (d.num_chars));
2298 }
2299
2300 /* Determine if the current character is the same as this
2301 new character. */
2302 if (d.num_chars == current->num_chars && d.result == current->result)
2303 {
2304 /* There are two cases to consider:
2305
2306 1) Equality of converted character (num_chars > 0)
2307 2) Equality of non-converted character (num_chars == 0) */
2308 if ((current->num_chars > 0
2309 && memcmp (current->chars, d.chars,
2310 WCHAR_BUFLEN (current->num_chars)) == 0)
2311 || (current->num_chars == 0
2312 && current->buflen == d.buflen
2313 && memcmp (current->buf, d.buf, current->buflen) == 0))
2314 ++current->repeat_count;
2315 else
2316 break;
2317 }
2318 else
2319 break;
2320 }
2321
2322 /* Push this next converted character onto the result vector. */
2323 repeat = current->repeat_count;
2324 vec->push_back (d);
2325 return repeat;
2326 }
2327}
2328
2329/* Print the characters in CHARS to the OBSTACK. QUOTE_CHAR is the quote
2330 character to use with string output. WIDTH is the size of the output
2331 character type. BYTE_ORDER is the target byte order. OPTIONS
2332 is the user's print options. */
2333
2334static void
2335print_converted_chars_to_obstack (struct obstack *obstack,
2336 const std::vector<converted_character> &chars,
2337 int quote_char, int width,
2338 enum bfd_endian byte_order,
2339 const struct value_print_options *options)
2340{
2341 unsigned int idx;
2342 const converted_character *elem;
2343 enum {START, SINGLE, REPEAT, INCOMPLETE, FINISH} state, last;
2344 gdb_wchar_t wide_quote_char = gdb_btowc (quote_char);
2345 bool need_escape = false;
2346
2347 /* Set the start state. */
2348 idx = 0;
2349 last = state = START;
2350 elem = NULL;
2351
2352 while (1)
2353 {
2354 switch (state)
2355 {
2356 case START:
2357 /* Nothing to do. */
2358 break;
2359
2360 case SINGLE:
2361 {
2362 int j;
2363
2364 /* We are outputting a single character
2365 (< options->repeat_count_threshold). */
2366
2367 if (last != SINGLE)
2368 {
2369 /* We were outputting some other type of content, so we
2370 must output and a comma and a quote. */
2371 if (last != START)
2372 obstack_grow_wstr (obstack, LCST (", "));
2373 obstack_grow (obstack, &wide_quote_char, sizeof (gdb_wchar_t));
2374 }
2375 /* Output the character. */
2376 for (j = 0; j < elem->repeat_count; ++j)
2377 {
2378 if (elem->result == wchar_iterate_ok)
2379 print_wchar (elem->chars[0], elem->buf, elem->buflen, width,
2380 byte_order, obstack, quote_char, &need_escape);
2381 else
2382 print_wchar (gdb_WEOF, elem->buf, elem->buflen, width,
2383 byte_order, obstack, quote_char, &need_escape);
2384 }
2385 }
2386 break;
2387
2388 case REPEAT:
2389 {
2390 int j;
2391
2392 /* We are outputting a character with a repeat count
2393 greater than options->repeat_count_threshold. */
2394
2395 if (last == SINGLE)
2396 {
2397 /* We were outputting a single string. Terminate the
2398 string. */
2399 obstack_grow (obstack, &wide_quote_char, sizeof (gdb_wchar_t));
2400 }
2401 if (last != START)
2402 obstack_grow_wstr (obstack, LCST (", "));
2403
2404 /* Output the character and repeat string. */
2405 obstack_grow_wstr (obstack, LCST ("'"));
2406 if (elem->result == wchar_iterate_ok)
2407 print_wchar (elem->chars[0], elem->buf, elem->buflen, width,
2408 byte_order, obstack, quote_char, &need_escape);
2409 else
2410 print_wchar (gdb_WEOF, elem->buf, elem->buflen, width,
2411 byte_order, obstack, quote_char, &need_escape);
2412 obstack_grow_wstr (obstack, LCST ("'"));
2413 std::string s = string_printf (_(" <repeats %u times>"),
2414 elem->repeat_count);
2415 for (j = 0; s[j]; ++j)
2416 {
2417 gdb_wchar_t w = gdb_btowc (s[j]);
2418 obstack_grow (obstack, &w, sizeof (gdb_wchar_t));
2419 }
2420 }
2421 break;
2422
2423 case INCOMPLETE:
2424 /* We are outputting an incomplete sequence. */
2425 if (last == SINGLE)
2426 {
2427 /* If we were outputting a string of SINGLE characters,
2428 terminate the quote. */
2429 obstack_grow (obstack, &wide_quote_char, sizeof (gdb_wchar_t));
2430 }
2431 if (last != START)
2432 obstack_grow_wstr (obstack, LCST (", "));
2433
2434 /* Output the incomplete sequence string. */
2435 obstack_grow_wstr (obstack, LCST ("<incomplete sequence "));
2436 print_wchar (gdb_WEOF, elem->buf, elem->buflen, width, byte_order,
2437 obstack, 0, &need_escape);
2438 obstack_grow_wstr (obstack, LCST (">"));
2439
2440 /* We do not attempt to output anything after this. */
2441 state = FINISH;
2442 break;
2443
2444 case FINISH:
2445 /* All done. If we were outputting a string of SINGLE
2446 characters, the string must be terminated. Otherwise,
2447 REPEAT and INCOMPLETE are always left properly terminated. */
2448 if (last == SINGLE)
2449 obstack_grow (obstack, &wide_quote_char, sizeof (gdb_wchar_t));
2450
2451 return;
2452 }
2453
2454 /* Get the next element and state. */
2455 last = state;
2456 if (state != FINISH)
2457 {
2458 elem = &chars[idx++];
2459 switch (elem->result)
2460 {
2461 case wchar_iterate_ok:
2463 if (elem->repeat_count > options->repeat_count_threshold)
2464 state = REPEAT;
2465 else
2466 state = SINGLE;
2467 break;
2468
2470 state = INCOMPLETE;
2471 break;
2472
2473 case wchar_iterate_eof:
2474 state = FINISH;
2475 break;
2476 }
2477 }
2478 }
2479}
2480
2481/* Print the character string STRING, printing at most LENGTH
2482 characters. LENGTH is -1 if the string is nul terminated. TYPE is
2483 the type of each character. OPTIONS holds the printing options;
2484 printing stops early if the number hits print_max; repeat counts
2485 are printed as appropriate. Print ellipses at the end if we had to
2486 stop before printing LENGTH characters, or if FORCE_ELLIPSES.
2487 QUOTE_CHAR is the character to print at each end of the string. If
2488 C_STYLE_TERMINATOR is true, and the last character is 0, then it is
2489 omitted. */
2490
2491void
2492generic_printstr (struct ui_file *stream, struct type *type,
2493 const gdb_byte *string, unsigned int length,
2494 const char *encoding, int force_ellipses,
2495 int quote_char, int c_style_terminator,
2496 const struct value_print_options *options)
2497{
2498 enum bfd_endian byte_order = type_byte_order (type);
2499 unsigned int i;
2500 int width = type->length ();
2501 int finished = 0;
2502 struct converted_character *last;
2503
2504 if (length == -1)
2505 {
2506 unsigned long current_char = 1;
2507
2508 for (i = 0; current_char; ++i)
2509 {
2510 QUIT;
2511 current_char = extract_unsigned_integer (string + i * width,
2512 width, byte_order);
2513 }
2514 length = i;
2515 }
2516
2517 /* If the string was not truncated due to `set print elements', and
2518 the last byte of it is a null, we don't print that, in
2519 traditional C style. */
2520 if (c_style_terminator
2521 && !force_ellipses
2522 && length > 0
2523 && (extract_unsigned_integer (string + (length - 1) * width,
2524 width, byte_order) == 0))
2525 length--;
2526
2527 if (length == 0)
2528 {
2529 gdb_printf (stream, "%c%c", quote_char, quote_char);
2530 return;
2531 }
2532
2533 /* Arrange to iterate over the characters, in wchar_t form. */
2534 wchar_iterator iter (string, length * width, encoding, width);
2535 std::vector<converted_character> converted_chars;
2536
2537 /* Convert characters until the string is over or the maximum
2538 number of printed characters has been reached. */
2539 i = 0;
2540 while (i < options->print_max)
2541 {
2542 int r;
2543
2544 QUIT;
2545
2546 /* Grab the next character and repeat count. */
2547 r = count_next_character (&iter, &converted_chars);
2548
2549 /* If less than zero, the end of the input string was reached. */
2550 if (r < 0)
2551 break;
2552
2553 /* Otherwise, add the count to the total print count and get
2554 the next character. */
2555 i += r;
2556 }
2557
2558 /* Get the last element and determine if the entire string was
2559 processed. */
2560 last = &converted_chars.back ();
2561 finished = (last->result == wchar_iterate_eof);
2562
2563 /* Ensure that CONVERTED_CHARS is terminated. */
2564 last->result = wchar_iterate_eof;
2565
2566 /* WCHAR_BUF is the obstack we use to represent the string in
2567 wchar_t form. */
2568 auto_obstack wchar_buf;
2569
2570 /* Print the output string to the obstack. */
2571 print_converted_chars_to_obstack (&wchar_buf, converted_chars, quote_char,
2572 width, byte_order, options);
2573
2574 if (force_ellipses || !finished)
2575 obstack_grow_wstr (&wchar_buf, LCST ("..."));
2576
2577 /* OUTPUT is where we collect `char's for printing. */
2578 auto_obstack output;
2579
2581 (gdb_byte *) obstack_base (&wchar_buf),
2582 obstack_object_size (&wchar_buf),
2583 sizeof (gdb_wchar_t), &output, translit_char);
2584 obstack_1grow (&output, '\0');
2585
2586 gdb_puts ((const char *) obstack_base (&output), stream);
2587}
2588
2589/* Print a string from the inferior, starting at ADDR and printing up to LEN
2590 characters, of WIDTH bytes a piece, to STREAM. If LEN is -1, printing
2591 stops at the first null byte, otherwise printing proceeds (including null
2592 bytes) until either print_max or LEN characters have been printed,
2593 whichever is smaller. ENCODING is the name of the string's
2594 encoding. It can be NULL, in which case the target encoding is
2595 assumed. */
2596
2597int
2598val_print_string (struct type *elttype, const char *encoding,
2599 CORE_ADDR addr, int len,
2600 struct ui_file *stream,
2601 const struct value_print_options *options)
2602{
2603 int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
2604 int err; /* Non-zero if we got a bad read. */
2605 int found_nul; /* Non-zero if we found the nul char. */
2606 unsigned int fetchlimit; /* Maximum number of chars to print. */
2607 int bytes_read;
2608 gdb::unique_xmalloc_ptr<gdb_byte> buffer; /* Dynamically growable fetch buffer. */
2609 struct gdbarch *gdbarch = elttype->arch ();
2610 enum bfd_endian byte_order = type_byte_order (elttype);
2611 int width = elttype->length ();
2612
2613 /* First we need to figure out the limit on the number of characters we are
2614 going to attempt to fetch and print. This is actually pretty simple. If
2615 LEN >= zero, then the limit is the minimum of LEN and print_max. If
2616 LEN is -1, then the limit is print_max. This is true regardless of
2617 whether print_max is zero, UINT_MAX (unlimited), or something in between,
2618 because finding the null byte (or available memory) is what actually
2619 limits the fetch. */
2620
2621 fetchlimit = (len == -1 ? options->print_max : std::min ((unsigned) len,
2622 options->print_max));
2623
2624 err = target_read_string (addr, len, width, fetchlimit,
2625 &buffer, &bytes_read);
2626
2627 addr += bytes_read;
2628
2629 /* We now have either successfully filled the buffer to fetchlimit,
2630 or terminated early due to an error or finding a null char when
2631 LEN is -1. */
2632
2633 /* Determine found_nul by looking at the last character read. */
2634 found_nul = 0;
2635 if (bytes_read >= width)
2636 found_nul = extract_unsigned_integer (buffer.get () + bytes_read - width,
2637 width, byte_order) == 0;
2638 if (len == -1 && !found_nul)
2639 {
2640 gdb_byte *peekbuf;
2641
2642 /* We didn't find a NUL terminator we were looking for. Attempt
2643 to peek at the next character. If not successful, or it is not
2644 a null byte, then force ellipsis to be printed. */
2645
2646 peekbuf = (gdb_byte *) alloca (width);
2647
2648 if (target_read_memory (addr, peekbuf, width) == 0
2649 && extract_unsigned_integer (peekbuf, width, byte_order) != 0)
2650 force_ellipsis = 1;
2651 }
2652 else if ((len >= 0 && err != 0) || (len > bytes_read / width))
2653 {
2654 /* Getting an error when we have a requested length, or fetching less
2655 than the number of characters actually requested, always make us
2656 print ellipsis. */
2657 force_ellipsis = 1;
2658 }
2659
2660 /* If we get an error before fetching anything, don't print a string.
2661 But if we fetch something and then get an error, print the string
2662 and then the error message. */
2663 if (err == 0 || bytes_read > 0)
2664 current_language->printstr (stream, elttype, buffer.get (),
2665 bytes_read / width,
2666 encoding, force_ellipsis, options);
2667
2668 if (err != 0)
2669 {
2670 std::string str = memory_error_message (TARGET_XFER_E_IO, gdbarch, addr);
2671
2672 gdb_printf (stream, _("<error: %ps>"),
2674 str.c_str ()));
2675 }
2676
2677 return (bytes_read / width);
2678}
2679
2680/* Handle 'show print max-depth'. */
2681
2682static void
2683show_print_max_depth (struct ui_file *file, int from_tty,
2684 struct cmd_list_element *c, const char *value)
2685{
2686 gdb_printf (file, _("Maximum print depth is %s.\n"), value);
2687}
2688
2689
2690/* The 'set input-radix' command writes to this auxiliary variable.
2691 If the requested radix is valid, INPUT_RADIX is updated; otherwise,
2692 it is left unchanged. */
2693
2694static unsigned input_radix_1 = 10;
2695
2696/* Validate an input or output radix setting, and make sure the user
2697 knows what they really did here. Radix setting is confusing, e.g.
2698 setting the input radix to "10" never changes it! */
2699
2700static void
2701set_input_radix (const char *args, int from_tty, struct cmd_list_element *c)
2702{
2703 set_input_radix_1 (from_tty, input_radix_1);
2704}
2705
2706static void
2707set_input_radix_1 (int from_tty, unsigned radix)
2708{
2709 /* We don't currently disallow any input radix except 0 or 1, which don't
2710 make any mathematical sense. In theory, we can deal with any input
2711 radix greater than 1, even if we don't have unique digits for every
2712 value from 0 to radix-1, but in practice we lose on large radix values.
2713 We should either fix the lossage or restrict the radix range more.
2714 (FIXME). */
2715
2716 if (radix < 2)
2717 {
2719 error (_("Nonsense input radix ``decimal %u''; input radix unchanged."),
2720 radix);
2721 }
2722 input_radix_1 = input_radix = radix;
2723 if (from_tty)
2724 {
2725 gdb_printf (_("Input radix now set to "
2726 "decimal %u, hex %x, octal %o.\n"),
2727 radix, radix, radix);
2728 }
2729}
2730
2731/* The 'set output-radix' command writes to this auxiliary variable.
2732 If the requested radix is valid, OUTPUT_RADIX is updated,
2733 otherwise, it is left unchanged. */
2734
2735static unsigned output_radix_1 = 10;
2736
2737static void
2738set_output_radix (const char *args, int from_tty, struct cmd_list_element *c)
2739{
2741}
2742
2743static void
2744set_output_radix_1 (int from_tty, unsigned radix)
2745{
2746 /* Validate the radix and disallow ones that we aren't prepared to
2747 handle correctly, leaving the radix unchanged. */
2748 switch (radix)
2749 {
2750 case 16:
2751 user_print_options.output_format = 'x'; /* hex */
2752 break;
2753 case 10:
2754 user_print_options.output_format = 0; /* decimal */
2755 break;
2756 case 8:
2757 user_print_options.output_format = 'o'; /* octal */
2758 break;
2759 default:
2761 error (_("Unsupported output radix ``decimal %u''; "
2762 "output radix unchanged."),
2763 radix);
2764 }
2765 output_radix_1 = output_radix = radix;
2766 if (from_tty)
2767 {
2768 gdb_printf (_("Output radix now set to "
2769 "decimal %u, hex %x, octal %o.\n"),
2770 radix, radix, radix);
2771 }
2772}
2773
2774/* Set both the input and output radix at once. Try to set the output radix
2775 first, since it has the most restrictive range. An radix that is valid as
2776 an output radix is also valid as an input radix.
2777
2778 It may be useful to have an unusual input radix. If the user wishes to
2779 set an input radix that is not valid as an output radix, he needs to use
2780 the 'set input-radix' command. */
2781
2782static void
2783set_radix (const char *arg, int from_tty)
2784{
2785 unsigned radix;
2786
2787 radix = (arg == NULL) ? 10 : parse_and_eval_long (arg);
2788 set_output_radix_1 (0, radix);
2789 set_input_radix_1 (0, radix);
2790 if (from_tty)
2791 {
2792 gdb_printf (_("Input and output radices now set to "
2793 "decimal %u, hex %x, octal %o.\n"),
2794 radix, radix, radix);
2795 }
2796}
2797
2798/* Show both the input and output radices. */
2799
2800static void
2801show_radix (const char *arg, int from_tty)
2802{
2803 if (from_tty)
2804 {
2806 {
2807 gdb_printf (_("Input and output radices set to "
2808 "decimal %u, hex %x, octal %o.\n"),
2810 }
2811 else
2812 {
2813 gdb_printf (_("Input radix set to decimal "
2814 "%u, hex %x, octal %o.\n"),
2816 gdb_printf (_("Output radix set to decimal "
2817 "%u, hex %x, octal %o.\n"),
2819 }
2820 }
2821}
2822
2823
2824/* Controls printing of vtbl's. */
2825static void
2826show_vtblprint (struct ui_file *file, int from_tty,
2827 struct cmd_list_element *c, const char *value)
2828{
2829 gdb_printf (file, _("\
2830Printing of C++ virtual function tables is %s.\n"),
2831 value);
2832}
2833
2834/* Controls looking up an object's derived type using what we find in
2835 its vtables. */
2836static void
2837show_objectprint (struct ui_file *file, int from_tty,
2838 struct cmd_list_element *c,
2839 const char *value)
2840{
2841 gdb_printf (file, _("\
2842Printing of object's derived type based on vtable info is %s.\n"),
2843 value);
2844}
2845
2846static void
2847show_static_field_print (struct ui_file *file, int from_tty,
2848 struct cmd_list_element *c,
2849 const char *value)
2850{
2851 gdb_printf (file,
2852 _("Printing of C++ static members is %s.\n"),
2853 value);
2854}
2855
2856
2857
2858/* A couple typedefs to make writing the options a bit more
2859 convenient. */
2866
2867/* Definitions of options for the "print" and "compile print"
2868 commands. */
2870
2872 "address",
2873 [] (value_print_options *opt) { return &opt->addressprint; },
2874 show_addressprint, /* show_cmd_cb */
2875 N_("Set printing of addresses."),
2876 N_("Show printing of addresses."),
2877 NULL, /* help_doc */
2878 },
2879
2881 "array",
2882 [] (value_print_options *opt) { return &opt->prettyformat_arrays; },
2883 show_prettyformat_arrays, /* show_cmd_cb */
2884 N_("Set pretty formatting of arrays."),
2885 N_("Show pretty formatting of arrays."),
2886 NULL, /* help_doc */
2887 },
2888
2890 "array-indexes",
2891 [] (value_print_options *opt) { return &opt->print_array_indexes; },
2892 show_print_array_indexes, /* show_cmd_cb */
2893 N_("Set printing of array indexes."),
2894 N_("Show printing of array indexes."),
2895 NULL, /* help_doc */
2896 },
2897
2899 "nibbles",
2900 [] (value_print_options *opt) { return &opt->nibblesprint; },
2901 show_nibbles, /* show_cmd_cb */
2902 N_("Set whether to print binary values in groups of four bits."),
2903 N_("Show whether to print binary values in groups of four bits."),
2904 NULL, /* help_doc */
2905 },
2906
2908 "elements",
2909 [] (value_print_options *opt) { return &opt->print_max; },
2910 show_print_max, /* show_cmd_cb */
2911 N_("Set limit on string chars or array elements to print."),
2912 N_("Show limit on string chars or array elements to print."),
2913 N_("\"unlimited\" causes there to be no limit."),
2914 },
2915
2917 "max-depth",
2918 [] (value_print_options *opt) { return &opt->max_depth; },
2919 show_print_max_depth, /* show_cmd_cb */
2920 N_("Set maximum print depth for nested structures, unions and arrays."),
2921 N_("Show maximum print depth for nested structures, unions, and arrays."),
2922 N_("When structures, unions, or arrays are nested beyond this depth then they\n\
2923will be replaced with either '{...}' or '(...)' depending on the language.\n\
2924Use \"unlimited\" to print the complete structure.")
2925 },
2926
2928 "memory-tag-violations",
2929 [] (value_print_options *opt) { return &opt->memory_tag_violations; },
2930 show_memory_tag_violations, /* show_cmd_cb */
2931 N_("Set printing of memory tag violations for pointers."),
2932 N_("Show printing of memory tag violations for pointers."),
2933 N_("Issue a warning when the printed value is a pointer\n\
2934whose logical tag doesn't match the allocation tag of the memory\n\
2935location it points to."),
2936 },
2937
2939 "null-stop",
2940 [] (value_print_options *opt) { return &opt->stop_print_at_null; },
2941 show_stop_print_at_null, /* show_cmd_cb */
2942 N_("Set printing of char arrays to stop at first null char."),
2943 N_("Show printing of char arrays to stop at first null char."),
2944 NULL, /* help_doc */
2945 },
2946
2948 "object",
2949 [] (value_print_options *opt) { return &opt->objectprint; },
2950 show_objectprint, /* show_cmd_cb */
2951 _("Set printing of C++ virtual function tables."),
2952 _("Show printing of C++ virtual function tables."),
2953 NULL, /* help_doc */
2954 },
2955
2957 "pretty",
2958 [] (value_print_options *opt) { return &opt->prettyformat_structs; },
2959 show_prettyformat_structs, /* show_cmd_cb */
2960 N_("Set pretty formatting of structures."),
2961 N_("Show pretty formatting of structures."),
2962 NULL, /* help_doc */
2963 },
2964
2966 "raw-values",
2967 [] (value_print_options *opt) { return &opt->raw; },
2968 NULL, /* show_cmd_cb */
2969 N_("Set whether to print values in raw form."),
2970 N_("Show whether to print values in raw form."),
2971 N_("If set, values are printed in raw form, bypassing any\n\
2972pretty-printers for that value.")
2973 },
2974
2976 "repeats",
2977 [] (value_print_options *opt) { return &opt->repeat_count_threshold; },
2978 show_repeat_count_threshold, /* show_cmd_cb */
2979 N_("Set threshold for repeated print elements."),
2980 N_("Show threshold for repeated print elements."),
2981 N_("\"unlimited\" causes all elements to be individually printed."),
2982 },
2983
2985 "static-members",
2986 [] (value_print_options *opt) { return &opt->static_field_print; },
2987 show_static_field_print, /* show_cmd_cb */
2988 N_("Set printing of C++ static members."),
2989 N_("Show printing of C++ static members."),
2990 NULL, /* help_doc */
2991 },
2992
2994 "symbol",
2995 [] (value_print_options *opt) { return &opt->symbol_print; },
2996 show_symbol_print, /* show_cmd_cb */
2997 N_("Set printing of symbol names when printing pointers."),
2998 N_("Show printing of symbol names when printing pointers."),
2999 NULL, /* help_doc */
3000 },
3001
3003 "union",
3004 [] (value_print_options *opt) { return &opt->unionprint; },
3005 show_unionprint, /* show_cmd_cb */
3006 N_("Set printing of unions interior to structures."),
3007 N_("Show printing of unions interior to structures."),
3008 NULL, /* help_doc */
3009 },
3010
3012 "vtbl",
3013 [] (value_print_options *opt) { return &opt->vtblprint; },
3014 show_vtblprint, /* show_cmd_cb */
3015 N_("Set printing of C++ virtual function tables."),
3016 N_("Show printing of C++ virtual function tables."),
3017 NULL, /* help_doc */
3018 },
3019};
3020
3021/* See valprint.h. */
3022
3025{
3026 return {{value_print_option_defs}, opts};
3027}
3028
3029#if GDB_SELF_TEST
3030
3031/* Test printing of TYPE_CODE_FLAGS values. */
3032
3033static void
3034test_print_flags (gdbarch *arch)
3035{
3036 type *flags_type = arch_flags_type (arch, "test_type", 32);
3037 type *field_type = builtin_type (arch)->builtin_uint32;
3038
3039 /* Value: 1010 1010
3040 Fields: CCCB BAAA */
3041 append_flags_type_field (flags_type, 0, 3, field_type, "A");
3042 append_flags_type_field (flags_type, 3, 2, field_type, "B");
3043 append_flags_type_field (flags_type, 5, 3, field_type, "C");
3044
3045 value *val = allocate_value (flags_type);
3046 gdb_byte *contents = value_contents_writeable (val).data ();
3047 store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa);
3048
3049 string_file out;
3050 val_print_type_code_flags (flags_type, val, 0, &out);
3051 SELF_CHECK (out.string () == "[ A=2 B=1 C=5 ]");
3052}
3053
3054#endif
3055
3056void _initialize_valprint ();
3057void
3059{
3060#if GDB_SELF_TEST
3061 selftests::register_test_foreach_arch ("print-flags", test_print_flags);
3062#endif
3063
3064 set_show_commands setshow_print_cmds
3065 = add_setshow_prefix_cmd ("print", no_class,
3066 _("Generic command for setting how things print."),
3067 _("Generic command for showing print settings."),
3069 &setlist, &showlist);
3070 add_alias_cmd ("p", setshow_print_cmds.set, no_class, 1, &setlist);
3071 /* Prefer set print to set prompt. */
3072 add_alias_cmd ("pr", setshow_print_cmds.set, no_class, 1, &setlist);
3073 add_alias_cmd ("p", setshow_print_cmds.show, no_class, 1, &showlist);
3074 add_alias_cmd ("pr", setshow_print_cmds.show, no_class, 1, &showlist);
3075
3076 set_show_commands setshow_print_raw_cmds
3078 ("raw", no_class,
3079 _("Generic command for setting what things to print in \"raw\" mode."),
3080 _("Generic command for showing \"print raw\" settings."),
3082 deprecate_cmd (setshow_print_raw_cmds.set, nullptr);
3083 deprecate_cmd (setshow_print_raw_cmds.show, nullptr);
3084
3088
3090 _("\
3091Set default input radix for entering numbers."), _("\
3092Show default input radix for entering numbers."), NULL,
3095 &setlist, &showlist);
3096
3098 _("\
3099Set default output radix for printing of values."), _("\
3100Show default output radix for printing of values."), NULL,
3103 &setlist, &showlist);
3104
3105 /* The "set radix" and "show radix" commands are special in that
3106 they are like normal set and show commands but allow two normally
3107 independent variables to be either set or shown with a single
3108 command. So the usual deprecated_add_set_cmd() and [deleted]
3109 add_show_from_set() commands aren't really appropriate. */
3110 /* FIXME: i18n: With the new add_setshow_integer command, that is no
3111 longer true - show can display anything. */
3112 add_cmd ("radix", class_support, set_radix, _("\
3113Set default input and output number radices.\n\
3114Use 'set input-radix' or 'set output-radix' to independently set each.\n\
3115Without an argument, sets both radices back to the default value of 10."),
3116 &setlist);
3117 add_cmd ("radix", class_support, show_radix, _("\
3118Show the default input and output number radices.\n\
3119Use 'show input-radix' or 'show output-radix' to independently show each."),
3120 &showlist);
3121}
struct value * ada_to_fixed_value(struct value *val)
Definition ada-lang.c:8874
int code
Definition ada-lex.l:688
void annotate_elt_rep_end(void)
Definition annotate.c:586
void annotate_array_section_begin(int idx, struct type *elttype)
Definition annotate.c:568
void annotate_elt(void)
Definition annotate.c:593
void annotate_array_section_end(void)
Definition annotate.c:600
void annotate_elt_rep(unsigned int repcount)
Definition annotate.c:579
void f()
Definition 1.cc:36
void cp_print_class_member(const gdb_byte *, struct type *, struct ui_file *, const char *)
const char * host_charset(void)
Definition charset.c:416
void convert_between_encodings(const char *from, const char *to, const gdb_byte *bytes, unsigned int num_bytes, int width, struct obstack *output, enum transliterations translit)
Definition charset.c:497
@ translit_char
Definition charset.h:48
wchar_iterate_result
Definition charset.h:75
@ wchar_iterate_eof
Definition charset.h:83
@ wchar_iterate_invalid
Definition charset.h:79
@ wchar_iterate_incomplete
Definition charset.h:81
@ wchar_iterate_ok
Definition charset.h:77
ui_file_style style() const
Definition cli-style.c:169
const std::string & string()
Definition ui-file.h:194
virtual void wrap_here(int indent)
Definition ui-file.h:117
int iterate(enum wchar_iterate_result *out_result, gdb_wchar_t **out_chars, const gdb_byte **ptr, size_t *len)
Definition charset.c:608
struct cmd_list_element * showlist
Definition cli-cmds.c:125
struct cmd_list_element * showprintlist
Definition cli-cmds.c:161
struct cmd_list_element * setprintlist
Definition cli-cmds.c:159
struct cmd_list_element * setlist
Definition cli-cmds.c:117
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
Definition cli-decode.c:280
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:428
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cli_style_option variable_name_style
cli_style_option metadata_style
@ class_support
Definition command.h:58
@ no_class
Definition command.h:53
std::string memory_error_message(enum target_xfer_status err, struct gdbarch *gdbarch, CORE_ADDR memaddr)
Definition corefile.c:162
void cplus_print_method_ptr(const gdb_byte *contents, struct type *type, struct ui_file *stream)
Definition cp-abi.c:128
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:561
@ Val_prettyformat_default
Definition defs.h:425
@ Val_prettyformat
Definition defs.h:423
@ Val_no_prettyformat
Definition defs.h:422
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition findvar.c:153
language
Definition defs.h:211
@ language_ada
Definition defs.h:226
@ lval_memory
Definition defs.h:364
@ lval_register
Definition defs.h:366
#define UINT_MAX
Definition defs.h:453
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:526
#define QUIT
Definition defs.h:186
LONGEST parse_and_eval_long(const char *exp)
Definition eval.c:62
int apply_ext_lang_val_pretty_printer(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition extension.c:477
#define SINGLE
Definition f-exp.c:269
bool demangle
#define gdb_WEOF
Definition gdb_wchar.h:108
int gdb_wint_t
Definition gdb_wchar.h:102
char gdb_wchar_t
Definition gdb_wchar.h:101
#define gdb_iswxdigit
Definition gdb_wchar.h:106
#define gdb_iswprint
Definition gdb_wchar.h:105
#define LCST(X)
Definition gdb_wchar.h:110
#define gdb_btowc
Definition gdb_wchar.h:107
#define INTERMEDIATE_ENCODING
Definition gdb_wchar.h:117
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1370
int gdbarch_addressable_memory_unit_size(struct gdbarch *gdbarch)
Definition gdbarch.c:5200
CORE_ADDR gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
Definition gdbarch.c:3070
enum bfd_endian type_byte_order(const struct type *type)
Definition gdbtypes.c:4018
struct type * arch_flags_type(struct gdbarch *gdbarch, const char *name, int bit)
Definition gdbtypes.c:5935
void append_flags_type_field(struct type *type, int start_bitpos, int nr_bits, struct type *field_type, const char *name)
Definition gdbtypes.c:5954
bool get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
Definition gdbtypes.c:1220
int type_not_associated(const struct type *type)
Definition gdbtypes.c:4491
bool is_fixed_point_type(struct type *type)
Definition gdbtypes.c:6116
int type_not_allocated(const struct type *type)
Definition gdbtypes.c:4479
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:3010
#define TYPE_IS_REFERENCE(t)
Definition gdbtypes.h:156
void print_scalar_formatted(const gdb_byte *, struct type *, const struct value_print_options *, int, struct ui_file *)
Definition printcmd.c:367
@ TYPE_CODE_UNDEF
Definition gdbtypes.h:100
#define TYPE_FIELD_BITSIZE(thistype, n)
Definition gdbtypes.h:2123
#define TYPE_ERROR_NAME(type)
Definition gdbtypes.h:2234
std::string gmp_string_printf(const char *fmt,...)
Definition gmp-utils.c:23
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
Definition gnu-nat.c:1790
unsigned dummy
Definition go32-nat.c:8
size_t size
Definition go32-nat.c:241
struct inferior * current_inferior(void)
Definition inferior.c:54
const struct language_defn * current_language
Definition language.c:83
void add_setshow_cmds_for_options(command_class cmd_class, void *data, gdb::array_view< const option_def > options, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-option.c:771
void register_test_foreach_arch(const std::string &name, self_test_foreach_arch_function *function)
int print_address_demangle(const struct value_print_options *opts, struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream, int do_demangle)
Definition printcmd.c:767
struct type * builtin_bool
Definition gdbtypes.h:2263
struct type * builtin_uint32
Definition gdbtypes.h:2288
gdb_wchar_t chars[WCHAR_BUFLEN_MAX]
Definition valprint.c:70
const gdb_byte * buf
Definition valprint.c:73
enum wchar_iterate_result result
Definition valprint.c:67
LONGEST loc_bitpos() const
Definition gdbtypes.h:586
LONGEST loc_enumval() const
Definition gdbtypes.h:598
const char * name() const
Definition gdbtypes.h:569
struct type * type() const
Definition gdbtypes.h:559
virtual void print_array_index(struct type *index_type, LONGEST index_value, struct ui_file *stream, const value_print_options *options) const
Definition language.c:581
virtual void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options) const
Definition language.c:607
virtual void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const
Definition c-lang.c:193
virtual void printchar(int ch, struct type *chtype, struct ui_file *stream) const
Definition c-lang.c:159
virtual const char * get_digit_separator() const
Definition language.h:287
cmd_list_element * set
Definition command.h:406
cmd_list_element * show
Definition command.h:406
struct type * target_type() const
Definition gdbtypes.h:1000
type_code code() const
Definition gdbtypes.h:927
ULONGEST length() const
Definition gdbtypes.h:954
struct field & field(int idx) const
Definition gdbtypes.h:983
bool is_unsigned() const
Definition gdbtypes.h:1063
int num_fields() const
Definition gdbtypes.h:965
bool is_stub() const
Definition gdbtypes.h:1091
gdbarch * arch() const
Definition gdbtypes.c:245
ULONGEST bit_stride() const
Definition gdbtypes.h:1053
const gdb_mpq & fixed_point_scaling_factor()
Definition gdbtypes.c:6143
type * index_type() const
Definition gdbtypes.h:995
struct type * fixed_point_type_base_type()
Definition gdbtypes.c:6128
bool is_flag_enum() const
Definition gdbtypes.h:1244
const ui_file_style * ptr() const
Definition ui-style.h:233
unsigned int print_max
Definition valprint.h:58
enum val_prettyformat prettyformat
Definition valprint.h:30
unsigned int repeat_count_threshold
Definition valprint.h:62
bool prettyformat_structs
Definition valprint.h:36
Definition value.c:181
LONGEST embedded_offset
Definition value.c:347
CORE_ADDR address
Definition value.c:246
std::string target_float_to_string(const gdb_byte *addr, const struct type *type, const char *format)
int target_read_string(CORE_ADDR addr, int len, int width, unsigned int fetchlimit, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *bytes_read)
Definition target.c:65
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1771
@ TARGET_XFER_E_IO
Definition target.h:227
void val_print_not_allocated(struct ui_file *stream)
Definition typeprint.c:895
void val_print_not_associated(struct ui_file *stream)
Definition typeprint.c:903
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
Definition typeprint.c:391
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
Definition ui-out.h:151
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition utils.c:3114
void print_spaces(int n, struct ui_file *stream)
Definition utils.c:1947
void gdb_putc(int c)
Definition utils.c:1841
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
Definition utils.c:1877
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1865
void fputs_styled(const char *linebuffer, const ui_file_style &style, struct ui_file *stream)
Definition utils.c:1796
void gdb_flush(struct ui_file *stream)
Definition utils.c:1477
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1788
#define gdb_stdlog
Definition utils.h:196
struct value * value_at(struct type *type, CORE_ADDR addr)
Definition valops.c:1017
struct value * value_addr(struct value *arg1)
Definition valops.c:1543
struct value * value_cast(struct type *type, struct value *arg2)
Definition valops.c:408
struct value * value_real_part(struct value *value)
Definition valops.c:4116
struct value * value_imaginary_part(struct value *value)
Definition valops.c:4128
#define LOW_NIBBLE( x)
static void show_stop_print_at_null(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:221
static void generic_value_print_ptr(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:485
static void show_repeat_count_threshold(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:200
void get_formatted_print_options(struct value_print_options *opts, char format)
Definition valprint.c:145
#define HIGH_ONE
static void generic_val_print_fixed_point(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:823
void generic_value_print(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
Definition valprint.c:888
#define LOW_TWO
static void generic_value_print_bool(struct value *value, struct ui_file *stream, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
Definition valprint.c:738
static void show_nibbles(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:263
static void set_output_radix_1(int, unsigned)
Definition valprint.c:2744
static void generic_val_print_enum_1(struct type *type, LONGEST val, struct ui_file *stream)
Definition valprint.c:609
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:1172
unsigned output_radix
Definition valprint.c:175
static void show_print_array_indexes(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:189
void get_no_prettyformat_print_options(struct value_print_options *opts)
Definition valprint.c:136
void generic_emit_char(int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding)
Definition valprint.c:2174
#define CARRY_OUT( x)
void value_print_scalar_formatted(struct value *val, const struct value_print_options *options, int size, struct ui_file *stream)
Definition valprint.c:1259
void print_decimal_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, bool is_signed, enum bfd_endian byte_order)
Definition valprint.c:1686
void val_print_unavailable(struct ui_file *stream)
Definition valprint.c:411
static void show_memory_tag_violations(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:210
#define LOW_ZERO
static void generic_val_print_enum(struct type *type, int embedded_offset, struct ui_file *stream, struct value *original_value, const struct value_print_options *options)
Definition valprint.c:693
void print_octal_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order)
Definition valprint.c:1485
static void generic_val_print_func(struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, struct value *original_value, const struct value_print_options *options)
Definition valprint.c:714
#define CARRY_LEFT(x)
void _initialize_valprint()
Definition valprint.c:3058
int valprint_check_validity(struct ui_file *stream, struct type *type, LONGEST embedded_offset, const struct value *val)
Definition valprint.c:332
#define PRINT_MAX_DEFAULT
Definition valprint.c:97
static void show_addressprint(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:274
int val_print_scalar_type_p(struct type *type)
Definition valprint.c:296
static bool val_print_scalar_or_string_type_p(struct type *type, const struct language_defn *language)
Definition valprint.c:322
gdb::option::option_def_group make_value_print_options_def_group(value_print_options *opts)
Definition valprint.c:3024
static void generic_value_print_char(struct value *value, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:779
static void show_print_max(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:153
static void show_vtblprint(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:2826
static unsigned input_radix_1
Definition valprint.c:2694
unsigned input_radix
Definition valprint.c:165
struct cmd_list_element * showprintrawlist
Definition valprint.c:84
static void emit_octal_digit(struct ui_file *stream, bool *seen_a_one, int digit)
Definition valprint.c:1473
#define CARRY_ZERO
void val_print_optimized_out(const struct value *val, struct ui_file *stream)
Definition valprint.c:396
#define MID_ONE
int longest_to_int(LONGEST arg)
Definition valprint.c:1353
bool val_print_check_max_depth(struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1085
static const gdb::option::option_def value_print_option_defs[]
Definition valprint.c:2869
static void print_unpacked_pointer(struct type *type, struct type *elttype, CORE_ADDR address, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:430
static void generic_value_print_complex(struct value *val, struct ui_file *stream, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
Definition valprint.c:848
#define WCHAR_BUFLEN(X)
Definition valprint.c:54
static void generic_val_print_array(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
Definition valprint.c:452
void ATTRIBUTE_UNUSED debug_val(struct value *val)
Definition valprint.c:1199
#define MID_TWO
static unsigned output_radix_1
Definition valprint.c:2735
static bool maybe_negate_by_bytes(const gdb_byte *bytes, unsigned len, enum bfd_endian byte_order, gdb::byte_vector *out_vec)
Definition valprint.c:1642
void val_print_invalid_address(struct ui_file *stream)
Definition valprint.c:417
static void generic_value_print_int(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:766
static void print_converted_chars_to_obstack(struct obstack *obstack, const std::vector< converted_character > &chars, int quote_char, int width, enum bfd_endian byte_order, const struct value_print_options *options)
Definition valprint.c:2335
#define CARRY_ONE
int val_print_string(struct type *elttype, const char *encoding, CORE_ADDR addr, int len, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:2598
#define WCHAR_BUFLEN_MAX
Definition valprint.c:57
#define PRINT_MAX_DEPTH_DEFAULT
Definition valprint.c:98
static void show_output_radix(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:177
void get_user_print_options(struct value_print_options *opts)
Definition valprint.c:128
static void set_input_radix_1(int, unsigned)
Definition valprint.c:2707
void common_val_print_checked(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1158
#define HIGH_ZERO
static void show_radix(const char *arg, int from_tty)
Definition valprint.c:2801
static void show_print_max_depth(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:2683
static void generic_val_print_ref(struct type *type, int embedded_offset, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options)
Definition valprint.c:542
static void show_static_field_print(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:2847
static void set_input_radix(const char *args, int from_tty, struct cmd_list_element *c)
Definition valprint.c:2701
static void generic_val_print_float(struct type *type, struct ui_file *stream, struct value *original_value, const struct value_print_options *options)
Definition valprint.c:809
static int value_check_printable(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:1104
static void show_unionprint(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:252
void print_hex_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad)
Definition valprint.c:1822
void print_floating(const gdb_byte *valaddr, struct type *type, struct ui_file *stream)
Definition valprint.c:1373
#define HIGH_NIBBLE(x)
static void append_string_as_wide(const char *string, struct obstack *output)
Definition valprint.c:2059
static void print_wchar(gdb_wint_t w, const gdb_byte *orig, int orig_len, int width, enum bfd_endian byte_order, struct obstack *output, int quoter, bool *need_escapep)
Definition valprint.c:2079
void value_print_array_elements(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, unsigned int i)
Definition valprint.c:1922
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)
Definition valprint.c:1316
static int wchar_printable(gdb_wchar_t w)
Definition valprint.c:2046
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1014
static void set_output_radix(const char *args, int from_tty, struct cmd_list_element *c)
Definition valprint.c:2738
void print_function_pointer_address(const struct value_print_options *options, struct gdbarch *gdbarch, CORE_ADDR address, struct ui_file *stream)
Definition valprint.c:1885
static void show_prettyformat_arrays(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:242
static void val_print_type_code_flags(struct type *type, struct value *original_value, int embedded_offset, struct ui_file *stream)
Definition valprint.c:1206
#define HIGH_TWO
void print_binary_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad, const struct value_print_options *options)
Definition valprint.c:1381
struct value_print_options user_print_options
Definition valprint.c:100
void maybe_print_array_index(struct type *index_type, LONGEST index, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:1909
static void show_input_radix(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:167
static void print_ref_address(struct type *type, const gdb_byte *address_buffer, int embedded_offset, struct ui_file *stream)
Definition valprint.c:506
static const gdb_byte * get_value_addr_contents(struct value *deref_val)
Definition valprint.c:526
static void set_radix(const char *arg, int from_tty)
Definition valprint.c:2783
#define LOW_ONE
#define SHIFT(x)
struct cmd_list_element * setprintrawlist
Definition valprint.c:83
static int count_next_character(wchar_iterator *iter, std::vector< converted_character > *vec)
Definition valprint.c:2250
void val_print_not_saved(struct ui_file *stream)
Definition valprint.c:405
#define MAX_WCHARS
Definition valprint.c:50
void generic_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, int quote_char, int c_style_terminator, const struct value_print_options *options)
Definition valprint.c:2492
#define BITS_IN_OCTAL
static void show_objectprint(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:2837
static void show_symbol_print(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:281
static void show_prettyformat_structs(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition valprint.c:233
static void generic_value_print_memberptr(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
Definition valprint.c:868
int value_bytes_available(const struct value *value, LONGEST offset, LONGEST length)
Definition value.c:391
struct type * value_type(const struct value *value)
Definition value.c:1109
int value_entirely_optimized_out(struct value *value)
Definition value.c:453
struct value * coerce_ref_if_computed(const struct value *arg)
Definition value.c:3857
int value_lazy(const struct value *value)
Definition value.c:1440
gdb::array_view< const gdb_byte > value_contents_for_printing_const(const struct value *value)
Definition value.c:1275
struct value * allocate_value(struct type *type)
Definition value.c:1053
CORE_ADDR unpack_pointer(struct type *type, const gdb_byte *valaddr)
Definition value.c:3012
void value_fetch_lazy(struct value *val)
Definition value.c:4162
struct value * value_from_component_bitsize(struct value *whole, struct type *type, LONGEST bit_offset, LONGEST bit_length)
Definition value.c:3828
CORE_ADDR value_address(const struct value *value)
Definition value.c:1607
gdb::array_view< gdb_byte > value_contents_writeable(struct value *value)
Definition value.c:1473
int value_bits_any_optimized_out(const struct value *value, int bit_offset, int bit_length)
Definition value.c:400
const char * value_internal_function_name(struct value *val)
Definition value.c:2538
bool value_contents_eq(const struct value *val1, LONGEST offset1, const struct value *val2, LONGEST offset2, LONGEST length)
Definition value.c:910
enum lval_type value_lval_const(const struct value *value)
Definition value.c:1601
void pack_long(gdb_byte *buf, struct type *type, LONGEST num)
Definition value.c:3513
gdb::array_view< const gdb_byte > value_contents_for_printing(struct value *value)
Definition value.c:1265
int value_bits_synthetic_pointer(const struct value *value, LONGEST offset, LONGEST length)
Definition value.c:1543
int value_entirely_unavailable(struct value *value)
Definition value.c:447
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)
Definition value.c:2921