1 /* Print values for GNU debugger GDB.
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "gdb_string.h"
29 #include "expression.h"
33 #include "breakpoint.h"
37 #include "symfile.h" /* for overlay functions */
38 #include "objfiles.h" /* ditto */
39 #include "completer.h" /* for completion functions */
41 #include "gdb_assert.h"
46 #include "exceptions.h"
49 #include "parser-defs.h"
51 #include "arch-utils.h"
54 #include "tui/tui.h" /* For tui_active et.al. */
57 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
58 # define USE_PRINTF_I64 1
59 # define PRINTF_HAS_LONG_LONG
61 # define USE_PRINTF_I64 0
64 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
72 /* True if the value should be printed raw -- that is, bypassing
73 python-based formatters. */
77 /* Last specified output format. */
79 static char last_format
= 0;
81 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
83 static char last_size
= 'w';
85 /* Default address to examine next, and associated architecture. */
87 static struct gdbarch
*next_gdbarch
;
88 static CORE_ADDR next_address
;
90 /* Number of delay instructions following current disassembled insn. */
92 static int branch_delay_insns
;
94 /* Last address examined. */
96 static CORE_ADDR last_examine_address
;
98 /* Contents of last address examined.
99 This is not valid past the end of the `x' command! */
101 static struct value
*last_examine_value
;
103 /* Largest offset between a symbolic value and an address, that will be
104 printed as `0x1234 <symbol+offset>'. */
106 static unsigned int max_symbolic_offset
= UINT_MAX
;
108 show_max_symbolic_offset (struct ui_file
*file
, int from_tty
,
109 struct cmd_list_element
*c
, const char *value
)
111 fprintf_filtered (file
,
112 _("The largest offset that will be "
113 "printed in <symbol+1234> form is %s.\n"),
117 /* Append the source filename and linenumber of the symbol when
118 printing a symbolic value as `<symbol at filename:linenum>' if set. */
119 static int print_symbol_filename
= 0;
121 show_print_symbol_filename (struct ui_file
*file
, int from_tty
,
122 struct cmd_list_element
*c
, const char *value
)
124 fprintf_filtered (file
, _("Printing of source filename and "
125 "line number with <symbol> is %s.\n"),
129 /* Number of auto-display expression currently being displayed.
130 So that we can disable it if we get an error or a signal within it.
131 -1 when not doing one. */
133 int current_display_number
;
137 /* Chain link to next auto-display item. */
138 struct display
*next
;
140 /* The expression as the user typed it. */
143 /* Expression to be evaluated and displayed. */
144 struct expression
*exp
;
146 /* Item number of this auto-display item. */
149 /* Display format specified. */
150 struct format_data format
;
152 /* Program space associated with `block'. */
153 struct program_space
*pspace
;
155 /* Innermost block required by this expression when evaluated */
158 /* Status of this display (enabled or disabled) */
162 /* Chain of expressions whose values should be displayed
163 automatically each time the program stops. */
165 static struct display
*display_chain
;
167 static int display_number
;
169 /* Prototypes for exported functions. */
171 void output_command (char *, int);
173 void _initialize_printcmd (void);
175 /* Prototypes for local functions. */
177 static void do_one_display (struct display
*);
180 /* Decode a format specification. *STRING_PTR should point to it.
181 OFORMAT and OSIZE are used as defaults for the format and size
182 if none are given in the format specification.
183 If OSIZE is zero, then the size field of the returned value
184 should be set only if a size is explicitly specified by the
186 The structure returned describes all the data
187 found in the specification. In addition, *STRING_PTR is advanced
188 past the specification and past all whitespace following it. */
190 static struct format_data
191 decode_format (char **string_ptr
, int oformat
, int osize
)
193 struct format_data val
;
194 char *p
= *string_ptr
;
201 if (*p
>= '0' && *p
<= '9')
202 val
.count
= atoi (p
);
203 while (*p
>= '0' && *p
<= '9')
206 /* Now process size or format letters that follow. */
210 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
217 else if (*p
>= 'a' && *p
<= 'z')
223 while (*p
== ' ' || *p
== '\t')
227 /* Set defaults for format and size if not specified. */
228 if (val
.format
== '?')
232 /* Neither has been specified. */
233 val
.format
= oformat
;
237 /* If a size is specified, any format makes a reasonable
238 default except 'i'. */
239 val
.format
= oformat
== 'i' ? 'x' : oformat
;
241 else if (val
.size
== '?')
245 /* Pick the appropriate size for an address. This is deferred
246 until do_examine when we know the actual architecture to use.
247 A special size value of 'a' is used to indicate this case. */
248 val
.size
= osize
? 'a' : osize
;
251 /* Floating point has to be word or giantword. */
252 if (osize
== 'w' || osize
== 'g')
255 /* Default it to giantword if the last used size is not
257 val
.size
= osize
? 'g' : osize
;
260 /* Characters default to one byte. */
261 val
.size
= osize
? 'b' : osize
;
264 /* Display strings with byte size chars unless explicitly
270 /* The default is the size most recently specified. */
277 /* Print value VAL on stream according to OPTIONS.
278 Do not end with a newline.
279 SIZE is the letter for the size of datum being printed.
280 This is used to pad hex numbers so they line up. SIZE is 0
281 for print / output and set for examine. */
284 print_formatted (struct value
*val
, int size
,
285 const struct value_print_options
*options
,
286 struct ui_file
*stream
)
288 struct type
*type
= check_typedef (value_type (val
));
289 int len
= TYPE_LENGTH (type
);
291 if (VALUE_LVAL (val
) == lval_memory
)
292 next_address
= value_address (val
) + len
;
296 switch (options
->format
)
300 struct type
*elttype
= value_type (val
);
302 next_address
= (value_address (val
)
303 + val_print_string (elttype
, NULL
,
304 value_address (val
), -1,
305 stream
, options
) * len
);
310 /* We often wrap here if there are long symbolic names. */
312 next_address
= (value_address (val
)
313 + gdb_print_insn (get_type_arch (type
),
314 value_address (val
), stream
,
315 &branch_delay_insns
));
320 if (options
->format
== 0 || options
->format
== 's'
321 || TYPE_CODE (type
) == TYPE_CODE_REF
322 || TYPE_CODE (type
) == TYPE_CODE_ARRAY
323 || TYPE_CODE (type
) == TYPE_CODE_STRING
324 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
325 || TYPE_CODE (type
) == TYPE_CODE_UNION
326 || TYPE_CODE (type
) == TYPE_CODE_NAMESPACE
)
327 value_print (val
, stream
, options
);
329 /* User specified format, so don't look to the the type to
330 tell us what to do. */
331 print_scalar_formatted (value_contents (val
), type
,
332 options
, size
, stream
);
335 /* Return builtin floating point type of same length as TYPE.
336 If no such type is found, return TYPE itself. */
338 float_type_from_length (struct type
*type
)
340 struct gdbarch
*gdbarch
= get_type_arch (type
);
341 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
342 unsigned int len
= TYPE_LENGTH (type
);
344 if (len
== TYPE_LENGTH (builtin
->builtin_float
))
345 type
= builtin
->builtin_float
;
346 else if (len
== TYPE_LENGTH (builtin
->builtin_double
))
347 type
= builtin
->builtin_double
;
348 else if (len
== TYPE_LENGTH (builtin
->builtin_long_double
))
349 type
= builtin
->builtin_long_double
;
354 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
355 according to OPTIONS and SIZE on STREAM.
356 Formats s and i are not supported at this level.
358 This is how the elements of an array or structure are printed
362 print_scalar_formatted (const void *valaddr
, struct type
*type
,
363 const struct value_print_options
*options
,
364 int size
, struct ui_file
*stream
)
366 struct gdbarch
*gdbarch
= get_type_arch (type
);
367 LONGEST val_long
= 0;
368 unsigned int len
= TYPE_LENGTH (type
);
369 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
371 /* If we get here with a string format, try again without it. Go
372 all the way back to the language printers, which may call us
374 if (options
->format
== 's')
376 struct value_print_options opts
= *options
;
379 val_print (type
, valaddr
, 0, 0, stream
, 0, NULL
, &opts
,
384 if (len
> sizeof(LONGEST
) &&
385 (TYPE_CODE (type
) == TYPE_CODE_INT
386 || TYPE_CODE (type
) == TYPE_CODE_ENUM
))
388 switch (options
->format
)
391 print_octal_chars (stream
, valaddr
, len
, byte_order
);
395 print_decimal_chars (stream
, valaddr
, len
, byte_order
);
398 print_binary_chars (stream
, valaddr
, len
, byte_order
);
401 print_hex_chars (stream
, valaddr
, len
, byte_order
);
404 print_char_chars (stream
, type
, valaddr
, len
, byte_order
);
411 if (options
->format
!= 'f')
412 val_long
= unpack_long (type
, valaddr
);
414 /* If the value is a pointer, and pointers and addresses are not the
415 same, then at this point, the value's length (in target bytes) is
416 gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */
417 if (TYPE_CODE (type
) == TYPE_CODE_PTR
)
418 len
= gdbarch_addr_bit (gdbarch
) / TARGET_CHAR_BIT
;
420 /* If we are printing it as unsigned, truncate it in case it is actually
421 a negative signed value (e.g. "print/u (short)-1" should print 65535
422 (if shorts are 16 bits) instead of 4294967295). */
423 if (options
->format
!= 'd' || TYPE_UNSIGNED (type
))
425 if (len
< sizeof (LONGEST
))
426 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
429 switch (options
->format
)
434 /* No size specified, like in print. Print varying # of digits. */
435 print_longest (stream
, 'x', 1, val_long
);
444 print_longest (stream
, size
, 1, val_long
);
447 error (_("Undefined output size \"%c\"."), size
);
452 print_longest (stream
, 'd', 1, val_long
);
456 print_longest (stream
, 'u', 0, val_long
);
461 print_longest (stream
, 'o', 1, val_long
);
463 fprintf_filtered (stream
, "0");
468 CORE_ADDR addr
= unpack_pointer (type
, valaddr
);
470 print_address (gdbarch
, addr
, stream
);
476 struct value_print_options opts
= *options
;
479 if (TYPE_UNSIGNED (type
))
480 type
= builtin_type (gdbarch
)->builtin_true_unsigned_char
;
482 type
= builtin_type (gdbarch
)->builtin_true_char
;
484 value_print (value_from_longest (type
, val_long
), stream
, &opts
);
489 type
= float_type_from_length (type
);
490 print_floating (valaddr
, type
, stream
);
494 internal_error (__FILE__
, __LINE__
,
495 _("failed internal consistency check"));
498 /* Binary; 't' stands for "two". */
500 char bits
[8 * (sizeof val_long
) + 1];
501 char buf
[8 * (sizeof val_long
) + 32];
506 width
= 8 * (sizeof val_long
);
523 error (_("Undefined output size \"%c\"."), size
);
529 bits
[width
] = (val_long
& 1) ? '1' : '0';
534 while (*cp
&& *cp
== '0')
540 fputs_filtered (buf
, stream
);
545 error (_("Undefined output format \"%c\"."), options
->format
);
549 /* Specify default address for `x' command.
550 The `info lines' command uses this. */
553 set_next_address (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
555 struct type
*ptr_type
= builtin_type (gdbarch
)->builtin_data_ptr
;
557 next_gdbarch
= gdbarch
;
560 /* Make address available to the user as $_. */
561 set_internalvar (lookup_internalvar ("_"),
562 value_from_pointer (ptr_type
, addr
));
565 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
566 after LEADIN. Print nothing if no symbolic name is found nearby.
567 Optionally also print source file and line number, if available.
568 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
569 or to interpret it as a possible C++ name and convert it back to source
570 form. However note that DO_DEMANGLE can be overridden by the specific
571 settings of the demangle and asm_demangle variables. */
574 print_address_symbolic (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
575 struct ui_file
*stream
,
576 int do_demangle
, char *leadin
)
579 char *filename
= NULL
;
584 /* Throw away both name and filename. */
585 struct cleanup
*cleanup_chain
= make_cleanup (free_current_contents
, &name
);
586 make_cleanup (free_current_contents
, &filename
);
588 if (build_address_symbolic (gdbarch
, addr
, do_demangle
, &name
, &offset
,
589 &filename
, &line
, &unmapped
))
591 do_cleanups (cleanup_chain
);
595 fputs_filtered (leadin
, stream
);
597 fputs_filtered ("<*", stream
);
599 fputs_filtered ("<", stream
);
600 fputs_filtered (name
, stream
);
602 fprintf_filtered (stream
, "+%u", (unsigned int) offset
);
604 /* Append source filename and line number if desired. Give specific
605 line # of this addr, if we have it; else line # of the nearest symbol. */
606 if (print_symbol_filename
&& filename
!= NULL
)
609 fprintf_filtered (stream
, " at %s:%d", filename
, line
);
611 fprintf_filtered (stream
, " in %s", filename
);
614 fputs_filtered ("*>", stream
);
616 fputs_filtered (">", stream
);
618 do_cleanups (cleanup_chain
);
621 /* Given an address ADDR return all the elements needed to print the
622 address in a symbolic form. NAME can be mangled or not depending
623 on DO_DEMANGLE (and also on the asm_demangle global variable,
624 manipulated via ''set print asm-demangle''). Return 0 in case of
625 success, when all the info in the OUT paramters is valid. Return 1
628 build_address_symbolic (struct gdbarch
*gdbarch
,
629 CORE_ADDR addr
, /* IN */
630 int do_demangle
, /* IN */
631 char **name
, /* OUT */
632 int *offset
, /* OUT */
633 char **filename
, /* OUT */
635 int *unmapped
) /* OUT */
637 struct minimal_symbol
*msymbol
;
638 struct symbol
*symbol
;
639 CORE_ADDR name_location
= 0;
640 struct obj_section
*section
= NULL
;
641 char *name_temp
= "";
643 /* Let's say it is mapped (not unmapped). */
646 /* Determine if the address is in an overlay, and whether it is
648 if (overlay_debugging
)
650 section
= find_pc_overlay (addr
);
651 if (pc_in_unmapped_range (addr
, section
))
654 addr
= overlay_mapped_address (addr
, section
);
658 /* First try to find the address in the symbol table, then
659 in the minsyms. Take the closest one. */
661 /* This is defective in the sense that it only finds text symbols. So
662 really this is kind of pointless--we should make sure that the
663 minimal symbols have everything we need (by changing that we could
664 save some memory, but for many debug format--ELF/DWARF or
665 anything/stabs--it would be inconvenient to eliminate those minimal
667 msymbol
= lookup_minimal_symbol_by_pc_section (addr
, section
);
668 symbol
= find_pc_sect_function (addr
, section
);
672 /* If this is a function (i.e. a code address), strip out any
673 non-address bits. For instance, display a pointer to the
674 first instruction of a Thumb function as <function>; the
675 second instruction will be <function+2>, even though the
676 pointer is <function+3>. This matches the ISA behavior. */
677 addr
= gdbarch_addr_bits_remove (gdbarch
, addr
);
679 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
680 if (do_demangle
|| asm_demangle
)
681 name_temp
= SYMBOL_PRINT_NAME (symbol
);
683 name_temp
= SYMBOL_LINKAGE_NAME (symbol
);
688 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
|| symbol
== NULL
)
690 /* The msymbol is closer to the address than the symbol;
691 use the msymbol instead. */
693 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
694 if (do_demangle
|| asm_demangle
)
695 name_temp
= SYMBOL_PRINT_NAME (msymbol
);
697 name_temp
= SYMBOL_LINKAGE_NAME (msymbol
);
700 if (symbol
== NULL
&& msymbol
== NULL
)
703 /* If the nearest symbol is too far away, don't print anything symbolic. */
705 /* For when CORE_ADDR is larger than unsigned int, we do math in
706 CORE_ADDR. But when we detect unsigned wraparound in the
707 CORE_ADDR math, we ignore this test and print the offset,
708 because addr+max_symbolic_offset has wrapped through the end
709 of the address space back to the beginning, giving bogus comparison. */
710 if (addr
> name_location
+ max_symbolic_offset
711 && name_location
+ max_symbolic_offset
> name_location
)
714 *offset
= addr
- name_location
;
716 *name
= xstrdup (name_temp
);
718 if (print_symbol_filename
)
720 struct symtab_and_line sal
;
722 sal
= find_pc_sect_line (addr
, section
, 0);
726 *filename
= xstrdup (sal
.symtab
->filename
);
734 /* Print address ADDR symbolically on STREAM.
735 First print it as a number. Then perhaps print
736 <SYMBOL + OFFSET> after the number. */
739 print_address (struct gdbarch
*gdbarch
,
740 CORE_ADDR addr
, struct ui_file
*stream
)
742 fputs_filtered (paddress (gdbarch
, addr
), stream
);
743 print_address_symbolic (gdbarch
, addr
, stream
, asm_demangle
, " ");
746 /* Return a prefix for instruction address:
747 "=> " for current instruction, else " ". */
750 pc_prefix (CORE_ADDR addr
)
752 if (has_stack_frames ())
754 struct frame_info
*frame
;
757 frame
= get_selected_frame (NULL
);
758 pc
= get_frame_pc (frame
);
766 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
767 controls whether to print the symbolic name "raw" or demangled.
768 Global setting "addressprint" controls whether to print hex address
772 print_address_demangle (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
773 struct ui_file
*stream
, int do_demangle
)
775 struct value_print_options opts
;
777 get_user_print_options (&opts
);
780 fprintf_filtered (stream
, "0");
782 else if (opts
.addressprint
)
784 fputs_filtered (paddress (gdbarch
, addr
), stream
);
785 print_address_symbolic (gdbarch
, addr
, stream
, do_demangle
, " ");
789 print_address_symbolic (gdbarch
, addr
, stream
, do_demangle
, "");
794 /* Examine data at address ADDR in format FMT.
795 Fetch it from memory and print on gdb_stdout. */
798 do_examine (struct format_data fmt
, struct gdbarch
*gdbarch
, CORE_ADDR addr
)
803 struct type
*val_type
= NULL
;
806 struct value_print_options opts
;
811 next_gdbarch
= gdbarch
;
814 /* Instruction format implies fetch single bytes
815 regardless of the specified size.
816 The case of strings is handled in decode_format, only explicit
817 size operator are not changed to 'b'. */
823 /* Pick the appropriate size for an address. */
824 if (gdbarch_ptr_bit (next_gdbarch
) == 64)
826 else if (gdbarch_ptr_bit (next_gdbarch
) == 32)
828 else if (gdbarch_ptr_bit (next_gdbarch
) == 16)
831 /* Bad value for gdbarch_ptr_bit. */
832 internal_error (__FILE__
, __LINE__
,
833 _("failed internal consistency check"));
837 val_type
= builtin_type (next_gdbarch
)->builtin_int8
;
838 else if (size
== 'h')
839 val_type
= builtin_type (next_gdbarch
)->builtin_int16
;
840 else if (size
== 'w')
841 val_type
= builtin_type (next_gdbarch
)->builtin_int32
;
842 else if (size
== 'g')
843 val_type
= builtin_type (next_gdbarch
)->builtin_int64
;
847 struct type
*char_type
= NULL
;
849 /* Search for "char16_t" or "char32_t" types or fall back to 8-bit char
850 if type is not found. */
852 char_type
= builtin_type (next_gdbarch
)->builtin_char16
;
853 else if (size
== 'w')
854 char_type
= builtin_type (next_gdbarch
)->builtin_char32
;
856 val_type
= char_type
;
859 if (size
!= '\0' && size
!= 'b')
860 warning (_("Unable to display strings with size '%c', using 'b' \
863 val_type
= builtin_type (next_gdbarch
)->builtin_int8
;
872 if (format
== 's' || format
== 'i')
875 get_formatted_print_options (&opts
, format
);
877 /* Print as many objects as specified in COUNT, at most maxelts per line,
878 with the address of the next one at the start of each line. */
884 fputs_filtered (pc_prefix (next_address
), gdb_stdout
);
885 print_address (next_gdbarch
, next_address
, gdb_stdout
);
886 printf_filtered (":");
891 printf_filtered ("\t");
892 /* Note that print_formatted sets next_address for the next
894 last_examine_address
= next_address
;
896 if (last_examine_value
)
897 value_free (last_examine_value
);
899 /* The value to be displayed is not fetched greedily.
900 Instead, to avoid the possibility of a fetched value not
901 being used, its retrieval is delayed until the print code
902 uses it. When examining an instruction stream, the
903 disassembler will perform its own memory fetch using just
904 the address stored in LAST_EXAMINE_VALUE. FIXME: Should
905 the disassembler be modified so that LAST_EXAMINE_VALUE
906 is left with the byte sequence from the last complete
907 instruction fetched from memory? */
908 last_examine_value
= value_at_lazy (val_type
, next_address
);
910 if (last_examine_value
)
911 release_value (last_examine_value
);
913 print_formatted (last_examine_value
, size
, &opts
, gdb_stdout
);
915 /* Display any branch delay slots following the final insn. */
916 if (format
== 'i' && count
== 1)
917 count
+= branch_delay_insns
;
919 printf_filtered ("\n");
920 gdb_flush (gdb_stdout
);
925 validate_format (struct format_data fmt
, char *cmdname
)
928 error (_("Size letters are meaningless in \"%s\" command."), cmdname
);
930 error (_("Item count other than 1 is meaningless in \"%s\" command."),
932 if (fmt
.format
== 'i')
933 error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
934 fmt
.format
, cmdname
);
937 /* Evaluate string EXP as an expression in the current language and
938 print the resulting value. EXP may contain a format specifier as the
939 first argument ("/x myvar" for example, to print myvar in hex). */
942 print_command_1 (char *exp
, int inspect
, int voidprint
)
944 struct expression
*expr
;
945 struct cleanup
*old_chain
= 0;
948 struct format_data fmt
;
951 if (exp
&& *exp
== '/')
954 fmt
= decode_format (&exp
, last_format
, 0);
955 validate_format (fmt
, "print");
956 last_format
= format
= fmt
.format
;
968 expr
= parse_expression (exp
);
969 old_chain
= make_cleanup (free_current_contents
, &expr
);
971 val
= evaluate_expression (expr
);
974 val
= access_value_history (0);
976 if (voidprint
|| (val
&& value_type (val
) &&
977 TYPE_CODE (value_type (val
)) != TYPE_CODE_VOID
))
979 struct value_print_options opts
;
980 int histindex
= record_latest_value (val
);
983 annotate_value_history_begin (histindex
, value_type (val
));
985 annotate_value_begin (value_type (val
));
988 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"",
990 else if (histindex
>= 0)
991 printf_filtered ("$%d = ", histindex
);
994 annotate_value_history_value ();
996 get_formatted_print_options (&opts
, format
);
997 opts
.inspect_it
= inspect
;
1000 print_formatted (val
, fmt
.size
, &opts
, gdb_stdout
);
1001 printf_filtered ("\n");
1004 annotate_value_history_end ();
1006 annotate_value_end ();
1009 printf_unfiltered ("\") )\030");
1013 do_cleanups (old_chain
);
1017 print_command (char *exp
, int from_tty
)
1019 print_command_1 (exp
, 0, 1);
1022 /* Same as print, except in epoch, it gets its own window. */
1024 inspect_command (char *exp
, int from_tty
)
1026 extern int epoch_interface
;
1028 print_command_1 (exp
, epoch_interface
, 1);
1031 /* Same as print, except it doesn't print void results. */
1033 call_command (char *exp
, int from_tty
)
1035 print_command_1 (exp
, 0, 0);
1039 output_command (char *exp
, int from_tty
)
1041 struct expression
*expr
;
1042 struct cleanup
*old_chain
;
1045 struct format_data fmt
;
1046 struct value_print_options opts
;
1051 if (exp
&& *exp
== '/')
1054 fmt
= decode_format (&exp
, 0, 0);
1055 validate_format (fmt
, "output");
1056 format
= fmt
.format
;
1059 expr
= parse_expression (exp
);
1060 old_chain
= make_cleanup (free_current_contents
, &expr
);
1062 val
= evaluate_expression (expr
);
1064 annotate_value_begin (value_type (val
));
1066 get_formatted_print_options (&opts
, format
);
1068 print_formatted (val
, fmt
.size
, &opts
, gdb_stdout
);
1070 annotate_value_end ();
1073 gdb_flush (gdb_stdout
);
1075 do_cleanups (old_chain
);
1079 set_command (char *exp
, int from_tty
)
1081 struct expression
*expr
= parse_expression (exp
);
1082 struct cleanup
*old_chain
=
1083 make_cleanup (free_current_contents
, &expr
);
1085 evaluate_expression (expr
);
1086 do_cleanups (old_chain
);
1090 sym_info (char *arg
, int from_tty
)
1092 struct minimal_symbol
*msymbol
;
1093 struct objfile
*objfile
;
1094 struct obj_section
*osect
;
1095 CORE_ADDR addr
, sect_addr
;
1097 unsigned int offset
;
1100 error_no_arg (_("address"));
1102 addr
= parse_and_eval_address (arg
);
1103 ALL_OBJSECTIONS (objfile
, osect
)
1105 /* Only process each object file once, even if there's a separate
1107 if (objfile
->separate_debug_objfile_backlink
)
1110 sect_addr
= overlay_mapped_address (addr
, osect
);
1112 if (obj_section_addr (osect
) <= sect_addr
1113 && sect_addr
< obj_section_endaddr (osect
)
1114 && (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr
, osect
)))
1116 const char *obj_name
, *mapped
, *sec_name
, *msym_name
;
1118 struct cleanup
*old_chain
;
1121 offset
= sect_addr
- SYMBOL_VALUE_ADDRESS (msymbol
);
1122 mapped
= section_is_mapped (osect
) ? _("mapped") : _("unmapped");
1123 sec_name
= osect
->the_bfd_section
->name
;
1124 msym_name
= SYMBOL_PRINT_NAME (msymbol
);
1126 /* Don't print the offset if it is zero.
1127 We assume there's no need to handle i18n of "sym + offset". */
1129 loc_string
= xstrprintf ("%s + %u", msym_name
, offset
);
1131 loc_string
= xstrprintf ("%s", msym_name
);
1133 /* Use a cleanup to free loc_string in case the user quits
1134 a pagination request inside printf_filtered. */
1135 old_chain
= make_cleanup (xfree
, loc_string
);
1137 gdb_assert (osect
->objfile
&& osect
->objfile
->name
);
1138 obj_name
= osect
->objfile
->name
;
1140 if (MULTI_OBJFILE_P ())
1141 if (pc_in_unmapped_range (addr
, osect
))
1142 if (section_is_overlay (osect
))
1143 printf_filtered (_("%s in load address range of "
1144 "%s overlay section %s of %s\n"),
1145 loc_string
, mapped
, sec_name
, obj_name
);
1147 printf_filtered (_("%s in load address range of "
1148 "section %s of %s\n"),
1149 loc_string
, sec_name
, obj_name
);
1151 if (section_is_overlay (osect
))
1152 printf_filtered (_("%s in %s overlay section %s of %s\n"),
1153 loc_string
, mapped
, sec_name
, obj_name
);
1155 printf_filtered (_("%s in section %s of %s\n"),
1156 loc_string
, sec_name
, obj_name
);
1158 if (pc_in_unmapped_range (addr
, osect
))
1159 if (section_is_overlay (osect
))
1160 printf_filtered (_("%s in load address range of %s overlay "
1162 loc_string
, mapped
, sec_name
);
1164 printf_filtered (_("%s in load address range of section %s\n"),
1165 loc_string
, sec_name
);
1167 if (section_is_overlay (osect
))
1168 printf_filtered (_("%s in %s overlay section %s\n"),
1169 loc_string
, mapped
, sec_name
);
1171 printf_filtered (_("%s in section %s\n"),
1172 loc_string
, sec_name
);
1174 do_cleanups (old_chain
);
1178 printf_filtered (_("No symbol matches %s.\n"), arg
);
1182 address_info (char *exp
, int from_tty
)
1184 struct gdbarch
*gdbarch
;
1187 struct minimal_symbol
*msymbol
;
1189 struct obj_section
*section
;
1190 CORE_ADDR load_addr
, context_pc
= 0;
1191 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
1192 if exp is a field of `this'. */
1195 error (_("Argument required."));
1197 sym
= lookup_symbol (exp
, get_selected_block (&context_pc
), VAR_DOMAIN
,
1198 &is_a_field_of_this
);
1201 if (is_a_field_of_this
)
1203 printf_filtered ("Symbol \"");
1204 fprintf_symbol_filtered (gdb_stdout
, exp
,
1205 current_language
->la_language
, DMGL_ANSI
);
1206 printf_filtered ("\" is a field of the local class variable ");
1207 if (current_language
->la_language
== language_objc
)
1208 printf_filtered ("`self'\n"); /* ObjC equivalent of "this" */
1210 printf_filtered ("`this'\n");
1214 msymbol
= lookup_minimal_symbol (exp
, NULL
, NULL
);
1216 if (msymbol
!= NULL
)
1218 gdbarch
= get_objfile_arch (msymbol_objfile (msymbol
));
1219 load_addr
= SYMBOL_VALUE_ADDRESS (msymbol
);
1221 printf_filtered ("Symbol \"");
1222 fprintf_symbol_filtered (gdb_stdout
, exp
,
1223 current_language
->la_language
, DMGL_ANSI
);
1224 printf_filtered ("\" is at ");
1225 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1226 printf_filtered (" in a file compiled without debugging");
1227 section
= SYMBOL_OBJ_SECTION (msymbol
);
1228 if (section_is_overlay (section
))
1230 load_addr
= overlay_unmapped_address (load_addr
, section
);
1231 printf_filtered (",\n -- loaded at ");
1232 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1233 printf_filtered (" in overlay section %s",
1234 section
->the_bfd_section
->name
);
1236 printf_filtered (".\n");
1239 error (_("No symbol \"%s\" in current context."), exp
);
1243 printf_filtered ("Symbol \"");
1244 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_PRINT_NAME (sym
),
1245 current_language
->la_language
, DMGL_ANSI
);
1246 printf_filtered ("\" is ");
1247 val
= SYMBOL_VALUE (sym
);
1248 section
= SYMBOL_OBJ_SECTION (sym
);
1249 gdbarch
= get_objfile_arch (SYMBOL_SYMTAB (sym
)->objfile
);
1251 switch (SYMBOL_CLASS (sym
))
1254 case LOC_CONST_BYTES
:
1255 printf_filtered ("constant");
1259 printf_filtered ("a label at address ");
1260 load_addr
= SYMBOL_VALUE_ADDRESS (sym
);
1261 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1262 if (section_is_overlay (section
))
1264 load_addr
= overlay_unmapped_address (load_addr
, section
);
1265 printf_filtered (",\n -- loaded at ");
1266 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1267 printf_filtered (" in overlay section %s",
1268 section
->the_bfd_section
->name
);
1273 /* FIXME: cagney/2004-01-26: It should be possible to
1274 unconditionally call the SYMBOL_COMPUTED_OPS method when available.
1275 Unfortunately DWARF 2 stores the frame-base (instead of the
1276 function) location in a function's symbol. Oops! For the
1277 moment enable this when/where applicable. */
1278 SYMBOL_COMPUTED_OPS (sym
)->describe_location (sym
, context_pc
,
1283 /* GDBARCH is the architecture associated with the objfile the symbol
1284 is defined in; the target architecture may be different, and may
1285 provide additional registers. However, we do not know the target
1286 architecture at this point. We assume the objfile architecture
1287 will contain all the standard registers that occur in debug info
1289 regno
= SYMBOL_REGISTER_OPS (sym
)->register_number (sym
, gdbarch
);
1291 if (SYMBOL_IS_ARGUMENT (sym
))
1292 printf_filtered (_("an argument in register %s"),
1293 gdbarch_register_name (gdbarch
, regno
));
1295 printf_filtered (_("a variable in register %s"),
1296 gdbarch_register_name (gdbarch
, regno
));
1300 printf_filtered (_("static storage at address "));
1301 load_addr
= SYMBOL_VALUE_ADDRESS (sym
);
1302 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1303 if (section_is_overlay (section
))
1305 load_addr
= overlay_unmapped_address (load_addr
, section
);
1306 printf_filtered (_(",\n -- loaded at "));
1307 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1308 printf_filtered (_(" in overlay section %s"),
1309 section
->the_bfd_section
->name
);
1313 case LOC_REGPARM_ADDR
:
1314 /* Note comment at LOC_REGISTER. */
1315 regno
= SYMBOL_REGISTER_OPS (sym
)->register_number (sym
, gdbarch
);
1316 printf_filtered (_("address of an argument in register %s"),
1317 gdbarch_register_name (gdbarch
, regno
));
1321 printf_filtered (_("an argument at offset %ld"), val
);
1325 printf_filtered (_("a local variable at frame offset %ld"), val
);
1329 printf_filtered (_("a reference argument at offset %ld"), val
);
1333 printf_filtered (_("a typedef"));
1337 printf_filtered (_("a function at address "));
1338 load_addr
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
));
1339 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1340 if (section_is_overlay (section
))
1342 load_addr
= overlay_unmapped_address (load_addr
, section
);
1343 printf_filtered (_(",\n -- loaded at "));
1344 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1345 printf_filtered (_(" in overlay section %s"),
1346 section
->the_bfd_section
->name
);
1350 case LOC_UNRESOLVED
:
1352 struct minimal_symbol
*msym
;
1354 msym
= lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym
), NULL
, NULL
);
1356 printf_filtered ("unresolved");
1359 section
= SYMBOL_OBJ_SECTION (msym
);
1360 load_addr
= SYMBOL_VALUE_ADDRESS (msym
);
1363 && (section
->the_bfd_section
->flags
& SEC_THREAD_LOCAL
) != 0)
1364 printf_filtered (_("a thread-local variable at offset %s "
1365 "in the thread-local storage for `%s'"),
1366 paddress (gdbarch
, load_addr
),
1367 section
->objfile
->name
);
1370 printf_filtered (_("static storage at address "));
1371 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1372 if (section_is_overlay (section
))
1374 load_addr
= overlay_unmapped_address (load_addr
, section
);
1375 printf_filtered (_(",\n -- loaded at "));
1376 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1377 printf_filtered (_(" in overlay section %s"),
1378 section
->the_bfd_section
->name
);
1385 case LOC_OPTIMIZED_OUT
:
1386 printf_filtered (_("optimized out"));
1390 printf_filtered (_("of unknown (botched) type"));
1393 printf_filtered (".\n");
1398 x_command (char *exp
, int from_tty
)
1400 struct expression
*expr
;
1401 struct format_data fmt
;
1402 struct cleanup
*old_chain
;
1405 fmt
.format
= last_format
? last_format
: 'x';
1406 fmt
.size
= last_size
;
1410 if (exp
&& *exp
== '/')
1413 fmt
= decode_format (&exp
, last_format
, last_size
);
1416 /* If we have an expression, evaluate it and use it as the address. */
1418 if (exp
!= 0 && *exp
!= 0)
1420 expr
= parse_expression (exp
);
1421 /* Cause expression not to be there any more if this command is
1422 repeated with Newline. But don't clobber a user-defined
1423 command's definition. */
1426 old_chain
= make_cleanup (free_current_contents
, &expr
);
1427 val
= evaluate_expression (expr
);
1428 if (TYPE_CODE (value_type (val
)) == TYPE_CODE_REF
)
1429 val
= coerce_ref (val
);
1430 /* In rvalue contexts, such as this, functions are coerced into
1431 pointers to functions. This makes "x/i main" work. */
1432 if (/* last_format == 'i' && */
1433 TYPE_CODE (value_type (val
)) == TYPE_CODE_FUNC
1434 && VALUE_LVAL (val
) == lval_memory
)
1435 next_address
= value_address (val
);
1437 next_address
= value_as_address (val
);
1439 next_gdbarch
= expr
->gdbarch
;
1440 do_cleanups (old_chain
);
1444 error_no_arg (_("starting display address"));
1446 do_examine (fmt
, next_gdbarch
, next_address
);
1448 /* If the examine succeeds, we remember its size and format for next
1449 time. Set last_size to 'b' for strings. */
1450 if (fmt
.format
== 's')
1453 last_size
= fmt
.size
;
1454 last_format
= fmt
.format
;
1456 /* Set a couple of internal variables if appropriate. */
1457 if (last_examine_value
)
1459 /* Make last address examined available to the user as $_. Use
1460 the correct pointer type. */
1461 struct type
*pointer_type
1462 = lookup_pointer_type (value_type (last_examine_value
));
1463 set_internalvar (lookup_internalvar ("_"),
1464 value_from_pointer (pointer_type
,
1465 last_examine_address
));
1467 /* Make contents of last address examined available to the user
1468 as $__. If the last value has not been fetched from memory
1469 then don't fetch it now; instead mark it by voiding the $__
1471 if (value_lazy (last_examine_value
))
1472 clear_internalvar (lookup_internalvar ("__"));
1474 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1479 /* Add an expression to the auto-display chain.
1480 Specify the expression. */
1483 display_command (char *exp
, int from_tty
)
1485 struct format_data fmt
;
1486 struct expression
*expr
;
1487 struct display
*new;
1491 /* NOTE: cagney/2003-02-13 The `tui_active' was previously
1493 if (tui_active
&& exp
!= NULL
&& *exp
== '$')
1494 display_it
= (tui_set_layout_for_display_command (exp
) == TUI_FAILURE
);
1508 fmt
= decode_format (&exp
, 0, 0);
1509 if (fmt
.size
&& fmt
.format
== 0)
1511 if (fmt
.format
== 'i' || fmt
.format
== 's')
1522 innermost_block
= NULL
;
1523 expr
= parse_expression (exp
);
1525 new = (struct display
*) xmalloc (sizeof (struct display
));
1527 new->exp_string
= xstrdup (exp
);
1529 new->block
= innermost_block
;
1530 new->pspace
= current_program_space
;
1531 new->next
= display_chain
;
1532 new->number
= ++display_number
;
1535 display_chain
= new;
1537 if (from_tty
&& target_has_execution
)
1538 do_one_display (new);
1545 free_display (struct display
*d
)
1547 xfree (d
->exp_string
);
1552 /* Clear out the display_chain. Done when new symtabs are loaded,
1553 since this invalidates the types stored in many expressions. */
1556 clear_displays (void)
1560 while ((d
= display_chain
) != NULL
)
1562 display_chain
= d
->next
;
1567 /* Delete the auto-display number NUM. */
1570 delete_display (int num
)
1572 struct display
*d1
, *d
;
1575 error (_("No display number %d."), num
);
1577 if (display_chain
->number
== num
)
1580 display_chain
= d1
->next
;
1584 for (d
= display_chain
;; d
= d
->next
)
1587 error (_("No display number %d."), num
);
1588 if (d
->next
->number
== num
)
1598 /* Delete some values from the auto-display chain.
1599 Specify the element numbers. */
1602 undisplay_command (char *args
, int from_tty
)
1610 if (query (_("Delete all auto-display expressions? ")))
1619 while (*p1
>= '0' && *p1
<= '9')
1621 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1622 error (_("Arguments must be display numbers."));
1626 delete_display (num
);
1629 while (*p
== ' ' || *p
== '\t')
1635 /* Display a single auto-display.
1636 Do nothing if the display cannot be printed in the current context,
1637 or if the display is disabled. */
1640 do_one_display (struct display
*d
)
1642 int within_current_scope
;
1644 if (d
->enabled_p
== 0)
1647 /* The expression carries the architecture that was used at parse time.
1648 This is a problem if the expression depends on architecture features
1649 (e.g. register numbers), and the current architecture is now different.
1650 For example, a display statement like "display/i $pc" is expected to
1651 display the PC register of the current architecture, not the arch at
1652 the time the display command was given. Therefore, we re-parse the
1653 expression if the current architecture has changed. */
1654 if (d
->exp
!= NULL
&& d
->exp
->gdbarch
!= get_current_arch ())
1663 volatile struct gdb_exception ex
;
1665 TRY_CATCH (ex
, RETURN_MASK_ALL
)
1667 innermost_block
= NULL
;
1668 d
->exp
= parse_expression (d
->exp_string
);
1669 d
->block
= innermost_block
;
1673 /* Can't re-parse the expression. Disable this display item. */
1675 warning (_("Unable to display \"%s\": %s"),
1676 d
->exp_string
, ex
.message
);
1683 if (d
->pspace
== current_program_space
)
1684 within_current_scope
= contained_in (get_selected_block (0), d
->block
);
1686 within_current_scope
= 0;
1689 within_current_scope
= 1;
1690 if (!within_current_scope
)
1693 current_display_number
= d
->number
;
1695 annotate_display_begin ();
1696 printf_filtered ("%d", d
->number
);
1697 annotate_display_number_end ();
1698 printf_filtered (": ");
1704 annotate_display_format ();
1706 printf_filtered ("x/");
1707 if (d
->format
.count
!= 1)
1708 printf_filtered ("%d", d
->format
.count
);
1709 printf_filtered ("%c", d
->format
.format
);
1710 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1711 printf_filtered ("%c", d
->format
.size
);
1712 printf_filtered (" ");
1714 annotate_display_expression ();
1716 puts_filtered (d
->exp_string
);
1717 annotate_display_expression_end ();
1719 if (d
->format
.count
!= 1 || d
->format
.format
== 'i')
1720 printf_filtered ("\n");
1722 printf_filtered (" ");
1724 val
= evaluate_expression (d
->exp
);
1725 addr
= value_as_address (val
);
1726 if (d
->format
.format
== 'i')
1727 addr
= gdbarch_addr_bits_remove (d
->exp
->gdbarch
, addr
);
1729 annotate_display_value ();
1731 do_examine (d
->format
, d
->exp
->gdbarch
, addr
);
1735 struct value_print_options opts
;
1737 annotate_display_format ();
1739 if (d
->format
.format
)
1740 printf_filtered ("/%c ", d
->format
.format
);
1742 annotate_display_expression ();
1744 puts_filtered (d
->exp_string
);
1745 annotate_display_expression_end ();
1747 printf_filtered (" = ");
1749 annotate_display_expression ();
1751 get_formatted_print_options (&opts
, d
->format
.format
);
1752 opts
.raw
= d
->format
.raw
;
1753 print_formatted (evaluate_expression (d
->exp
),
1754 d
->format
.size
, &opts
, gdb_stdout
);
1755 printf_filtered ("\n");
1758 annotate_display_end ();
1760 gdb_flush (gdb_stdout
);
1761 current_display_number
= -1;
1764 /* Display all of the values on the auto-display chain which can be
1765 evaluated in the current scope. */
1772 for (d
= display_chain
; d
; d
= d
->next
)
1776 /* Delete the auto-display which we were in the process of displaying.
1777 This is done when there is an error or a signal. */
1780 disable_display (int num
)
1784 for (d
= display_chain
; d
; d
= d
->next
)
1785 if (d
->number
== num
)
1790 printf_unfiltered (_("No display number %d.\n"), num
);
1794 disable_current_display (void)
1796 if (current_display_number
>= 0)
1798 disable_display (current_display_number
);
1799 fprintf_unfiltered (gdb_stderr
,
1800 _("Disabling display %d to "
1801 "avoid infinite recursion.\n"),
1802 current_display_number
);
1804 current_display_number
= -1;
1808 display_info (char *ignore
, int from_tty
)
1813 printf_unfiltered (_("There are no auto-display expressions now.\n"));
1815 printf_filtered (_("Auto-display expressions now in effect:\n\
1816 Num Enb Expression\n"));
1818 for (d
= display_chain
; d
; d
= d
->next
)
1820 printf_filtered ("%d: %c ", d
->number
, "ny"[(int) d
->enabled_p
]);
1822 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1824 else if (d
->format
.format
)
1825 printf_filtered ("/%c ", d
->format
.format
);
1826 puts_filtered (d
->exp_string
);
1827 if (d
->block
&& !contained_in (get_selected_block (0), d
->block
))
1828 printf_filtered (_(" (cannot be evaluated in the current context)"));
1829 printf_filtered ("\n");
1830 gdb_flush (gdb_stdout
);
1835 enable_display (char *args
, int from_tty
)
1844 for (d
= display_chain
; d
; d
= d
->next
)
1851 while (*p1
>= '0' && *p1
<= '9')
1853 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1854 error (_("Arguments must be display numbers."));
1858 for (d
= display_chain
; d
; d
= d
->next
)
1859 if (d
->number
== num
)
1864 printf_unfiltered (_("No display number %d.\n"), num
);
1867 while (*p
== ' ' || *p
== '\t')
1873 disable_display_command (char *args
, int from_tty
)
1881 for (d
= display_chain
; d
; d
= d
->next
)
1888 while (*p1
>= '0' && *p1
<= '9')
1890 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1891 error (_("Arguments must be display numbers."));
1893 disable_display (atoi (p
));
1896 while (*p
== ' ' || *p
== '\t')
1901 /* display_chain items point to blocks and expressions. Some expressions in
1902 turn may point to symbols.
1903 Both symbols and blocks are obstack_alloc'd on objfile_stack, and are
1904 obstack_free'd when a shared library is unloaded.
1905 Clear pointers that are about to become dangling.
1906 Both .exp and .block fields will be restored next time we need to display
1907 an item by re-parsing .exp_string field in the new execution context. */
1910 clear_dangling_display_expressions (struct so_list
*solib
)
1912 struct objfile
*objfile
= solib
->objfile
;
1915 /* With no symbol file we cannot have a block or expression from it. */
1916 if (objfile
== NULL
)
1918 if (objfile
->separate_debug_objfile_backlink
)
1919 objfile
= objfile
->separate_debug_objfile_backlink
;
1920 gdb_assert (objfile
->pspace
== solib
->pspace
);
1922 for (d
= display_chain
; d
!= NULL
; d
= d
->next
)
1924 if (d
->pspace
!= solib
->pspace
)
1927 if (lookup_objfile_from_block (d
->block
) == objfile
1928 || (d
->exp
&& exp_uses_objfile (d
->exp
, objfile
)))
1938 /* Print the value in stack frame FRAME of a variable specified by a
1939 struct symbol. NAME is the name to print; if NULL then VAR's print
1940 name will be used. STREAM is the ui_file on which to print the
1941 value. INDENT specifies the number of indent levels to print
1942 before printing the variable name. */
1945 print_variable_and_value (const char *name
, struct symbol
*var
,
1946 struct frame_info
*frame
,
1947 struct ui_file
*stream
, int indent
)
1949 volatile struct gdb_exception except
;
1952 name
= SYMBOL_PRINT_NAME (var
);
1954 fprintf_filtered (stream
, "%s%s = ", n_spaces (2 * indent
), name
);
1955 TRY_CATCH (except
, RETURN_MASK_ERROR
)
1958 struct value_print_options opts
;
1960 val
= read_var_value (var
, frame
);
1961 get_user_print_options (&opts
);
1962 common_val_print (val
, stream
, indent
, &opts
, current_language
);
1964 if (except
.reason
< 0)
1965 fprintf_filtered(stream
, "<error reading variable %s (%s)>", name
,
1967 fprintf_filtered (stream
, "\n");
1970 /* printf "printf format string" ARG to STREAM. */
1973 ui_printf (char *arg
, struct ui_file
*stream
)
1977 char *string
= NULL
;
1978 struct value
**val_args
;
1980 char *current_substring
;
1982 int allocated_args
= 20;
1983 struct cleanup
*old_cleanups
;
1985 val_args
= xmalloc (allocated_args
* sizeof (struct value
*));
1986 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1989 error_no_arg (_("format-control string and values to print"));
1991 /* Skip white space before format string */
1992 while (*s
== ' ' || *s
== '\t')
1995 /* A format string should follow, enveloped in double quotes. */
1997 error (_("Bad format string, missing '\"'."));
1999 /* Parse the format-control string and copy it into the string STRING,
2000 processing some kinds of escape sequence. */
2002 f
= string
= (char *) alloca (strlen (s
) + 1);
2010 error (_("Bad format string, non-terminated '\"'."));
2043 /* ??? TODO: handle other escape sequences */
2044 error (_("Unrecognized escape character \\%c in format string."),
2054 /* Skip over " and following space and comma. */
2057 while (*s
== ' ' || *s
== '\t')
2060 if (*s
!= ',' && *s
!= 0)
2061 error (_("Invalid argument syntax"));
2065 while (*s
== ' ' || *s
== '\t')
2068 /* Need extra space for the '\0's. Doubling the size is sufficient. */
2069 substrings
= alloca (strlen (string
) * 2);
2070 current_substring
= substrings
;
2073 /* Now scan the string for %-specs and see what kinds of args they want.
2074 argclass[I] classifies the %-specs so we can give printf_filtered
2075 something of the right size. */
2079 int_arg
, long_arg
, long_long_arg
, ptr_arg
,
2080 string_arg
, wide_string_arg
, wide_char_arg
,
2081 double_arg
, long_double_arg
, decfloat_arg
2083 enum argclass
*argclass
;
2084 enum argclass this_argclass
;
2089 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
2096 int seen_hash
= 0, seen_zero
= 0, lcount
= 0, seen_prec
= 0;
2097 int seen_space
= 0, seen_plus
= 0;
2098 int seen_big_l
= 0, seen_h
= 0, seen_big_h
= 0;
2099 int seen_big_d
= 0, seen_double_big_d
= 0;
2102 /* Check the validity of the format specifier, and work
2103 out what argument it expects. We only accept C89
2104 format strings, with the exception of long long (which
2105 we autoconf for). */
2107 /* Skip over "%%". */
2114 /* The first part of a format specifier is a set of flag
2116 while (strchr ("0-+ #", *f
))
2129 /* The next part of a format specifier is a width. */
2130 while (strchr ("0123456789", *f
))
2133 /* The next part of a format specifier is a precision. */
2138 while (strchr ("0123456789", *f
))
2142 /* The next part of a format specifier is a length modifier. */
2163 /* Decimal32 modifier. */
2169 /* Decimal64 and Decimal128 modifiers. */
2174 /* Check for a Decimal128. */
2178 seen_double_big_d
= 1;
2194 if (seen_space
|| seen_plus
)
2201 this_argclass
= int_arg
;
2202 else if (lcount
== 1)
2203 this_argclass
= long_arg
;
2205 this_argclass
= long_long_arg
;
2212 this_argclass
= lcount
== 0 ? int_arg
: wide_char_arg
;
2213 if (lcount
> 1 || seen_h
|| seen_big_l
)
2215 if (seen_prec
|| seen_zero
|| seen_space
|| seen_plus
)
2220 this_argclass
= ptr_arg
;
2221 if (lcount
|| seen_h
|| seen_big_l
)
2223 if (seen_prec
|| seen_zero
|| seen_space
|| seen_plus
)
2228 this_argclass
= lcount
== 0 ? string_arg
: wide_string_arg
;
2229 if (lcount
> 1 || seen_h
|| seen_big_l
)
2231 if (seen_zero
|| seen_space
|| seen_plus
)
2240 if (seen_big_h
|| seen_big_d
|| seen_double_big_d
)
2241 this_argclass
= decfloat_arg
;
2242 else if (seen_big_l
)
2243 this_argclass
= long_double_arg
;
2245 this_argclass
= double_arg
;
2247 if (lcount
|| seen_h
)
2252 error (_("`*' not supported for precision or width in printf"));
2255 error (_("Format specifier `n' not supported in printf"));
2258 error (_("Incomplete format specifier at end of format string"));
2261 error (_("Unrecognized format specifier '%c' in printf"), *f
);
2265 error (_("Inappropriate modifiers to "
2266 "format specifier '%c' in printf"),
2271 if (lcount
> 1 && USE_PRINTF_I64
)
2273 /* Windows' printf does support long long, but not the usual way.
2274 Convert %lld to %I64d. */
2275 int length_before_ll
= f
- last_arg
- 1 - lcount
;
2277 strncpy (current_substring
, last_arg
, length_before_ll
);
2278 strcpy (current_substring
+ length_before_ll
, "I64");
2279 current_substring
[length_before_ll
+ 3] =
2280 last_arg
[length_before_ll
+ lcount
];
2281 current_substring
+= length_before_ll
+ 4;
2283 else if (this_argclass
== wide_string_arg
2284 || this_argclass
== wide_char_arg
)
2286 /* Convert %ls or %lc to %s. */
2287 int length_before_ls
= f
- last_arg
- 2;
2289 strncpy (current_substring
, last_arg
, length_before_ls
);
2290 strcpy (current_substring
+ length_before_ls
, "s");
2291 current_substring
+= length_before_ls
+ 2;
2295 strncpy (current_substring
, last_arg
, f
- last_arg
);
2296 current_substring
+= f
- last_arg
;
2298 *current_substring
++ = '\0';
2300 argclass
[nargs_wanted
++] = this_argclass
;
2303 /* Now, parse all arguments and evaluate them.
2304 Store the VALUEs in VAL_ARGS. */
2310 if (nargs
== allocated_args
)
2311 val_args
= (struct value
**) xrealloc ((char *) val_args
,
2312 (allocated_args
*= 2)
2313 * sizeof (struct value
*));
2315 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
2323 if (nargs
!= nargs_wanted
)
2324 error (_("Wrong number of arguments for specified format-string"));
2326 /* Now actually print them. */
2327 current_substring
= substrings
;
2328 for (i
= 0; i
< nargs
; i
++)
2330 switch (argclass
[i
])
2338 tem
= value_as_address (val_args
[i
]);
2340 /* This is a %s argument. Find the length of the string. */
2346 read_memory (tem
+ j
, &c
, 1);
2351 /* Copy the string contents into a string inside GDB. */
2352 str
= (gdb_byte
*) alloca (j
+ 1);
2354 read_memory (tem
, str
, j
);
2357 fprintf_filtered (stream
, current_substring
, (char *) str
);
2360 case wide_string_arg
:
2365 struct gdbarch
*gdbarch
2366 = get_type_arch (value_type (val_args
[i
]));
2367 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2368 struct type
*wctype
= lookup_typename (current_language
, gdbarch
,
2369 "wchar_t", NULL
, 0);
2370 int wcwidth
= TYPE_LENGTH (wctype
);
2371 gdb_byte
*buf
= alloca (wcwidth
);
2372 struct obstack output
;
2373 struct cleanup
*inner_cleanup
;
2375 tem
= value_as_address (val_args
[i
]);
2377 /* This is a %s argument. Find the length of the string. */
2378 for (j
= 0;; j
+= wcwidth
)
2381 read_memory (tem
+ j
, buf
, wcwidth
);
2382 if (extract_unsigned_integer (buf
, wcwidth
, byte_order
) == 0)
2386 /* Copy the string contents into a string inside GDB. */
2387 str
= (gdb_byte
*) alloca (j
+ wcwidth
);
2389 read_memory (tem
, str
, j
);
2390 memset (&str
[j
], 0, wcwidth
);
2392 obstack_init (&output
);
2393 inner_cleanup
= make_cleanup_obstack_free (&output
);
2395 convert_between_encodings (target_wide_charset (gdbarch
),
2398 &output
, translit_char
);
2399 obstack_grow_str0 (&output
, "");
2401 fprintf_filtered (stream
, current_substring
,
2402 obstack_base (&output
));
2403 do_cleanups (inner_cleanup
);
2408 struct gdbarch
*gdbarch
2409 = get_type_arch (value_type (val_args
[i
]));
2410 struct type
*wctype
= lookup_typename (current_language
, gdbarch
,
2411 "wchar_t", NULL
, 0);
2412 struct type
*valtype
;
2413 struct obstack output
;
2414 struct cleanup
*inner_cleanup
;
2415 const gdb_byte
*bytes
;
2417 valtype
= value_type (val_args
[i
]);
2418 if (TYPE_LENGTH (valtype
) != TYPE_LENGTH (wctype
)
2419 || TYPE_CODE (valtype
) != TYPE_CODE_INT
)
2420 error (_("expected wchar_t argument for %%lc"));
2422 bytes
= value_contents (val_args
[i
]);
2424 obstack_init (&output
);
2425 inner_cleanup
= make_cleanup_obstack_free (&output
);
2427 convert_between_encodings (target_wide_charset (gdbarch
),
2429 bytes
, TYPE_LENGTH (valtype
),
2430 TYPE_LENGTH (valtype
),
2431 &output
, translit_char
);
2432 obstack_grow_str0 (&output
, "");
2434 fprintf_filtered (stream
, current_substring
,
2435 obstack_base (&output
));
2436 do_cleanups (inner_cleanup
);
2441 struct type
*type
= value_type (val_args
[i
]);
2445 /* If format string wants a float, unchecked-convert the value
2446 to floating point of the same size. */
2447 type
= float_type_from_length (type
);
2448 val
= unpack_double (type
, value_contents (val_args
[i
]), &inv
);
2450 error (_("Invalid floating value found in program."));
2452 fprintf_filtered (stream
, current_substring
, (double) val
);
2455 case long_double_arg
:
2456 #ifdef HAVE_LONG_DOUBLE
2458 struct type
*type
= value_type (val_args
[i
]);
2462 /* If format string wants a float, unchecked-convert the value
2463 to floating point of the same size. */
2464 type
= float_type_from_length (type
);
2465 val
= unpack_double (type
, value_contents (val_args
[i
]), &inv
);
2467 error (_("Invalid floating value found in program."));
2469 fprintf_filtered (stream
, current_substring
,
2474 error (_("long double not supported in printf"));
2477 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2479 long long val
= value_as_long (val_args
[i
]);
2481 fprintf_filtered (stream
, current_substring
, val
);
2485 error (_("long long not supported in printf"));
2489 int val
= value_as_long (val_args
[i
]);
2491 fprintf_filtered (stream
, current_substring
, val
);
2496 long val
= value_as_long (val_args
[i
]);
2498 fprintf_filtered (stream
, current_substring
, val
);
2502 /* Handles decimal floating values. */
2505 const gdb_byte
*param_ptr
= value_contents (val_args
[i
]);
2507 #if defined (PRINTF_HAS_DECFLOAT)
2508 /* If we have native support for Decimal floating
2509 printing, handle it here. */
2510 fprintf_filtered (stream
, current_substring
, param_ptr
);
2513 /* As a workaround until vasprintf has native support for DFP
2514 we convert the DFP values to string and print them using
2515 the %s format specifier. */
2518 int nnull_chars
= 0;
2520 /* Parameter data. */
2521 struct type
*param_type
= value_type (val_args
[i
]);
2522 unsigned int param_len
= TYPE_LENGTH (param_type
);
2523 struct gdbarch
*gdbarch
= get_type_arch (param_type
);
2524 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2526 /* DFP output data. */
2527 struct value
*dfp_value
= NULL
;
2531 struct type
*dfp_type
= NULL
;
2532 char decstr
[MAX_DECIMAL_STRING
];
2534 /* Points to the end of the string so that we can go back
2535 and check for DFP length modifiers. */
2536 eos
= current_substring
+ strlen (current_substring
);
2538 /* Look for the float/double format specifier. */
2539 while (*eos
!= 'f' && *eos
!= 'e' && *eos
!= 'E'
2540 && *eos
!= 'g' && *eos
!= 'G')
2545 /* Search for the '%' char and extract the size and type of
2546 the output decimal value based on its modifiers
2547 (%Hf, %Df, %DDf). */
2548 while (*--sos
!= '%')
2553 dfp_type
= builtin_type (gdbarch
)->builtin_decfloat
;
2555 else if (*sos
== 'D' && *(sos
- 1) == 'D')
2558 dfp_type
= builtin_type (gdbarch
)->builtin_declong
;
2564 dfp_type
= builtin_type (gdbarch
)->builtin_decdouble
;
2568 /* Replace %Hf, %Df and %DDf with %s's. */
2571 /* Go through the whole format string and pull the correct
2572 number of chars back to compensate for the change in the
2573 format specifier. */
2574 while (nnull_chars
< nargs
- i
)
2582 /* Conversion between different DFP types. */
2583 if (TYPE_CODE (param_type
) == TYPE_CODE_DECFLOAT
)
2584 decimal_convert (param_ptr
, param_len
, byte_order
,
2585 dec
, dfp_len
, byte_order
);
2587 /* If this is a non-trivial conversion, just output 0.
2588 A correct converted value can be displayed by explicitly
2589 casting to a DFP type. */
2590 decimal_from_string (dec
, dfp_len
, byte_order
, "0");
2592 dfp_value
= value_from_decfloat (dfp_type
, dec
);
2594 dfp_ptr
= (gdb_byte
*) value_contents (dfp_value
);
2596 decimal_to_string (dfp_ptr
, dfp_len
, byte_order
, decstr
);
2598 /* Print the DFP value. */
2599 fprintf_filtered (stream
, current_substring
, decstr
);
2607 /* We avoid the host's %p because pointers are too
2608 likely to be the wrong size. The only interesting
2609 modifier for %p is a width; extract that, and then
2610 handle %p as glibc would: %#x or a literal "(nil)". */
2612 char *p
, *fmt
, *fmt_p
;
2613 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2614 long long val
= value_as_long (val_args
[i
]);
2616 long val
= value_as_long (val_args
[i
]);
2619 fmt
= alloca (strlen (current_substring
) + 5);
2621 /* Copy up to the leading %. */
2622 p
= current_substring
;
2626 int is_percent
= (*p
== '%');
2641 /* Copy any width. */
2642 while (*p
>= '0' && *p
< '9')
2645 gdb_assert (*p
== 'p' && *(p
+ 1) == '\0');
2648 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2654 fprintf_filtered (stream
, fmt
, val
);
2660 fprintf_filtered (stream
, fmt
, "(nil)");
2666 internal_error (__FILE__
, __LINE__
,
2667 _("failed internal consistency check"));
2669 /* Skip to the next substring. */
2670 current_substring
+= strlen (current_substring
) + 1;
2672 /* Print the portion of the format string after the last argument.
2673 Note that this will not include any ordinary %-specs, but it
2674 might include "%%". That is why we use printf_filtered and not
2675 puts_filtered here. Also, we pass a dummy argument because
2676 some platforms have modified GCC to include -Wformat-security
2677 by default, which will warn here if there is no argument. */
2678 fprintf_filtered (stream
, last_arg
, 0);
2680 do_cleanups (old_cleanups
);
2683 /* Implement the "printf" command. */
2686 printf_command (char *arg
, int from_tty
)
2688 ui_printf (arg
, gdb_stdout
);
2691 /* Implement the "eval" command. */
2694 eval_command (char *arg
, int from_tty
)
2696 struct ui_file
*ui_out
= mem_fileopen ();
2697 struct cleanup
*cleanups
= make_cleanup_ui_file_delete (ui_out
);
2700 ui_printf (arg
, ui_out
);
2702 expanded
= ui_file_xstrdup (ui_out
, NULL
);
2703 make_cleanup (xfree
, expanded
);
2705 execute_command (expanded
, from_tty
);
2707 do_cleanups (cleanups
);
2711 _initialize_printcmd (void)
2713 struct cmd_list_element
*c
;
2715 current_display_number
= -1;
2717 observer_attach_solib_unloaded (clear_dangling_display_expressions
);
2719 add_info ("address", address_info
,
2720 _("Describe where symbol SYM is stored."));
2722 add_info ("symbol", sym_info
, _("\
2723 Describe what symbol is at location ADDR.\n\
2724 Only for symbols with fixed locations (global or static scope)."));
2726 add_com ("x", class_vars
, x_command
, _("\
2727 Examine memory: x/FMT ADDRESS.\n\
2728 ADDRESS is an expression for the memory address to examine.\n\
2729 FMT is a repeat count followed by a format letter and a size letter.\n\
2730 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2731 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2732 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2733 The specified number of objects of the specified size are printed\n\
2734 according to the format.\n\n\
2735 Defaults for format and size letters are those previously used.\n\
2736 Default count is 1. Default address is following last thing printed\n\
2737 with this command or \"print\"."));
2740 add_com ("whereis", class_vars
, whereis_command
,
2741 _("Print line number and file of definition of variable."));
2744 add_info ("display", display_info
, _("\
2745 Expressions to display when program stops, with code numbers."));
2747 add_cmd ("undisplay", class_vars
, undisplay_command
, _("\
2748 Cancel some expressions to be displayed when program stops.\n\
2749 Arguments are the code numbers of the expressions to stop displaying.\n\
2750 No argument means cancel all automatic-display expressions.\n\
2751 \"delete display\" has the same effect as this command.\n\
2752 Do \"info display\" to see current list of code numbers."),
2755 add_com ("display", class_vars
, display_command
, _("\
2756 Print value of expression EXP each time the program stops.\n\
2757 /FMT may be used before EXP as in the \"print\" command.\n\
2758 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2759 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2760 and examining is done as in the \"x\" command.\n\n\
2761 With no argument, display all currently requested auto-display expressions.\n\
2762 Use \"undisplay\" to cancel display requests previously made."));
2764 add_cmd ("display", class_vars
, enable_display
, _("\
2765 Enable some expressions to be displayed when program stops.\n\
2766 Arguments are the code numbers of the expressions to resume displaying.\n\
2767 No argument means enable all automatic-display expressions.\n\
2768 Do \"info display\" to see current list of code numbers."), &enablelist
);
2770 add_cmd ("display", class_vars
, disable_display_command
, _("\
2771 Disable some expressions to be displayed when program stops.\n\
2772 Arguments are the code numbers of the expressions to stop displaying.\n\
2773 No argument means disable all automatic-display expressions.\n\
2774 Do \"info display\" to see current list of code numbers."), &disablelist
);
2776 add_cmd ("display", class_vars
, undisplay_command
, _("\
2777 Cancel some expressions to be displayed when program stops.\n\
2778 Arguments are the code numbers of the expressions to stop displaying.\n\
2779 No argument means cancel all automatic-display expressions.\n\
2780 Do \"info display\" to see current list of code numbers."), &deletelist
);
2782 add_com ("printf", class_vars
, printf_command
, _("\
2783 printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2784 This is useful for formatted output in user-defined commands."));
2786 add_com ("output", class_vars
, output_command
, _("\
2787 Like \"print\" but don't put in value history and don't print newline.\n\
2788 This is useful in user-defined commands."));
2790 add_prefix_cmd ("set", class_vars
, set_command
, _("\
2791 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2792 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2793 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2794 with $), a register (a few standard names starting with $), or an actual\n\
2795 variable in the program being debugged. EXP is any valid expression.\n\
2796 Use \"set variable\" for variables with names identical to set subcommands.\n\
2798 With a subcommand, this command modifies parts of the gdb environment.\n\
2799 You can see these environment settings with the \"show\" command."),
2800 &setlist
, "set ", 1, &cmdlist
);
2802 add_com ("assign", class_vars
, set_command
, _("\
2803 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2804 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2805 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2806 with $), a register (a few standard names starting with $), or an actual\n\
2807 variable in the program being debugged. EXP is any valid expression.\n\
2808 Use \"set variable\" for variables with names identical to set subcommands.\n\
2809 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2810 You can see these environment settings with the \"show\" command."));
2812 /* "call" is the same as "set", but handy for dbx users to call fns. */
2813 c
= add_com ("call", class_vars
, call_command
, _("\
2814 Call a function in the program.\n\
2815 The argument is the function name and arguments, in the notation of the\n\
2816 current working language. The result is printed and saved in the value\n\
2817 history, if it is not void."));
2818 set_cmd_completer (c
, expression_completer
);
2820 add_cmd ("variable", class_vars
, set_command
, _("\
2821 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2822 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2823 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2824 with $), a register (a few standard names starting with $), or an actual\n\
2825 variable in the program being debugged. EXP is any valid expression.\n\
2826 This may usually be abbreviated to simply \"set\"."),
2829 c
= add_com ("print", class_vars
, print_command
, _("\
2830 Print value of expression EXP.\n\
2831 Variables accessible are those of the lexical environment of the selected\n\
2832 stack frame, plus all those whose scope is global or an entire file.\n\
2834 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2835 $$NUM refers to NUM'th value back from the last one.\n\
2836 Names starting with $ refer to registers (with the values they would have\n\
2837 if the program were to return to the stack frame now selected, restoring\n\
2838 all registers saved by frames farther in) or else to debugger\n\
2839 \"convenience\" variables (any such name not a known register).\n\
2840 Use assignment expressions to give values to convenience variables.\n\
2842 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2843 @ is a binary operator for treating consecutive data objects\n\
2844 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2845 element is FOO, whose second element is stored in the space following\n\
2846 where FOO is stored, etc. FOO must be an expression whose value\n\
2847 resides in memory.\n\
2849 EXP may be preceded with /FMT, where FMT is a format letter\n\
2850 but no count or size letter (see \"x\" command)."));
2851 set_cmd_completer (c
, expression_completer
);
2852 add_com_alias ("p", "print", class_vars
, 1);
2854 c
= add_com ("inspect", class_vars
, inspect_command
, _("\
2855 Same as \"print\" command, except that if you are running in the epoch\n\
2856 environment, the value is printed in its own window."));
2857 set_cmd_completer (c
, expression_completer
);
2859 add_setshow_uinteger_cmd ("max-symbolic-offset", no_class
,
2860 &max_symbolic_offset
, _("\
2861 Set the largest offset that will be printed in <symbol+1234> form."), _("\
2862 Show the largest offset that will be printed in <symbol+1234> form."), NULL
,
2864 show_max_symbolic_offset
,
2865 &setprintlist
, &showprintlist
);
2866 add_setshow_boolean_cmd ("symbol-filename", no_class
,
2867 &print_symbol_filename
, _("\
2868 Set printing of source filename and line number with <symbol>."), _("\
2869 Show printing of source filename and line number with <symbol>."), NULL
,
2871 show_print_symbol_filename
,
2872 &setprintlist
, &showprintlist
);
2874 add_com ("eval", no_class
, eval_command
, _("\
2875 Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
2876 a command line, and call it."));