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 #ifdef CC_HAS_LONG_LONG
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 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
), 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
), 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
, stdout
, format
, Val_pretty_default
);
327 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
328 format
, size
, 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 value is unsigned, truncate it in case negative. */
374 if (len
== sizeof (char))
375 val_long
&= (1 << 8 * sizeof(char)) - 1;
376 else if (len
== sizeof (short))
377 val_long
&= (1 << 8 * sizeof(short)) - 1;
378 else if (len
== sizeof (long))
379 val_long
&= (unsigned long) - 1;
387 /* no size specified, like in print. Print varying # of digits. */
388 print_longest (stream
, 'x', 1, val_long
);
397 print_longest (stream
, size
, 1, val_long
);
400 error ("Undefined output size \"%c\".", size
);
405 print_longest (stream
, 'd', 1, val_long
);
409 print_longest (stream
, 'u', 0, val_long
);
414 print_longest (stream
, 'o', 1, val_long
);
416 fprintf_filtered (stream
, "0");
420 print_address (unpack_pointer (type
, valaddr
), stream
);
424 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
429 if (len
== sizeof (float))
430 type
= builtin_type_float
;
431 else if (len
== sizeof (double))
432 type
= builtin_type_double
;
433 print_floating (valaddr
, type
, stream
);
440 /* Binary; 't' stands for "two". */
442 char bits
[8*(sizeof val_long
) + 1];
447 width
= 8*(sizeof val_long
);
464 error ("Undefined output size \"%c\".", size
);
470 bits
[width
] = (val_long
& 1) ? '1' : '0';
475 while (*cp
&& *cp
== '0')
480 fprintf_filtered (stream
, local_binary_format_prefix());
481 fprintf_filtered (stream
, cp
);
482 fprintf_filtered (stream
, local_binary_format_suffix());
487 error ("Undefined output format \"%c\".", format
);
491 /* Specify default address for `x' command.
492 `info lines' uses this. */
495 set_next_address (addr
)
500 /* Make address available to the user as $_. */
501 set_internalvar (lookup_internalvar ("_"),
502 value_from_longest (lookup_pointer_type (builtin_type_void
),
506 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
507 after LEADIN. Print nothing if no symbolic name is found nearby.
508 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
509 or to interpret it as a possible C++ name and convert it back to source
510 form. However note that DO_DEMANGLE can be overridden by the specific
511 settings of the demangle and asm_demangle variables. */
514 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
520 CORE_ADDR name_location
;
521 register struct symbol
*symbol
;
524 /* First try to find the address in the symbol tables to find
525 static functions. If that doesn't succeed we try the minimal symbol
526 vector for symbols in non-text space.
527 FIXME: Should find a way to get at the static non-text symbols too. */
529 symbol
= find_pc_function (addr
);
532 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
534 name
= SYMBOL_SOURCE_NAME (symbol
);
536 name
= SYMBOL_LINKAGE_NAME (symbol
);
540 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (addr
);
542 /* If nothing comes out, don't print anything symbolic. */
545 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
547 name
= SYMBOL_SOURCE_NAME (msymbol
);
549 name
= SYMBOL_LINKAGE_NAME (msymbol
);
552 /* If the nearest symbol is too far away, don't print anything symbolic. */
554 /* For when CORE_ADDR is larger than unsigned int, we do math in
555 CORE_ADDR. But when we detect unsigned wraparound in the
556 CORE_ADDR math, we ignore this test and print the offset,
557 because addr+max_symbolic_offset has wrapped through the end
558 of the address space back to the beginning, giving bogus comparison. */
559 if (addr
> name_location
+ max_symbolic_offset
560 && name_location
+ max_symbolic_offset
> name_location
)
563 fputs_filtered (leadin
, stream
);
564 fputs_filtered ("<", stream
);
565 fputs_filtered (name
, stream
);
566 if (addr
!= name_location
)
567 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
569 /* Append source filename and line number if desired. */
570 if (symbol
&& print_symbol_filename
)
572 struct symtab_and_line sal
;
574 sal
= find_pc_line (addr
, 0);
576 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
578 fputs_filtered (">", stream
);
581 /* Print address ADDR symbolically on STREAM.
582 First print it as a number. Then perhaps print
583 <SYMBOL + OFFSET> after the number. */
586 print_address (addr
, stream
)
590 #if 0 && defined (ADDR_BITS_REMOVE)
591 /* This is wrong for pointer to char, in which we do want to print
593 fprintf_filtered (stream
, local_hex_format(), ADDR_BITS_REMOVE(addr
));
595 fprintf_filtered (stream
, local_hex_format(), addr
);
597 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
600 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
601 controls whether to print the symbolic name "raw" or demangled.
602 Global setting "addressprint" controls whether to print hex address
606 print_address_demangle (addr
, stream
, do_demangle
)
612 fprintf_filtered (stream
, "0");
613 } else if (addressprint
) {
614 fprintf_filtered (stream
, local_hex_format(), addr
);
615 print_address_symbolic (addr
, stream
, do_demangle
, " ");
617 print_address_symbolic (addr
, stream
, do_demangle
, "");
622 /* Examine data at address ADDR in format FMT.
623 Fetch it from memory and print on stdout. */
626 do_examine (fmt
, addr
)
627 struct format_data fmt
;
630 register char format
= 0;
632 register int count
= 1;
633 struct type
*val_type
;
635 register int maxelts
;
642 /* String or instruction format implies fetch single bytes
643 regardless of the specified size. */
644 if (format
== 's' || format
== 'i')
648 val_type
= builtin_type_char
;
649 else if (size
== 'h')
650 val_type
= builtin_type_short
;
651 else if (size
== 'w')
652 val_type
= builtin_type_long
;
653 else if (size
== 'g')
654 #ifndef CC_HAS_LONG_LONG
655 val_type
= builtin_type_double
;
657 val_type
= builtin_type_long_long
;
665 if (format
== 's' || format
== 'i')
668 /* Print as many objects as specified in COUNT, at most maxelts per line,
669 with the address of the next one at the start of each line. */
673 print_address (next_address
, stdout
);
674 printf_filtered (":");
679 printf_filtered ("\t");
680 /* Note that print_formatted sets next_address for the next
682 last_examine_address
= next_address
;
683 last_examine_value
= value_at (val_type
, next_address
);
684 print_formatted (last_examine_value
, format
, size
);
686 printf_filtered ("\n");
692 validate_format (fmt
, cmdname
)
693 struct format_data fmt
;
697 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
699 error ("Item count other than 1 is meaningless in \"%s\" command.",
701 if (fmt
.format
== 'i' || fmt
.format
== 's')
702 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
703 fmt
.format
, cmdname
);
706 /* Evaluate string EXP as an expression in the current language and
707 print the resulting value. EXP may contain a format specifier as the
708 first argument ("/x myvar" for example, to print myvar in hex).
712 print_command_1 (exp
, inspect
, voidprint
)
717 struct expression
*expr
;
718 register struct cleanup
*old_chain
= 0;
719 register char format
= 0;
721 struct format_data fmt
;
724 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
725 inspect_it
= inspect
;
727 if (exp
&& *exp
== '/')
730 fmt
= decode_format (&exp
, last_format
, 0);
731 validate_format (fmt
, "print");
732 last_format
= format
= fmt
.format
;
743 extern int objectprint
;
745 expr
= parse_expression (exp
);
746 old_chain
= make_cleanup (free_current_contents
, &expr
);
748 val
= evaluate_expression (expr
);
750 /* C++: figure out what type we actually want to print it as. */
751 type
= VALUE_TYPE (val
);
754 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
755 || TYPE_CODE (type
) == TYPE_CODE_REF
)
756 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
757 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
761 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
765 type
= VALUE_TYPE (val
);
770 val
= access_value_history (0);
772 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
773 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
775 int histindex
= record_latest_value (val
);
778 printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
780 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
782 print_formatted (val
, format
, fmt
.size
);
783 printf_filtered ("\n");
789 do_cleanups (old_chain
);
790 inspect_it
= 0; /* Reset print routines to normal */
795 print_command (exp
, from_tty
)
799 print_command_1 (exp
, 0, 1);
802 /* Same as print, except in epoch, it gets its own window */
805 inspect_command (exp
, from_tty
)
809 extern int epoch_interface
;
811 print_command_1 (exp
, epoch_interface
, 1);
814 /* Same as print, except it doesn't print void results. */
817 call_command (exp
, from_tty
)
821 print_command_1 (exp
, 0, 0);
826 output_command (exp
, from_tty
)
830 struct expression
*expr
;
831 register struct cleanup
*old_chain
;
832 register char format
= 0;
834 struct format_data fmt
;
836 if (exp
&& *exp
== '/')
839 fmt
= decode_format (&exp
, 0, 0);
840 validate_format (fmt
, "output");
844 expr
= parse_expression (exp
);
845 old_chain
= make_cleanup (free_current_contents
, &expr
);
847 val
= evaluate_expression (expr
);
849 print_formatted (val
, format
, fmt
.size
);
851 do_cleanups (old_chain
);
856 set_command (exp
, from_tty
)
860 struct expression
*expr
= parse_expression (exp
);
861 register struct cleanup
*old_chain
862 = make_cleanup (free_current_contents
, &expr
);
863 evaluate_expression (expr
);
864 do_cleanups (old_chain
);
869 address_info (exp
, from_tty
)
873 register struct symbol
*sym
;
874 register struct minimal_symbol
*msymbol
;
876 register long basereg
;
877 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
878 if exp is a field of `this'. */
881 error ("Argument required.");
883 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
884 &is_a_field_of_this
, (struct symtab
**)NULL
);
887 if (is_a_field_of_this
)
889 printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp
);
893 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
896 printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n",
897 exp
, local_hex_string(SYMBOL_VALUE_ADDRESS (msymbol
)));
899 error ("No symbol \"%s\" in current context.", exp
);
903 printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym
));
904 val
= SYMBOL_VALUE (sym
);
905 basereg
= SYMBOL_BASEREG (sym
);
907 switch (SYMBOL_CLASS (sym
))
910 case LOC_CONST_BYTES
:
915 printf ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym
)));
919 printf ("a variable in register %s", reg_names
[val
]);
923 printf ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym
)));
927 printf ("an argument in register %s", reg_names
[val
]);
930 case LOC_REGPARM_ADDR
:
931 printf ("address of an argument in register %s", reg_names
[val
]);
935 printf ("an argument at offset %ld", val
);
939 printf ("an argument at frame offset %ld", val
);
943 printf ("a local variable at frame offset %ld", val
);
947 printf ("a reference argument at offset %ld", val
);
951 printf ("a variable at offset %ld from register %s",
952 val
, reg_names
[basereg
]);
955 case LOC_BASEREG_ARG
:
956 printf ("an argument at offset %ld from register %s",
957 val
, reg_names
[basereg
]);
961 printf ("a typedef");
965 printf ("a function at address %s",
966 local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym
))));
969 case LOC_OPTIMIZED_OUT
:
970 printf_filtered ("optimized out");
974 printf ("of unknown (botched) type");
981 x_command (exp
, from_tty
)
985 struct expression
*expr
;
986 struct format_data fmt
;
987 struct cleanup
*old_chain
;
990 fmt
.format
= last_format
;
991 fmt
.size
= last_size
;
994 if (exp
&& *exp
== '/')
997 fmt
= decode_format (&exp
, last_format
, last_size
);
1000 /* If we have an expression, evaluate it and use it as the address. */
1002 if (exp
!= 0 && *exp
!= 0)
1004 expr
= parse_expression (exp
);
1005 /* Cause expression not to be there any more
1006 if this command is repeated with Newline.
1007 But don't clobber a user-defined command's definition. */
1010 old_chain
= make_cleanup (free_current_contents
, &expr
);
1011 val
= evaluate_expression (expr
);
1012 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1013 val
= value_ind (val
);
1014 /* In rvalue contexts, such as this, functions are coerced into
1015 pointers to functions. This makes "x/i main" work. */
1016 if (/* last_format == 'i'
1017 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1018 && VALUE_LVAL (val
) == lval_memory
)
1019 next_address
= VALUE_ADDRESS (val
);
1021 next_address
= value_as_pointer (val
);
1022 do_cleanups (old_chain
);
1025 do_examine (fmt
, next_address
);
1027 /* If the examine succeeds, we remember its size and format for next time. */
1028 last_size
= fmt
.size
;
1029 last_format
= fmt
.format
;
1031 /* Set a couple of internal variables if appropriate. */
1032 if (last_examine_value
)
1034 /* Make last address examined available to the user as $_. Use
1035 the correct pointer type. */
1036 set_internalvar (lookup_internalvar ("_"),
1037 value_from_longest (
1038 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1039 (LONGEST
) last_examine_address
));
1041 /* Make contents of last address examined available to the user as $__.*/
1042 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1047 /* Add an expression to the auto-display chain.
1048 Specify the expression. */
1051 display_command (exp
, from_tty
)
1055 struct format_data fmt
;
1056 register struct expression
*expr
;
1057 register struct display
*new;
1068 fmt
= decode_format (&exp
, 0, 0);
1069 if (fmt
.size
&& fmt
.format
== 0)
1071 if (fmt
.format
== 'i' || fmt
.format
== 's')
1081 innermost_block
= 0;
1082 expr
= parse_expression (exp
);
1084 new = (struct display
*) xmalloc (sizeof (struct display
));
1087 new->block
= innermost_block
;
1088 new->next
= display_chain
;
1089 new->number
= ++display_number
;
1091 new->status
= enabled
;
1092 display_chain
= new;
1094 if (from_tty
&& target_has_execution
)
1095 do_one_display (new);
1108 /* Clear out the display_chain.
1109 Done when new symtabs are loaded, since this invalidates
1110 the types stored in many expressions. */
1115 register struct display
*d
;
1117 while ((d
= display_chain
) != NULL
)
1120 display_chain
= d
->next
;
1125 /* Delete the auto-display number NUM. */
1128 delete_display (num
)
1131 register struct display
*d1
, *d
;
1134 error ("No display number %d.", num
);
1136 if (display_chain
->number
== num
)
1139 display_chain
= d1
->next
;
1143 for (d
= display_chain
; ; d
= d
->next
)
1146 error ("No display number %d.", num
);
1147 if (d
->next
->number
== num
)
1157 /* Delete some values from the auto-display chain.
1158 Specify the element numbers. */
1161 undisplay_command (args
, from_tty
)
1165 register char *p
= args
;
1171 if (query ("Delete all auto-display expressions? "))
1180 while (*p1
>= '0' && *p1
<= '9') p1
++;
1181 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1182 error ("Arguments must be display numbers.");
1186 delete_display (num
);
1189 while (*p
== ' ' || *p
== '\t') p
++;
1194 /* Display a single auto-display.
1195 Do nothing if the display cannot be printed in the current context,
1196 or if the display is disabled. */
1202 int within_current_scope
;
1204 if (d
->status
== disabled
)
1208 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1210 within_current_scope
= 1;
1211 if (!within_current_scope
)
1214 current_display_number
= d
->number
;
1216 printf_filtered ("%d: ", d
->number
);
1221 printf_filtered ("x/");
1222 if (d
->format
.count
!= 1)
1223 printf_filtered ("%d", d
->format
.count
);
1224 printf_filtered ("%c", d
->format
.format
);
1225 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1226 printf_filtered ("%c", d
->format
.size
);
1227 printf_filtered (" ");
1228 print_expression (d
->exp
, stdout
);
1229 if (d
->format
.count
!= 1)
1230 printf_filtered ("\n");
1232 printf_filtered (" ");
1234 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1235 if (d
->format
.format
== 'i')
1236 addr
= ADDR_BITS_REMOVE (addr
);
1238 do_examine (d
->format
, addr
);
1242 if (d
->format
.format
)
1243 printf_filtered ("/%c ", d
->format
.format
);
1244 print_expression (d
->exp
, stdout
);
1245 printf_filtered (" = ");
1246 print_formatted (evaluate_expression (d
->exp
),
1247 d
->format
.format
, d
->format
.size
);
1248 printf_filtered ("\n");
1252 current_display_number
= -1;
1255 /* Display all of the values on the auto-display chain which can be
1256 evaluated in the current scope. */
1261 register struct display
*d
;
1263 for (d
= display_chain
; d
; d
= d
->next
)
1267 /* Delete the auto-display which we were in the process of displaying.
1268 This is done when there is an error or a signal. */
1271 disable_display (num
)
1274 register struct display
*d
;
1276 for (d
= display_chain
; d
; d
= d
->next
)
1277 if (d
->number
== num
)
1279 d
->status
= disabled
;
1282 printf ("No display number %d.\n", num
);
1286 disable_current_display ()
1288 if (current_display_number
>= 0)
1290 disable_display (current_display_number
);
1291 fprintf (stderr
, "Disabling display %d to avoid infinite recursion.\n",
1292 current_display_number
);
1294 current_display_number
= -1;
1298 display_info (ignore
, from_tty
)
1302 register struct display
*d
;
1305 printf ("There are no auto-display expressions now.\n");
1307 printf_filtered ("Auto-display expressions now in effect:\n\
1308 Num Enb Expression\n");
1310 for (d
= display_chain
; d
; d
= d
->next
)
1312 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1314 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1316 else if (d
->format
.format
)
1317 printf_filtered ("/%c ", d
->format
.format
);
1318 print_expression (d
->exp
, stdout
);
1319 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1320 printf_filtered (" (cannot be evaluated in the current context)");
1321 printf_filtered ("\n");
1327 enable_display (args
, from_tty
)
1331 register char *p
= args
;
1334 register struct display
*d
;
1338 for (d
= display_chain
; d
; d
= d
->next
)
1339 d
->status
= enabled
;
1345 while (*p1
>= '0' && *p1
<= '9')
1347 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1348 error ("Arguments must be display numbers.");
1352 for (d
= display_chain
; d
; d
= d
->next
)
1353 if (d
->number
== num
)
1355 d
->status
= enabled
;
1358 printf ("No display number %d.\n", num
);
1361 while (*p
== ' ' || *p
== '\t')
1368 disable_display_command (args
, from_tty
)
1372 register char *p
= args
;
1374 register struct display
*d
;
1378 for (d
= display_chain
; d
; d
= d
->next
)
1379 d
->status
= disabled
;
1385 while (*p1
>= '0' && *p1
<= '9')
1387 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1388 error ("Arguments must be display numbers.");
1390 disable_display (atoi (p
));
1393 while (*p
== ' ' || *p
== '\t')
1399 /* Print the value in stack frame FRAME of a variable
1400 specified by a struct symbol. */
1403 print_variable_value (var
, frame
, stream
)
1408 value val
= read_var_value (var
, frame
);
1409 value_print (val
, stream
, 0, Val_pretty_default
);
1412 /* Print the arguments of a stack frame, given the function FUNC
1413 running in that frame (as a symbol), the info on the frame,
1414 and the number of args according to the stack frame (or -1 if unknown). */
1416 /* References here and elsewhere to "number of args according to the
1417 stack frame" appear in all cases to refer to "number of ints of args
1418 according to the stack frame". At least for VAX, i386, isi. */
1421 print_frame_args (func
, fi
, num
, stream
)
1422 struct symbol
*func
;
1423 struct frame_info
*fi
;
1431 register struct symbol
*sym
;
1433 /* Offset of next stack argument beyond the one we have seen that is
1434 at the highest offset.
1435 -1 if we haven't come to a stack argument yet. */
1436 long highest_offset
= -1;
1438 /* Number of ints of arguments that we have printed so far. */
1439 int args_printed
= 0;
1443 b
= SYMBOL_BLOCK_VALUE (func
);
1444 nsyms
= BLOCK_NSYMS (b
);
1447 for (i
= 0; i
< nsyms
; i
++)
1450 sym
= BLOCK_SYM (b
, i
);
1452 /* Keep track of the highest stack argument offset seen, and
1453 skip over any kinds of symbols we don't care about. */
1455 switch (SYMBOL_CLASS (sym
)) {
1459 long current_offset
= SYMBOL_VALUE (sym
);
1461 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1463 /* Compute address of next argument by adding the size of
1464 this argument and rounding to an int boundary. */
1466 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1467 & ~(sizeof (int) - 1));
1469 /* If this is the highest offset seen yet, set highest_offset. */
1470 if (highest_offset
== -1
1471 || (current_offset
> highest_offset
))
1472 highest_offset
= current_offset
;
1474 /* Add the number of ints we're about to print to args_printed. */
1475 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1478 /* We care about types of symbols, but don't need to keep track of
1479 stack offsets in them. */
1481 case LOC_REGPARM_ADDR
:
1484 case LOC_BASEREG_ARG
:
1487 /* Other types of symbols we just skip over. */
1492 /* We have to look up the symbol because arguments can have
1493 two entries (one a parameter, one a local) and the one we
1494 want is the local, which lookup_symbol will find for us.
1495 This includes gcc1 (not gcc2) on the sparc when passing a
1496 small structure and gcc2 when the argument type is float
1497 and it is passed as a double and converted to float by
1498 the prologue (in the latter case the type of the LOC_ARG
1499 symbol is double and the type of the LOC_LOCAL symbol is
1500 float). There are also LOC_ARG/LOC_REGISTER pairs which
1501 are not combined in symbol-reading. */
1502 /* But if the parameter name is null, don't try it.
1503 Null parameter names occur on the RS/6000, for traceback tables.
1504 FIXME, should we even print them? */
1506 if (*SYMBOL_NAME (sym
))
1509 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1511 /* Print the current arg. */
1513 fprintf_filtered (stream
, ", ");
1515 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1516 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1517 fputs_filtered ("=", stream
);
1519 /* Avoid value_print because it will deref ref parameters. We just
1520 want to print their addresses. Print ??? for args whose address
1521 we do not know. We pass 2 as "recurse" to val_print because our
1522 standard indentation here is 4 spaces, and val_print indents
1523 2 for each recurse. */
1524 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1526 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1527 stream
, 0, 0, 2, Val_no_prettyprint
);
1529 fputs_filtered ("???", stream
);
1533 /* Don't print nameless args in situations where we don't know
1534 enough about the stack to find them. */
1539 if (highest_offset
== -1)
1540 start
= FRAME_ARGS_SKIP
;
1542 start
= highest_offset
;
1544 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1549 /* Print nameless args on STREAM.
1550 FI is the frameinfo for this frame, START is the offset
1551 of the first nameless arg, and NUM is the number of nameless args to
1552 print. FIRST is nonzero if this is the first argument (not just
1553 the first nameless arg). */
1555 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1556 struct frame_info
*fi
;
1566 for (i
= 0; i
< num
; i
++)
1569 #ifdef NAMELESS_ARG_VALUE
1570 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1572 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1576 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1580 fprintf_filtered (stream
, ", ");
1582 #ifdef PRINT_NAMELESS_INTEGER
1583 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1585 #ifdef PRINT_TYPELESS_INTEGER
1586 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1588 fprintf_filtered (stream
, "%d", arg_value
);
1589 #endif /* PRINT_TYPELESS_INTEGER */
1590 #endif /* PRINT_NAMELESS_INTEGER */
1592 start
+= sizeof (int);
1596 /* Make makeva* work on an __INT_VARARGS_H machine. */
1598 #if defined (__INT_VARARGS_H)
1599 /* This is used on an 88k. Not sure whether it is used by anything else. */
1600 #define MAKEVA_END(list) \
1602 retval.__va_arg = 0; \
1603 retval.__va_stk = (int *) (list)->aligner.arg_bytes; \
1604 retval.__va_reg = (int *) (list)->aligner.arg_bytes; \
1608 /* This is an interface which allows to us make a va_list. */
1611 unsigned int max_arg_size
;
1613 /* Current position in bytes. */
1614 unsigned int argindex
;
1616 #ifdef MAKEVA_EXTRA_INFO
1617 /* For host dependent information. */
1621 /* Some systems (mips, pa) would like this to be aligned, and it never
1626 double force_double_align
;
1627 LONGEST force_long_align
;
1631 /* Tell the caller how many bytes to allocate for a makeva_list with NARGS
1632 arguments and whose largest argument is MAX_ARG_SIZE bytes. This
1633 way the caller can use alloca, malloc, or some other allocator. */
1635 makeva_size (nargs
, max_arg_size
)
1637 unsigned int max_arg_size
;
1639 return sizeof (makeva_list
) + nargs
* max_arg_size
;
1642 /* Start working on LIST with NARGS arguments and whose largest
1643 argument is MAX_ARG_SIZE bytes. */
1645 makeva_start (list
, nargs
, max_arg_size
)
1648 unsigned int max_arg_size
;
1650 list
->nargs
= nargs
;
1651 list
->max_arg_size
= max_arg_size
;
1652 #if defined (MAKEVA_START)
1653 MAKEVA_START (list
);
1659 /* Add ARG to LIST. */
1661 makeva_arg (list
, argaddr
, argsize
)
1664 unsigned int argsize
;
1666 #if defined (MAKEVA_ARG)
1667 MAKEVA_ARG (list
, argaddr
, argsize
);
1669 memcpy (&list
->aligner
.arg_bytes
[list
->argindex
], argaddr
, argsize
);
1670 list
->argindex
+= argsize
;
1674 /* From LIST, for which makeva_arg has been called for each arg,
1675 return a va_list containing the args. */
1680 #if defined (MAKEVA_END)
1683 /* This works if a va_list is just a pointer to the arguments. */
1684 return (va_list) list
->aligner
.arg_bytes
;
1690 printf_command (arg
, from_tty
)
1695 register char *s
= arg
;
1699 int allocated_args
= 20;
1700 va_list args_to_vprintf
;
1702 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1705 error_no_arg ("format-control string and values to print");
1707 /* Skip white space before format string */
1708 while (*s
== ' ' || *s
== '\t') s
++;
1710 /* A format string should follow, enveloped in double quotes */
1712 error ("Bad format string, missing '\"'.");
1714 /* Parse the format-control string and copy it into the string STRING,
1715 processing some kinds of escape sequence. */
1717 f
= string
= (char *) alloca (strlen (s
) + 1);
1724 error ("Bad format string, non-terminated '\"'.");
1725 /* doesn't return */
1746 /* ??? TODO: handle other escape sequences */
1747 error ("Unrecognized \\ escape character in format string.");
1756 /* Skip over " and following space and comma. */
1759 while (*s
== ' ' || *s
== '\t') s
++;
1761 if (*s
!= ',' && *s
!= 0)
1762 error ("Invalid argument syntax");
1765 while (*s
== ' ' || *s
== '\t') s
++;
1768 /* Now scan the string for %-specs and see what kinds of args they want.
1769 argclass[I] classifies the %-specs so we can give vprintf something
1770 of the right size. */
1772 enum argclass
{int_arg
, string_arg
, double_arg
, long_long_arg
};
1773 enum argclass
*argclass
;
1777 makeva_list
*args_makeva
;
1779 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1786 while (strchr ("0123456789.hlL-+ #", *f
))
1788 if (*f
== 'l' || *f
== 'L')
1793 argclass
[nargs_wanted
++] = string_arg
;
1794 else if (*f
== 'e' || *f
== 'f' || *f
== 'g')
1795 argclass
[nargs_wanted
++] = double_arg
;
1796 else if (lcount
> 1)
1797 argclass
[nargs_wanted
++] = long_long_arg
;
1799 argclass
[nargs_wanted
++] = int_arg
;
1803 /* Now, parse all arguments and evaluate them.
1804 Store the VALUEs in VAL_ARGS. */
1809 if (nargs
== allocated_args
)
1810 val_args
= (value
*) xrealloc ((char *) val_args
,
1811 (allocated_args
*= 2)
1814 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1816 /* If format string wants a float, unchecked-convert the value to
1817 floating point of the same size */
1819 if (argclass
[nargs
] == double_arg
)
1821 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1822 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1823 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1824 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1832 if (nargs
!= nargs_wanted
)
1833 error ("Wrong number of arguments for specified format-string");
1835 /* Now lay out an argument-list containing the arguments
1836 as doubles, integers and C pointers. */
1838 args_makeva
= (makeva_list
*)
1839 alloca (makeva_size (nargs
, sizeof (double)));
1840 makeva_start (args_makeva
, nargs
, sizeof (double));
1841 for (i
= 0; i
< nargs
; i
++)
1843 if (argclass
[i
] == string_arg
)
1848 tem
= value_as_pointer (val_args
[i
]);
1850 /* This is a %s argument. Find the length of the string. */
1855 read_memory (tem
+ j
, &c
, 1);
1860 /* Copy the string contents into a string inside GDB. */
1861 str
= (char *) alloca (j
+ 1);
1862 read_memory (tem
, str
, j
);
1865 /* Pass address of internal copy as the arg to vprintf. */
1866 makeva_arg (args_makeva
, &str
, sizeof (str
));
1868 else if (VALUE_TYPE (val_args
[i
])->code
== TYPE_CODE_FLT
)
1870 double val
= value_as_double (val_args
[i
]);
1871 makeva_arg (args_makeva
, &val
, sizeof (val
));
1874 #ifdef CC_HAS_LONG_LONG
1875 if (argclass
[i
] == long_long_arg
)
1877 long long val
= value_as_long (val_args
[i
]);
1878 makeva_arg (args_makeva
, &val
, sizeof (val
));
1883 long val
= value_as_long (val_args
[i
]);
1884 makeva_arg (args_makeva
, &val
, sizeof (val
));
1887 args_to_vprintf
= makeva_end (args_makeva
);
1890 /* FIXME: We should be using vprintf_filtered, but as long as it has an
1891 arbitrary limit that is unacceptable. Correct fix is for vprintf_filtered
1892 to scan down the format string so it knows how big a buffer it needs.
1894 But for now, just force out any pending output, so at least the output
1895 appears in the correct order. */
1896 wrap_here ((char *)NULL
);
1897 vprintf (string
, args_to_vprintf
);
1900 /* Dump a specified section of assembly code. With no command line
1901 arguments, this command will dump the assembly code for the
1902 function surrounding the pc value in the selected frame. With one
1903 argument, it will dump the assembly code surrounding that pc value.
1904 Two arguments are interpeted as bounds within which to dump
1909 disassemble_command (arg
, from_tty
)
1913 CORE_ADDR low
, high
;
1921 if (!selected_frame
)
1922 error ("No frame selected.\n");
1924 pc
= get_frame_pc (selected_frame
);
1925 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1926 error ("No function contains program counter for selected frame.\n");
1928 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1931 pc
= parse_and_eval_address (arg
);
1932 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1933 error ("No function contains specified address.\n");
1937 /* Two arguments. */
1938 *space_index
= '\0';
1939 low
= parse_and_eval_address (arg
);
1940 high
= parse_and_eval_address (space_index
+ 1);
1943 printf_filtered ("Dump of assembler code ");
1946 printf_filtered ("for function %s:\n", name
);
1950 printf_filtered ("from %s ", local_hex_string(low
));
1951 printf_filtered ("to %s:\n", local_hex_string(high
));
1954 /* Dump the specified range. */
1955 for (pc
= low
; pc
< high
; )
1958 print_address (pc
, stdout
);
1959 printf_filtered (":\t");
1960 pc
+= print_insn (pc
, stdout
);
1961 printf_filtered ("\n");
1963 printf_filtered ("End of assembler dump.\n");
1969 _initialize_printcmd ()
1971 current_display_number
= -1;
1973 add_info ("address", address_info
,
1974 "Describe where variable VAR is stored.");
1976 add_com ("x", class_vars
, x_command
,
1977 "Examine memory: x/FMT ADDRESS.\n\
1978 ADDRESS is an expression for the memory address to examine.\n\
1979 FMT is a repeat count followed by a format letter and a size letter.\n\
1980 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
1981 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
1982 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
1983 The specified number of objects of the specified size are printed\n\
1984 according to the format.\n\n\
1985 Defaults for format and size letters are those previously used.\n\
1986 Default count is 1. Default address is following last thing printed\n\
1987 with this command or \"print\".");
1989 add_com ("disassemble", class_vars
, disassemble_command
,
1990 "Disassemble a specified section of memory.\n\
1991 Default is the function surrounding the pc of the selected frame.\n\
1992 With a single argument, the function surrounding that address is dumped.\n\
1993 Two arguments are taken as a range of memory to dump.");
1996 add_com ("whereis", class_vars
, whereis_command
,
1997 "Print line number and file of definition of variable.");
2000 add_info ("display", display_info
,
2001 "Expressions to display when program stops, with code numbers.");
2003 add_cmd ("undisplay", class_vars
, undisplay_command
,
2004 "Cancel some expressions to be displayed when program stops.\n\
2005 Arguments are the code numbers of the expressions to stop displaying.\n\
2006 No argument means cancel all automatic-display expressions.\n\
2007 \"delete display\" has the same effect as this command.\n\
2008 Do \"info display\" to see current list of code numbers.",
2011 add_com ("display", class_vars
, display_command
,
2012 "Print value of expression EXP each time the program stops.\n\
2013 /FMT may be used before EXP as in the \"print\" command.\n\
2014 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2015 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2016 and examining is done as in the \"x\" command.\n\n\
2017 With no argument, display all currently requested auto-display expressions.\n\
2018 Use \"undisplay\" to cancel display requests previously made.");
2020 add_cmd ("display", class_vars
, enable_display
,
2021 "Enable some expressions to be displayed when program stops.\n\
2022 Arguments are the code numbers of the expressions to resume displaying.\n\
2023 No argument means enable all automatic-display expressions.\n\
2024 Do \"info display\" to see current list of code numbers.", &enablelist
);
2026 add_cmd ("display", class_vars
, disable_display_command
,
2027 "Disable some expressions to be displayed when program stops.\n\
2028 Arguments are the code numbers of the expressions to stop displaying.\n\
2029 No argument means disable all automatic-display expressions.\n\
2030 Do \"info display\" to see current list of code numbers.", &disablelist
);
2032 add_cmd ("display", class_vars
, undisplay_command
,
2033 "Cancel some expressions to be displayed when program stops.\n\
2034 Arguments are the code numbers of the expressions to stop displaying.\n\
2035 No argument means cancel all automatic-display expressions.\n\
2036 Do \"info display\" to see current list of code numbers.", &deletelist
);
2038 add_com ("printf", class_vars
, printf_command
,
2039 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2040 This is useful for formatted output in user-defined commands.");
2041 add_com ("output", class_vars
, output_command
,
2042 "Like \"print\" but don't put in value history and don't print newline.\n\
2043 This is useful in user-defined commands.");
2045 add_prefix_cmd ("set", class_vars
, set_command
,
2046 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2047 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2048 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2049 with $), a register (a few standard names starting with $), or an actual\n\
2050 variable in the program being debugged. EXP is any valid expression.\n\
2051 Use \"set variable\" for variables with names identical to set subcommands.\n\
2052 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2053 You can see these environment settings with the \"show\" command.",
2054 &setlist
, "set ", 1, &cmdlist
);
2056 /* "call" is the same as "set", but handy for dbx users to call fns. */
2057 add_com ("call", class_vars
, call_command
,
2058 "Call a function in the program.\n\
2059 The argument is the function name and arguments, in the notation of the\n\
2060 current working language. The result is printed and saved in the value\n\
2061 history, if it is not void.");
2063 add_cmd ("variable", class_vars
, set_command
,
2064 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2065 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2066 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2067 with $), a register (a few standard names starting with $), or an actual\n\
2068 variable in the program being debugged. EXP is any valid expression.\n\
2069 This may usually be abbreviated to simply \"set\".",
2072 add_com ("print", class_vars
, print_command
,
2073 concat ("Print value of expression EXP.\n\
2074 Variables accessible are those of the lexical environment of the selected\n\
2075 stack frame, plus all those whose scope is global or an entire file.\n\
2077 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2078 $$NUM refers to NUM'th value back from the last one.\n\
2079 Names starting with $ refer to registers (with the values they would have\n\
2080 if the program were to return to the stack frame now selected, restoring\n\
2081 all registers saved by frames farther in) or else to debugger\n\
2082 \"convenience\" variables (any such name not a known register).\n\
2083 Use assignment expressions to give values to convenience variables.\n",
2085 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2086 @ is a binary operator for treating consecutive data objects\n\
2087 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2088 element is FOO, whose second element is stored in the space following\n\
2089 where FOO is stored, etc. FOO must be an expression whose value\n\
2090 resides in memory.\n",
2092 EXP may be preceded with /FMT, where FMT is a format letter\n\
2093 but no count or size letter (see \"x\" command).", NULL
));
2094 add_com_alias ("p", "print", class_vars
, 1);
2096 add_com ("inspect", class_vars
, inspect_command
,
2097 "Same as \"print\" command, except that if you are running in the epoch\n\
2098 environment, the value is printed in its own window.");
2101 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2102 (char *)&max_symbolic_offset
,
2103 "Set the largest offset that will be printed in <symbol+1234> form.",
2107 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2108 (char *)&print_symbol_filename
,
2109 "Set printing of source filename and line number with <symbol>.",