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
73 /* True if the value should be printed raw -- that is, bypassing
74 python-based formatters. */
78 /* Last specified output format. */
80 static char last_format
= 0;
82 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
84 static char last_size
= 'w';
86 /* Default address to examine next, and associated architecture. */
88 static struct gdbarch
*next_gdbarch
;
89 static CORE_ADDR next_address
;
91 /* Number of delay instructions following current disassembled insn. */
93 static int branch_delay_insns
;
95 /* Last address examined. */
97 static CORE_ADDR last_examine_address
;
99 /* Contents of last address examined.
100 This is not valid past the end of the `x' command! */
102 static struct value
*last_examine_value
;
104 /* Largest offset between a symbolic value and an address, that will be
105 printed as `0x1234 <symbol+offset>'. */
107 static unsigned int max_symbolic_offset
= UINT_MAX
;
109 show_max_symbolic_offset (struct ui_file
*file
, int from_tty
,
110 struct cmd_list_element
*c
, const char *value
)
112 fprintf_filtered (file
,
113 _("The largest offset that will be "
114 "printed in <symbol+1234> form is %s.\n"),
118 /* Append the source filename and linenumber of the symbol when
119 printing a symbolic value as `<symbol at filename:linenum>' if set. */
120 static int print_symbol_filename
= 0;
122 show_print_symbol_filename (struct ui_file
*file
, int from_tty
,
123 struct cmd_list_element
*c
, const char *value
)
125 fprintf_filtered (file
, _("Printing of source filename and "
126 "line number with <symbol> is %s.\n"),
130 /* Number of auto-display expression currently being displayed.
131 So that we can disable it if we get an error or a signal within it.
132 -1 when not doing one. */
134 int current_display_number
;
138 /* Chain link to next auto-display item. */
139 struct display
*next
;
141 /* The expression as the user typed it. */
144 /* Expression to be evaluated and displayed. */
145 struct expression
*exp
;
147 /* Item number of this auto-display item. */
150 /* Display format specified. */
151 struct format_data format
;
153 /* Program space associated with `block'. */
154 struct program_space
*pspace
;
156 /* Innermost block required by this expression when evaluated. */
159 /* Status of this display (enabled or disabled). */
163 /* Chain of expressions whose values should be displayed
164 automatically each time the program stops. */
166 static struct display
*display_chain
;
168 static int display_number
;
170 /* Prototypes for exported functions. */
172 void output_command (char *, int);
174 void _initialize_printcmd (void);
176 /* Prototypes for local functions. */
178 static void do_one_display (struct display
*);
181 /* Decode a format specification. *STRING_PTR should point to it.
182 OFORMAT and OSIZE are used as defaults for the format and size
183 if none are given in the format specification.
184 If OSIZE is zero, then the size field of the returned value
185 should be set only if a size is explicitly specified by the
187 The structure returned describes all the data
188 found in the specification. In addition, *STRING_PTR is advanced
189 past the specification and past all whitespace following it. */
191 static struct format_data
192 decode_format (char **string_ptr
, int oformat
, int osize
)
194 struct format_data val
;
195 char *p
= *string_ptr
;
202 if (*p
>= '0' && *p
<= '9')
203 val
.count
= atoi (p
);
204 while (*p
>= '0' && *p
<= '9')
207 /* Now process size or format letters that follow. */
211 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
218 else if (*p
>= 'a' && *p
<= 'z')
224 while (*p
== ' ' || *p
== '\t')
228 /* Set defaults for format and size if not specified. */
229 if (val
.format
== '?')
233 /* Neither has been specified. */
234 val
.format
= oformat
;
238 /* If a size is specified, any format makes a reasonable
239 default except 'i'. */
240 val
.format
= oformat
== 'i' ? 'x' : oformat
;
242 else if (val
.size
== '?')
246 /* Pick the appropriate size for an address. This is deferred
247 until do_examine when we know the actual architecture to use.
248 A special size value of 'a' is used to indicate this case. */
249 val
.size
= osize
? 'a' : osize
;
252 /* Floating point has to be word or giantword. */
253 if (osize
== 'w' || osize
== 'g')
256 /* Default it to giantword if the last used size is not
258 val
.size
= osize
? 'g' : osize
;
261 /* Characters default to one byte. */
262 val
.size
= osize
? 'b' : osize
;
265 /* Display strings with byte size chars unless explicitly
271 /* The default is the size most recently specified. */
278 /* Print value VAL on stream according to OPTIONS.
279 Do not end with a newline.
280 SIZE is the letter for the size of datum being printed.
281 This is used to pad hex numbers so they line up. SIZE is 0
282 for print / output and set for examine. */
285 print_formatted (struct value
*val
, int size
,
286 const struct value_print_options
*options
,
287 struct ui_file
*stream
)
289 struct type
*type
= check_typedef (value_type (val
));
290 int len
= TYPE_LENGTH (type
);
292 if (VALUE_LVAL (val
) == lval_memory
)
293 next_address
= value_address (val
) + len
;
297 switch (options
->format
)
301 struct type
*elttype
= value_type (val
);
303 next_address
= (value_address (val
)
304 + val_print_string (elttype
, NULL
,
305 value_address (val
), -1,
306 stream
, options
) * len
);
311 /* We often wrap here if there are long symbolic names. */
313 next_address
= (value_address (val
)
314 + gdb_print_insn (get_type_arch (type
),
315 value_address (val
), stream
,
316 &branch_delay_insns
));
321 if (options
->format
== 0 || options
->format
== 's'
322 || TYPE_CODE (type
) == TYPE_CODE_REF
323 || TYPE_CODE (type
) == TYPE_CODE_ARRAY
324 || TYPE_CODE (type
) == TYPE_CODE_STRING
325 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
326 || TYPE_CODE (type
) == TYPE_CODE_UNION
327 || TYPE_CODE (type
) == TYPE_CODE_NAMESPACE
)
328 value_print (val
, stream
, options
);
330 /* User specified format, so don't look to the the type to
331 tell us what to do. */
332 print_scalar_formatted (value_contents (val
), type
,
333 options
, size
, stream
);
336 /* Return builtin floating point type of same length as TYPE.
337 If no such type is found, return TYPE itself. */
339 float_type_from_length (struct type
*type
)
341 struct gdbarch
*gdbarch
= get_type_arch (type
);
342 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
343 unsigned int len
= TYPE_LENGTH (type
);
345 if (len
== TYPE_LENGTH (builtin
->builtin_float
))
346 type
= builtin
->builtin_float
;
347 else if (len
== TYPE_LENGTH (builtin
->builtin_double
))
348 type
= builtin
->builtin_double
;
349 else if (len
== TYPE_LENGTH (builtin
->builtin_long_double
))
350 type
= builtin
->builtin_long_double
;
355 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
356 according to OPTIONS and SIZE on STREAM.
357 Formats s and i are not supported at this level.
359 This is how the elements of an array or structure are printed
363 print_scalar_formatted (const void *valaddr
, struct type
*type
,
364 const struct value_print_options
*options
,
365 int size
, struct ui_file
*stream
)
367 struct gdbarch
*gdbarch
= get_type_arch (type
);
368 LONGEST val_long
= 0;
369 unsigned int len
= TYPE_LENGTH (type
);
370 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
372 /* If we get here with a string format, try again without it. Go
373 all the way back to the language printers, which may call us
375 if (options
->format
== 's')
377 struct value_print_options opts
= *options
;
380 val_print (type
, valaddr
, 0, 0, stream
, 0, NULL
, &opts
,
385 if (len
> sizeof(LONGEST
) &&
386 (TYPE_CODE (type
) == TYPE_CODE_INT
387 || TYPE_CODE (type
) == TYPE_CODE_ENUM
))
389 switch (options
->format
)
392 print_octal_chars (stream
, valaddr
, len
, byte_order
);
396 print_decimal_chars (stream
, valaddr
, len
, byte_order
);
399 print_binary_chars (stream
, valaddr
, len
, byte_order
);
402 print_hex_chars (stream
, valaddr
, len
, byte_order
);
405 print_char_chars (stream
, type
, valaddr
, len
, byte_order
);
412 if (options
->format
!= 'f')
413 val_long
= unpack_long (type
, valaddr
);
415 /* If the value is a pointer, and pointers and addresses are not the
416 same, then at this point, the value's length (in target bytes) is
417 gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */
418 if (TYPE_CODE (type
) == TYPE_CODE_PTR
)
419 len
= gdbarch_addr_bit (gdbarch
) / TARGET_CHAR_BIT
;
421 /* If we are printing it as unsigned, truncate it in case it is actually
422 a negative signed value (e.g. "print/u (short)-1" should print 65535
423 (if shorts are 16 bits) instead of 4294967295). */
424 if (options
->format
!= 'd' || TYPE_UNSIGNED (type
))
426 if (len
< sizeof (LONGEST
))
427 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
430 switch (options
->format
)
435 /* No size specified, like in print. Print varying # of digits. */
436 print_longest (stream
, 'x', 1, val_long
);
445 print_longest (stream
, size
, 1, val_long
);
448 error (_("Undefined output size \"%c\"."), size
);
453 print_longest (stream
, 'd', 1, val_long
);
457 print_longest (stream
, 'u', 0, val_long
);
462 print_longest (stream
, 'o', 1, val_long
);
464 fprintf_filtered (stream
, "0");
469 CORE_ADDR addr
= unpack_pointer (type
, valaddr
);
471 print_address (gdbarch
, addr
, stream
);
477 struct value_print_options opts
= *options
;
480 if (TYPE_UNSIGNED (type
))
481 type
= builtin_type (gdbarch
)->builtin_true_unsigned_char
;
483 type
= builtin_type (gdbarch
)->builtin_true_char
;
485 value_print (value_from_longest (type
, val_long
), stream
, &opts
);
490 type
= float_type_from_length (type
);
491 print_floating (valaddr
, type
, stream
);
495 internal_error (__FILE__
, __LINE__
,
496 _("failed internal consistency check"));
499 /* Binary; 't' stands for "two". */
501 char bits
[8 * (sizeof val_long
) + 1];
502 char buf
[8 * (sizeof val_long
) + 32];
507 width
= 8 * (sizeof val_long
);
524 error (_("Undefined output size \"%c\"."), size
);
530 bits
[width
] = (val_long
& 1) ? '1' : '0';
535 while (*cp
&& *cp
== '0')
541 fputs_filtered (buf
, stream
);
546 error (_("Undefined output format \"%c\"."), options
->format
);
550 /* Specify default address for `x' command.
551 The `info lines' command uses this. */
554 set_next_address (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
556 struct type
*ptr_type
= builtin_type (gdbarch
)->builtin_data_ptr
;
558 next_gdbarch
= gdbarch
;
561 /* Make address available to the user as $_. */
562 set_internalvar (lookup_internalvar ("_"),
563 value_from_pointer (ptr_type
, addr
));
566 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
567 after LEADIN. Print nothing if no symbolic name is found nearby.
568 Optionally also print source file and line number, if available.
569 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
570 or to interpret it as a possible C++ name and convert it back to source
571 form. However note that DO_DEMANGLE can be overridden by the specific
572 settings of the demangle and asm_demangle variables. */
575 print_address_symbolic (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
576 struct ui_file
*stream
,
577 int do_demangle
, char *leadin
)
580 char *filename
= NULL
;
585 /* Throw away both name and filename. */
586 struct cleanup
*cleanup_chain
= make_cleanup (free_current_contents
, &name
);
587 make_cleanup (free_current_contents
, &filename
);
589 if (build_address_symbolic (gdbarch
, addr
, do_demangle
, &name
, &offset
,
590 &filename
, &line
, &unmapped
))
592 do_cleanups (cleanup_chain
);
596 fputs_filtered (leadin
, stream
);
598 fputs_filtered ("<*", stream
);
600 fputs_filtered ("<", stream
);
601 fputs_filtered (name
, stream
);
603 fprintf_filtered (stream
, "+%u", (unsigned int) offset
);
605 /* Append source filename and line number if desired. Give specific
606 line # of this addr, if we have it; else line # of the nearest symbol. */
607 if (print_symbol_filename
&& filename
!= NULL
)
610 fprintf_filtered (stream
, " at %s:%d", filename
, line
);
612 fprintf_filtered (stream
, " in %s", filename
);
615 fputs_filtered ("*>", stream
);
617 fputs_filtered (">", stream
);
619 do_cleanups (cleanup_chain
);
622 /* Given an address ADDR return all the elements needed to print the
623 address in a symbolic form. NAME can be mangled or not depending
624 on DO_DEMANGLE (and also on the asm_demangle global variable,
625 manipulated via ''set print asm-demangle''). Return 0 in case of
626 success, when all the info in the OUT paramters is valid. Return 1
629 build_address_symbolic (struct gdbarch
*gdbarch
,
630 CORE_ADDR addr
, /* IN */
631 int do_demangle
, /* IN */
632 char **name
, /* OUT */
633 int *offset
, /* OUT */
634 char **filename
, /* OUT */
636 int *unmapped
) /* OUT */
638 struct minimal_symbol
*msymbol
;
639 struct symbol
*symbol
;
640 CORE_ADDR name_location
= 0;
641 struct obj_section
*section
= NULL
;
642 char *name_temp
= "";
644 /* Let's say it is mapped (not unmapped). */
647 /* Determine if the address is in an overlay, and whether it is
649 if (overlay_debugging
)
651 section
= find_pc_overlay (addr
);
652 if (pc_in_unmapped_range (addr
, section
))
655 addr
= overlay_mapped_address (addr
, section
);
659 /* First try to find the address in the symbol table, then
660 in the minsyms. Take the closest one. */
662 /* This is defective in the sense that it only finds text symbols. So
663 really this is kind of pointless--we should make sure that the
664 minimal symbols have everything we need (by changing that we could
665 save some memory, but for many debug format--ELF/DWARF or
666 anything/stabs--it would be inconvenient to eliminate those minimal
668 msymbol
= lookup_minimal_symbol_by_pc_section (addr
, section
);
669 symbol
= find_pc_sect_function (addr
, section
);
673 /* If this is a function (i.e. a code address), strip out any
674 non-address bits. For instance, display a pointer to the
675 first instruction of a Thumb function as <function>; the
676 second instruction will be <function+2>, even though the
677 pointer is <function+3>. This matches the ISA behavior. */
678 addr
= gdbarch_addr_bits_remove (gdbarch
, addr
);
680 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
681 if (do_demangle
|| asm_demangle
)
682 name_temp
= SYMBOL_PRINT_NAME (symbol
);
684 name_temp
= SYMBOL_LINKAGE_NAME (symbol
);
689 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
|| symbol
== NULL
)
691 /* The msymbol is closer to the address than the symbol;
692 use the msymbol instead. */
694 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
695 if (do_demangle
|| asm_demangle
)
696 name_temp
= SYMBOL_PRINT_NAME (msymbol
);
698 name_temp
= SYMBOL_LINKAGE_NAME (msymbol
);
701 if (symbol
== NULL
&& msymbol
== NULL
)
704 /* If the nearest symbol is too far away, don't print anything symbolic. */
706 /* For when CORE_ADDR is larger than unsigned int, we do math in
707 CORE_ADDR. But when we detect unsigned wraparound in the
708 CORE_ADDR math, we ignore this test and print the offset,
709 because addr+max_symbolic_offset has wrapped through the end
710 of the address space back to the beginning, giving bogus comparison. */
711 if (addr
> name_location
+ max_symbolic_offset
712 && name_location
+ max_symbolic_offset
> name_location
)
715 *offset
= addr
- name_location
;
717 *name
= xstrdup (name_temp
);
719 if (print_symbol_filename
)
721 struct symtab_and_line sal
;
723 sal
= find_pc_sect_line (addr
, section
, 0);
727 *filename
= xstrdup (sal
.symtab
->filename
);
735 /* Print address ADDR symbolically on STREAM.
736 First print it as a number. Then perhaps print
737 <SYMBOL + OFFSET> after the number. */
740 print_address (struct gdbarch
*gdbarch
,
741 CORE_ADDR addr
, struct ui_file
*stream
)
743 fputs_filtered (paddress (gdbarch
, addr
), stream
);
744 print_address_symbolic (gdbarch
, addr
, stream
, asm_demangle
, " ");
747 /* Return a prefix for instruction address:
748 "=> " for current instruction, else " ". */
751 pc_prefix (CORE_ADDR addr
)
753 if (has_stack_frames ())
755 struct frame_info
*frame
;
758 frame
= get_selected_frame (NULL
);
759 pc
= get_frame_pc (frame
);
767 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
768 controls whether to print the symbolic name "raw" or demangled.
769 Global setting "addressprint" controls whether to print hex address
773 print_address_demangle (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
774 struct ui_file
*stream
, int do_demangle
)
776 struct value_print_options opts
;
778 get_user_print_options (&opts
);
781 fprintf_filtered (stream
, "0");
783 else if (opts
.addressprint
)
785 fputs_filtered (paddress (gdbarch
, addr
), stream
);
786 print_address_symbolic (gdbarch
, addr
, stream
, do_demangle
, " ");
790 print_address_symbolic (gdbarch
, addr
, stream
, do_demangle
, "");
795 /* Examine data at address ADDR in format FMT.
796 Fetch it from memory and print on gdb_stdout. */
799 do_examine (struct format_data fmt
, struct gdbarch
*gdbarch
, CORE_ADDR addr
)
804 struct type
*val_type
= NULL
;
807 struct value_print_options opts
;
812 next_gdbarch
= gdbarch
;
815 /* Instruction format implies fetch single bytes
816 regardless of the specified size.
817 The case of strings is handled in decode_format, only explicit
818 size operator are not changed to 'b'. */
824 /* Pick the appropriate size for an address. */
825 if (gdbarch_ptr_bit (next_gdbarch
) == 64)
827 else if (gdbarch_ptr_bit (next_gdbarch
) == 32)
829 else if (gdbarch_ptr_bit (next_gdbarch
) == 16)
832 /* Bad value for gdbarch_ptr_bit. */
833 internal_error (__FILE__
, __LINE__
,
834 _("failed internal consistency check"));
838 val_type
= builtin_type (next_gdbarch
)->builtin_int8
;
839 else if (size
== 'h')
840 val_type
= builtin_type (next_gdbarch
)->builtin_int16
;
841 else if (size
== 'w')
842 val_type
= builtin_type (next_gdbarch
)->builtin_int32
;
843 else if (size
== 'g')
844 val_type
= builtin_type (next_gdbarch
)->builtin_int64
;
848 struct type
*char_type
= NULL
;
850 /* Search for "char16_t" or "char32_t" types or fall back to 8-bit char
851 if type is not found. */
853 char_type
= builtin_type (next_gdbarch
)->builtin_char16
;
854 else if (size
== 'w')
855 char_type
= builtin_type (next_gdbarch
)->builtin_char32
;
857 val_type
= char_type
;
860 if (size
!= '\0' && size
!= 'b')
861 warning (_("Unable to display strings with "
862 "size '%c', using 'b' instead."), size
);
864 val_type
= builtin_type (next_gdbarch
)->builtin_int8
;
873 if (format
== 's' || format
== 'i')
876 get_formatted_print_options (&opts
, format
);
878 /* Print as many objects as specified in COUNT, at most maxelts per line,
879 with the address of the next one at the start of each line. */
885 fputs_filtered (pc_prefix (next_address
), gdb_stdout
);
886 print_address (next_gdbarch
, next_address
, gdb_stdout
);
887 printf_filtered (":");
892 printf_filtered ("\t");
893 /* Note that print_formatted sets next_address for the next
895 last_examine_address
= next_address
;
897 if (last_examine_value
)
898 value_free (last_examine_value
);
900 /* The value to be displayed is not fetched greedily.
901 Instead, to avoid the possibility of a fetched value not
902 being used, its retrieval is delayed until the print code
903 uses it. When examining an instruction stream, the
904 disassembler will perform its own memory fetch using just
905 the address stored in LAST_EXAMINE_VALUE. FIXME: Should
906 the disassembler be modified so that LAST_EXAMINE_VALUE
907 is left with the byte sequence from the last complete
908 instruction fetched from memory? */
909 last_examine_value
= value_at_lazy (val_type
, next_address
);
911 if (last_examine_value
)
912 release_value (last_examine_value
);
914 print_formatted (last_examine_value
, size
, &opts
, gdb_stdout
);
916 /* Display any branch delay slots following the final insn. */
917 if (format
== 'i' && count
== 1)
918 count
+= branch_delay_insns
;
920 printf_filtered ("\n");
921 gdb_flush (gdb_stdout
);
926 validate_format (struct format_data fmt
, char *cmdname
)
929 error (_("Size letters are meaningless in \"%s\" command."), cmdname
);
931 error (_("Item count other than 1 is meaningless in \"%s\" command."),
933 if (fmt
.format
== 'i')
934 error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
935 fmt
.format
, cmdname
);
938 /* Evaluate string EXP as an expression in the current language and
939 print the resulting value. EXP may contain a format specifier as the
940 first argument ("/x myvar" for example, to print myvar in hex). */
943 print_command_1 (char *exp
, int inspect
, int voidprint
)
945 struct expression
*expr
;
946 struct cleanup
*old_chain
= 0;
949 struct format_data fmt
;
952 if (exp
&& *exp
== '/')
955 fmt
= decode_format (&exp
, last_format
, 0);
956 validate_format (fmt
, "print");
957 last_format
= format
= fmt
.format
;
969 expr
= parse_expression (exp
);
970 old_chain
= make_cleanup (free_current_contents
, &expr
);
972 val
= evaluate_expression (expr
);
975 val
= access_value_history (0);
977 if (voidprint
|| (val
&& value_type (val
) &&
978 TYPE_CODE (value_type (val
)) != TYPE_CODE_VOID
))
980 struct value_print_options opts
;
981 int histindex
= record_latest_value (val
);
984 annotate_value_history_begin (histindex
, value_type (val
));
986 annotate_value_begin (value_type (val
));
989 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"",
991 else if (histindex
>= 0)
992 printf_filtered ("$%d = ", histindex
);
995 annotate_value_history_value ();
997 get_formatted_print_options (&opts
, format
);
998 opts
.inspect_it
= inspect
;
1001 print_formatted (val
, fmt
.size
, &opts
, gdb_stdout
);
1002 printf_filtered ("\n");
1005 annotate_value_history_end ();
1007 annotate_value_end ();
1010 printf_unfiltered ("\") )\030");
1014 do_cleanups (old_chain
);
1018 print_command (char *exp
, int from_tty
)
1020 print_command_1 (exp
, 0, 1);
1023 /* Same as print, except in epoch, it gets its own window. */
1025 inspect_command (char *exp
, int from_tty
)
1027 extern int epoch_interface
;
1029 print_command_1 (exp
, epoch_interface
, 1);
1032 /* Same as print, except it doesn't print void results. */
1034 call_command (char *exp
, int from_tty
)
1036 print_command_1 (exp
, 0, 0);
1040 output_command (char *exp
, int from_tty
)
1042 struct expression
*expr
;
1043 struct cleanup
*old_chain
;
1046 struct format_data fmt
;
1047 struct value_print_options opts
;
1052 if (exp
&& *exp
== '/')
1055 fmt
= decode_format (&exp
, 0, 0);
1056 validate_format (fmt
, "output");
1057 format
= fmt
.format
;
1060 expr
= parse_expression (exp
);
1061 old_chain
= make_cleanup (free_current_contents
, &expr
);
1063 val
= evaluate_expression (expr
);
1065 annotate_value_begin (value_type (val
));
1067 get_formatted_print_options (&opts
, format
);
1069 print_formatted (val
, fmt
.size
, &opts
, gdb_stdout
);
1071 annotate_value_end ();
1074 gdb_flush (gdb_stdout
);
1076 do_cleanups (old_chain
);
1080 set_command (char *exp
, int from_tty
)
1082 struct expression
*expr
= parse_expression (exp
);
1083 struct cleanup
*old_chain
=
1084 make_cleanup (free_current_contents
, &expr
);
1086 evaluate_expression (expr
);
1087 do_cleanups (old_chain
);
1091 sym_info (char *arg
, int from_tty
)
1093 struct minimal_symbol
*msymbol
;
1094 struct objfile
*objfile
;
1095 struct obj_section
*osect
;
1096 CORE_ADDR addr
, sect_addr
;
1098 unsigned int offset
;
1101 error_no_arg (_("address"));
1103 addr
= parse_and_eval_address (arg
);
1104 ALL_OBJSECTIONS (objfile
, osect
)
1106 /* Only process each object file once, even if there's a separate
1108 if (objfile
->separate_debug_objfile_backlink
)
1111 sect_addr
= overlay_mapped_address (addr
, osect
);
1113 if (obj_section_addr (osect
) <= sect_addr
1114 && sect_addr
< obj_section_endaddr (osect
)
1115 && (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr
, osect
)))
1117 const char *obj_name
, *mapped
, *sec_name
, *msym_name
;
1119 struct cleanup
*old_chain
;
1122 offset
= sect_addr
- SYMBOL_VALUE_ADDRESS (msymbol
);
1123 mapped
= section_is_mapped (osect
) ? _("mapped") : _("unmapped");
1124 sec_name
= osect
->the_bfd_section
->name
;
1125 msym_name
= SYMBOL_PRINT_NAME (msymbol
);
1127 /* Don't print the offset if it is zero.
1128 We assume there's no need to handle i18n of "sym + offset". */
1130 loc_string
= xstrprintf ("%s + %u", msym_name
, offset
);
1132 loc_string
= xstrprintf ("%s", msym_name
);
1134 /* Use a cleanup to free loc_string in case the user quits
1135 a pagination request inside printf_filtered. */
1136 old_chain
= make_cleanup (xfree
, loc_string
);
1138 gdb_assert (osect
->objfile
&& osect
->objfile
->name
);
1139 obj_name
= osect
->objfile
->name
;
1141 if (MULTI_OBJFILE_P ())
1142 if (pc_in_unmapped_range (addr
, osect
))
1143 if (section_is_overlay (osect
))
1144 printf_filtered (_("%s in load address range of "
1145 "%s overlay section %s of %s\n"),
1146 loc_string
, mapped
, sec_name
, obj_name
);
1148 printf_filtered (_("%s in load address range of "
1149 "section %s of %s\n"),
1150 loc_string
, sec_name
, obj_name
);
1152 if (section_is_overlay (osect
))
1153 printf_filtered (_("%s in %s overlay section %s of %s\n"),
1154 loc_string
, mapped
, sec_name
, obj_name
);
1156 printf_filtered (_("%s in section %s of %s\n"),
1157 loc_string
, sec_name
, obj_name
);
1159 if (pc_in_unmapped_range (addr
, osect
))
1160 if (section_is_overlay (osect
))
1161 printf_filtered (_("%s in load address range of %s overlay "
1163 loc_string
, mapped
, sec_name
);
1165 printf_filtered (_("%s in load address range of section %s\n"),
1166 loc_string
, sec_name
);
1168 if (section_is_overlay (osect
))
1169 printf_filtered (_("%s in %s overlay section %s\n"),
1170 loc_string
, mapped
, sec_name
);
1172 printf_filtered (_("%s in section %s\n"),
1173 loc_string
, sec_name
);
1175 do_cleanups (old_chain
);
1179 printf_filtered (_("No symbol matches %s.\n"), arg
);
1183 address_info (char *exp
, int from_tty
)
1185 struct gdbarch
*gdbarch
;
1188 struct minimal_symbol
*msymbol
;
1190 struct obj_section
*section
;
1191 CORE_ADDR load_addr
, context_pc
= 0;
1192 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
1193 if exp is a field of `this'. */
1196 error (_("Argument required."));
1198 sym
= lookup_symbol (exp
, get_selected_block (&context_pc
), VAR_DOMAIN
,
1199 &is_a_field_of_this
);
1202 if (is_a_field_of_this
)
1204 printf_filtered ("Symbol \"");
1205 fprintf_symbol_filtered (gdb_stdout
, exp
,
1206 current_language
->la_language
, DMGL_ANSI
);
1207 printf_filtered ("\" is a field of the local class variable ");
1208 if (current_language
->la_language
== language_objc
)
1209 printf_filtered ("`self'\n"); /* ObjC equivalent of "this" */
1211 printf_filtered ("`this'\n");
1215 msymbol
= lookup_minimal_symbol (exp
, NULL
, NULL
);
1217 if (msymbol
!= NULL
)
1219 gdbarch
= get_objfile_arch (msymbol_objfile (msymbol
));
1220 load_addr
= SYMBOL_VALUE_ADDRESS (msymbol
);
1222 printf_filtered ("Symbol \"");
1223 fprintf_symbol_filtered (gdb_stdout
, exp
,
1224 current_language
->la_language
, DMGL_ANSI
);
1225 printf_filtered ("\" is at ");
1226 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1227 printf_filtered (" in a file compiled without debugging");
1228 section
= SYMBOL_OBJ_SECTION (msymbol
);
1229 if (section_is_overlay (section
))
1231 load_addr
= overlay_unmapped_address (load_addr
, section
);
1232 printf_filtered (",\n -- loaded at ");
1233 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1234 printf_filtered (" in overlay section %s",
1235 section
->the_bfd_section
->name
);
1237 printf_filtered (".\n");
1240 error (_("No symbol \"%s\" in current context."), exp
);
1244 printf_filtered ("Symbol \"");
1245 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_PRINT_NAME (sym
),
1246 current_language
->la_language
, DMGL_ANSI
);
1247 printf_filtered ("\" is ");
1248 val
= SYMBOL_VALUE (sym
);
1249 section
= SYMBOL_OBJ_SECTION (sym
);
1250 gdbarch
= get_objfile_arch (SYMBOL_SYMTAB (sym
)->objfile
);
1252 switch (SYMBOL_CLASS (sym
))
1255 case LOC_CONST_BYTES
:
1256 printf_filtered ("constant");
1260 printf_filtered ("a label at address ");
1261 load_addr
= SYMBOL_VALUE_ADDRESS (sym
);
1262 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1263 if (section_is_overlay (section
))
1265 load_addr
= overlay_unmapped_address (load_addr
, section
);
1266 printf_filtered (",\n -- loaded at ");
1267 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1268 printf_filtered (" in overlay section %s",
1269 section
->the_bfd_section
->name
);
1274 /* FIXME: cagney/2004-01-26: It should be possible to
1275 unconditionally call the SYMBOL_COMPUTED_OPS method when available.
1276 Unfortunately DWARF 2 stores the frame-base (instead of the
1277 function) location in a function's symbol. Oops! For the
1278 moment enable this when/where applicable. */
1279 SYMBOL_COMPUTED_OPS (sym
)->describe_location (sym
, context_pc
,
1284 /* GDBARCH is the architecture associated with the objfile the symbol
1285 is defined in; the target architecture may be different, and may
1286 provide additional registers. However, we do not know the target
1287 architecture at this point. We assume the objfile architecture
1288 will contain all the standard registers that occur in debug info
1290 regno
= SYMBOL_REGISTER_OPS (sym
)->register_number (sym
, gdbarch
);
1292 if (SYMBOL_IS_ARGUMENT (sym
))
1293 printf_filtered (_("an argument in register %s"),
1294 gdbarch_register_name (gdbarch
, regno
));
1296 printf_filtered (_("a variable in register %s"),
1297 gdbarch_register_name (gdbarch
, regno
));
1301 printf_filtered (_("static storage at address "));
1302 load_addr
= SYMBOL_VALUE_ADDRESS (sym
);
1303 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1304 if (section_is_overlay (section
))
1306 load_addr
= overlay_unmapped_address (load_addr
, section
);
1307 printf_filtered (_(",\n -- loaded at "));
1308 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1309 printf_filtered (_(" in overlay section %s"),
1310 section
->the_bfd_section
->name
);
1314 case LOC_REGPARM_ADDR
:
1315 /* Note comment at LOC_REGISTER. */
1316 regno
= SYMBOL_REGISTER_OPS (sym
)->register_number (sym
, gdbarch
);
1317 printf_filtered (_("address of an argument in register %s"),
1318 gdbarch_register_name (gdbarch
, regno
));
1322 printf_filtered (_("an argument at offset %ld"), val
);
1326 printf_filtered (_("a local variable at frame offset %ld"), val
);
1330 printf_filtered (_("a reference argument at offset %ld"), val
);
1334 printf_filtered (_("a typedef"));
1338 printf_filtered (_("a function at address "));
1339 load_addr
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
));
1340 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1341 if (section_is_overlay (section
))
1343 load_addr
= overlay_unmapped_address (load_addr
, section
);
1344 printf_filtered (_(",\n -- loaded at "));
1345 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1346 printf_filtered (_(" in overlay section %s"),
1347 section
->the_bfd_section
->name
);
1351 case LOC_UNRESOLVED
:
1353 struct minimal_symbol
*msym
;
1355 msym
= lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym
), NULL
, NULL
);
1357 printf_filtered ("unresolved");
1360 section
= SYMBOL_OBJ_SECTION (msym
);
1361 load_addr
= SYMBOL_VALUE_ADDRESS (msym
);
1364 && (section
->the_bfd_section
->flags
& SEC_THREAD_LOCAL
) != 0)
1365 printf_filtered (_("a thread-local variable at offset %s "
1366 "in the thread-local storage for `%s'"),
1367 paddress (gdbarch
, load_addr
),
1368 section
->objfile
->name
);
1371 printf_filtered (_("static storage at address "));
1372 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1373 if (section_is_overlay (section
))
1375 load_addr
= overlay_unmapped_address (load_addr
, section
);
1376 printf_filtered (_(",\n -- loaded at "));
1377 fputs_filtered (paddress (gdbarch
, load_addr
), gdb_stdout
);
1378 printf_filtered (_(" in overlay section %s"),
1379 section
->the_bfd_section
->name
);
1386 case LOC_OPTIMIZED_OUT
:
1387 printf_filtered (_("optimized out"));
1391 printf_filtered (_("of unknown (botched) type"));
1394 printf_filtered (".\n");
1399 x_command (char *exp
, int from_tty
)
1401 struct expression
*expr
;
1402 struct format_data fmt
;
1403 struct cleanup
*old_chain
;
1406 fmt
.format
= last_format
? last_format
: 'x';
1407 fmt
.size
= last_size
;
1411 if (exp
&& *exp
== '/')
1414 fmt
= decode_format (&exp
, last_format
, last_size
);
1417 /* If we have an expression, evaluate it and use it as the address. */
1419 if (exp
!= 0 && *exp
!= 0)
1421 expr
= parse_expression (exp
);
1422 /* Cause expression not to be there any more if this command is
1423 repeated with Newline. But don't clobber a user-defined
1424 command's definition. */
1427 old_chain
= make_cleanup (free_current_contents
, &expr
);
1428 val
= evaluate_expression (expr
);
1429 if (TYPE_CODE (value_type (val
)) == TYPE_CODE_REF
)
1430 val
= coerce_ref (val
);
1431 /* In rvalue contexts, such as this, functions are coerced into
1432 pointers to functions. This makes "x/i main" work. */
1433 if (/* last_format == 'i' && */
1434 TYPE_CODE (value_type (val
)) == TYPE_CODE_FUNC
1435 && VALUE_LVAL (val
) == lval_memory
)
1436 next_address
= value_address (val
);
1438 next_address
= value_as_address (val
);
1440 next_gdbarch
= expr
->gdbarch
;
1441 do_cleanups (old_chain
);
1445 error_no_arg (_("starting display address"));
1447 do_examine (fmt
, next_gdbarch
, next_address
);
1449 /* If the examine succeeds, we remember its size and format for next
1450 time. Set last_size to 'b' for strings. */
1451 if (fmt
.format
== 's')
1454 last_size
= fmt
.size
;
1455 last_format
= fmt
.format
;
1457 /* Set a couple of internal variables if appropriate. */
1458 if (last_examine_value
)
1460 /* Make last address examined available to the user as $_. Use
1461 the correct pointer type. */
1462 struct type
*pointer_type
1463 = lookup_pointer_type (value_type (last_examine_value
));
1464 set_internalvar (lookup_internalvar ("_"),
1465 value_from_pointer (pointer_type
,
1466 last_examine_address
));
1468 /* Make contents of last address examined available to the user
1469 as $__. If the last value has not been fetched from memory
1470 then don't fetch it now; instead mark it by voiding the $__
1472 if (value_lazy (last_examine_value
))
1473 clear_internalvar (lookup_internalvar ("__"));
1475 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1480 /* Add an expression to the auto-display chain.
1481 Specify the expression. */
1484 display_command (char *exp
, int from_tty
)
1486 struct format_data fmt
;
1487 struct expression
*expr
;
1488 struct display
*new;
1492 /* NOTE: cagney/2003-02-13 The `tui_active' was previously
1494 if (tui_active
&& exp
!= NULL
&& *exp
== '$')
1495 display_it
= (tui_set_layout_for_display_command (exp
) == TUI_FAILURE
);
1509 fmt
= decode_format (&exp
, 0, 0);
1510 if (fmt
.size
&& fmt
.format
== 0)
1512 if (fmt
.format
== 'i' || fmt
.format
== 's')
1523 innermost_block
= NULL
;
1524 expr
= parse_expression (exp
);
1526 new = (struct display
*) xmalloc (sizeof (struct display
));
1528 new->exp_string
= xstrdup (exp
);
1530 new->block
= innermost_block
;
1531 new->pspace
= current_program_space
;
1532 new->next
= display_chain
;
1533 new->number
= ++display_number
;
1536 display_chain
= new;
1538 if (from_tty
&& target_has_execution
)
1539 do_one_display (new);
1546 free_display (struct display
*d
)
1548 xfree (d
->exp_string
);
1553 /* Clear out the display_chain. Done when new symtabs are loaded,
1554 since this invalidates the types stored in many expressions. */
1557 clear_displays (void)
1561 while ((d
= display_chain
) != NULL
)
1563 display_chain
= d
->next
;
1568 /* Delete the auto-display number NUM. */
1571 delete_display (int num
)
1573 struct display
*d1
, *d
;
1576 error (_("No display number %d."), num
);
1578 if (display_chain
->number
== num
)
1581 display_chain
= d1
->next
;
1585 for (d
= display_chain
;; d
= d
->next
)
1588 error (_("No display number %d."), num
);
1589 if (d
->next
->number
== num
)
1599 /* Delete some values from the auto-display chain.
1600 Specify the element numbers. */
1603 undisplay_command (char *args
, int from_tty
)
1611 if (query (_("Delete all auto-display expressions? ")))
1620 while (*p1
>= '0' && *p1
<= '9')
1622 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1623 error (_("Arguments must be display numbers."));
1627 delete_display (num
);
1630 while (*p
== ' ' || *p
== '\t')
1636 /* Display a single auto-display.
1637 Do nothing if the display cannot be printed in the current context,
1638 or if the display is disabled. */
1641 do_one_display (struct display
*d
)
1643 int within_current_scope
;
1645 if (d
->enabled_p
== 0)
1648 /* The expression carries the architecture that was used at parse time.
1649 This is a problem if the expression depends on architecture features
1650 (e.g. register numbers), and the current architecture is now different.
1651 For example, a display statement like "display/i $pc" is expected to
1652 display the PC register of the current architecture, not the arch at
1653 the time the display command was given. Therefore, we re-parse the
1654 expression if the current architecture has changed. */
1655 if (d
->exp
!= NULL
&& d
->exp
->gdbarch
!= get_current_arch ())
1664 volatile struct gdb_exception ex
;
1666 TRY_CATCH (ex
, RETURN_MASK_ALL
)
1668 innermost_block
= NULL
;
1669 d
->exp
= parse_expression (d
->exp_string
);
1670 d
->block
= innermost_block
;
1674 /* Can't re-parse the expression. Disable this display item. */
1676 warning (_("Unable to display \"%s\": %s"),
1677 d
->exp_string
, ex
.message
);
1684 if (d
->pspace
== current_program_space
)
1685 within_current_scope
= contained_in (get_selected_block (0), d
->block
);
1687 within_current_scope
= 0;
1690 within_current_scope
= 1;
1691 if (!within_current_scope
)
1694 current_display_number
= d
->number
;
1696 annotate_display_begin ();
1697 printf_filtered ("%d", d
->number
);
1698 annotate_display_number_end ();
1699 printf_filtered (": ");
1705 annotate_display_format ();
1707 printf_filtered ("x/");
1708 if (d
->format
.count
!= 1)
1709 printf_filtered ("%d", d
->format
.count
);
1710 printf_filtered ("%c", d
->format
.format
);
1711 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1712 printf_filtered ("%c", d
->format
.size
);
1713 printf_filtered (" ");
1715 annotate_display_expression ();
1717 puts_filtered (d
->exp_string
);
1718 annotate_display_expression_end ();
1720 if (d
->format
.count
!= 1 || d
->format
.format
== 'i')
1721 printf_filtered ("\n");
1723 printf_filtered (" ");
1725 val
= evaluate_expression (d
->exp
);
1726 addr
= value_as_address (val
);
1727 if (d
->format
.format
== 'i')
1728 addr
= gdbarch_addr_bits_remove (d
->exp
->gdbarch
, addr
);
1730 annotate_display_value ();
1732 do_examine (d
->format
, d
->exp
->gdbarch
, addr
);
1736 struct value_print_options opts
;
1738 annotate_display_format ();
1740 if (d
->format
.format
)
1741 printf_filtered ("/%c ", d
->format
.format
);
1743 annotate_display_expression ();
1745 puts_filtered (d
->exp_string
);
1746 annotate_display_expression_end ();
1748 printf_filtered (" = ");
1750 annotate_display_expression ();
1752 get_formatted_print_options (&opts
, d
->format
.format
);
1753 opts
.raw
= d
->format
.raw
;
1754 print_formatted (evaluate_expression (d
->exp
),
1755 d
->format
.size
, &opts
, gdb_stdout
);
1756 printf_filtered ("\n");
1759 annotate_display_end ();
1761 gdb_flush (gdb_stdout
);
1762 current_display_number
= -1;
1765 /* Display all of the values on the auto-display chain which can be
1766 evaluated in the current scope. */
1773 for (d
= display_chain
; d
; d
= d
->next
)
1777 /* Delete the auto-display which we were in the process of displaying.
1778 This is done when there is an error or a signal. */
1781 disable_display (int num
)
1785 for (d
= display_chain
; d
; d
= d
->next
)
1786 if (d
->number
== num
)
1791 printf_unfiltered (_("No display number %d.\n"), num
);
1795 disable_current_display (void)
1797 if (current_display_number
>= 0)
1799 disable_display (current_display_number
);
1800 fprintf_unfiltered (gdb_stderr
,
1801 _("Disabling display %d to "
1802 "avoid infinite recursion.\n"),
1803 current_display_number
);
1805 current_display_number
= -1;
1809 display_info (char *ignore
, int from_tty
)
1814 printf_unfiltered (_("There are no auto-display expressions now.\n"));
1816 printf_filtered (_("Auto-display expressions now in effect:\n\
1817 Num Enb Expression\n"));
1819 for (d
= display_chain
; d
; d
= d
->next
)
1821 printf_filtered ("%d: %c ", d
->number
, "ny"[(int) d
->enabled_p
]);
1823 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1825 else if (d
->format
.format
)
1826 printf_filtered ("/%c ", d
->format
.format
);
1827 puts_filtered (d
->exp_string
);
1828 if (d
->block
&& !contained_in (get_selected_block (0), d
->block
))
1829 printf_filtered (_(" (cannot be evaluated in the current context)"));
1830 printf_filtered ("\n");
1831 gdb_flush (gdb_stdout
);
1836 enable_display (char *args
, int from_tty
)
1845 for (d
= display_chain
; d
; d
= d
->next
)
1852 while (*p1
>= '0' && *p1
<= '9')
1854 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1855 error (_("Arguments must be display numbers."));
1859 for (d
= display_chain
; d
; d
= d
->next
)
1860 if (d
->number
== num
)
1865 printf_unfiltered (_("No display number %d.\n"), num
);
1868 while (*p
== ' ' || *p
== '\t')
1874 disable_display_command (char *args
, int from_tty
)
1882 for (d
= display_chain
; d
; d
= d
->next
)
1889 while (*p1
>= '0' && *p1
<= '9')
1891 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1892 error (_("Arguments must be display numbers."));
1894 disable_display (atoi (p
));
1897 while (*p
== ' ' || *p
== '\t')
1902 /* display_chain items point to blocks and expressions. Some expressions in
1903 turn may point to symbols.
1904 Both symbols and blocks are obstack_alloc'd on objfile_stack, and are
1905 obstack_free'd when a shared library is unloaded.
1906 Clear pointers that are about to become dangling.
1907 Both .exp and .block fields will be restored next time we need to display
1908 an item by re-parsing .exp_string field in the new execution context. */
1911 clear_dangling_display_expressions (struct so_list
*solib
)
1913 struct objfile
*objfile
= solib
->objfile
;
1916 /* With no symbol file we cannot have a block or expression from it. */
1917 if (objfile
== NULL
)
1919 if (objfile
->separate_debug_objfile_backlink
)
1920 objfile
= objfile
->separate_debug_objfile_backlink
;
1921 gdb_assert (objfile
->pspace
== solib
->pspace
);
1923 for (d
= display_chain
; d
!= NULL
; d
= d
->next
)
1925 if (d
->pspace
!= solib
->pspace
)
1928 if (lookup_objfile_from_block (d
->block
) == objfile
1929 || (d
->exp
&& exp_uses_objfile (d
->exp
, objfile
)))
1939 /* Print the value in stack frame FRAME of a variable specified by a
1940 struct symbol. NAME is the name to print; if NULL then VAR's print
1941 name will be used. STREAM is the ui_file on which to print the
1942 value. INDENT specifies the number of indent levels to print
1943 before printing the variable name. */
1946 print_variable_and_value (const char *name
, struct symbol
*var
,
1947 struct frame_info
*frame
,
1948 struct ui_file
*stream
, int indent
)
1950 volatile struct gdb_exception except
;
1953 name
= SYMBOL_PRINT_NAME (var
);
1955 fprintf_filtered (stream
, "%s%s = ", n_spaces (2 * indent
), name
);
1956 TRY_CATCH (except
, RETURN_MASK_ERROR
)
1959 struct value_print_options opts
;
1961 val
= read_var_value (var
, frame
);
1962 get_user_print_options (&opts
);
1963 common_val_print (val
, stream
, indent
, &opts
, current_language
);
1965 if (except
.reason
< 0)
1966 fprintf_filtered(stream
, "<error reading variable %s (%s)>", name
,
1968 fprintf_filtered (stream
, "\n");
1971 /* printf "printf format string" ARG to STREAM. */
1974 ui_printf (char *arg
, struct ui_file
*stream
)
1978 char *string
= NULL
;
1979 struct value
**val_args
;
1981 char *current_substring
;
1983 int allocated_args
= 20;
1984 struct cleanup
*old_cleanups
;
1986 val_args
= xmalloc (allocated_args
* sizeof (struct value
*));
1987 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1990 error_no_arg (_("format-control string and values to print"));
1992 /* Skip white space before format string. */
1993 while (*s
== ' ' || *s
== '\t')
1996 /* A format string should follow, enveloped in double quotes. */
1998 error (_("Bad format string, missing '\"'."));
2000 /* Parse the format-control string and copy it into the string STRING,
2001 processing some kinds of escape sequence. */
2003 f
= string
= (char *) alloca (strlen (s
) + 1);
2011 error (_("Bad format string, non-terminated '\"'."));
2044 /* ??? TODO: handle other escape sequences. */
2045 error (_("Unrecognized escape character \\%c in format string."),
2055 /* Skip over " and following space and comma. */
2058 while (*s
== ' ' || *s
== '\t')
2061 if (*s
!= ',' && *s
!= 0)
2062 error (_("Invalid argument syntax"));
2066 while (*s
== ' ' || *s
== '\t')
2069 /* Need extra space for the '\0's. Doubling the size is sufficient. */
2070 substrings
= alloca (strlen (string
) * 2);
2071 current_substring
= substrings
;
2074 /* Now scan the string for %-specs and see what kinds of args they want.
2075 argclass[I] classifies the %-specs so we can give printf_filtered
2076 something of the right size. */
2080 int_arg
, long_arg
, long_long_arg
, ptr_arg
,
2081 string_arg
, wide_string_arg
, wide_char_arg
,
2082 double_arg
, long_double_arg
, decfloat_arg
2084 enum argclass
*argclass
;
2085 enum argclass this_argclass
;
2090 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
2097 int seen_hash
= 0, seen_zero
= 0, lcount
= 0, seen_prec
= 0;
2098 int seen_space
= 0, seen_plus
= 0;
2099 int seen_big_l
= 0, seen_h
= 0, seen_big_h
= 0;
2100 int seen_big_d
= 0, seen_double_big_d
= 0;
2103 /* Check the validity of the format specifier, and work
2104 out what argument it expects. We only accept C89
2105 format strings, with the exception of long long (which
2106 we autoconf for). */
2108 /* Skip over "%%". */
2115 /* The first part of a format specifier is a set of flag
2117 while (strchr ("0-+ #", *f
))
2130 /* The next part of a format specifier is a width. */
2131 while (strchr ("0123456789", *f
))
2134 /* The next part of a format specifier is a precision. */
2139 while (strchr ("0123456789", *f
))
2143 /* The next part of a format specifier is a length modifier. */
2164 /* Decimal32 modifier. */
2170 /* Decimal64 and Decimal128 modifiers. */
2175 /* Check for a Decimal128. */
2179 seen_double_big_d
= 1;
2195 if (seen_space
|| seen_plus
)
2202 this_argclass
= int_arg
;
2203 else if (lcount
== 1)
2204 this_argclass
= long_arg
;
2206 this_argclass
= long_long_arg
;
2213 this_argclass
= lcount
== 0 ? int_arg
: wide_char_arg
;
2214 if (lcount
> 1 || seen_h
|| seen_big_l
)
2216 if (seen_prec
|| seen_zero
|| seen_space
|| seen_plus
)
2221 this_argclass
= ptr_arg
;
2222 if (lcount
|| seen_h
|| seen_big_l
)
2224 if (seen_prec
|| seen_zero
|| seen_space
|| seen_plus
)
2229 this_argclass
= lcount
== 0 ? string_arg
: wide_string_arg
;
2230 if (lcount
> 1 || seen_h
|| seen_big_l
)
2232 if (seen_zero
|| seen_space
|| seen_plus
)
2241 if (seen_big_h
|| seen_big_d
|| seen_double_big_d
)
2242 this_argclass
= decfloat_arg
;
2243 else if (seen_big_l
)
2244 this_argclass
= long_double_arg
;
2246 this_argclass
= double_arg
;
2248 if (lcount
|| seen_h
)
2253 error (_("`*' not supported for precision or width in printf"));
2256 error (_("Format specifier `n' not supported in printf"));
2259 error (_("Incomplete format specifier at end of format string"));
2262 error (_("Unrecognized format specifier '%c' in printf"), *f
);
2266 error (_("Inappropriate modifiers to "
2267 "format specifier '%c' in printf"),
2272 if (lcount
> 1 && USE_PRINTF_I64
)
2274 /* Windows' printf does support long long, but not the usual way.
2275 Convert %lld to %I64d. */
2276 int length_before_ll
= f
- last_arg
- 1 - lcount
;
2278 strncpy (current_substring
, last_arg
, length_before_ll
);
2279 strcpy (current_substring
+ length_before_ll
, "I64");
2280 current_substring
[length_before_ll
+ 3] =
2281 last_arg
[length_before_ll
+ lcount
];
2282 current_substring
+= length_before_ll
+ 4;
2284 else if (this_argclass
== wide_string_arg
2285 || this_argclass
== wide_char_arg
)
2287 /* Convert %ls or %lc to %s. */
2288 int length_before_ls
= f
- last_arg
- 2;
2290 strncpy (current_substring
, last_arg
, length_before_ls
);
2291 strcpy (current_substring
+ length_before_ls
, "s");
2292 current_substring
+= length_before_ls
+ 2;
2296 strncpy (current_substring
, last_arg
, f
- last_arg
);
2297 current_substring
+= f
- last_arg
;
2299 *current_substring
++ = '\0';
2301 argclass
[nargs_wanted
++] = this_argclass
;
2304 /* Now, parse all arguments and evaluate them.
2305 Store the VALUEs in VAL_ARGS. */
2311 if (nargs
== allocated_args
)
2312 val_args
= (struct value
**) xrealloc ((char *) val_args
,
2313 (allocated_args
*= 2)
2314 * sizeof (struct value
*));
2316 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
2324 if (nargs
!= nargs_wanted
)
2325 error (_("Wrong number of arguments for specified format-string"));
2327 /* Now actually print them. */
2328 current_substring
= substrings
;
2329 for (i
= 0; i
< nargs
; i
++)
2331 switch (argclass
[i
])
2339 tem
= value_as_address (val_args
[i
]);
2341 /* This is a %s argument. Find the length of the string. */
2347 read_memory (tem
+ j
, &c
, 1);
2352 /* Copy the string contents into a string inside GDB. */
2353 str
= (gdb_byte
*) alloca (j
+ 1);
2355 read_memory (tem
, str
, j
);
2358 fprintf_filtered (stream
, current_substring
, (char *) str
);
2361 case wide_string_arg
:
2366 struct gdbarch
*gdbarch
2367 = get_type_arch (value_type (val_args
[i
]));
2368 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2369 struct type
*wctype
= lookup_typename (current_language
, gdbarch
,
2370 "wchar_t", NULL
, 0);
2371 int wcwidth
= TYPE_LENGTH (wctype
);
2372 gdb_byte
*buf
= alloca (wcwidth
);
2373 struct obstack output
;
2374 struct cleanup
*inner_cleanup
;
2376 tem
= value_as_address (val_args
[i
]);
2378 /* This is a %s argument. Find the length of the string. */
2379 for (j
= 0;; j
+= wcwidth
)
2382 read_memory (tem
+ j
, buf
, wcwidth
);
2383 if (extract_unsigned_integer (buf
, wcwidth
, byte_order
) == 0)
2387 /* Copy the string contents into a string inside GDB. */
2388 str
= (gdb_byte
*) alloca (j
+ wcwidth
);
2390 read_memory (tem
, str
, j
);
2391 memset (&str
[j
], 0, wcwidth
);
2393 obstack_init (&output
);
2394 inner_cleanup
= make_cleanup_obstack_free (&output
);
2396 convert_between_encodings (target_wide_charset (gdbarch
),
2399 &output
, translit_char
);
2400 obstack_grow_str0 (&output
, "");
2402 fprintf_filtered (stream
, current_substring
,
2403 obstack_base (&output
));
2404 do_cleanups (inner_cleanup
);
2409 struct gdbarch
*gdbarch
2410 = get_type_arch (value_type (val_args
[i
]));
2411 struct type
*wctype
= lookup_typename (current_language
, gdbarch
,
2412 "wchar_t", NULL
, 0);
2413 struct type
*valtype
;
2414 struct obstack output
;
2415 struct cleanup
*inner_cleanup
;
2416 const gdb_byte
*bytes
;
2418 valtype
= value_type (val_args
[i
]);
2419 if (TYPE_LENGTH (valtype
) != TYPE_LENGTH (wctype
)
2420 || TYPE_CODE (valtype
) != TYPE_CODE_INT
)
2421 error (_("expected wchar_t argument for %%lc"));
2423 bytes
= value_contents (val_args
[i
]);
2425 obstack_init (&output
);
2426 inner_cleanup
= make_cleanup_obstack_free (&output
);
2428 convert_between_encodings (target_wide_charset (gdbarch
),
2430 bytes
, TYPE_LENGTH (valtype
),
2431 TYPE_LENGTH (valtype
),
2432 &output
, translit_char
);
2433 obstack_grow_str0 (&output
, "");
2435 fprintf_filtered (stream
, current_substring
,
2436 obstack_base (&output
));
2437 do_cleanups (inner_cleanup
);
2442 struct type
*type
= value_type (val_args
[i
]);
2446 /* If format string wants a float, unchecked-convert the value
2447 to floating point of the same size. */
2448 type
= float_type_from_length (type
);
2449 val
= unpack_double (type
, value_contents (val_args
[i
]), &inv
);
2451 error (_("Invalid floating value found in program."));
2453 fprintf_filtered (stream
, current_substring
, (double) val
);
2456 case long_double_arg
:
2457 #ifdef HAVE_LONG_DOUBLE
2459 struct type
*type
= value_type (val_args
[i
]);
2463 /* If format string wants a float, unchecked-convert the value
2464 to floating point of the same size. */
2465 type
= float_type_from_length (type
);
2466 val
= unpack_double (type
, value_contents (val_args
[i
]), &inv
);
2468 error (_("Invalid floating value found in program."));
2470 fprintf_filtered (stream
, current_substring
,
2475 error (_("long double not supported in printf"));
2478 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2480 long long val
= value_as_long (val_args
[i
]);
2482 fprintf_filtered (stream
, current_substring
, val
);
2486 error (_("long long not supported in printf"));
2490 int val
= value_as_long (val_args
[i
]);
2492 fprintf_filtered (stream
, current_substring
, val
);
2497 long val
= value_as_long (val_args
[i
]);
2499 fprintf_filtered (stream
, current_substring
, val
);
2503 /* Handles decimal floating values. */
2506 const gdb_byte
*param_ptr
= value_contents (val_args
[i
]);
2508 #if defined (PRINTF_HAS_DECFLOAT)
2509 /* If we have native support for Decimal floating
2510 printing, handle it here. */
2511 fprintf_filtered (stream
, current_substring
, param_ptr
);
2514 /* As a workaround until vasprintf has native support for DFP
2515 we convert the DFP values to string and print them using
2516 the %s format specifier. */
2519 int nnull_chars
= 0;
2521 /* Parameter data. */
2522 struct type
*param_type
= value_type (val_args
[i
]);
2523 unsigned int param_len
= TYPE_LENGTH (param_type
);
2524 struct gdbarch
*gdbarch
= get_type_arch (param_type
);
2525 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2527 /* DFP output data. */
2528 struct value
*dfp_value
= NULL
;
2532 struct type
*dfp_type
= NULL
;
2533 char decstr
[MAX_DECIMAL_STRING
];
2535 /* Points to the end of the string so that we can go back
2536 and check for DFP length modifiers. */
2537 eos
= current_substring
+ strlen (current_substring
);
2539 /* Look for the float/double format specifier. */
2540 while (*eos
!= 'f' && *eos
!= 'e' && *eos
!= 'E'
2541 && *eos
!= 'g' && *eos
!= 'G')
2546 /* Search for the '%' char and extract the size and type of
2547 the output decimal value based on its modifiers
2548 (%Hf, %Df, %DDf). */
2549 while (*--sos
!= '%')
2554 dfp_type
= builtin_type (gdbarch
)->builtin_decfloat
;
2556 else if (*sos
== 'D' && *(sos
- 1) == 'D')
2559 dfp_type
= builtin_type (gdbarch
)->builtin_declong
;
2565 dfp_type
= builtin_type (gdbarch
)->builtin_decdouble
;
2569 /* Replace %Hf, %Df and %DDf with %s's. */
2572 /* Go through the whole format string and pull the correct
2573 number of chars back to compensate for the change in the
2574 format specifier. */
2575 while (nnull_chars
< nargs
- i
)
2583 /* Conversion between different DFP types. */
2584 if (TYPE_CODE (param_type
) == TYPE_CODE_DECFLOAT
)
2585 decimal_convert (param_ptr
, param_len
, byte_order
,
2586 dec
, dfp_len
, byte_order
);
2588 /* If this is a non-trivial conversion, just output 0.
2589 A correct converted value can be displayed by explicitly
2590 casting to a DFP type. */
2591 decimal_from_string (dec
, dfp_len
, byte_order
, "0");
2593 dfp_value
= value_from_decfloat (dfp_type
, dec
);
2595 dfp_ptr
= (gdb_byte
*) value_contents (dfp_value
);
2597 decimal_to_string (dfp_ptr
, dfp_len
, byte_order
, decstr
);
2599 /* Print the DFP value. */
2600 fprintf_filtered (stream
, current_substring
, decstr
);
2608 /* We avoid the host's %p because pointers are too
2609 likely to be the wrong size. The only interesting
2610 modifier for %p is a width; extract that, and then
2611 handle %p as glibc would: %#x or a literal "(nil)". */
2613 char *p
, *fmt
, *fmt_p
;
2614 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2615 long long val
= value_as_long (val_args
[i
]);
2617 long val
= value_as_long (val_args
[i
]);
2620 fmt
= alloca (strlen (current_substring
) + 5);
2622 /* Copy up to the leading %. */
2623 p
= current_substring
;
2627 int is_percent
= (*p
== '%');
2642 /* Copy any width. */
2643 while (*p
>= '0' && *p
< '9')
2646 gdb_assert (*p
== 'p' && *(p
+ 1) == '\0');
2649 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
2655 fprintf_filtered (stream
, fmt
, val
);
2661 fprintf_filtered (stream
, fmt
, "(nil)");
2667 internal_error (__FILE__
, __LINE__
,
2668 _("failed internal consistency check"));
2670 /* Skip to the next substring. */
2671 current_substring
+= strlen (current_substring
) + 1;
2673 /* Print the portion of the format string after the last argument.
2674 Note that this will not include any ordinary %-specs, but it
2675 might include "%%". That is why we use printf_filtered and not
2676 puts_filtered here. Also, we pass a dummy argument because
2677 some platforms have modified GCC to include -Wformat-security
2678 by default, which will warn here if there is no argument. */
2679 fprintf_filtered (stream
, last_arg
, 0);
2681 do_cleanups (old_cleanups
);
2684 /* Implement the "printf" command. */
2687 printf_command (char *arg
, int from_tty
)
2689 ui_printf (arg
, gdb_stdout
);
2692 /* Implement the "eval" command. */
2695 eval_command (char *arg
, int from_tty
)
2697 struct ui_file
*ui_out
= mem_fileopen ();
2698 struct cleanup
*cleanups
= make_cleanup_ui_file_delete (ui_out
);
2701 ui_printf (arg
, ui_out
);
2703 expanded
= ui_file_xstrdup (ui_out
, NULL
);
2704 make_cleanup (xfree
, expanded
);
2706 execute_command (expanded
, from_tty
);
2708 do_cleanups (cleanups
);
2712 _initialize_printcmd (void)
2714 struct cmd_list_element
*c
;
2716 current_display_number
= -1;
2718 observer_attach_solib_unloaded (clear_dangling_display_expressions
);
2720 add_info ("address", address_info
,
2721 _("Describe where symbol SYM is stored."));
2723 add_info ("symbol", sym_info
, _("\
2724 Describe what symbol is at location ADDR.\n\
2725 Only for symbols with fixed locations (global or static scope)."));
2727 add_com ("x", class_vars
, x_command
, _("\
2728 Examine memory: x/FMT ADDRESS.\n\
2729 ADDRESS is an expression for the memory address to examine.\n\
2730 FMT is a repeat count followed by a format letter and a size letter.\n\
2731 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2732 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2733 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2734 The specified number of objects of the specified size are printed\n\
2735 according to the format.\n\n\
2736 Defaults for format and size letters are those previously used.\n\
2737 Default count is 1. Default address is following last thing printed\n\
2738 with this command or \"print\"."));
2741 add_com ("whereis", class_vars
, whereis_command
,
2742 _("Print line number and file of definition of variable."));
2745 add_info ("display", display_info
, _("\
2746 Expressions to display when program stops, with code numbers."));
2748 add_cmd ("undisplay", class_vars
, undisplay_command
, _("\
2749 Cancel some expressions to be displayed when program stops.\n\
2750 Arguments are the code numbers of the expressions to stop displaying.\n\
2751 No argument means cancel all automatic-display expressions.\n\
2752 \"delete display\" has the same effect as this command.\n\
2753 Do \"info display\" to see current list of code numbers."),
2756 add_com ("display", class_vars
, display_command
, _("\
2757 Print value of expression EXP each time the program stops.\n\
2758 /FMT may be used before EXP as in the \"print\" command.\n\
2759 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2760 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2761 and examining is done as in the \"x\" command.\n\n\
2762 With no argument, display all currently requested auto-display expressions.\n\
2763 Use \"undisplay\" to cancel display requests previously made."));
2765 add_cmd ("display", class_vars
, enable_display
, _("\
2766 Enable some expressions to be displayed when program stops.\n\
2767 Arguments are the code numbers of the expressions to resume displaying.\n\
2768 No argument means enable all automatic-display expressions.\n\
2769 Do \"info display\" to see current list of code numbers."), &enablelist
);
2771 add_cmd ("display", class_vars
, disable_display_command
, _("\
2772 Disable some expressions to be displayed when program stops.\n\
2773 Arguments are the code numbers of the expressions to stop displaying.\n\
2774 No argument means disable all automatic-display expressions.\n\
2775 Do \"info display\" to see current list of code numbers."), &disablelist
);
2777 add_cmd ("display", class_vars
, undisplay_command
, _("\
2778 Cancel some expressions to be displayed when program stops.\n\
2779 Arguments are the code numbers of the expressions to stop displaying.\n\
2780 No argument means cancel all automatic-display expressions.\n\
2781 Do \"info display\" to see current list of code numbers."), &deletelist
);
2783 add_com ("printf", class_vars
, printf_command
, _("\
2784 printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2785 This is useful for formatted output in user-defined commands."));
2787 add_com ("output", class_vars
, output_command
, _("\
2788 Like \"print\" but don't put in value history and don't print newline.\n\
2789 This is useful in user-defined commands."));
2791 add_prefix_cmd ("set", class_vars
, set_command
, _("\
2792 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2793 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2794 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2795 with $), a register (a few standard names starting with $), or an actual\n\
2796 variable in the program being debugged. EXP is any valid expression.\n\
2797 Use \"set variable\" for variables with names identical to set subcommands.\n\
2799 With a subcommand, this command modifies parts of the gdb environment.\n\
2800 You can see these environment settings with the \"show\" command."),
2801 &setlist
, "set ", 1, &cmdlist
);
2803 add_com ("assign", class_vars
, set_command
, _("\
2804 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2805 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2806 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2807 with $), a register (a few standard names starting with $), or an actual\n\
2808 variable in the program being debugged. EXP is any valid expression.\n\
2809 Use \"set variable\" for variables with names identical to set subcommands.\n\
2810 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2811 You can see these environment settings with the \"show\" command."));
2813 /* "call" is the same as "set", but handy for dbx users to call fns. */
2814 c
= add_com ("call", class_vars
, call_command
, _("\
2815 Call a function in the program.\n\
2816 The argument is the function name and arguments, in the notation of the\n\
2817 current working language. The result is printed and saved in the value\n\
2818 history, if it is not void."));
2819 set_cmd_completer (c
, expression_completer
);
2821 add_cmd ("variable", class_vars
, set_command
, _("\
2822 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2823 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2824 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2825 with $), a register (a few standard names starting with $), or an actual\n\
2826 variable in the program being debugged. EXP is any valid expression.\n\
2827 This may usually be abbreviated to simply \"set\"."),
2830 c
= add_com ("print", class_vars
, print_command
, _("\
2831 Print value of expression EXP.\n\
2832 Variables accessible are those of the lexical environment of the selected\n\
2833 stack frame, plus all those whose scope is global or an entire file.\n\
2835 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2836 $$NUM refers to NUM'th value back from the last one.\n\
2837 Names starting with $ refer to registers (with the values they would have\n\
2838 if the program were to return to the stack frame now selected, restoring\n\
2839 all registers saved by frames farther in) or else to debugger\n\
2840 \"convenience\" variables (any such name not a known register).\n\
2841 Use assignment expressions to give values to convenience variables.\n\
2843 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2844 @ is a binary operator for treating consecutive data objects\n\
2845 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2846 element is FOO, whose second element is stored in the space following\n\
2847 where FOO is stored, etc. FOO must be an expression whose value\n\
2848 resides in memory.\n\
2850 EXP may be preceded with /FMT, where FMT is a format letter\n\
2851 but no count or size letter (see \"x\" command)."));
2852 set_cmd_completer (c
, expression_completer
);
2853 add_com_alias ("p", "print", class_vars
, 1);
2855 c
= add_com ("inspect", class_vars
, inspect_command
, _("\
2856 Same as \"print\" command, except that if you are running in the epoch\n\
2857 environment, the value is printed in its own window."));
2858 set_cmd_completer (c
, expression_completer
);
2860 add_setshow_uinteger_cmd ("max-symbolic-offset", no_class
,
2861 &max_symbolic_offset
, _("\
2862 Set the largest offset that will be printed in <symbol+1234> form."), _("\
2863 Show the largest offset that will be printed in <symbol+1234> form."), NULL
,
2865 show_max_symbolic_offset
,
2866 &setprintlist
, &showprintlist
);
2867 add_setshow_boolean_cmd ("symbol-filename", no_class
,
2868 &print_symbol_filename
, _("\
2869 Set printing of source filename and line number with <symbol>."), _("\
2870 Show printing of source filename and line number with <symbol>."), NULL
,
2872 show_print_symbol_filename
,
2873 &setprintlist
, &showprintlist
);
2875 add_com ("eval", no_class
, eval_command
, _("\
2876 Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
2877 a command line, and call it."));