1 /* Print values for GNU debugger GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include "expression.h"
32 #include "breakpoint.h"
35 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
36 extern int addressprint
; /* Whether to print hex addresses in HLL " */
45 /* Last specified output format. */
47 static char last_format
= 'x';
49 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
51 static char last_size
= 'w';
53 /* Default address to examine next. */
55 static CORE_ADDR next_address
;
57 /* Last address examined. */
59 static CORE_ADDR last_examine_address
;
61 /* Contents of last address examined.
62 This is not valid past the end of the `x' command! */
64 static value last_examine_value
;
66 /* Largest offset between a symbolic value and an address, that will be
67 printed as `0x1234 <symbol+offset>'. */
69 static unsigned int max_symbolic_offset
= UINT_MAX
;
71 /* Append the source filename and linenumber of the symbol when
72 printing a symbolic value as `<symbol at filename:linenum>' if set. */
73 static int print_symbol_filename
= 0;
75 /* Number of auto-display expression currently being displayed.
76 So that we can disable it if we get an error or a signal within it.
77 -1 when not doing one. */
79 int current_display_number
;
81 /* Flag to low-level print routines that this value is being printed
82 in an epoch window. We'd like to pass this as a parameter, but
83 every routine would need to take it. Perhaps we can encapsulate
84 this in the I/O stream once we have GNU stdio. */
90 /* Chain link to next auto-display item. */
92 /* Expression to be evaluated and displayed. */
93 struct expression
*exp
;
94 /* Item number of this auto-display item. */
96 /* Display format specified. */
97 struct format_data format
;
98 /* Innermost block required by this expression when evaluated */
100 /* Status of this display (enabled or disabled) */
104 /* Chain of expressions whose values should be displayed
105 automatically each time the program stops. */
107 static struct display
*display_chain
;
109 static int display_number
;
111 /* Prototypes for local functions */
114 delete_display
PARAMS ((int));
117 enable_display
PARAMS ((char *, int));
120 disable_display_command
PARAMS ((char *, int));
123 disassemble_command
PARAMS ((char *, int));
126 printf_command
PARAMS ((char *, int));
129 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
133 display_info
PARAMS ((char *, int));
136 do_one_display
PARAMS ((struct display
*));
139 undisplay_command
PARAMS ((char *, int));
142 free_display
PARAMS ((struct display
*));
145 display_command
PARAMS ((char *, int));
148 x_command
PARAMS ((char *, int));
151 address_info
PARAMS ((char *, int));
154 set_command
PARAMS ((char *, int));
157 output_command
PARAMS ((char *, int));
160 call_command
PARAMS ((char *, int));
163 inspect_command
PARAMS ((char *, int));
166 print_command
PARAMS ((char *, int));
169 print_command_1
PARAMS ((char *, int, int));
172 validate_format
PARAMS ((struct format_data
, char *));
175 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
178 print_formatted
PARAMS ((value
, int, int));
180 static struct format_data
181 decode_format
PARAMS ((char **, int, int));
184 /* Decode a format specification. *STRING_PTR should point to it.
185 OFORMAT and OSIZE are used as defaults for the format and size
186 if none are given in the format specification.
187 If OSIZE is zero, then the size field of the returned value
188 should be set only if a size is explicitly specified by the
190 The structure returned describes all the data
191 found in the specification. In addition, *STRING_PTR is advanced
192 past the specification and past all whitespace following it. */
194 static struct format_data
195 decode_format (string_ptr
, oformat
, osize
)
200 struct format_data val
;
201 register char *p
= *string_ptr
;
207 if (*p
>= '0' && *p
<= '9')
208 val
.count
= atoi (p
);
209 while (*p
>= '0' && *p
<= '9') p
++;
211 /* Now process size or format letters that follow. */
215 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
217 else if (*p
>= 'a' && *p
<= 'z')
223 #ifndef CC_HAS_LONG_LONG
224 /* Make sure 'g' size is not used on integer types.
225 Well, actually, we can handle hex. */
226 if (val
.size
== 'g' && val
.format
!= 'f' && val
.format
!= 'x')
230 while (*p
== ' ' || *p
== '\t') p
++;
233 /* Set defaults for format and size if not specified. */
234 if (val
.format
== '?')
238 /* Neither has been specified. */
239 val
.format
= oformat
;
243 /* If a size is specified, any format makes a reasonable
244 default except 'i'. */
245 val
.format
= oformat
== 'i' ? 'x' : oformat
;
247 else if (val
.size
== '?')
252 /* Addresses must be words. */
253 val
.size
= osize
? 'w' : osize
;
256 /* Floating point has to be word or giantword. */
257 if (osize
== 'w' || osize
== 'g')
260 /* Default it to giantword if the last used size is not
262 val
.size
= osize
? 'g' : osize
;
265 /* Characters default to one byte. */
266 val
.size
= osize
? 'b' : osize
;
269 /* The default is the size most recently specified. */
276 /* Print value VAL on stdout according to FORMAT, a letter or 0.
277 Do not end with a newline.
278 0 means print VAL according to its own type.
279 SIZE is the letter for the size of datum being printed.
280 This is used to pad hex numbers so they line up. */
283 print_formatted (val
, format
, size
)
288 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
290 if (VALUE_LVAL (val
) == lval_memory
)
291 next_address
= VALUE_ADDRESS (val
) + len
;
296 next_address
= VALUE_ADDRESS (val
)
297 + value_print (value_addr (val
), stdout
, format
, Val_pretty_default
);
301 /* The old comment says
302 "Force output out, print_insn not using _filtered".
303 I'm not completely sure what that means, I suspect most print_insn
304 now do use _filtered, so I guess it's obsolete. */
305 /* We often wrap here if there are long symbolic names. */
307 next_address
= VALUE_ADDRESS (val
)
308 + print_insn (VALUE_ADDRESS (val
), stdout
);
313 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
314 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
315 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
316 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
317 || VALUE_REPEATED (val
))
318 value_print (val
, stdout
, format
, Val_pretty_default
);
320 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
321 format
, size
, stdout
);
325 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
326 according to letters FORMAT and SIZE on STREAM.
327 FORMAT may not be zero. Formats s and i are not supported at this level.
329 This is how the elements of an array or structure are printed
333 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
341 int len
= TYPE_LENGTH (type
);
343 if (len
> sizeof (LONGEST
)
351 /* We can't print it normally, but we can print it in hex.
352 Printing it in the wrong radix is more useful than saying
353 "use /x, you dummy". */
354 /* FIXME: we could also do octal or binary if that was the
356 /* FIXME: we should be using the size field to give us a minimum
357 field width to print. */
358 val_print_type_code_int (type
, valaddr
, stream
);
362 val_long
= unpack_long (type
, valaddr
);
364 /* If we are printing it as unsigned, truncate it in case it is actually
365 a negative signed value (e.g. "print/u (short)-1" should print 65535
366 (if shorts are 16 bits) instead of 4294967295). */
369 if (len
< sizeof (LONGEST
))
370 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
378 /* no size specified, like in print. Print varying # of digits. */
379 print_longest (stream
, 'x', 1, val_long
);
388 print_longest (stream
, size
, 1, val_long
);
391 error ("Undefined output size \"%c\".", size
);
396 print_longest (stream
, 'd', 1, val_long
);
400 print_longest (stream
, 'u', 0, val_long
);
405 print_longest (stream
, 'o', 1, val_long
);
407 fprintf_filtered (stream
, "0");
411 print_address (unpack_pointer (type
, valaddr
), stream
);
415 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
420 if (len
== sizeof (float))
421 type
= builtin_type_float
;
422 else if (len
== sizeof (double))
423 type
= builtin_type_double
;
424 print_floating (valaddr
, type
, stream
);
431 /* Binary; 't' stands for "two". */
433 char bits
[8*(sizeof val_long
) + 1];
438 width
= 8*(sizeof val_long
);
455 error ("Undefined output size \"%c\".", size
);
461 bits
[width
] = (val_long
& 1) ? '1' : '0';
466 while (*cp
&& *cp
== '0')
471 fprintf_filtered (stream
, local_binary_format_prefix());
472 fprintf_filtered (stream
, cp
);
473 fprintf_filtered (stream
, local_binary_format_suffix());
478 error ("Undefined output format \"%c\".", format
);
482 /* Specify default address for `x' command.
483 `info lines' uses this. */
486 set_next_address (addr
)
491 /* Make address available to the user as $_. */
492 set_internalvar (lookup_internalvar ("_"),
493 value_from_longest (lookup_pointer_type (builtin_type_void
),
497 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
498 after LEADIN. Print nothing if no symbolic name is found nearby.
499 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
500 or to interpret it as a possible C++ name and convert it back to source
501 form. However note that DO_DEMANGLE can be overridden by the specific
502 settings of the demangle and asm_demangle variables. */
505 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
511 CORE_ADDR name_location
;
512 register struct symbol
*symbol
;
515 /* First try to find the address in the symbol tables to find
516 static functions. If that doesn't succeed we try the minimal symbol
517 vector for symbols in non-text space.
518 FIXME: Should find a way to get at the static non-text symbols too. */
520 symbol
= find_pc_function (addr
);
523 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
525 name
= SYMBOL_SOURCE_NAME (symbol
);
527 name
= SYMBOL_LINKAGE_NAME (symbol
);
531 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (addr
);
533 /* If nothing comes out, don't print anything symbolic. */
536 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
538 name
= SYMBOL_SOURCE_NAME (msymbol
);
540 name
= SYMBOL_LINKAGE_NAME (msymbol
);
543 /* If the nearest symbol is too far away, don't print anything symbolic. */
545 /* For when CORE_ADDR is larger than unsigned int, we do math in
546 CORE_ADDR. But when we detect unsigned wraparound in the
547 CORE_ADDR math, we ignore this test and print the offset,
548 because addr+max_symbolic_offset has wrapped through the end
549 of the address space back to the beginning, giving bogus comparison. */
550 if (addr
> name_location
+ max_symbolic_offset
551 && name_location
+ max_symbolic_offset
> name_location
)
554 fputs_filtered (leadin
, stream
);
555 fputs_filtered ("<", stream
);
556 fputs_filtered (name
, stream
);
557 if (addr
!= name_location
)
558 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
560 /* Append source filename and line number if desired. */
561 if (symbol
&& print_symbol_filename
)
563 struct symtab_and_line sal
;
565 sal
= find_pc_line (addr
, 0);
567 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
569 fputs_filtered (">", stream
);
572 /* Print address ADDR symbolically on STREAM.
573 First print it as a number. Then perhaps print
574 <SYMBOL + OFFSET> after the number. */
577 print_address (addr
, stream
)
581 #if 0 && defined (ADDR_BITS_REMOVE)
582 /* This is wrong for pointer to char, in which we do want to print
584 fprintf_filtered (stream
, local_hex_format(),
585 (unsigned long) ADDR_BITS_REMOVE(addr
));
587 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
589 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
592 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
593 controls whether to print the symbolic name "raw" or demangled.
594 Global setting "addressprint" controls whether to print hex address
598 print_address_demangle (addr
, stream
, do_demangle
)
604 fprintf_filtered (stream
, "0");
605 } else if (addressprint
) {
606 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
607 print_address_symbolic (addr
, stream
, do_demangle
, " ");
609 print_address_symbolic (addr
, stream
, do_demangle
, "");
614 /* Examine data at address ADDR in format FMT.
615 Fetch it from memory and print on stdout. */
618 do_examine (fmt
, addr
)
619 struct format_data fmt
;
622 register char format
= 0;
624 register int count
= 1;
625 struct type
*val_type
= NULL
;
627 register int maxelts
;
634 /* String or instruction format implies fetch single bytes
635 regardless of the specified size. */
636 if (format
== 's' || format
== 'i')
639 /* I don't think the TYPE_CODE, TYPE_NAME, or TYPE_FLAGS matter.
640 This is just a (fairly twisted) way of telling print_formatted
643 val_type
= init_type (TYPE_CODE_INT
, 1, 0, NULL
, NULL
);
644 else if (size
== 'h')
645 val_type
= init_type (TYPE_CODE_INT
, 2, 0, NULL
, NULL
);
646 else if (size
== 'w')
647 val_type
= init_type (TYPE_CODE_INT
, 4, 0, NULL
, NULL
);
648 else if (size
== 'g')
649 val_type
= init_type (TYPE_CODE_INT
, 8, 0, NULL
, NULL
);
656 if (format
== 's' || format
== 'i')
659 /* Print as many objects as specified in COUNT, at most maxelts per line,
660 with the address of the next one at the start of each line. */
664 print_address (next_address
, stdout
);
665 printf_filtered (":");
670 printf_filtered ("\t");
671 /* Note that print_formatted sets next_address for the next
673 last_examine_address
= next_address
;
674 last_examine_value
= value_at (val_type
, next_address
);
675 print_formatted (last_examine_value
, format
, size
);
677 printf_filtered ("\n");
684 validate_format (fmt
, cmdname
)
685 struct format_data fmt
;
689 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
691 error ("Item count other than 1 is meaningless in \"%s\" command.",
693 if (fmt
.format
== 'i' || fmt
.format
== 's')
694 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
695 fmt
.format
, cmdname
);
698 /* Evaluate string EXP as an expression in the current language and
699 print the resulting value. EXP may contain a format specifier as the
700 first argument ("/x myvar" for example, to print myvar in hex).
704 print_command_1 (exp
, inspect
, voidprint
)
709 struct expression
*expr
;
710 register struct cleanup
*old_chain
= 0;
711 register char format
= 0;
713 struct format_data fmt
;
716 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
717 inspect_it
= inspect
;
719 if (exp
&& *exp
== '/')
722 fmt
= decode_format (&exp
, last_format
, 0);
723 validate_format (fmt
, "print");
724 last_format
= format
= fmt
.format
;
735 extern int objectprint
;
737 expr
= parse_expression (exp
);
738 old_chain
= make_cleanup (free_current_contents
, &expr
);
740 val
= evaluate_expression (expr
);
742 /* C++: figure out what type we actually want to print it as. */
743 type
= VALUE_TYPE (val
);
746 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
747 || TYPE_CODE (type
) == TYPE_CODE_REF
)
748 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
749 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
753 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
757 type
= VALUE_TYPE (val
);
762 val
= access_value_history (0);
764 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
765 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
767 int histindex
= record_latest_value (val
);
770 printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
772 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
774 print_formatted (val
, format
, fmt
.size
);
775 printf_filtered ("\n");
781 do_cleanups (old_chain
);
782 inspect_it
= 0; /* Reset print routines to normal */
787 print_command (exp
, from_tty
)
791 print_command_1 (exp
, 0, 1);
794 /* Same as print, except in epoch, it gets its own window */
797 inspect_command (exp
, from_tty
)
801 extern int epoch_interface
;
803 print_command_1 (exp
, epoch_interface
, 1);
806 /* Same as print, except it doesn't print void results. */
809 call_command (exp
, from_tty
)
813 print_command_1 (exp
, 0, 0);
818 output_command (exp
, from_tty
)
822 struct expression
*expr
;
823 register struct cleanup
*old_chain
;
824 register char format
= 0;
826 struct format_data fmt
;
828 if (exp
&& *exp
== '/')
831 fmt
= decode_format (&exp
, 0, 0);
832 validate_format (fmt
, "output");
836 expr
= parse_expression (exp
);
837 old_chain
= make_cleanup (free_current_contents
, &expr
);
839 val
= evaluate_expression (expr
);
841 print_formatted (val
, format
, fmt
.size
);
843 do_cleanups (old_chain
);
848 set_command (exp
, from_tty
)
852 struct expression
*expr
= parse_expression (exp
);
853 register struct cleanup
*old_chain
854 = make_cleanup (free_current_contents
, &expr
);
855 evaluate_expression (expr
);
856 do_cleanups (old_chain
);
861 address_info (exp
, from_tty
)
865 register struct symbol
*sym
;
866 register struct minimal_symbol
*msymbol
;
868 register long basereg
;
869 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
870 if exp is a field of `this'. */
873 error ("Argument required.");
875 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
876 &is_a_field_of_this
, (struct symtab
**)NULL
);
879 if (is_a_field_of_this
)
881 printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp
);
885 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
888 printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n",
890 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (msymbol
)));
892 error ("No symbol \"%s\" in current context.", exp
);
896 printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym
));
897 val
= SYMBOL_VALUE (sym
);
898 basereg
= SYMBOL_BASEREG (sym
);
900 switch (SYMBOL_CLASS (sym
))
903 case LOC_CONST_BYTES
:
908 printf ("a label at address %s",
909 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
913 printf ("a variable in register %s", reg_names
[val
]);
917 printf ("static storage at address %s",
918 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
922 printf ("an argument in register %s", reg_names
[val
]);
925 case LOC_REGPARM_ADDR
:
926 printf ("address of an argument in register %s", reg_names
[val
]);
930 printf ("an argument at offset %ld", val
);
934 printf ("an argument at frame offset %ld", val
);
938 printf ("a local variable at frame offset %ld", val
);
942 printf ("a reference argument at offset %ld", val
);
946 printf ("a variable at offset %ld from register %s",
947 val
, reg_names
[basereg
]);
950 case LOC_BASEREG_ARG
:
951 printf ("an argument at offset %ld from register %s",
952 val
, reg_names
[basereg
]);
956 printf ("a typedef");
960 printf ("a function at address %s",
961 local_hex_string((unsigned long) BLOCK_START (SYMBOL_BLOCK_VALUE (sym
))));
964 case LOC_OPTIMIZED_OUT
:
965 printf_filtered ("optimized out");
969 printf ("of unknown (botched) type");
976 x_command (exp
, from_tty
)
980 struct expression
*expr
;
981 struct format_data fmt
;
982 struct cleanup
*old_chain
;
985 fmt
.format
= last_format
;
986 fmt
.size
= last_size
;
989 if (exp
&& *exp
== '/')
992 fmt
= decode_format (&exp
, last_format
, last_size
);
995 /* If we have an expression, evaluate it and use it as the address. */
997 if (exp
!= 0 && *exp
!= 0)
999 expr
= parse_expression (exp
);
1000 /* Cause expression not to be there any more
1001 if this command is repeated with Newline.
1002 But don't clobber a user-defined command's definition. */
1005 old_chain
= make_cleanup (free_current_contents
, &expr
);
1006 val
= evaluate_expression (expr
);
1007 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1008 val
= value_ind (val
);
1009 /* In rvalue contexts, such as this, functions are coerced into
1010 pointers to functions. This makes "x/i main" work. */
1011 if (/* last_format == 'i'
1012 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1013 && VALUE_LVAL (val
) == lval_memory
)
1014 next_address
= VALUE_ADDRESS (val
);
1016 next_address
= value_as_pointer (val
);
1017 do_cleanups (old_chain
);
1020 do_examine (fmt
, next_address
);
1022 /* If the examine succeeds, we remember its size and format for next time. */
1023 last_size
= fmt
.size
;
1024 last_format
= fmt
.format
;
1026 /* Set a couple of internal variables if appropriate. */
1027 if (last_examine_value
)
1029 /* Make last address examined available to the user as $_. Use
1030 the correct pointer type. */
1031 set_internalvar (lookup_internalvar ("_"),
1032 value_from_longest (
1033 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1034 (LONGEST
) last_examine_address
));
1036 /* Make contents of last address examined available to the user as $__.*/
1037 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1042 /* Add an expression to the auto-display chain.
1043 Specify the expression. */
1046 display_command (exp
, from_tty
)
1050 struct format_data fmt
;
1051 register struct expression
*expr
;
1052 register struct display
*new;
1063 fmt
= decode_format (&exp
, 0, 0);
1064 if (fmt
.size
&& fmt
.format
== 0)
1066 if (fmt
.format
== 'i' || fmt
.format
== 's')
1076 innermost_block
= 0;
1077 expr
= parse_expression (exp
);
1079 new = (struct display
*) xmalloc (sizeof (struct display
));
1082 new->block
= innermost_block
;
1083 new->next
= display_chain
;
1084 new->number
= ++display_number
;
1086 new->status
= enabled
;
1087 display_chain
= new;
1089 if (from_tty
&& target_has_execution
)
1090 do_one_display (new);
1103 /* Clear out the display_chain.
1104 Done when new symtabs are loaded, since this invalidates
1105 the types stored in many expressions. */
1110 register struct display
*d
;
1112 while ((d
= display_chain
) != NULL
)
1115 display_chain
= d
->next
;
1120 /* Delete the auto-display number NUM. */
1123 delete_display (num
)
1126 register struct display
*d1
, *d
;
1129 error ("No display number %d.", num
);
1131 if (display_chain
->number
== num
)
1134 display_chain
= d1
->next
;
1138 for (d
= display_chain
; ; d
= d
->next
)
1141 error ("No display number %d.", num
);
1142 if (d
->next
->number
== num
)
1152 /* Delete some values from the auto-display chain.
1153 Specify the element numbers. */
1156 undisplay_command (args
, from_tty
)
1160 register char *p
= args
;
1166 if (query ("Delete all auto-display expressions? "))
1175 while (*p1
>= '0' && *p1
<= '9') p1
++;
1176 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1177 error ("Arguments must be display numbers.");
1181 delete_display (num
);
1184 while (*p
== ' ' || *p
== '\t') p
++;
1189 /* Display a single auto-display.
1190 Do nothing if the display cannot be printed in the current context,
1191 or if the display is disabled. */
1197 int within_current_scope
;
1199 if (d
->status
== disabled
)
1203 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1205 within_current_scope
= 1;
1206 if (!within_current_scope
)
1209 current_display_number
= d
->number
;
1211 printf_filtered ("%d: ", d
->number
);
1216 printf_filtered ("x/");
1217 if (d
->format
.count
!= 1)
1218 printf_filtered ("%d", d
->format
.count
);
1219 printf_filtered ("%c", d
->format
.format
);
1220 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1221 printf_filtered ("%c", d
->format
.size
);
1222 printf_filtered (" ");
1223 print_expression (d
->exp
, stdout
);
1224 if (d
->format
.count
!= 1)
1225 printf_filtered ("\n");
1227 printf_filtered (" ");
1229 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1230 if (d
->format
.format
== 'i')
1231 addr
= ADDR_BITS_REMOVE (addr
);
1233 do_examine (d
->format
, addr
);
1237 if (d
->format
.format
)
1238 printf_filtered ("/%c ", d
->format
.format
);
1239 print_expression (d
->exp
, stdout
);
1240 printf_filtered (" = ");
1241 print_formatted (evaluate_expression (d
->exp
),
1242 d
->format
.format
, d
->format
.size
);
1243 printf_filtered ("\n");
1247 current_display_number
= -1;
1250 /* Display all of the values on the auto-display chain which can be
1251 evaluated in the current scope. */
1256 register struct display
*d
;
1258 for (d
= display_chain
; d
; d
= d
->next
)
1262 /* Delete the auto-display which we were in the process of displaying.
1263 This is done when there is an error or a signal. */
1266 disable_display (num
)
1269 register struct display
*d
;
1271 for (d
= display_chain
; d
; d
= d
->next
)
1272 if (d
->number
== num
)
1274 d
->status
= disabled
;
1277 printf ("No display number %d.\n", num
);
1281 disable_current_display ()
1283 if (current_display_number
>= 0)
1285 disable_display (current_display_number
);
1286 fprintf (stderr
, "Disabling display %d to avoid infinite recursion.\n",
1287 current_display_number
);
1289 current_display_number
= -1;
1293 display_info (ignore
, from_tty
)
1297 register struct display
*d
;
1300 printf ("There are no auto-display expressions now.\n");
1302 printf_filtered ("Auto-display expressions now in effect:\n\
1303 Num Enb Expression\n");
1305 for (d
= display_chain
; d
; d
= d
->next
)
1307 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1309 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1311 else if (d
->format
.format
)
1312 printf_filtered ("/%c ", d
->format
.format
);
1313 print_expression (d
->exp
, stdout
);
1314 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1315 printf_filtered (" (cannot be evaluated in the current context)");
1316 printf_filtered ("\n");
1322 enable_display (args
, from_tty
)
1326 register char *p
= args
;
1329 register struct display
*d
;
1333 for (d
= display_chain
; d
; d
= d
->next
)
1334 d
->status
= enabled
;
1340 while (*p1
>= '0' && *p1
<= '9')
1342 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1343 error ("Arguments must be display numbers.");
1347 for (d
= display_chain
; d
; d
= d
->next
)
1348 if (d
->number
== num
)
1350 d
->status
= enabled
;
1353 printf ("No display number %d.\n", num
);
1356 while (*p
== ' ' || *p
== '\t')
1363 disable_display_command (args
, from_tty
)
1367 register char *p
= args
;
1369 register struct display
*d
;
1373 for (d
= display_chain
; d
; d
= d
->next
)
1374 d
->status
= disabled
;
1380 while (*p1
>= '0' && *p1
<= '9')
1382 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1383 error ("Arguments must be display numbers.");
1385 disable_display (atoi (p
));
1388 while (*p
== ' ' || *p
== '\t')
1394 /* Print the value in stack frame FRAME of a variable
1395 specified by a struct symbol. */
1398 print_variable_value (var
, frame
, stream
)
1403 value val
= read_var_value (var
, frame
);
1404 value_print (val
, stream
, 0, Val_pretty_default
);
1407 /* Print the arguments of a stack frame, given the function FUNC
1408 running in that frame (as a symbol), the info on the frame,
1409 and the number of args according to the stack frame (or -1 if unknown). */
1411 /* References here and elsewhere to "number of args according to the
1412 stack frame" appear in all cases to refer to "number of ints of args
1413 according to the stack frame". At least for VAX, i386, isi. */
1416 print_frame_args (func
, fi
, num
, stream
)
1417 struct symbol
*func
;
1418 struct frame_info
*fi
;
1422 struct block
*b
= NULL
;
1426 register struct symbol
*sym
;
1428 /* Offset of next stack argument beyond the one we have seen that is
1429 at the highest offset.
1430 -1 if we haven't come to a stack argument yet. */
1431 long highest_offset
= -1;
1433 /* Number of ints of arguments that we have printed so far. */
1434 int args_printed
= 0;
1438 b
= SYMBOL_BLOCK_VALUE (func
);
1439 nsyms
= BLOCK_NSYMS (b
);
1442 for (i
= 0; i
< nsyms
; i
++)
1445 sym
= BLOCK_SYM (b
, i
);
1447 /* Keep track of the highest stack argument offset seen, and
1448 skip over any kinds of symbols we don't care about. */
1450 switch (SYMBOL_CLASS (sym
)) {
1454 long current_offset
= SYMBOL_VALUE (sym
);
1456 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1458 /* Compute address of next argument by adding the size of
1459 this argument and rounding to an int boundary. */
1461 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1462 & ~(sizeof (int) - 1));
1464 /* If this is the highest offset seen yet, set highest_offset. */
1465 if (highest_offset
== -1
1466 || (current_offset
> highest_offset
))
1467 highest_offset
= current_offset
;
1469 /* Add the number of ints we're about to print to args_printed. */
1470 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1473 /* We care about types of symbols, but don't need to keep track of
1474 stack offsets in them. */
1476 case LOC_REGPARM_ADDR
:
1478 case LOC_BASEREG_ARG
:
1481 /* Other types of symbols we just skip over. */
1486 /* We have to look up the symbol because arguments can have
1487 two entries (one a parameter, one a local) and the one we
1488 want is the local, which lookup_symbol will find for us.
1489 This includes gcc1 (not gcc2) on the sparc when passing a
1490 small structure and gcc2 when the argument type is float
1491 and it is passed as a double and converted to float by
1492 the prologue (in the latter case the type of the LOC_ARG
1493 symbol is double and the type of the LOC_LOCAL symbol is
1494 float). There are also LOC_ARG/LOC_REGISTER pairs which
1495 are not combined in symbol-reading. */
1496 /* But if the parameter name is null, don't try it.
1497 Null parameter names occur on the RS/6000, for traceback tables.
1498 FIXME, should we even print them? */
1500 if (*SYMBOL_NAME (sym
))
1503 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1505 /* Print the current arg. */
1507 fprintf_filtered (stream
, ", ");
1509 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1510 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1511 fputs_filtered ("=", stream
);
1513 /* Avoid value_print because it will deref ref parameters. We just
1514 want to print their addresses. Print ??? for args whose address
1515 we do not know. We pass 2 as "recurse" to val_print because our
1516 standard indentation here is 4 spaces, and val_print indents
1517 2 for each recurse. */
1518 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1520 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1521 stream
, 0, 0, 2, Val_no_prettyprint
);
1523 fputs_filtered ("???", stream
);
1527 /* Don't print nameless args in situations where we don't know
1528 enough about the stack to find them. */
1533 if (highest_offset
== -1)
1534 start
= FRAME_ARGS_SKIP
;
1536 start
= highest_offset
;
1538 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1543 /* Print nameless args on STREAM.
1544 FI is the frameinfo for this frame, START is the offset
1545 of the first nameless arg, and NUM is the number of nameless args to
1546 print. FIRST is nonzero if this is the first argument (not just
1547 the first nameless arg). */
1549 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1550 struct frame_info
*fi
;
1560 for (i
= 0; i
< num
; i
++)
1563 #ifdef NAMELESS_ARG_VALUE
1564 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1566 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1570 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1574 fprintf_filtered (stream
, ", ");
1576 #ifdef PRINT_NAMELESS_INTEGER
1577 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1579 #ifdef PRINT_TYPELESS_INTEGER
1580 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1582 fprintf_filtered (stream
, "%d", arg_value
);
1583 #endif /* PRINT_TYPELESS_INTEGER */
1584 #endif /* PRINT_NAMELESS_INTEGER */
1586 start
+= sizeof (int);
1590 /* This is an interface which allows to us make a va_list. */
1593 unsigned int max_arg_size
;
1595 /* Current position in bytes. */
1596 unsigned int argindex
;
1598 #ifdef MAKEVA_EXTRA_INFO
1599 /* For host dependent information. */
1603 /* Some systems (mips, pa) would like this to be aligned, and it never
1608 double force_double_align
;
1609 LONGEST force_long_align
;
1613 /* Tell the caller how many bytes to allocate for a makeva_list with NARGS
1614 arguments and whose largest argument is MAX_ARG_SIZE bytes. This
1615 way the caller can use alloca, malloc, or some other allocator. */
1617 makeva_size (nargs
, max_arg_size
)
1619 unsigned int max_arg_size
;
1621 #if defined (MAKEVA_SIZE)
1622 MAKEVA_SIZE (nargs
, max_arg_size
);
1624 return sizeof (makeva_list
) + nargs
* max_arg_size
;
1628 /* Start working on LIST with NARGS arguments and whose largest
1629 argument is MAX_ARG_SIZE bytes. */
1631 makeva_start (list
, nargs
, max_arg_size
)
1634 unsigned int max_arg_size
;
1636 list
->nargs
= nargs
;
1637 list
->max_arg_size
= max_arg_size
;
1638 #if defined (MAKEVA_START)
1639 MAKEVA_START (list
);
1645 /* Add ARG to LIST. */
1647 makeva_arg (list
, argaddr
, argsize
)
1650 unsigned int argsize
;
1652 #if defined (MAKEVA_ARG)
1653 MAKEVA_ARG (list
, argaddr
, argsize
);
1655 memcpy (&list
->aligner
.arg_bytes
[list
->argindex
], argaddr
, argsize
);
1656 list
->argindex
+= argsize
;
1660 /* From LIST, for which makeva_arg has been called for each arg,
1661 return a va_list containing the args. */
1666 #if defined (MAKEVA_END)
1669 /* This works if a va_list is just a pointer to the arguments. */
1670 return (va_list) list
->aligner
.arg_bytes
;
1676 printf_command (arg
, from_tty
)
1681 register char *s
= arg
;
1685 int allocated_args
= 20;
1686 va_list args_to_vprintf
;
1688 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1691 error_no_arg ("format-control string and values to print");
1693 /* Skip white space before format string */
1694 while (*s
== ' ' || *s
== '\t') s
++;
1696 /* A format string should follow, enveloped in double quotes */
1698 error ("Bad format string, missing '\"'.");
1700 /* Parse the format-control string and copy it into the string STRING,
1701 processing some kinds of escape sequence. */
1703 f
= string
= (char *) alloca (strlen (s
) + 1);
1710 error ("Bad format string, non-terminated '\"'.");
1711 /* doesn't return */
1732 /* ??? TODO: handle other escape sequences */
1733 error ("Unrecognized \\ escape character in format string.");
1742 /* Skip over " and following space and comma. */
1745 while (*s
== ' ' || *s
== '\t') s
++;
1747 if (*s
!= ',' && *s
!= 0)
1748 error ("Invalid argument syntax");
1751 while (*s
== ' ' || *s
== '\t') s
++;
1754 /* Now scan the string for %-specs and see what kinds of args they want.
1755 argclass[I] classifies the %-specs so we can give vprintf something
1756 of the right size. */
1758 enum argclass
{int_arg
, string_arg
, double_arg
, long_long_arg
};
1759 enum argclass
*argclass
;
1763 /* We build up a va_list to pass to vprintf. This is unnecessary;
1764 instead of calling vprintf ("%d%f", <constructed va_list>) we
1765 could just call printf ("%d", arg1); printf ("%f", arg2);. Funny
1766 how I thought of that right *after* I got the MAKEVA stuff pretty much
1768 makeva_list
*args_makeva
;
1770 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1777 while (strchr ("0123456789.hlL-+ #", *f
))
1779 if (*f
== 'l' || *f
== 'L')
1784 argclass
[nargs_wanted
++] = string_arg
;
1785 else if (*f
== 'e' || *f
== 'f' || *f
== 'g')
1786 argclass
[nargs_wanted
++] = double_arg
;
1787 else if (lcount
> 1)
1788 argclass
[nargs_wanted
++] = long_long_arg
;
1790 argclass
[nargs_wanted
++] = int_arg
;
1794 /* Now, parse all arguments and evaluate them.
1795 Store the VALUEs in VAL_ARGS. */
1800 if (nargs
== allocated_args
)
1801 val_args
= (value
*) xrealloc ((char *) val_args
,
1802 (allocated_args
*= 2)
1805 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1807 /* If format string wants a float, unchecked-convert the value to
1808 floating point of the same size */
1810 if (argclass
[nargs
] == double_arg
)
1812 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1813 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1814 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1815 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1823 if (nargs
!= nargs_wanted
)
1824 error ("Wrong number of arguments for specified format-string");
1826 /* Now lay out an argument-list containing the arguments
1827 as doubles, integers and C pointers. */
1829 args_makeva
= (makeva_list
*)
1830 alloca (makeva_size (nargs
, sizeof (double)));
1831 makeva_start (args_makeva
, nargs
, sizeof (double));
1832 for (i
= 0; i
< nargs
; i
++)
1834 if (argclass
[i
] == string_arg
)
1839 tem
= value_as_pointer (val_args
[i
]);
1841 /* This is a %s argument. Find the length of the string. */
1846 read_memory (tem
+ j
, &c
, 1);
1851 /* Copy the string contents into a string inside GDB. */
1852 str
= (char *) alloca (j
+ 1);
1853 read_memory (tem
, str
, j
);
1856 /* Pass address of internal copy as the arg to vprintf. */
1857 makeva_arg (args_makeva
, &str
, sizeof (str
));
1859 else if (VALUE_TYPE (val_args
[i
])->code
== TYPE_CODE_FLT
)
1861 double val
= value_as_double (val_args
[i
]);
1862 makeva_arg (args_makeva
, &val
, sizeof (val
));
1865 #ifdef CC_HAS_LONG_LONG
1866 if (argclass
[i
] == long_long_arg
)
1868 long long val
= value_as_long (val_args
[i
]);
1869 makeva_arg (args_makeva
, &val
, sizeof (val
));
1874 long val
= value_as_long (val_args
[i
]);
1875 makeva_arg (args_makeva
, &val
, sizeof (val
));
1878 args_to_vprintf
= makeva_end (args_makeva
);
1881 /* FIXME: We should be using vprintf_filtered, but as long as it has an
1882 arbitrary limit that is unacceptable. Correct fix is for vprintf_filtered
1883 to scan down the format string so it knows how big a buffer it needs.
1885 But for now, just force out any pending output, so at least the output
1886 appears in the correct order. */
1887 wrap_here ((char *)NULL
);
1888 vprintf (string
, args_to_vprintf
);
1891 /* Dump a specified section of assembly code. With no command line
1892 arguments, this command will dump the assembly code for the
1893 function surrounding the pc value in the selected frame. With one
1894 argument, it will dump the assembly code surrounding that pc value.
1895 Two arguments are interpeted as bounds within which to dump
1900 disassemble_command (arg
, from_tty
)
1904 CORE_ADDR low
, high
;
1912 if (!selected_frame
)
1913 error ("No frame selected.\n");
1915 pc
= get_frame_pc (selected_frame
);
1916 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1917 error ("No function contains program counter for selected frame.\n");
1919 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1922 pc
= parse_and_eval_address (arg
);
1923 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1924 error ("No function contains specified address.\n");
1928 /* Two arguments. */
1929 *space_index
= '\0';
1930 low
= parse_and_eval_address (arg
);
1931 high
= parse_and_eval_address (space_index
+ 1);
1934 printf_filtered ("Dump of assembler code ");
1937 printf_filtered ("for function %s:\n", name
);
1941 printf_filtered ("from %s ", local_hex_string((unsigned long) low
));
1942 printf_filtered ("to %s:\n", local_hex_string((unsigned long) high
));
1945 /* Dump the specified range. */
1946 for (pc
= low
; pc
< high
; )
1949 print_address (pc
, stdout
);
1950 printf_filtered (":\t");
1951 pc
+= print_insn (pc
, stdout
);
1952 printf_filtered ("\n");
1954 printf_filtered ("End of assembler dump.\n");
1960 _initialize_printcmd ()
1962 current_display_number
= -1;
1964 add_info ("address", address_info
,
1965 "Describe where variable VAR is stored.");
1967 add_com ("x", class_vars
, x_command
,
1968 "Examine memory: x/FMT ADDRESS.\n\
1969 ADDRESS is an expression for the memory address to examine.\n\
1970 FMT is a repeat count followed by a format letter and a size letter.\n\
1971 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
1972 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
1973 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
1974 The specified number of objects of the specified size are printed\n\
1975 according to the format.\n\n\
1976 Defaults for format and size letters are those previously used.\n\
1977 Default count is 1. Default address is following last thing printed\n\
1978 with this command or \"print\".");
1980 add_com ("disassemble", class_vars
, disassemble_command
,
1981 "Disassemble a specified section of memory.\n\
1982 Default is the function surrounding the pc of the selected frame.\n\
1983 With a single argument, the function surrounding that address is dumped.\n\
1984 Two arguments are taken as a range of memory to dump.");
1987 add_com ("whereis", class_vars
, whereis_command
,
1988 "Print line number and file of definition of variable.");
1991 add_info ("display", display_info
,
1992 "Expressions to display when program stops, with code numbers.");
1994 add_cmd ("undisplay", class_vars
, undisplay_command
,
1995 "Cancel some expressions to be displayed when program stops.\n\
1996 Arguments are the code numbers of the expressions to stop displaying.\n\
1997 No argument means cancel all automatic-display expressions.\n\
1998 \"delete display\" has the same effect as this command.\n\
1999 Do \"info display\" to see current list of code numbers.",
2002 add_com ("display", class_vars
, display_command
,
2003 "Print value of expression EXP each time the program stops.\n\
2004 /FMT may be used before EXP as in the \"print\" command.\n\
2005 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2006 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2007 and examining is done as in the \"x\" command.\n\n\
2008 With no argument, display all currently requested auto-display expressions.\n\
2009 Use \"undisplay\" to cancel display requests previously made.");
2011 add_cmd ("display", class_vars
, enable_display
,
2012 "Enable some expressions to be displayed when program stops.\n\
2013 Arguments are the code numbers of the expressions to resume displaying.\n\
2014 No argument means enable all automatic-display expressions.\n\
2015 Do \"info display\" to see current list of code numbers.", &enablelist
);
2017 add_cmd ("display", class_vars
, disable_display_command
,
2018 "Disable some expressions to be displayed when program stops.\n\
2019 Arguments are the code numbers of the expressions to stop displaying.\n\
2020 No argument means disable all automatic-display expressions.\n\
2021 Do \"info display\" to see current list of code numbers.", &disablelist
);
2023 add_cmd ("display", class_vars
, undisplay_command
,
2024 "Cancel some expressions to be displayed when program stops.\n\
2025 Arguments are the code numbers of the expressions to stop displaying.\n\
2026 No argument means cancel all automatic-display expressions.\n\
2027 Do \"info display\" to see current list of code numbers.", &deletelist
);
2029 add_com ("printf", class_vars
, printf_command
,
2030 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2031 This is useful for formatted output in user-defined commands.");
2032 add_com ("output", class_vars
, output_command
,
2033 "Like \"print\" but don't put in value history and don't print newline.\n\
2034 This is useful in user-defined commands.");
2036 add_prefix_cmd ("set", class_vars
, set_command
,
2037 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2038 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2039 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2040 with $), a register (a few standard names starting with $), or an actual\n\
2041 variable in the program being debugged. EXP is any valid expression.\n\
2042 Use \"set variable\" for variables with names identical to set subcommands.\n\
2043 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2044 You can see these environment settings with the \"show\" command.",
2045 &setlist
, "set ", 1, &cmdlist
);
2047 /* "call" is the same as "set", but handy for dbx users to call fns. */
2048 add_com ("call", class_vars
, call_command
,
2049 "Call a function in the program.\n\
2050 The argument is the function name and arguments, in the notation of the\n\
2051 current working language. The result is printed and saved in the value\n\
2052 history, if it is not void.");
2054 add_cmd ("variable", class_vars
, set_command
,
2055 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2056 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2057 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2058 with $), a register (a few standard names starting with $), or an actual\n\
2059 variable in the program being debugged. EXP is any valid expression.\n\
2060 This may usually be abbreviated to simply \"set\".",
2063 add_com ("print", class_vars
, print_command
,
2064 concat ("Print value of expression EXP.\n\
2065 Variables accessible are those of the lexical environment of the selected\n\
2066 stack frame, plus all those whose scope is global or an entire file.\n\
2068 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2069 $$NUM refers to NUM'th value back from the last one.\n\
2070 Names starting with $ refer to registers (with the values they would have\n\
2071 if the program were to return to the stack frame now selected, restoring\n\
2072 all registers saved by frames farther in) or else to debugger\n\
2073 \"convenience\" variables (any such name not a known register).\n\
2074 Use assignment expressions to give values to convenience variables.\n",
2076 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2077 @ is a binary operator for treating consecutive data objects\n\
2078 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2079 element is FOO, whose second element is stored in the space following\n\
2080 where FOO is stored, etc. FOO must be an expression whose value\n\
2081 resides in memory.\n",
2083 EXP may be preceded with /FMT, where FMT is a format letter\n\
2084 but no count or size letter (see \"x\" command).", NULL
));
2085 add_com_alias ("p", "print", class_vars
, 1);
2087 add_com ("inspect", class_vars
, inspect_command
,
2088 "Same as \"print\" command, except that if you are running in the epoch\n\
2089 environment, the value is printed in its own window.");
2092 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2093 (char *)&max_symbolic_offset
,
2094 "Set the largest offset that will be printed in <symbol+1234> form.",
2098 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2099 (char *)&print_symbol_filename
,
2100 "Set printing of source filename and line number with <symbol>.",