1 /* Print values for GNU debugger GDB.
3 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
5 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 2 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, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
31 #include "expression.h"
35 #include "breakpoint.h"
39 #include "symfile.h" /* for overlay functions */
40 #include "objfiles.h" /* ditto */
41 #include "completer.h" /* for completion functions */
43 #include "gdb_assert.h"
48 #include "tui/tui.h" /* For tui_active et.al. */
51 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
52 extern int addressprint
; /* Whether to print hex addresses in HLL " */
61 /* Last specified output format. */
63 static char last_format
= 'x';
65 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
67 static char last_size
= 'w';
69 /* Default address to examine next. */
71 static CORE_ADDR next_address
;
73 /* Last address examined. */
75 static CORE_ADDR last_examine_address
;
77 /* Contents of last address examined.
78 This is not valid past the end of the `x' command! */
80 static struct value
*last_examine_value
;
82 /* Largest offset between a symbolic value and an address, that will be
83 printed as `0x1234 <symbol+offset>'. */
85 static unsigned int max_symbolic_offset
= UINT_MAX
;
87 /* Append the source filename and linenumber of the symbol when
88 printing a symbolic value as `<symbol at filename:linenum>' if set. */
89 static int print_symbol_filename
= 0;
91 /* Number of auto-display expression currently being displayed.
92 So that we can disable it if we get an error or a signal within it.
93 -1 when not doing one. */
95 int current_display_number
;
97 /* Flag to low-level print routines that this value is being printed
98 in an epoch window. We'd like to pass this as a parameter, but
99 every routine would need to take it. Perhaps we can encapsulate
100 this in the I/O stream once we have GNU stdio. */
106 /* Chain link to next auto-display item. */
107 struct display
*next
;
108 /* Expression to be evaluated and displayed. */
109 struct expression
*exp
;
110 /* Item number of this auto-display item. */
112 /* Display format specified. */
113 struct format_data format
;
114 /* Innermost block required by this expression when evaluated */
116 /* Status of this display (enabled or disabled) */
120 /* Chain of expressions whose values should be displayed
121 automatically each time the program stops. */
123 static struct display
*display_chain
;
125 static int display_number
;
127 /* Prototypes for exported functions. */
129 void output_command (char *, int);
131 void _initialize_printcmd (void);
133 /* Prototypes for local functions. */
135 static void delete_display (int);
137 static void enable_display (char *, int);
139 static void disable_display_command (char *, int);
141 static void printf_command (char *, int);
143 static void display_info (char *, int);
145 static void do_one_display (struct display
*);
147 static void undisplay_command (char *, int);
149 static void free_display (struct display
*);
151 static void display_command (char *, int);
153 void x_command (char *, int);
155 static void address_info (char *, int);
157 static void set_command (char *, int);
159 static void call_command (char *, int);
161 static void inspect_command (char *, int);
163 static void print_command (char *, int);
165 static void print_command_1 (char *, int, int);
167 static void validate_format (struct format_data
, char *);
169 static void print_formatted (struct value
*, int, int, struct ui_file
*);
171 static struct format_data
decode_format (char **, int, int);
173 static void sym_info (char *, int);
176 /* Decode a format specification. *STRING_PTR should point to it.
177 OFORMAT and OSIZE are used as defaults for the format and size
178 if none are given in the format specification.
179 If OSIZE is zero, then the size field of the returned value
180 should be set only if a size is explicitly specified by the
182 The structure returned describes all the data
183 found in the specification. In addition, *STRING_PTR is advanced
184 past the specification and past all whitespace following it. */
186 static struct format_data
187 decode_format (char **string_ptr
, int oformat
, int osize
)
189 struct format_data val
;
190 char *p
= *string_ptr
;
196 if (*p
>= '0' && *p
<= '9')
197 val
.count
= atoi (p
);
198 while (*p
>= '0' && *p
<= '9')
201 /* Now process size or format letters that follow. */
205 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
207 else if (*p
>= 'a' && *p
<= 'z')
213 while (*p
== ' ' || *p
== '\t')
217 /* Set defaults for format and size if not specified. */
218 if (val
.format
== '?')
222 /* Neither has been specified. */
223 val
.format
= oformat
;
227 /* If a size is specified, any format makes a reasonable
228 default except 'i'. */
229 val
.format
= oformat
== 'i' ? 'x' : oformat
;
231 else if (val
.size
== '?')
236 /* Pick the appropriate size for an address. */
237 if (TARGET_PTR_BIT
== 64)
238 val
.size
= osize
? 'g' : osize
;
239 else if (TARGET_PTR_BIT
== 32)
240 val
.size
= osize
? 'w' : osize
;
241 else if (TARGET_PTR_BIT
== 16)
242 val
.size
= osize
? 'h' : osize
;
244 /* Bad value for TARGET_PTR_BIT */
245 internal_error (__FILE__
, __LINE__
, _("failed internal consistency check"));
248 /* Floating point has to be word or giantword. */
249 if (osize
== 'w' || osize
== 'g')
252 /* Default it to giantword if the last used size is not
254 val
.size
= osize
? 'g' : osize
;
257 /* Characters default to one byte. */
258 val
.size
= osize
? 'b' : osize
;
261 /* The default is the size most recently specified. */
268 /* Print value VAL on stream according to FORMAT, a letter or 0.
269 Do not end with a newline.
270 0 means print VAL according to its own type.
271 SIZE is the letter for the size of datum being printed.
272 This is used to pad hex numbers so they line up. */
275 print_formatted (struct value
*val
, int format
, int size
,
276 struct ui_file
*stream
)
278 struct type
*type
= check_typedef (value_type (val
));
279 int len
= TYPE_LENGTH (type
);
281 if (VALUE_LVAL (val
) == lval_memory
)
283 next_address
= VALUE_ADDRESS (val
) + len
;
289 /* FIXME: Need to handle wchar_t's here... */
290 next_address
= VALUE_ADDRESS (val
)
291 + val_print_string (VALUE_ADDRESS (val
), -1, 1, stream
);
295 /* The old comment says
296 "Force output out, print_insn not using _filtered".
297 I'm not completely sure what that means, I suspect most print_insn
298 now do use _filtered, so I guess it's obsolete.
299 --Yes, it does filter now, and so this is obsolete. -JB */
301 /* We often wrap here if there are long symbolic names. */
303 next_address
= VALUE_ADDRESS (val
)
304 + gdb_print_insn (VALUE_ADDRESS (val
), stream
);
309 || TYPE_CODE (type
) == TYPE_CODE_ARRAY
310 || TYPE_CODE (type
) == TYPE_CODE_STRING
311 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
312 || TYPE_CODE (type
) == TYPE_CODE_UNION
313 || TYPE_CODE (type
) == TYPE_CODE_NAMESPACE
)
314 /* If format is 0, use the 'natural' format for
315 * that type of value. If the type is non-scalar,
316 * we have to use language rules to print it as
317 * a series of scalars.
319 value_print (val
, stream
, format
, Val_pretty_default
);
321 /* User specified format, so don't look to the
322 * the type to tell us what to do.
324 print_scalar_formatted (value_contents (val
), type
,
325 format
, size
, stream
);
329 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
330 according to letters FORMAT and SIZE on STREAM.
331 FORMAT may not be zero. Formats s and i are not supported at this level.
333 This is how the elements of an array or structure are printed
337 print_scalar_formatted (const void *valaddr
, struct type
*type
,
338 int format
, int size
, struct ui_file
*stream
)
340 LONGEST val_long
= 0;
341 unsigned int len
= TYPE_LENGTH (type
);
343 if (len
> sizeof(LONGEST
) &&
344 (TYPE_CODE (type
) == TYPE_CODE_INT
345 || TYPE_CODE (type
) == TYPE_CODE_ENUM
))
350 print_octal_chars (stream
, valaddr
, len
);
354 print_decimal_chars (stream
, valaddr
, len
);
357 print_binary_chars (stream
, valaddr
, len
);
360 print_hex_chars (stream
, valaddr
, len
);
363 print_char_chars (stream
, valaddr
, len
);
371 val_long
= unpack_long (type
, valaddr
);
373 /* If the value is a pointer, and pointers and addresses are not the
374 same, then at this point, the value's length (in target bytes) is
375 TARGET_ADDR_BIT/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */
376 if (TYPE_CODE (type
) == TYPE_CODE_PTR
)
377 len
= TARGET_ADDR_BIT
/ TARGET_CHAR_BIT
;
379 /* If we are printing it as unsigned, truncate it in case it is actually
380 a negative signed value (e.g. "print/u (short)-1" should print 65535
381 (if shorts are 16 bits) instead of 4294967295). */
384 if (len
< sizeof (LONGEST
))
385 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
393 /* no size specified, like in print. Print varying # of digits. */
394 print_longest (stream
, 'x', 1, val_long
);
403 print_longest (stream
, size
, 1, val_long
);
406 error (_("Undefined output size \"%c\"."), size
);
411 print_longest (stream
, 'd', 1, val_long
);
415 print_longest (stream
, 'u', 0, val_long
);
420 print_longest (stream
, 'o', 1, val_long
);
422 fprintf_filtered (stream
, "0");
427 CORE_ADDR addr
= unpack_pointer (type
, valaddr
);
428 print_address (addr
, stream
);
433 value_print (value_from_longest (builtin_type_true_char
, val_long
),
434 stream
, 0, Val_pretty_default
);
438 if (len
== TYPE_LENGTH (builtin_type_float
))
439 type
= builtin_type_float
;
440 else if (len
== TYPE_LENGTH (builtin_type_double
))
441 type
= builtin_type_double
;
442 else if (len
== TYPE_LENGTH (builtin_type_long_double
))
443 type
= builtin_type_long_double
;
444 print_floating (valaddr
, type
, stream
);
448 internal_error (__FILE__
, __LINE__
, _("failed internal consistency check"));
451 /* Binary; 't' stands for "two". */
453 char bits
[8 * (sizeof val_long
) + 1];
454 char buf
[8 * (sizeof val_long
) + 32];
459 width
= 8 * (sizeof val_long
);
476 error (_("Undefined output size \"%c\"."), size
);
482 bits
[width
] = (val_long
& 1) ? '1' : '0';
487 while (*cp
&& *cp
== '0')
493 fputs_filtered (buf
, stream
);
498 error (_("Undefined output format \"%c\"."), format
);
502 /* Specify default address for `x' command.
503 `info lines' uses this. */
506 set_next_address (CORE_ADDR addr
)
510 /* Make address available to the user as $_. */
511 set_internalvar (lookup_internalvar ("_"),
512 value_from_pointer (lookup_pointer_type (builtin_type_void
),
516 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
517 after LEADIN. Print nothing if no symbolic name is found nearby.
518 Optionally also print source file and line number, if available.
519 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
520 or to interpret it as a possible C++ name and convert it back to source
521 form. However note that DO_DEMANGLE can be overridden by the specific
522 settings of the demangle and asm_demangle variables. */
525 print_address_symbolic (CORE_ADDR addr
, struct ui_file
*stream
, int do_demangle
,
529 char *filename
= NULL
;
534 /* throw away both name and filename */
535 struct cleanup
*cleanup_chain
= make_cleanup (free_current_contents
, &name
);
536 make_cleanup (free_current_contents
, &filename
);
538 if (build_address_symbolic (addr
, do_demangle
, &name
, &offset
, &filename
, &line
, &unmapped
))
540 do_cleanups (cleanup_chain
);
544 fputs_filtered (leadin
, stream
);
546 fputs_filtered ("<*", stream
);
548 fputs_filtered ("<", stream
);
549 fputs_filtered (name
, stream
);
551 fprintf_filtered (stream
, "+%u", (unsigned int) offset
);
553 /* Append source filename and line number if desired. Give specific
554 line # of this addr, if we have it; else line # of the nearest symbol. */
555 if (print_symbol_filename
&& filename
!= NULL
)
558 fprintf_filtered (stream
, " at %s:%d", filename
, line
);
560 fprintf_filtered (stream
, " in %s", filename
);
563 fputs_filtered ("*>", stream
);
565 fputs_filtered (">", stream
);
567 do_cleanups (cleanup_chain
);
570 /* Given an address ADDR return all the elements needed to print the
571 address in a symbolic form. NAME can be mangled or not depending
572 on DO_DEMANGLE (and also on the asm_demangle global variable,
573 manipulated via ''set print asm-demangle''). Return 0 in case of
574 success, when all the info in the OUT paramters is valid. Return 1
577 build_address_symbolic (CORE_ADDR addr
, /* IN */
578 int do_demangle
, /* IN */
579 char **name
, /* OUT */
580 int *offset
, /* OUT */
581 char **filename
, /* OUT */
583 int *unmapped
) /* OUT */
585 struct minimal_symbol
*msymbol
;
586 struct symbol
*symbol
;
587 struct symtab
*symtab
= 0;
588 CORE_ADDR name_location
= 0;
589 asection
*section
= 0;
590 char *name_temp
= "";
592 /* Let's say it is unmapped. */
595 /* Determine if the address is in an overlay, and whether it is
597 if (overlay_debugging
)
599 section
= find_pc_overlay (addr
);
600 if (pc_in_unmapped_range (addr
, section
))
603 addr
= overlay_mapped_address (addr
, section
);
607 /* First try to find the address in the symbol table, then
608 in the minsyms. Take the closest one. */
610 /* This is defective in the sense that it only finds text symbols. So
611 really this is kind of pointless--we should make sure that the
612 minimal symbols have everything we need (by changing that we could
613 save some memory, but for many debug format--ELF/DWARF or
614 anything/stabs--it would be inconvenient to eliminate those minimal
616 msymbol
= lookup_minimal_symbol_by_pc_section (addr
, section
);
617 symbol
= find_pc_sect_function (addr
, section
);
621 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
622 if (do_demangle
|| asm_demangle
)
623 name_temp
= SYMBOL_PRINT_NAME (symbol
);
625 name_temp
= DEPRECATED_SYMBOL_NAME (symbol
);
630 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
|| symbol
== NULL
)
632 /* The msymbol is closer to the address than the symbol;
633 use the msymbol instead. */
636 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
637 if (do_demangle
|| asm_demangle
)
638 name_temp
= SYMBOL_PRINT_NAME (msymbol
);
640 name_temp
= DEPRECATED_SYMBOL_NAME (msymbol
);
643 if (symbol
== NULL
&& msymbol
== NULL
)
646 /* If the nearest symbol is too far away, don't print anything symbolic. */
648 /* For when CORE_ADDR is larger than unsigned int, we do math in
649 CORE_ADDR. But when we detect unsigned wraparound in the
650 CORE_ADDR math, we ignore this test and print the offset,
651 because addr+max_symbolic_offset has wrapped through the end
652 of the address space back to the beginning, giving bogus comparison. */
653 if (addr
> name_location
+ max_symbolic_offset
654 && name_location
+ max_symbolic_offset
> name_location
)
657 *offset
= addr
- name_location
;
659 *name
= xstrdup (name_temp
);
661 if (print_symbol_filename
)
663 struct symtab_and_line sal
;
665 sal
= find_pc_sect_line (addr
, section
, 0);
669 *filename
= xstrdup (sal
.symtab
->filename
);
672 else if (symtab
&& symbol
&& symbol
->line
)
674 *filename
= xstrdup (symtab
->filename
);
675 *line
= symbol
->line
;
679 *filename
= xstrdup (symtab
->filename
);
686 /* Print address ADDR on STREAM. USE_LOCAL means the same thing as for
689 deprecated_print_address_numeric (CORE_ADDR addr
, int use_local
,
690 struct ui_file
*stream
)
693 fputs_filtered (paddress (addr
), stream
);
696 int addr_bit
= TARGET_ADDR_BIT
;
698 if (addr_bit
< (sizeof (CORE_ADDR
) * HOST_CHAR_BIT
))
699 addr
&= ((CORE_ADDR
) 1 << addr_bit
) - 1;
700 print_longest (stream
, 'x', 0, (ULONGEST
) addr
);
704 /* Print address ADDR symbolically on STREAM.
705 First print it as a number. Then perhaps print
706 <SYMBOL + OFFSET> after the number. */
709 print_address (CORE_ADDR addr
, struct ui_file
*stream
)
711 deprecated_print_address_numeric (addr
, 1, stream
);
712 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
715 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
716 controls whether to print the symbolic name "raw" or demangled.
717 Global setting "addressprint" controls whether to print hex address
721 print_address_demangle (CORE_ADDR addr
, struct ui_file
*stream
, int do_demangle
)
725 fprintf_filtered (stream
, "0");
727 else if (addressprint
)
729 deprecated_print_address_numeric (addr
, 1, stream
);
730 print_address_symbolic (addr
, stream
, do_demangle
, " ");
734 print_address_symbolic (addr
, stream
, do_demangle
, "");
739 /* These are the types that $__ will get after an examine command of one
742 static struct type
*examine_i_type
;
744 static struct type
*examine_b_type
;
745 static struct type
*examine_h_type
;
746 static struct type
*examine_w_type
;
747 static struct type
*examine_g_type
;
749 /* Examine data at address ADDR in format FMT.
750 Fetch it from memory and print on gdb_stdout. */
753 do_examine (struct format_data fmt
, CORE_ADDR addr
)
758 struct type
*val_type
= NULL
;
767 /* String or instruction format implies fetch single bytes
768 regardless of the specified size. */
769 if (format
== 's' || format
== 'i')
773 val_type
= examine_i_type
;
774 else if (size
== 'b')
775 val_type
= examine_b_type
;
776 else if (size
== 'h')
777 val_type
= examine_h_type
;
778 else if (size
== 'w')
779 val_type
= examine_w_type
;
780 else if (size
== 'g')
781 val_type
= examine_g_type
;
788 if (format
== 's' || format
== 'i')
791 /* Print as many objects as specified in COUNT, at most maxelts per line,
792 with the address of the next one at the start of each line. */
797 print_address (next_address
, gdb_stdout
);
798 printf_filtered (":");
803 printf_filtered ("\t");
804 /* Note that print_formatted sets next_address for the next
806 last_examine_address
= next_address
;
808 if (last_examine_value
)
809 value_free (last_examine_value
);
811 /* The value to be displayed is not fetched greedily.
812 Instead, to avoid the posibility of a fetched value not
813 being used, its retreval is delayed until the print code
814 uses it. When examining an instruction stream, the
815 disassembler will perform its own memory fetch using just
816 the address stored in LAST_EXAMINE_VALUE. FIXME: Should
817 the disassembler be modified so that LAST_EXAMINE_VALUE
818 is left with the byte sequence from the last complete
819 instruction fetched from memory? */
820 last_examine_value
= value_at_lazy (val_type
, next_address
);
822 if (last_examine_value
)
823 release_value (last_examine_value
);
825 print_formatted (last_examine_value
, format
, size
, gdb_stdout
);
827 printf_filtered ("\n");
828 gdb_flush (gdb_stdout
);
833 validate_format (struct format_data fmt
, char *cmdname
)
836 error (_("Size letters are meaningless in \"%s\" command."), cmdname
);
838 error (_("Item count other than 1 is meaningless in \"%s\" command."),
840 if (fmt
.format
== 'i' || fmt
.format
== 's')
841 error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
842 fmt
.format
, cmdname
);
845 /* Evaluate string EXP as an expression in the current language and
846 print the resulting value. EXP may contain a format specifier as the
847 first argument ("/x myvar" for example, to print myvar in hex).
851 print_command_1 (char *exp
, int inspect
, int voidprint
)
853 struct expression
*expr
;
854 struct cleanup
*old_chain
= 0;
857 struct format_data fmt
;
860 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
861 inspect_it
= inspect
;
863 if (exp
&& *exp
== '/')
866 fmt
= decode_format (&exp
, last_format
, 0);
867 validate_format (fmt
, "print");
868 last_format
= format
= fmt
.format
;
880 expr
= parse_expression (exp
);
881 old_chain
= make_cleanup (free_current_contents
, &expr
);
883 val
= evaluate_expression (expr
);
886 val
= access_value_history (0);
888 if (voidprint
|| (val
&& value_type (val
) &&
889 TYPE_CODE (value_type (val
)) != TYPE_CODE_VOID
))
891 int histindex
= record_latest_value (val
);
894 annotate_value_history_begin (histindex
, value_type (val
));
896 annotate_value_begin (value_type (val
));
899 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
900 else if (histindex
>= 0)
901 printf_filtered ("$%d = ", histindex
);
904 annotate_value_history_value ();
906 print_formatted (val
, format
, fmt
.size
, gdb_stdout
);
907 printf_filtered ("\n");
910 annotate_value_history_end ();
912 annotate_value_end ();
915 printf_unfiltered ("\") )\030");
919 do_cleanups (old_chain
);
920 inspect_it
= 0; /* Reset print routines to normal */
924 print_command (char *exp
, int from_tty
)
926 print_command_1 (exp
, 0, 1);
929 /* Same as print, except in epoch, it gets its own window */
931 inspect_command (char *exp
, int from_tty
)
933 extern int epoch_interface
;
935 print_command_1 (exp
, epoch_interface
, 1);
938 /* Same as print, except it doesn't print void results. */
940 call_command (char *exp
, int from_tty
)
942 print_command_1 (exp
, 0, 0);
946 output_command (char *exp
, int from_tty
)
948 struct expression
*expr
;
949 struct cleanup
*old_chain
;
952 struct format_data fmt
;
954 if (exp
&& *exp
== '/')
957 fmt
= decode_format (&exp
, 0, 0);
958 validate_format (fmt
, "output");
962 expr
= parse_expression (exp
);
963 old_chain
= make_cleanup (free_current_contents
, &expr
);
965 val
= evaluate_expression (expr
);
967 annotate_value_begin (value_type (val
));
969 print_formatted (val
, format
, fmt
.size
, gdb_stdout
);
971 annotate_value_end ();
974 gdb_flush (gdb_stdout
);
976 do_cleanups (old_chain
);
980 set_command (char *exp
, int from_tty
)
982 struct expression
*expr
= parse_expression (exp
);
983 struct cleanup
*old_chain
=
984 make_cleanup (free_current_contents
, &expr
);
985 evaluate_expression (expr
);
986 do_cleanups (old_chain
);
990 sym_info (char *arg
, int from_tty
)
992 struct minimal_symbol
*msymbol
;
993 struct objfile
*objfile
;
994 struct obj_section
*osect
;
996 CORE_ADDR addr
, sect_addr
;
1001 error_no_arg (_("address"));
1003 addr
= parse_and_eval_address (arg
);
1004 ALL_OBJSECTIONS (objfile
, osect
)
1006 sect
= osect
->the_bfd_section
;
1007 sect_addr
= overlay_mapped_address (addr
, sect
);
1009 if (osect
->addr
<= sect_addr
&& sect_addr
< osect
->endaddr
&&
1010 (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr
, sect
)))
1013 offset
= sect_addr
- SYMBOL_VALUE_ADDRESS (msymbol
);
1015 printf_filtered ("%s + %u in ",
1016 SYMBOL_PRINT_NAME (msymbol
), offset
);
1018 printf_filtered ("%s in ",
1019 SYMBOL_PRINT_NAME (msymbol
));
1020 if (pc_in_unmapped_range (addr
, sect
))
1021 printf_filtered (_("load address range of "));
1022 if (section_is_overlay (sect
))
1023 printf_filtered (_("%s overlay "),
1024 section_is_mapped (sect
) ? "mapped" : "unmapped");
1025 printf_filtered (_("section %s"), sect
->name
);
1026 printf_filtered ("\n");
1030 printf_filtered (_("No symbol matches %s.\n"), arg
);
1034 address_info (char *exp
, int from_tty
)
1037 struct minimal_symbol
*msymbol
;
1041 CORE_ADDR load_addr
;
1042 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
1043 if exp is a field of `this'. */
1046 error (_("Argument required."));
1048 sym
= lookup_symbol (exp
, get_selected_block (0), VAR_DOMAIN
,
1049 &is_a_field_of_this
, (struct symtab
**) NULL
);
1052 if (is_a_field_of_this
)
1054 printf_filtered ("Symbol \"");
1055 fprintf_symbol_filtered (gdb_stdout
, exp
,
1056 current_language
->la_language
, DMGL_ANSI
);
1057 printf_filtered ("\" is a field of the local class variable ");
1058 if (current_language
->la_language
== language_objc
)
1059 printf_filtered ("`self'\n"); /* ObjC equivalent of "this" */
1061 printf_filtered ("`this'\n");
1065 msymbol
= lookup_minimal_symbol (exp
, NULL
, NULL
);
1067 if (msymbol
!= NULL
)
1069 load_addr
= SYMBOL_VALUE_ADDRESS (msymbol
);
1071 printf_filtered ("Symbol \"");
1072 fprintf_symbol_filtered (gdb_stdout
, exp
,
1073 current_language
->la_language
, DMGL_ANSI
);
1074 printf_filtered ("\" is at ");
1075 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1076 printf_filtered (" in a file compiled without debugging");
1077 section
= SYMBOL_BFD_SECTION (msymbol
);
1078 if (section_is_overlay (section
))
1080 load_addr
= overlay_unmapped_address (load_addr
, section
);
1081 printf_filtered (",\n -- loaded at ");
1082 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1083 printf_filtered (" in overlay section %s", section
->name
);
1085 printf_filtered (".\n");
1088 error (_("No symbol \"%s\" in current context."), exp
);
1092 printf_filtered ("Symbol \"");
1093 fprintf_symbol_filtered (gdb_stdout
, DEPRECATED_SYMBOL_NAME (sym
),
1094 current_language
->la_language
, DMGL_ANSI
);
1095 printf_filtered ("\" is ");
1096 val
= SYMBOL_VALUE (sym
);
1097 basereg
= SYMBOL_BASEREG (sym
);
1098 section
= SYMBOL_BFD_SECTION (sym
);
1100 switch (SYMBOL_CLASS (sym
))
1103 case LOC_CONST_BYTES
:
1104 printf_filtered ("constant");
1108 printf_filtered ("a label at address ");
1109 deprecated_print_address_numeric (load_addr
= SYMBOL_VALUE_ADDRESS (sym
),
1111 if (section_is_overlay (section
))
1113 load_addr
= overlay_unmapped_address (load_addr
, section
);
1114 printf_filtered (",\n -- loaded at ");
1115 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1116 printf_filtered (" in overlay section %s", section
->name
);
1121 case LOC_COMPUTED_ARG
:
1122 /* FIXME: cagney/2004-01-26: It should be possible to
1123 unconditionally call the SYMBOL_OPS method when available.
1124 Unfortunately DWARF 2 stores the frame-base (instead of the
1125 function) location in a function's symbol. Oops! For the
1126 moment enable this when/where applicable. */
1127 SYMBOL_OPS (sym
)->describe_location (sym
, gdb_stdout
);
1131 printf_filtered (_("a variable in register %s"), REGISTER_NAME (val
));
1135 printf_filtered (_("static storage at address "));
1136 deprecated_print_address_numeric (load_addr
= SYMBOL_VALUE_ADDRESS (sym
),
1138 if (section_is_overlay (section
))
1140 load_addr
= overlay_unmapped_address (load_addr
, section
);
1141 printf_filtered (_(",\n -- loaded at "));
1142 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1143 printf_filtered (_(" in overlay section %s"), section
->name
);
1148 printf_filtered (_("external global (indirect addressing), at address *("));
1149 deprecated_print_address_numeric (load_addr
= SYMBOL_VALUE_ADDRESS (sym
),
1151 printf_filtered (")");
1152 if (section_is_overlay (section
))
1154 load_addr
= overlay_unmapped_address (load_addr
, section
);
1155 printf_filtered (_(",\n -- loaded at "));
1156 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1157 printf_filtered (_(" in overlay section %s"), section
->name
);
1162 printf_filtered (_("an argument in register %s"), REGISTER_NAME (val
));
1165 case LOC_REGPARM_ADDR
:
1166 printf_filtered (_("address of an argument in register %s"), REGISTER_NAME (val
));
1170 printf_filtered (_("an argument at offset %ld"), val
);
1174 printf_filtered (_("an argument at frame offset %ld"), val
);
1178 printf_filtered (_("a local variable at frame offset %ld"), val
);
1182 printf_filtered (_("a reference argument at offset %ld"), val
);
1186 printf_filtered (_("a variable at offset %ld from register %s"),
1187 val
, REGISTER_NAME (basereg
));
1190 case LOC_BASEREG_ARG
:
1191 printf_filtered (_("an argument at offset %ld from register %s"),
1192 val
, REGISTER_NAME (basereg
));
1196 printf_filtered (_("a typedef"));
1200 printf_filtered (_("a function at address "));
1201 deprecated_print_address_numeric (load_addr
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)),
1203 if (section_is_overlay (section
))
1205 load_addr
= overlay_unmapped_address (load_addr
, section
);
1206 printf_filtered (_(",\n -- loaded at "));
1207 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1208 printf_filtered (_(" in overlay section %s"), section
->name
);
1212 case LOC_UNRESOLVED
:
1214 struct minimal_symbol
*msym
;
1216 msym
= lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym
), NULL
, NULL
);
1218 printf_filtered ("unresolved");
1221 section
= SYMBOL_BFD_SECTION (msym
);
1222 printf_filtered (_("static storage at address "));
1223 deprecated_print_address_numeric (load_addr
= SYMBOL_VALUE_ADDRESS (msym
),
1225 if (section_is_overlay (section
))
1227 load_addr
= overlay_unmapped_address (load_addr
, section
);
1228 printf_filtered (_(",\n -- loaded at "));
1229 deprecated_print_address_numeric (load_addr
, 1, gdb_stdout
);
1230 printf_filtered (_(" in overlay section %s"), section
->name
);
1236 case LOC_HP_THREAD_LOCAL_STATIC
:
1238 "a thread-local variable at offset %ld from the thread base register %s",
1239 val
, REGISTER_NAME (basereg
));
1242 case LOC_OPTIMIZED_OUT
:
1243 printf_filtered (_("optimized out"));
1247 printf_filtered (_("of unknown (botched) type"));
1250 printf_filtered (".\n");
1254 x_command (char *exp
, int from_tty
)
1256 struct expression
*expr
;
1257 struct format_data fmt
;
1258 struct cleanup
*old_chain
;
1261 fmt
.format
= last_format
;
1262 fmt
.size
= last_size
;
1265 if (exp
&& *exp
== '/')
1268 fmt
= decode_format (&exp
, last_format
, last_size
);
1271 /* If we have an expression, evaluate it and use it as the address. */
1273 if (exp
!= 0 && *exp
!= 0)
1275 expr
= parse_expression (exp
);
1276 /* Cause expression not to be there any more
1277 if this command is repeated with Newline.
1278 But don't clobber a user-defined command's definition. */
1281 old_chain
= make_cleanup (free_current_contents
, &expr
);
1282 val
= evaluate_expression (expr
);
1283 if (TYPE_CODE (value_type (val
)) == TYPE_CODE_REF
)
1284 val
= value_ind (val
);
1285 /* In rvalue contexts, such as this, functions are coerced into
1286 pointers to functions. This makes "x/i main" work. */
1287 if (/* last_format == 'i' && */
1288 TYPE_CODE (value_type (val
)) == TYPE_CODE_FUNC
1289 && VALUE_LVAL (val
) == lval_memory
)
1290 next_address
= VALUE_ADDRESS (val
);
1292 next_address
= value_as_address (val
);
1293 do_cleanups (old_chain
);
1296 do_examine (fmt
, next_address
);
1298 /* If the examine succeeds, we remember its size and format for next time. */
1299 last_size
= fmt
.size
;
1300 last_format
= fmt
.format
;
1302 /* Set a couple of internal variables if appropriate. */
1303 if (last_examine_value
)
1305 /* Make last address examined available to the user as $_. Use
1306 the correct pointer type. */
1307 struct type
*pointer_type
1308 = lookup_pointer_type (value_type (last_examine_value
));
1309 set_internalvar (lookup_internalvar ("_"),
1310 value_from_pointer (pointer_type
,
1311 last_examine_address
));
1313 /* Make contents of last address examined available to the user as $__. */
1314 /* If the last value has not been fetched from memory then don't
1315 fetch it now - instead mark it by voiding the $__ variable. */
1316 if (value_lazy (last_examine_value
))
1317 set_internalvar (lookup_internalvar ("__"),
1318 allocate_value (builtin_type_void
));
1320 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1325 /* Add an expression to the auto-display chain.
1326 Specify the expression. */
1329 display_command (char *exp
, int from_tty
)
1331 struct format_data fmt
;
1332 struct expression
*expr
;
1333 struct display
*new;
1337 /* NOTE: cagney/2003-02-13 The `tui_active' was previously
1339 if (tui_active
&& exp
!= NULL
&& *exp
== '$')
1340 display_it
= (tui_set_layout_for_display_command (exp
) == TUI_FAILURE
);
1354 fmt
= decode_format (&exp
, 0, 0);
1355 if (fmt
.size
&& fmt
.format
== 0)
1357 if (fmt
.format
== 'i' || fmt
.format
== 's')
1367 innermost_block
= 0;
1368 expr
= parse_expression (exp
);
1370 new = (struct display
*) xmalloc (sizeof (struct display
));
1373 new->block
= innermost_block
;
1374 new->next
= display_chain
;
1375 new->number
= ++display_number
;
1378 display_chain
= new;
1380 if (from_tty
&& target_has_execution
)
1381 do_one_display (new);
1388 free_display (struct display
*d
)
1394 /* Clear out the display_chain.
1395 Done when new symtabs are loaded, since this invalidates
1396 the types stored in many expressions. */
1399 clear_displays (void)
1403 while ((d
= display_chain
) != NULL
)
1406 display_chain
= d
->next
;
1411 /* Delete the auto-display number NUM. */
1414 delete_display (int num
)
1416 struct display
*d1
, *d
;
1419 error (_("No display number %d."), num
);
1421 if (display_chain
->number
== num
)
1424 display_chain
= d1
->next
;
1428 for (d
= display_chain
;; d
= d
->next
)
1431 error (_("No display number %d."), num
);
1432 if (d
->next
->number
== num
)
1442 /* Delete some values from the auto-display chain.
1443 Specify the element numbers. */
1446 undisplay_command (char *args
, int from_tty
)
1454 if (query ("Delete all auto-display expressions? "))
1463 while (*p1
>= '0' && *p1
<= '9')
1465 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1466 error (_("Arguments must be display numbers."));
1470 delete_display (num
);
1473 while (*p
== ' ' || *p
== '\t')
1479 /* Display a single auto-display.
1480 Do nothing if the display cannot be printed in the current context,
1481 or if the display is disabled. */
1484 do_one_display (struct display
*d
)
1486 int within_current_scope
;
1488 if (d
->enabled_p
== 0)
1492 within_current_scope
= contained_in (get_selected_block (0), d
->block
);
1494 within_current_scope
= 1;
1495 if (!within_current_scope
)
1498 current_display_number
= d
->number
;
1500 annotate_display_begin ();
1501 printf_filtered ("%d", d
->number
);
1502 annotate_display_number_end ();
1503 printf_filtered (": ");
1509 annotate_display_format ();
1511 printf_filtered ("x/");
1512 if (d
->format
.count
!= 1)
1513 printf_filtered ("%d", d
->format
.count
);
1514 printf_filtered ("%c", d
->format
.format
);
1515 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1516 printf_filtered ("%c", d
->format
.size
);
1517 printf_filtered (" ");
1519 annotate_display_expression ();
1521 print_expression (d
->exp
, gdb_stdout
);
1522 annotate_display_expression_end ();
1524 if (d
->format
.count
!= 1)
1525 printf_filtered ("\n");
1527 printf_filtered (" ");
1529 val
= evaluate_expression (d
->exp
);
1530 addr
= value_as_address (val
);
1531 if (d
->format
.format
== 'i')
1532 addr
= ADDR_BITS_REMOVE (addr
);
1534 annotate_display_value ();
1536 do_examine (d
->format
, addr
);
1540 annotate_display_format ();
1542 if (d
->format
.format
)
1543 printf_filtered ("/%c ", d
->format
.format
);
1545 annotate_display_expression ();
1547 print_expression (d
->exp
, gdb_stdout
);
1548 annotate_display_expression_end ();
1550 printf_filtered (" = ");
1552 annotate_display_expression ();
1554 print_formatted (evaluate_expression (d
->exp
),
1555 d
->format
.format
, d
->format
.size
, gdb_stdout
);
1556 printf_filtered ("\n");
1559 annotate_display_end ();
1561 gdb_flush (gdb_stdout
);
1562 current_display_number
= -1;
1565 /* Display all of the values on the auto-display chain which can be
1566 evaluated in the current scope. */
1573 for (d
= display_chain
; d
; d
= d
->next
)
1577 /* Delete the auto-display which we were in the process of displaying.
1578 This is done when there is an error or a signal. */
1581 disable_display (int num
)
1585 for (d
= display_chain
; d
; d
= d
->next
)
1586 if (d
->number
== num
)
1591 printf_unfiltered (_("No display number %d.\n"), num
);
1595 disable_current_display (void)
1597 if (current_display_number
>= 0)
1599 disable_display (current_display_number
);
1600 fprintf_unfiltered (gdb_stderr
, "Disabling display %d to avoid infinite recursion.\n",
1601 current_display_number
);
1603 current_display_number
= -1;
1607 display_info (char *ignore
, int from_tty
)
1612 printf_unfiltered (_("There are no auto-display expressions now.\n"));
1614 printf_filtered (_("Auto-display expressions now in effect:\n\
1615 Num Enb Expression\n"));
1617 for (d
= display_chain
; d
; d
= d
->next
)
1619 printf_filtered ("%d: %c ", d
->number
, "ny"[(int) d
->enabled_p
]);
1621 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1623 else if (d
->format
.format
)
1624 printf_filtered ("/%c ", d
->format
.format
);
1625 print_expression (d
->exp
, gdb_stdout
);
1626 if (d
->block
&& !contained_in (get_selected_block (0), d
->block
))
1627 printf_filtered (_(" (cannot be evaluated in the current context)"));
1628 printf_filtered ("\n");
1629 gdb_flush (gdb_stdout
);
1634 enable_display (char *args
, int from_tty
)
1643 for (d
= display_chain
; d
; d
= d
->next
)
1650 while (*p1
>= '0' && *p1
<= '9')
1652 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1653 error (_("Arguments must be display numbers."));
1657 for (d
= display_chain
; d
; d
= d
->next
)
1658 if (d
->number
== num
)
1663 printf_unfiltered (_("No display number %d.\n"), num
);
1666 while (*p
== ' ' || *p
== '\t')
1672 disable_display_command (char *args
, int from_tty
)
1680 for (d
= display_chain
; d
; d
= d
->next
)
1687 while (*p1
>= '0' && *p1
<= '9')
1689 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1690 error (_("Arguments must be display numbers."));
1692 disable_display (atoi (p
));
1695 while (*p
== ' ' || *p
== '\t')
1701 /* Print the value in stack frame FRAME of a variable
1702 specified by a struct symbol. */
1705 print_variable_value (struct symbol
*var
, struct frame_info
*frame
,
1706 struct ui_file
*stream
)
1708 struct value
*val
= read_var_value (var
, frame
);
1710 value_print (val
, stream
, 0, Val_pretty_default
);
1714 printf_command (char *arg
, int from_tty
)
1718 char *string
= NULL
;
1719 struct value
**val_args
;
1721 char *current_substring
;
1723 int allocated_args
= 20;
1724 struct cleanup
*old_cleanups
;
1726 val_args
= (struct value
**) xmalloc (allocated_args
1727 * sizeof (struct value
*));
1728 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1731 error_no_arg (_("format-control string and values to print"));
1733 /* Skip white space before format string */
1734 while (*s
== ' ' || *s
== '\t')
1737 /* A format string should follow, enveloped in double quotes */
1739 error (_("Bad format string, missing '\"'."));
1741 /* Parse the format-control string and copy it into the string STRING,
1742 processing some kinds of escape sequence. */
1744 f
= string
= (char *) alloca (strlen (s
) + 1);
1752 error (_("Bad format string, non-terminated '\"'."));
1785 /* ??? TODO: handle other escape sequences */
1786 error (_("Unrecognized escape character \\%c in format string."),
1796 /* Skip over " and following space and comma. */
1799 while (*s
== ' ' || *s
== '\t')
1802 if (*s
!= ',' && *s
!= 0)
1803 error (_("Invalid argument syntax"));
1807 while (*s
== ' ' || *s
== '\t')
1810 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1811 substrings
= alloca (strlen (string
) * 2);
1812 current_substring
= substrings
;
1815 /* Now scan the string for %-specs and see what kinds of args they want.
1816 argclass[I] classifies the %-specs so we can give printf_filtered
1817 something of the right size. */
1821 no_arg
, int_arg
, string_arg
, double_arg
, long_long_arg
1823 enum argclass
*argclass
;
1824 enum argclass this_argclass
;
1830 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1838 while (strchr ("0123456789.hlL-+ #", *f
))
1840 if (*f
== 'l' || *f
== 'L')
1847 this_argclass
= string_arg
;
1853 this_argclass
= double_arg
;
1857 error (_("`*' not supported for precision or width in printf"));
1860 error (_("Format specifier `n' not supported in printf"));
1863 this_argclass
= no_arg
;
1868 this_argclass
= long_long_arg
;
1870 this_argclass
= int_arg
;
1874 if (this_argclass
!= no_arg
)
1876 strncpy (current_substring
, last_arg
, f
- last_arg
);
1877 current_substring
+= f
- last_arg
;
1878 *current_substring
++ = '\0';
1880 argclass
[nargs_wanted
++] = this_argclass
;
1884 /* Now, parse all arguments and evaluate them.
1885 Store the VALUEs in VAL_ARGS. */
1890 if (nargs
== allocated_args
)
1891 val_args
= (struct value
**) xrealloc ((char *) val_args
,
1892 (allocated_args
*= 2)
1893 * sizeof (struct value
*));
1895 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1897 /* If format string wants a float, unchecked-convert the value to
1898 floating point of the same size */
1900 if (argclass
[nargs
] == double_arg
)
1902 struct type
*type
= value_type (val_args
[nargs
]);
1903 if (TYPE_LENGTH (type
) == sizeof (float))
1904 deprecated_set_value_type (val_args
[nargs
], builtin_type_float
);
1905 if (TYPE_LENGTH (type
) == sizeof (double))
1906 deprecated_set_value_type (val_args
[nargs
], builtin_type_double
);
1914 if (nargs
!= nargs_wanted
)
1915 error (_("Wrong number of arguments for specified format-string"));
1917 /* Now actually print them. */
1918 current_substring
= substrings
;
1919 for (i
= 0; i
< nargs
; i
++)
1921 switch (argclass
[i
])
1928 tem
= value_as_address (val_args
[i
]);
1930 /* This is a %s argument. Find the length of the string. */
1935 read_memory (tem
+ j
, &c
, 1);
1940 /* Copy the string contents into a string inside GDB. */
1941 str
= (char *) alloca (j
+ 1);
1943 read_memory (tem
, str
, j
);
1946 printf_filtered (current_substring
, str
);
1951 double val
= value_as_double (val_args
[i
]);
1952 printf_filtered (current_substring
, val
);
1956 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1958 long long val
= value_as_long (val_args
[i
]);
1959 printf_filtered (current_substring
, val
);
1963 error (_("long long not supported in printf"));
1967 /* FIXME: there should be separate int_arg and long_arg. */
1968 long val
= value_as_long (val_args
[i
]);
1969 printf_filtered (current_substring
, val
);
1972 default: /* purecov: deadcode */
1973 error (_("internal error in printf_command")); /* purecov: deadcode */
1975 /* Skip to the next substring. */
1976 current_substring
+= strlen (current_substring
) + 1;
1978 /* Print the portion of the format string after the last argument. */
1979 puts_filtered (last_arg
);
1981 do_cleanups (old_cleanups
);
1985 _initialize_printcmd (void)
1987 struct cmd_list_element
*c
;
1989 current_display_number
= -1;
1991 add_info ("address", address_info
,
1992 "Describe where symbol SYM is stored.");
1994 add_info ("symbol", sym_info
,
1995 "Describe what symbol is at location ADDR.\n\
1996 Only for symbols with fixed locations (global or static scope).");
1998 add_com ("x", class_vars
, x_command
,
1999 concat ("Examine memory: x/FMT ADDRESS.\n\
2000 ADDRESS is an expression for the memory address to examine.\n\
2001 FMT is a repeat count followed by a format letter and a size letter.\n\
2002 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2003 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n",
2004 "Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2005 The specified number of objects of the specified size are printed\n\
2006 according to the format.\n\n\
2007 Defaults for format and size letters are those previously used.\n\
2008 Default count is 1. Default address is following last thing printed\n\
2009 with this command or \"print\".", NULL
));
2012 add_com ("whereis", class_vars
, whereis_command
,
2013 "Print line number and file of definition of variable.");
2016 add_info ("display", display_info
,
2017 "Expressions to display when program stops, with code numbers.");
2019 add_cmd ("undisplay", class_vars
, undisplay_command
,
2020 "Cancel some expressions to be displayed when program stops.\n\
2021 Arguments are the code numbers of the expressions to stop displaying.\n\
2022 No argument means cancel all automatic-display expressions.\n\
2023 \"delete display\" has the same effect as this command.\n\
2024 Do \"info display\" to see current list of code numbers.",
2027 add_com ("display", class_vars
, display_command
,
2028 "Print value of expression EXP each time the program stops.\n\
2029 /FMT may be used before EXP as in the \"print\" command.\n\
2030 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2031 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2032 and examining is done as in the \"x\" command.\n\n\
2033 With no argument, display all currently requested auto-display expressions.\n\
2034 Use \"undisplay\" to cancel display requests previously made."
2037 add_cmd ("display", class_vars
, enable_display
,
2038 "Enable some expressions to be displayed when program stops.\n\
2039 Arguments are the code numbers of the expressions to resume displaying.\n\
2040 No argument means enable all automatic-display expressions.\n\
2041 Do \"info display\" to see current list of code numbers.", &enablelist
);
2043 add_cmd ("display", class_vars
, disable_display_command
,
2044 "Disable some expressions to be displayed when program stops.\n\
2045 Arguments are the code numbers of the expressions to stop displaying.\n\
2046 No argument means disable all automatic-display expressions.\n\
2047 Do \"info display\" to see current list of code numbers.", &disablelist
);
2049 add_cmd ("display", class_vars
, undisplay_command
,
2050 "Cancel some expressions to be displayed when program stops.\n\
2051 Arguments are the code numbers of the expressions to stop displaying.\n\
2052 No argument means cancel all automatic-display expressions.\n\
2053 Do \"info display\" to see current list of code numbers.", &deletelist
);
2055 add_com ("printf", class_vars
, printf_command
,
2056 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2057 This is useful for formatted output in user-defined commands.");
2059 add_com ("output", class_vars
, output_command
,
2060 "Like \"print\" but don't put in value history and don't print newline.\n\
2061 This is useful in user-defined commands.");
2063 add_prefix_cmd ("set", class_vars
, set_command
,
2064 concat ("Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2065 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2066 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2067 with $), a register (a few standard names starting with $), or an actual\n\
2068 variable in the program being debugged. EXP is any valid expression.\n",
2069 "Use \"set variable\" for variables with names identical to set subcommands.\n\
2070 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2071 You can see these environment settings with the \"show\" command.", NULL
),
2072 &setlist
, "set ", 1, &cmdlist
);
2074 add_com ("assign", class_vars
, set_command
, concat ("Evaluate expression \
2075 EXP and assign result to variable VAR, using assignment\n\
2076 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2077 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2078 with $), a register (a few standard names starting with $), or an actual\n\
2079 variable in the program being debugged. EXP is any valid expression.\n",
2080 "Use \"set variable\" for variables with names identical to set subcommands.\n\
2081 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2082 You can see these environment settings with the \"show\" command.", NULL
));
2084 /* "call" is the same as "set", but handy for dbx users to call fns. */
2085 c
= add_com ("call", class_vars
, call_command
,
2086 "Call a function in the program.\n\
2087 The argument is the function name and arguments, in the notation of the\n\
2088 current working language. The result is printed and saved in the value\n\
2089 history, if it is not void.");
2090 set_cmd_completer (c
, location_completer
);
2092 add_cmd ("variable", class_vars
, set_command
,
2093 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2094 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2095 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2096 with $), a register (a few standard names starting with $), or an actual\n\
2097 variable in the program being debugged. EXP is any valid expression.\n\
2098 This may usually be abbreviated to simply \"set\".",
2101 c
= add_com ("print", class_vars
, print_command
,
2102 concat ("Print value of expression EXP.\n\
2103 Variables accessible are those of the lexical environment of the selected\n\
2104 stack frame, plus all those whose scope is global or an entire file.\n\
2106 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2107 $$NUM refers to NUM'th value back from the last one.\n\
2108 Names starting with $ refer to registers (with the values they would have\n",
2109 "if the program were to return to the stack frame now selected, restoring\n\
2110 all registers saved by frames farther in) or else to debugger\n\
2111 \"convenience\" variables (any such name not a known register).\n\
2112 Use assignment expressions to give values to convenience variables.\n",
2114 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2115 @ is a binary operator for treating consecutive data objects\n\
2116 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2117 element is FOO, whose second element is stored in the space following\n\
2118 where FOO is stored, etc. FOO must be an expression whose value\n\
2119 resides in memory.\n",
2121 EXP may be preceded with /FMT, where FMT is a format letter\n\
2122 but no count or size letter (see \"x\" command).", NULL
));
2123 set_cmd_completer (c
, location_completer
);
2124 add_com_alias ("p", "print", class_vars
, 1);
2126 c
= add_com ("inspect", class_vars
, inspect_command
,
2127 "Same as \"print\" command, except that if you are running in the epoch\n\
2128 environment, the value is printed in its own window.");
2129 set_cmd_completer (c
, location_completer
);
2131 deprecated_add_show_from_set
2132 (add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2133 (char *) &max_symbolic_offset
,
2134 "Set the largest offset that will be printed in <symbol+1234> form.",
2137 deprecated_add_show_from_set
2138 (add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2139 (char *) &print_symbol_filename
, "\
2140 Set printing of source filename and line number with <symbol>.",
2144 /* For examine/instruction a single byte quantity is specified as
2145 the data. This avoids problems with value_at_lazy() requiring a
2146 valid data type (and rejecting VOID). */
2147 examine_i_type
= init_type (TYPE_CODE_INT
, 1, 0, "examine_i_type", NULL
);
2149 examine_b_type
= init_type (TYPE_CODE_INT
, 1, 0, "examine_b_type", NULL
);
2150 examine_h_type
= init_type (TYPE_CODE_INT
, 2, 0, "examine_h_type", NULL
);
2151 examine_w_type
= init_type (TYPE_CODE_INT
, 4, 0, "examine_w_type", NULL
);
2152 examine_g_type
= init_type (TYPE_CODE_INT
, 8, 0, "examine_g_type", NULL
);