1 /* Print values for GNU debugger GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
29 #include "expression.h"
33 #include "breakpoint.h"
37 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
38 extern int addressprint
; /* Whether to print hex addresses in HLL " */
47 /* Last specified output format. */
49 static char last_format
= 'x';
51 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
53 static char last_size
= 'w';
55 /* Default address to examine next. */
57 static CORE_ADDR next_address
;
59 /* Last address examined. */
61 static CORE_ADDR last_examine_address
;
63 /* Contents of last address examined.
64 This is not valid past the end of the `x' command! */
66 static value last_examine_value
;
68 /* Largest offset between a symbolic value and an address, that will be
69 printed as `0x1234 <symbol+offset>'. */
71 static unsigned int max_symbolic_offset
= UINT_MAX
;
73 /* Append the source filename and linenumber of the symbol when
74 printing a symbolic value as `<symbol at filename:linenum>' if set. */
75 static int print_symbol_filename
= 0;
77 /* Switch for quick display of symbolic addresses -- only uses minsyms,
78 not full search of symtabs. */
80 int fast_symbolic_addr
= 1;
82 /* Number of auto-display expression currently being displayed.
83 So that we can disable it if we get an error or a signal within it.
84 -1 when not doing one. */
86 int current_display_number
;
88 /* Flag to low-level print routines that this value is being printed
89 in an epoch window. We'd like to pass this as a parameter, but
90 every routine would need to take it. Perhaps we can encapsulate
91 this in the I/O stream once we have GNU stdio. */
97 /* Chain link to next auto-display item. */
99 /* Expression to be evaluated and displayed. */
100 struct expression
*exp
;
101 /* Item number of this auto-display item. */
103 /* Display format specified. */
104 struct format_data format
;
105 /* Innermost block required by this expression when evaluated */
107 /* Status of this display (enabled or disabled) */
111 /* Chain of expressions whose values should be displayed
112 automatically each time the program stops. */
114 static struct display
*display_chain
;
116 static int display_number
;
118 /* Prototypes for local functions */
121 delete_display
PARAMS ((int));
124 enable_display
PARAMS ((char *, int));
127 disable_display_command
PARAMS ((char *, int));
130 disassemble_command
PARAMS ((char *, int));
133 printf_command
PARAMS ((char *, int));
136 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
140 display_info
PARAMS ((char *, int));
143 do_one_display
PARAMS ((struct display
*));
146 undisplay_command
PARAMS ((char *, int));
149 free_display
PARAMS ((struct display
*));
152 display_command
PARAMS ((char *, int));
155 x_command
PARAMS ((char *, int));
158 address_info
PARAMS ((char *, int));
161 set_command
PARAMS ((char *, int));
164 output_command
PARAMS ((char *, int));
167 call_command
PARAMS ((char *, int));
170 inspect_command
PARAMS ((char *, int));
173 print_command
PARAMS ((char *, int));
176 print_command_1
PARAMS ((char *, int, int));
179 validate_format
PARAMS ((struct format_data
, char *));
182 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
185 print_formatted
PARAMS ((value
, int, int));
187 static struct format_data
188 decode_format
PARAMS ((char **, int, int));
191 /* Decode a format specification. *STRING_PTR should point to it.
192 OFORMAT and OSIZE are used as defaults for the format and size
193 if none are given in the format specification.
194 If OSIZE is zero, then the size field of the returned value
195 should be set only if a size is explicitly specified by the
197 The structure returned describes all the data
198 found in the specification. In addition, *STRING_PTR is advanced
199 past the specification and past all whitespace following it. */
201 static struct format_data
202 decode_format (string_ptr
, oformat
, osize
)
207 struct format_data val
;
208 register char *p
= *string_ptr
;
214 if (*p
>= '0' && *p
<= '9')
215 val
.count
= atoi (p
);
216 while (*p
>= '0' && *p
<= '9') p
++;
218 /* Now process size or format letters that follow. */
222 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
224 else if (*p
>= 'a' && *p
<= 'z')
230 #ifndef CC_HAS_LONG_LONG
231 /* Make sure 'g' size is not used on integer types.
232 Well, actually, we can handle hex. */
233 if (val
.size
== 'g' && val
.format
!= 'f' && val
.format
!= 'x')
237 while (*p
== ' ' || *p
== '\t') p
++;
240 /* Set defaults for format and size if not specified. */
241 if (val
.format
== '?')
245 /* Neither has been specified. */
246 val
.format
= oformat
;
250 /* If a size is specified, any format makes a reasonable
251 default except 'i'. */
252 val
.format
= oformat
== 'i' ? 'x' : oformat
;
254 else if (val
.size
== '?')
259 /* Addresses must be words. */
260 val
.size
= osize
? 'w' : osize
;
263 /* Floating point has to be word or giantword. */
264 if (osize
== 'w' || osize
== 'g')
267 /* Default it to giantword if the last used size is not
269 val
.size
= osize
? 'g' : osize
;
272 /* Characters default to one byte. */
273 val
.size
= osize
? 'b' : osize
;
276 /* The default is the size most recently specified. */
283 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
284 Do not end with a newline.
285 0 means print VAL according to its own type.
286 SIZE is the letter for the size of datum being printed.
287 This is used to pad hex numbers so they line up. */
290 print_formatted (val
, format
, size
)
295 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
297 if (VALUE_LVAL (val
) == lval_memory
)
298 next_address
= VALUE_ADDRESS (val
) + len
;
303 next_address
= VALUE_ADDRESS (val
)
304 + value_print (value_addr (val
), gdb_stdout
, format
, Val_pretty_default
);
308 /* The old comment says
309 "Force output out, print_insn not using _filtered".
310 I'm not completely sure what that means, I suspect most print_insn
311 now do use _filtered, so I guess it's obsolete. */
312 /* We often wrap here if there are long symbolic names. */
314 next_address
= VALUE_ADDRESS (val
)
315 + print_insn (VALUE_ADDRESS (val
), gdb_stdout
);
320 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
321 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
322 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
323 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
324 || VALUE_REPEATED (val
))
325 value_print (val
, gdb_stdout
, format
, Val_pretty_default
);
327 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
328 format
, size
, gdb_stdout
);
332 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
333 according to letters FORMAT and SIZE on STREAM.
334 FORMAT may not be zero. Formats s and i are not supported at this level.
336 This is how the elements of an array or structure are printed
340 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
348 int len
= TYPE_LENGTH (type
);
350 if (len
> sizeof (LONGEST
)
358 /* We can't print it normally, but we can print it in hex.
359 Printing it in the wrong radix is more useful than saying
360 "use /x, you dummy". */
361 /* FIXME: we could also do octal or binary if that was the
363 /* FIXME: we should be using the size field to give us a minimum
364 field width to print. */
365 val_print_type_code_int (type
, valaddr
, stream
);
369 val_long
= unpack_long (type
, valaddr
);
371 /* If we are printing it as unsigned, truncate it in case it is actually
372 a negative signed value (e.g. "print/u (short)-1" should print 65535
373 (if shorts are 16 bits) instead of 4294967295). */
376 if (len
< sizeof (LONGEST
))
377 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
385 /* no size specified, like in print. Print varying # of digits. */
386 print_longest (stream
, 'x', 1, val_long
);
395 print_longest (stream
, size
, 1, val_long
);
398 error ("Undefined output size \"%c\".", size
);
403 print_longest (stream
, 'd', 1, val_long
);
407 print_longest (stream
, 'u', 0, val_long
);
412 print_longest (stream
, 'o', 1, val_long
);
414 fprintf_filtered (stream
, "0");
418 print_address (unpack_pointer (type
, valaddr
), stream
);
422 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
427 if (len
== sizeof (float))
428 type
= builtin_type_float
;
429 else if (len
== sizeof (double))
430 type
= builtin_type_double
;
431 print_floating (valaddr
, type
, stream
);
438 /* Binary; 't' stands for "two". */
440 char bits
[8*(sizeof val_long
) + 1];
445 width
= 8*(sizeof val_long
);
462 error ("Undefined output size \"%c\".", size
);
468 bits
[width
] = (val_long
& 1) ? '1' : '0';
473 while (*cp
&& *cp
== '0')
478 fprintf_filtered (stream
, local_binary_format_prefix());
479 fprintf_filtered (stream
, cp
);
480 fprintf_filtered (stream
, local_binary_format_suffix());
485 error ("Undefined output format \"%c\".", format
);
489 /* Specify default address for `x' command.
490 `info lines' uses this. */
493 set_next_address (addr
)
498 /* Make address available to the user as $_. */
499 set_internalvar (lookup_internalvar ("_"),
500 value_from_longest (lookup_pointer_type (builtin_type_void
),
504 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
505 after LEADIN. Print nothing if no symbolic name is found nearby.
506 Optionally also print source file and line number, if available.
507 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
508 or to interpret it as a possible C++ name and convert it back to source
509 form. However note that DO_DEMANGLE can be overridden by the specific
510 settings of the demangle and asm_demangle variables. */
513 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
519 struct minimal_symbol
*msymbol
;
520 struct symbol
*symbol
;
521 struct symtab
*symtab
= 0;
522 CORE_ADDR name_location
;
525 /* First try to find the address in the symbol table, then
526 in the minsyms. Take the closest one. */
528 symbol
= fast_symbolic_addr
? 0:
529 find_addr_symbol (addr
, &symtab
, &name_location
);
533 name
= SYMBOL_SOURCE_NAME (symbol
);
535 name
= SYMBOL_LINKAGE_NAME (symbol
);
538 msymbol
= lookup_minimal_symbol_by_pc (addr
);
541 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
)
543 /* The msymbol is closer to the address than the symbol;
544 use the msymbol instead. */
547 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
549 name
= SYMBOL_SOURCE_NAME (msymbol
);
551 name
= SYMBOL_LINKAGE_NAME (msymbol
);
555 /* If the nearest symbol is too far away, don't print anything symbolic. */
557 /* For when CORE_ADDR is larger than unsigned int, we do math in
558 CORE_ADDR. But when we detect unsigned wraparound in the
559 CORE_ADDR math, we ignore this test and print the offset,
560 because addr+max_symbolic_offset has wrapped through the end
561 of the address space back to the beginning, giving bogus comparison. */
562 if (addr
> name_location
+ max_symbolic_offset
563 && name_location
+ max_symbolic_offset
> name_location
)
566 fputs_filtered (leadin
, stream
);
567 fputs_filtered ("<", stream
);
568 fputs_filtered (name
, stream
);
569 if (addr
!= name_location
)
570 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
572 /* Append source filename and line number if desired. Give specific
573 line # of this addr, if we have it; else line # of the nearest symbol. */
574 if (print_symbol_filename
)
576 struct symtab_and_line sal
;
578 sal
= find_pc_line (addr
, 0);
580 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
581 else if (symtab
&& symbol
&& symbol
->line
)
582 fprintf_filtered (stream
, " at %s:%d", symtab
->filename
, symbol
->line
);
584 fprintf_filtered (stream
, " in %s", symtab
->filename
);
586 fputs_filtered (">", stream
);
590 /* Print address ADDR symbolically on STREAM.
591 First print it as a number. Then perhaps print
592 <SYMBOL + OFFSET> after the number. */
595 print_address (addr
, stream
)
599 #if 0 && defined (ADDR_BITS_REMOVE)
600 /* This is wrong for pointer to char, in which we do want to print
602 fprintf_filtered (stream
, local_hex_format(),
603 (unsigned long) ADDR_BITS_REMOVE(addr
));
605 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
607 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
610 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
611 controls whether to print the symbolic name "raw" or demangled.
612 Global setting "addressprint" controls whether to print hex address
616 print_address_demangle (addr
, stream
, do_demangle
)
622 fprintf_filtered (stream
, "0");
623 } else if (addressprint
) {
624 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
625 print_address_symbolic (addr
, stream
, do_demangle
, " ");
627 print_address_symbolic (addr
, stream
, do_demangle
, "");
632 /* These are the types that $__ will get after an examine command of one
635 static struct type
*examine_b_type
;
636 static struct type
*examine_h_type
;
637 static struct type
*examine_w_type
;
638 static struct type
*examine_g_type
;
640 /* Examine data at address ADDR in format FMT.
641 Fetch it from memory and print on gdb_stdout. */
644 do_examine (fmt
, addr
)
645 struct format_data fmt
;
648 register char format
= 0;
650 register int count
= 1;
651 struct type
*val_type
= NULL
;
653 register int maxelts
;
660 /* String or instruction format implies fetch single bytes
661 regardless of the specified size. */
662 if (format
== 's' || format
== 'i')
666 val_type
= examine_b_type
;
667 else if (size
== 'h')
668 val_type
= examine_h_type
;
669 else if (size
== 'w')
670 val_type
= examine_w_type
;
671 else if (size
== 'g')
672 val_type
= examine_g_type
;
679 if (format
== 's' || format
== 'i')
682 /* Print as many objects as specified in COUNT, at most maxelts per line,
683 with the address of the next one at the start of each line. */
687 print_address (next_address
, gdb_stdout
);
688 printf_filtered (":");
693 printf_filtered ("\t");
694 /* Note that print_formatted sets next_address for the next
696 last_examine_address
= next_address
;
697 last_examine_value
= value_at (val_type
, next_address
);
698 print_formatted (last_examine_value
, format
, size
);
700 printf_filtered ("\n");
701 gdb_flush (gdb_stdout
);
706 validate_format (fmt
, cmdname
)
707 struct format_data fmt
;
711 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
713 error ("Item count other than 1 is meaningless in \"%s\" command.",
715 if (fmt
.format
== 'i' || fmt
.format
== 's')
716 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
717 fmt
.format
, cmdname
);
720 /* Evaluate string EXP as an expression in the current language and
721 print the resulting value. EXP may contain a format specifier as the
722 first argument ("/x myvar" for example, to print myvar in hex).
726 print_command_1 (exp
, inspect
, voidprint
)
731 struct expression
*expr
;
732 register struct cleanup
*old_chain
= 0;
733 register char format
= 0;
735 struct format_data fmt
;
738 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
739 inspect_it
= inspect
;
741 if (exp
&& *exp
== '/')
744 fmt
= decode_format (&exp
, last_format
, 0);
745 validate_format (fmt
, "print");
746 last_format
= format
= fmt
.format
;
757 extern int objectprint
;
759 expr
= parse_expression (exp
);
760 old_chain
= make_cleanup (free_current_contents
, &expr
);
762 val
= evaluate_expression (expr
);
764 /* C++: figure out what type we actually want to print it as. */
765 type
= VALUE_TYPE (val
);
768 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
769 || TYPE_CODE (type
) == TYPE_CODE_REF
)
770 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
771 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
775 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
779 type
= VALUE_TYPE (val
);
784 val
= access_value_history (0);
786 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
787 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
789 int histindex
= record_latest_value (val
);
792 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
794 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
796 print_formatted (val
, format
, fmt
.size
);
797 printf_filtered ("\n");
799 printf_unfiltered("\") )\030");
803 do_cleanups (old_chain
);
804 inspect_it
= 0; /* Reset print routines to normal */
809 print_command (exp
, from_tty
)
813 print_command_1 (exp
, 0, 1);
816 /* Same as print, except in epoch, it gets its own window */
819 inspect_command (exp
, from_tty
)
823 extern int epoch_interface
;
825 print_command_1 (exp
, epoch_interface
, 1);
828 /* Same as print, except it doesn't print void results. */
831 call_command (exp
, from_tty
)
835 print_command_1 (exp
, 0, 0);
840 output_command (exp
, from_tty
)
844 struct expression
*expr
;
845 register struct cleanup
*old_chain
;
846 register char format
= 0;
848 struct format_data fmt
;
850 if (exp
&& *exp
== '/')
853 fmt
= decode_format (&exp
, 0, 0);
854 validate_format (fmt
, "output");
858 expr
= parse_expression (exp
);
859 old_chain
= make_cleanup (free_current_contents
, &expr
);
861 val
= evaluate_expression (expr
);
863 print_formatted (val
, format
, fmt
.size
);
865 do_cleanups (old_chain
);
870 set_command (exp
, from_tty
)
874 struct expression
*expr
= parse_expression (exp
);
875 register struct cleanup
*old_chain
876 = make_cleanup (free_current_contents
, &expr
);
877 evaluate_expression (expr
);
878 do_cleanups (old_chain
);
883 address_info (exp
, from_tty
)
887 register struct symbol
*sym
;
888 register struct minimal_symbol
*msymbol
;
890 register long basereg
;
891 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
892 if exp is a field of `this'. */
895 error ("Argument required.");
897 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
898 &is_a_field_of_this
, (struct symtab
**)NULL
);
901 if (is_a_field_of_this
)
903 printf_filtered ("Symbol \"");
904 fprintf_symbol_filtered (gdb_stdout
, exp
,
905 current_language
->la_language
, DMGL_ANSI
);
906 printf_filtered ("\" is a field of the local class variable `this'\n");
910 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
914 printf_filtered ("Symbol \"");
915 fprintf_symbol_filtered (gdb_stdout
, exp
,
916 current_language
->la_language
, DMGL_ANSI
);
917 printf_filtered ("\" is at %s in a file compiled without debugging.\n",
918 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (msymbol
)));
921 error ("No symbol \"%s\" in current context.", exp
);
925 printf_filtered ("Symbol \"");
926 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_NAME (sym
),
927 current_language
->la_language
, DMGL_ANSI
);
928 printf_filtered ("\" is ", SYMBOL_NAME (sym
));
929 val
= SYMBOL_VALUE (sym
);
930 basereg
= SYMBOL_BASEREG (sym
);
932 switch (SYMBOL_CLASS (sym
))
935 case LOC_CONST_BYTES
:
936 printf_filtered ("constant");
940 printf_filtered ("a label at address %s",
941 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
945 printf_filtered ("a variable in register %s", reg_names
[val
]);
949 printf_filtered ("static storage at address %s",
950 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
954 printf_filtered ("an argument in register %s", reg_names
[val
]);
957 case LOC_REGPARM_ADDR
:
958 printf_filtered ("address of an argument in register %s", reg_names
[val
]);
962 printf_filtered ("an argument at offset %ld", val
);
966 printf_filtered ("an argument at frame offset %ld", val
);
970 printf_filtered ("a local variable at frame offset %ld", val
);
974 printf_filtered ("a reference argument at offset %ld", val
);
978 printf_filtered ("a variable at offset %ld from register %s",
979 val
, reg_names
[basereg
]);
982 case LOC_BASEREG_ARG
:
983 printf_filtered ("an argument at offset %ld from register %s",
984 val
, reg_names
[basereg
]);
988 printf_filtered ("a typedef");
992 printf_filtered ("a function at address %s",
993 local_hex_string((unsigned long) BLOCK_START (SYMBOL_BLOCK_VALUE (sym
))));
996 case LOC_OPTIMIZED_OUT
:
997 printf_filtered ("optimized out");
1001 printf_filtered ("of unknown (botched) type");
1004 printf_filtered (".\n");
1008 x_command (exp
, from_tty
)
1012 struct expression
*expr
;
1013 struct format_data fmt
;
1014 struct cleanup
*old_chain
;
1017 fmt
.format
= last_format
;
1018 fmt
.size
= last_size
;
1021 if (exp
&& *exp
== '/')
1024 fmt
= decode_format (&exp
, last_format
, last_size
);
1027 /* If we have an expression, evaluate it and use it as the address. */
1029 if (exp
!= 0 && *exp
!= 0)
1031 expr
= parse_expression (exp
);
1032 /* Cause expression not to be there any more
1033 if this command is repeated with Newline.
1034 But don't clobber a user-defined command's definition. */
1037 old_chain
= make_cleanup (free_current_contents
, &expr
);
1038 val
= evaluate_expression (expr
);
1039 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1040 val
= value_ind (val
);
1041 /* In rvalue contexts, such as this, functions are coerced into
1042 pointers to functions. This makes "x/i main" work. */
1043 if (/* last_format == 'i'
1044 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1045 && VALUE_LVAL (val
) == lval_memory
)
1046 next_address
= VALUE_ADDRESS (val
);
1048 next_address
= value_as_pointer (val
);
1049 do_cleanups (old_chain
);
1052 do_examine (fmt
, next_address
);
1054 /* If the examine succeeds, we remember its size and format for next time. */
1055 last_size
= fmt
.size
;
1056 last_format
= fmt
.format
;
1058 /* Set a couple of internal variables if appropriate. */
1059 if (last_examine_value
)
1061 /* Make last address examined available to the user as $_. Use
1062 the correct pointer type. */
1063 set_internalvar (lookup_internalvar ("_"),
1064 value_from_longest (
1065 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1066 (LONGEST
) last_examine_address
));
1068 /* Make contents of last address examined available to the user as $__.*/
1069 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1074 /* Add an expression to the auto-display chain.
1075 Specify the expression. */
1078 display_command (exp
, from_tty
)
1082 struct format_data fmt
;
1083 register struct expression
*expr
;
1084 register struct display
*new;
1095 fmt
= decode_format (&exp
, 0, 0);
1096 if (fmt
.size
&& fmt
.format
== 0)
1098 if (fmt
.format
== 'i' || fmt
.format
== 's')
1108 innermost_block
= 0;
1109 expr
= parse_expression (exp
);
1111 new = (struct display
*) xmalloc (sizeof (struct display
));
1114 new->block
= innermost_block
;
1115 new->next
= display_chain
;
1116 new->number
= ++display_number
;
1118 new->status
= enabled
;
1119 display_chain
= new;
1121 if (from_tty
&& target_has_execution
)
1122 do_one_display (new);
1135 /* Clear out the display_chain.
1136 Done when new symtabs are loaded, since this invalidates
1137 the types stored in many expressions. */
1142 register struct display
*d
;
1144 while ((d
= display_chain
) != NULL
)
1147 display_chain
= d
->next
;
1152 /* Delete the auto-display number NUM. */
1155 delete_display (num
)
1158 register struct display
*d1
, *d
;
1161 error ("No display number %d.", num
);
1163 if (display_chain
->number
== num
)
1166 display_chain
= d1
->next
;
1170 for (d
= display_chain
; ; d
= d
->next
)
1173 error ("No display number %d.", num
);
1174 if (d
->next
->number
== num
)
1184 /* Delete some values from the auto-display chain.
1185 Specify the element numbers. */
1188 undisplay_command (args
, from_tty
)
1192 register char *p
= args
;
1198 if (query ("Delete all auto-display expressions? "))
1207 while (*p1
>= '0' && *p1
<= '9') p1
++;
1208 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1209 error ("Arguments must be display numbers.");
1213 delete_display (num
);
1216 while (*p
== ' ' || *p
== '\t') p
++;
1221 /* Display a single auto-display.
1222 Do nothing if the display cannot be printed in the current context,
1223 or if the display is disabled. */
1229 int within_current_scope
;
1231 if (d
->status
== disabled
)
1235 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1237 within_current_scope
= 1;
1238 if (!within_current_scope
)
1241 current_display_number
= d
->number
;
1243 printf_filtered ("%d: ", d
->number
);
1248 printf_filtered ("x/");
1249 if (d
->format
.count
!= 1)
1250 printf_filtered ("%d", d
->format
.count
);
1251 printf_filtered ("%c", d
->format
.format
);
1252 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1253 printf_filtered ("%c", d
->format
.size
);
1254 printf_filtered (" ");
1255 print_expression (d
->exp
, gdb_stdout
);
1256 if (d
->format
.count
!= 1)
1257 printf_filtered ("\n");
1259 printf_filtered (" ");
1261 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1262 if (d
->format
.format
== 'i')
1263 addr
= ADDR_BITS_REMOVE (addr
);
1265 do_examine (d
->format
, addr
);
1269 if (d
->format
.format
)
1270 printf_filtered ("/%c ", d
->format
.format
);
1271 print_expression (d
->exp
, gdb_stdout
);
1272 printf_filtered (" = ");
1273 print_formatted (evaluate_expression (d
->exp
),
1274 d
->format
.format
, d
->format
.size
);
1275 printf_filtered ("\n");
1278 gdb_flush (gdb_stdout
);
1279 current_display_number
= -1;
1282 /* Display all of the values on the auto-display chain which can be
1283 evaluated in the current scope. */
1288 register struct display
*d
;
1290 for (d
= display_chain
; d
; d
= d
->next
)
1294 /* Delete the auto-display which we were in the process of displaying.
1295 This is done when there is an error or a signal. */
1298 disable_display (num
)
1301 register struct display
*d
;
1303 for (d
= display_chain
; d
; d
= d
->next
)
1304 if (d
->number
== num
)
1306 d
->status
= disabled
;
1309 printf_unfiltered ("No display number %d.\n", num
);
1313 disable_current_display ()
1315 if (current_display_number
>= 0)
1317 disable_display (current_display_number
);
1318 fprintf_unfiltered (gdb_stderr
, "Disabling display %d to avoid infinite recursion.\n",
1319 current_display_number
);
1321 current_display_number
= -1;
1325 display_info (ignore
, from_tty
)
1329 register struct display
*d
;
1332 printf_unfiltered ("There are no auto-display expressions now.\n");
1334 printf_filtered ("Auto-display expressions now in effect:\n\
1335 Num Enb Expression\n");
1337 for (d
= display_chain
; d
; d
= d
->next
)
1339 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1341 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1343 else if (d
->format
.format
)
1344 printf_filtered ("/%c ", d
->format
.format
);
1345 print_expression (d
->exp
, gdb_stdout
);
1346 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1347 printf_filtered (" (cannot be evaluated in the current context)");
1348 printf_filtered ("\n");
1349 gdb_flush (gdb_stdout
);
1354 enable_display (args
, from_tty
)
1358 register char *p
= args
;
1361 register struct display
*d
;
1365 for (d
= display_chain
; d
; d
= d
->next
)
1366 d
->status
= enabled
;
1372 while (*p1
>= '0' && *p1
<= '9')
1374 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1375 error ("Arguments must be display numbers.");
1379 for (d
= display_chain
; d
; d
= d
->next
)
1380 if (d
->number
== num
)
1382 d
->status
= enabled
;
1385 printf_unfiltered ("No display number %d.\n", num
);
1388 while (*p
== ' ' || *p
== '\t')
1395 disable_display_command (args
, from_tty
)
1399 register char *p
= args
;
1401 register struct display
*d
;
1405 for (d
= display_chain
; d
; d
= d
->next
)
1406 d
->status
= disabled
;
1412 while (*p1
>= '0' && *p1
<= '9')
1414 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1415 error ("Arguments must be display numbers.");
1417 disable_display (atoi (p
));
1420 while (*p
== ' ' || *p
== '\t')
1426 /* Print the value in stack frame FRAME of a variable
1427 specified by a struct symbol. */
1430 print_variable_value (var
, frame
, stream
)
1435 value val
= read_var_value (var
, frame
);
1436 value_print (val
, stream
, 0, Val_pretty_default
);
1439 /* Print the arguments of a stack frame, given the function FUNC
1440 running in that frame (as a symbol), the info on the frame,
1441 and the number of args according to the stack frame (or -1 if unknown). */
1443 /* References here and elsewhere to "number of args according to the
1444 stack frame" appear in all cases to refer to "number of ints of args
1445 according to the stack frame". At least for VAX, i386, isi. */
1448 print_frame_args (func
, fi
, num
, stream
)
1449 struct symbol
*func
;
1450 struct frame_info
*fi
;
1454 struct block
*b
= NULL
;
1458 register struct symbol
*sym
;
1460 /* Offset of next stack argument beyond the one we have seen that is
1461 at the highest offset.
1462 -1 if we haven't come to a stack argument yet. */
1463 long highest_offset
= -1;
1465 /* Number of ints of arguments that we have printed so far. */
1466 int args_printed
= 0;
1470 b
= SYMBOL_BLOCK_VALUE (func
);
1471 nsyms
= BLOCK_NSYMS (b
);
1474 for (i
= 0; i
< nsyms
; i
++)
1477 sym
= BLOCK_SYM (b
, i
);
1479 /* Keep track of the highest stack argument offset seen, and
1480 skip over any kinds of symbols we don't care about. */
1482 switch (SYMBOL_CLASS (sym
)) {
1486 long current_offset
= SYMBOL_VALUE (sym
);
1488 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1490 /* Compute address of next argument by adding the size of
1491 this argument and rounding to an int boundary. */
1493 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1494 & ~(sizeof (int) - 1));
1496 /* If this is the highest offset seen yet, set highest_offset. */
1497 if (highest_offset
== -1
1498 || (current_offset
> highest_offset
))
1499 highest_offset
= current_offset
;
1501 /* Add the number of ints we're about to print to args_printed. */
1502 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1505 /* We care about types of symbols, but don't need to keep track of
1506 stack offsets in them. */
1508 case LOC_REGPARM_ADDR
:
1510 case LOC_BASEREG_ARG
:
1513 /* Other types of symbols we just skip over. */
1518 /* We have to look up the symbol because arguments can have
1519 two entries (one a parameter, one a local) and the one we
1520 want is the local, which lookup_symbol will find for us.
1521 This includes gcc1 (not gcc2) on the sparc when passing a
1522 small structure and gcc2 when the argument type is float
1523 and it is passed as a double and converted to float by
1524 the prologue (in the latter case the type of the LOC_ARG
1525 symbol is double and the type of the LOC_LOCAL symbol is
1527 /* But if the parameter name is null, don't try it.
1528 Null parameter names occur on the RS/6000, for traceback tables.
1529 FIXME, should we even print them? */
1531 if (*SYMBOL_NAME (sym
))
1533 struct symbol
*nsym
;
1534 nsym
= lookup_symbol
1536 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1537 if (SYMBOL_CLASS (nsym
) == LOC_REGISTER
)
1539 /* There is a LOC_ARG/LOC_REGISTER pair. This means that
1540 it was passed on the stack and loaded into a register,
1541 or passed in a register and stored in a stack slot.
1542 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
1544 Reasons for using the LOC_ARG:
1545 (1) because find_saved_registers may be slow for remote
1547 (2) because registers are often re-used and stack slots
1548 rarely (never?) are. Therefore using the stack slot is
1549 much less likely to print garbage.
1551 Reasons why we might want to use the LOC_REGISTER:
1552 (1) So that the backtrace prints the same value as
1553 "print foo". I see no compelling reason why this needs
1554 to be the case; having the backtrace print the value which
1555 was passed in, and "print foo" print the value as modified
1556 within the called function, makes perfect sense to me.
1558 Additional note: It might be nice if "info args" displayed
1560 One more note: There is a case with sparc sturcture passing
1561 where we need to use the LOC_REGISTER, but this is dealt with
1562 by creating a single LOC_REGPARM in symbol reading. */
1564 /* Leave sym (the LOC_ARG) alone. */
1571 /* Print the current arg. */
1573 fprintf_filtered (stream
, ", ");
1575 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1576 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1577 fputs_filtered ("=", stream
);
1579 /* Avoid value_print because it will deref ref parameters. We just
1580 want to print their addresses. Print ??? for args whose address
1581 we do not know. We pass 2 as "recurse" to val_print because our
1582 standard indentation here is 4 spaces, and val_print indents
1583 2 for each recurse. */
1584 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1586 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1587 stream
, 0, 0, 2, Val_no_prettyprint
);
1589 fputs_filtered ("???", stream
);
1593 /* Don't print nameless args in situations where we don't know
1594 enough about the stack to find them. */
1599 if (highest_offset
== -1)
1600 start
= FRAME_ARGS_SKIP
;
1602 start
= highest_offset
;
1604 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1609 /* Print nameless args on STREAM.
1610 FI is the frameinfo for this frame, START is the offset
1611 of the first nameless arg, and NUM is the number of nameless args to
1612 print. FIRST is nonzero if this is the first argument (not just
1613 the first nameless arg). */
1615 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1616 struct frame_info
*fi
;
1626 for (i
= 0; i
< num
; i
++)
1629 #ifdef NAMELESS_ARG_VALUE
1630 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1632 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1636 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1640 fprintf_filtered (stream
, ", ");
1642 #ifdef PRINT_NAMELESS_INTEGER
1643 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1645 #ifdef PRINT_TYPELESS_INTEGER
1646 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1648 fprintf_filtered (stream
, "%d", arg_value
);
1649 #endif /* PRINT_TYPELESS_INTEGER */
1650 #endif /* PRINT_NAMELESS_INTEGER */
1652 start
+= sizeof (int);
1658 printf_command (arg
, from_tty
)
1663 register char *s
= arg
;
1667 char *current_substring
;
1669 int allocated_args
= 20;
1670 struct cleanup
*old_cleanups
;
1672 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1673 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1676 error_no_arg ("format-control string and values to print");
1678 /* Skip white space before format string */
1679 while (*s
== ' ' || *s
== '\t') s
++;
1681 /* A format string should follow, enveloped in double quotes */
1683 error ("Bad format string, missing '\"'.");
1685 /* Parse the format-control string and copy it into the string STRING,
1686 processing some kinds of escape sequence. */
1688 f
= string
= (char *) alloca (strlen (s
) + 1);
1696 error ("Bad format string, non-terminated '\"'.");
1717 /* ??? TODO: handle other escape sequences */
1718 error ("Unrecognized \\ escape character in format string.");
1727 /* Skip over " and following space and comma. */
1730 while (*s
== ' ' || *s
== '\t') s
++;
1732 if (*s
!= ',' && *s
!= 0)
1733 error ("Invalid argument syntax");
1736 while (*s
== ' ' || *s
== '\t') s
++;
1738 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1739 substrings
= alloca (strlen (string
) * 2);
1740 current_substring
= substrings
;
1743 /* Now scan the string for %-specs and see what kinds of args they want.
1744 argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
1745 of the right size. */
1747 enum argclass
{no_arg
, int_arg
, string_arg
, double_arg
, long_long_arg
};
1748 enum argclass
*argclass
;
1749 enum argclass this_argclass
;
1755 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1763 while (strchr ("0123456789.hlL-+ #", *f
))
1765 if (*f
== 'l' || *f
== 'L')
1772 this_argclass
= string_arg
;
1778 this_argclass
= double_arg
;
1782 error ("`*' not supported for precision or width in printf");
1785 error ("Format specifier `n' not supported in printf");
1788 this_argclass
= no_arg
;
1793 this_argclass
= long_long_arg
;
1795 this_argclass
= int_arg
;
1799 if (this_argclass
!= no_arg
)
1801 strncpy (current_substring
, last_arg
, f
- last_arg
);
1802 current_substring
+= f
- last_arg
;
1803 *current_substring
++ = '\0';
1805 argclass
[nargs_wanted
++] = this_argclass
;
1809 /* Now, parse all arguments and evaluate them.
1810 Store the VALUEs in VAL_ARGS. */
1815 if (nargs
== allocated_args
)
1816 val_args
= (value
*) xrealloc ((char *) val_args
,
1817 (allocated_args
*= 2)
1820 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1822 /* If format string wants a float, unchecked-convert the value to
1823 floating point of the same size */
1825 if (argclass
[nargs
] == double_arg
)
1827 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1828 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1829 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1830 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1838 if (nargs
!= nargs_wanted
)
1839 error ("Wrong number of arguments for specified format-string");
1841 /* FIXME: We should be using vprintf_filtered, but as long as it
1842 has an arbitrary limit that is unacceptable. Correct fix is
1843 for vprintf_filtered to scan down the format string so it knows
1844 how big a buffer it needs (perhaps by putting a vasprintf (see
1845 GNU C library) in libiberty).
1847 But for now, just force out any pending output, so at least the output
1848 appears in the correct order. */
1849 wrap_here ((char *)NULL
);
1851 /* Now actually print them. */
1852 current_substring
= substrings
;
1853 for (i
= 0; i
< nargs
; i
++)
1855 switch (argclass
[i
])
1862 tem
= value_as_pointer (val_args
[i
]);
1864 /* This is a %s argument. Find the length of the string. */
1869 read_memory (tem
+ j
, &c
, 1);
1874 /* Copy the string contents into a string inside GDB. */
1875 str
= (char *) alloca (j
+ 1);
1876 read_memory (tem
, str
, j
);
1879 /* Don't use printf_filtered because of arbitrary limit. */
1880 printf_unfiltered (current_substring
, str
);
1885 double val
= value_as_double (val_args
[i
]);
1886 /* Don't use printf_filtered because of arbitrary limit. */
1887 printf_unfiltered (current_substring
, val
);
1891 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1893 long long val
= value_as_long (val_args
[i
]);
1894 /* Don't use printf_filtered because of arbitrary limit. */
1895 printf_unfiltered (current_substring
, val
);
1899 error ("long long not supported in printf");
1903 /* FIXME: there should be separate int_arg and long_arg. */
1904 long val
= value_as_long (val_args
[i
]);
1905 /* Don't use printf_filtered because of arbitrary limit. */
1906 printf_unfiltered (current_substring
, val
);
1910 error ("internal error in printf_command");
1912 /* Skip to the next substring. */
1913 current_substring
+= strlen (current_substring
) + 1;
1915 /* Print the portion of the format string after the last argument. */
1916 /* It would be OK to use printf_filtered here. */
1919 do_cleanups (old_cleanups
);
1922 /* Dump a specified section of assembly code. With no command line
1923 arguments, this command will dump the assembly code for the
1924 function surrounding the pc value in the selected frame. With one
1925 argument, it will dump the assembly code surrounding that pc value.
1926 Two arguments are interpeted as bounds within which to dump
1931 disassemble_command (arg
, from_tty
)
1935 CORE_ADDR low
, high
;
1943 if (!selected_frame
)
1944 error ("No frame selected.\n");
1946 pc
= get_frame_pc (selected_frame
);
1947 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1948 error ("No function contains program counter for selected frame.\n");
1950 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1953 pc
= parse_and_eval_address (arg
);
1954 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1955 error ("No function contains specified address.\n");
1959 /* Two arguments. */
1960 *space_index
= '\0';
1961 low
= parse_and_eval_address (arg
);
1962 high
= parse_and_eval_address (space_index
+ 1);
1965 printf_filtered ("Dump of assembler code ");
1968 printf_filtered ("for function %s:\n", name
);
1972 printf_filtered ("from %s ", local_hex_string((unsigned long) low
));
1973 printf_filtered ("to %s:\n", local_hex_string((unsigned long) high
));
1976 /* Dump the specified range. */
1977 for (pc
= low
; pc
< high
; )
1980 print_address (pc
, gdb_stdout
);
1981 printf_filtered (":\t");
1982 /* We often wrap here if there are long symbolic names. */
1984 pc
+= print_insn (pc
, gdb_stdout
);
1985 printf_filtered ("\n");
1987 printf_filtered ("End of assembler dump.\n");
1988 gdb_flush (gdb_stdout
);
1993 _initialize_printcmd ()
1995 current_display_number
= -1;
1997 add_info ("address", address_info
,
1998 "Describe where variable VAR is stored.");
2000 add_com ("x", class_vars
, x_command
,
2001 "Examine memory: x/FMT ADDRESS.\n\
2002 ADDRESS is an expression for the memory address to examine.\n\
2003 FMT is a repeat count followed by a format letter and a size letter.\n\
2004 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2005 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2006 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2007 The specified number of objects of the specified size are printed\n\
2008 according to the format.\n\n\
2009 Defaults for format and size letters are those previously used.\n\
2010 Default count is 1. Default address is following last thing printed\n\
2011 with this command or \"print\".");
2013 add_com ("disassemble", class_vars
, disassemble_command
,
2014 "Disassemble a specified section of memory.\n\
2015 Default is the function surrounding the pc of the selected frame.\n\
2016 With a single argument, the function surrounding that address is dumped.\n\
2017 Two arguments are taken as a range of memory to dump.");
2020 add_com ("whereis", class_vars
, whereis_command
,
2021 "Print line number and file of definition of variable.");
2024 add_info ("display", display_info
,
2025 "Expressions to display when program stops, with code numbers.");
2027 add_cmd ("undisplay", class_vars
, undisplay_command
,
2028 "Cancel some expressions to be displayed when program stops.\n\
2029 Arguments are the code numbers of the expressions to stop displaying.\n\
2030 No argument means cancel all automatic-display expressions.\n\
2031 \"delete display\" has the same effect as this command.\n\
2032 Do \"info display\" to see current list of code numbers.",
2035 add_com ("display", class_vars
, display_command
,
2036 "Print value of expression EXP each time the program stops.\n\
2037 /FMT may be used before EXP as in the \"print\" command.\n\
2038 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2039 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2040 and examining is done as in the \"x\" command.\n\n\
2041 With no argument, display all currently requested auto-display expressions.\n\
2042 Use \"undisplay\" to cancel display requests previously made.");
2044 add_cmd ("display", class_vars
, enable_display
,
2045 "Enable some expressions to be displayed when program stops.\n\
2046 Arguments are the code numbers of the expressions to resume displaying.\n\
2047 No argument means enable all automatic-display expressions.\n\
2048 Do \"info display\" to see current list of code numbers.", &enablelist
);
2050 add_cmd ("display", class_vars
, disable_display_command
,
2051 "Disable some expressions to be displayed when program stops.\n\
2052 Arguments are the code numbers of the expressions to stop displaying.\n\
2053 No argument means disable all automatic-display expressions.\n\
2054 Do \"info display\" to see current list of code numbers.", &disablelist
);
2056 add_cmd ("display", class_vars
, undisplay_command
,
2057 "Cancel some expressions to be displayed when program stops.\n\
2058 Arguments are the code numbers of the expressions to stop displaying.\n\
2059 No argument means cancel all automatic-display expressions.\n\
2060 Do \"info display\" to see current list of code numbers.", &deletelist
);
2062 add_com ("printf", class_vars
, printf_command
,
2063 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2064 This is useful for formatted output in user-defined commands.");
2065 add_com ("output", class_vars
, output_command
,
2066 "Like \"print\" but don't put in value history and don't print newline.\n\
2067 This is useful in user-defined commands.");
2069 add_prefix_cmd ("set", class_vars
, set_command
,
2070 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2071 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2072 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2073 with $), a register (a few standard names starting with $), or an actual\n\
2074 variable in the program being debugged. EXP is any valid expression.\n\
2075 Use \"set variable\" for variables with names identical to set subcommands.\n\
2076 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2077 You can see these environment settings with the \"show\" command.",
2078 &setlist
, "set ", 1, &cmdlist
);
2080 /* "call" is the same as "set", but handy for dbx users to call fns. */
2081 add_com ("call", class_vars
, call_command
,
2082 "Call a function in the program.\n\
2083 The argument is the function name and arguments, in the notation of the\n\
2084 current working language. The result is printed and saved in the value\n\
2085 history, if it is not void.");
2087 add_cmd ("variable", class_vars
, set_command
,
2088 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2089 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2090 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2091 with $), a register (a few standard names starting with $), or an actual\n\
2092 variable in the program being debugged. EXP is any valid expression.\n\
2093 This may usually be abbreviated to simply \"set\".",
2096 add_com ("print", class_vars
, print_command
,
2097 concat ("Print value of expression EXP.\n\
2098 Variables accessible are those of the lexical environment of the selected\n\
2099 stack frame, plus all those whose scope is global or an entire file.\n\
2101 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2102 $$NUM refers to NUM'th value back from the last one.\n\
2103 Names starting with $ refer to registers (with the values they would have\n\
2104 if the program were to return to the stack frame now selected, restoring\n\
2105 all registers saved by frames farther in) or else to debugger\n\
2106 \"convenience\" variables (any such name not a known register).\n\
2107 Use assignment expressions to give values to convenience variables.\n",
2109 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2110 @ is a binary operator for treating consecutive data objects\n\
2111 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2112 element is FOO, whose second element is stored in the space following\n\
2113 where FOO is stored, etc. FOO must be an expression whose value\n\
2114 resides in memory.\n",
2116 EXP may be preceded with /FMT, where FMT is a format letter\n\
2117 but no count or size letter (see \"x\" command).", NULL
));
2118 add_com_alias ("p", "print", class_vars
, 1);
2120 add_com ("inspect", class_vars
, inspect_command
,
2121 "Same as \"print\" command, except that if you are running in the epoch\n\
2122 environment, the value is printed in its own window.");
2125 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2126 (char *)&max_symbolic_offset
,
2127 "Set the largest offset that will be printed in <symbol+1234> form.",
2131 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2132 (char *)&print_symbol_filename
,
2133 "Set printing of source filename and line number with <symbol>.",
2138 add_set_cmd ("fast-symbolic-addr", no_class
, var_boolean
,
2139 (char *)&fast_symbolic_addr
,
2140 "Set fast printing of symbolic addresses (using minimal symbols).",
2144 examine_b_type
= init_type (TYPE_CODE_INT
, 1, 0, NULL
, NULL
);
2145 examine_h_type
= init_type (TYPE_CODE_INT
, 2, 0, NULL
, NULL
);
2146 examine_w_type
= init_type (TYPE_CODE_INT
, 4, 0, NULL
, NULL
);
2147 examine_g_type
= init_type (TYPE_CODE_INT
, 8, 0, NULL
, NULL
);