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 /* These are just for containing_function_bounds. It might be better
36 to move containing_function_bounds to blockframe.c or thereabouts. */
41 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
42 extern int addressprint
; /* Whether to print hex addresses in HLL " */
51 /* Last specified output format. */
53 static char last_format
= 'x';
55 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
57 static char last_size
= 'w';
59 /* Default address to examine next. */
61 static CORE_ADDR next_address
;
63 /* Last address examined. */
65 static CORE_ADDR last_examine_address
;
67 /* Contents of last address examined.
68 This is not valid past the end of the `x' command! */
70 static value last_examine_value
;
72 /* Largest offset between a symbolic value and an address, that will be
73 printed as `0x1234 <symbol+offset>'. */
75 static unsigned int max_symbolic_offset
= UINT_MAX
;
77 /* Append the source filename and linenumber of the symbol when
78 printing a symbolic value as `<symbol at filename:linenum>' if set. */
79 static int print_symbol_filename
= 0;
81 /* Number of auto-display expression currently being displayed.
82 So that we can disable it if we get an error or a signal within it.
83 -1 when not doing one. */
85 int current_display_number
;
87 /* Flag to low-level print routines that this value is being printed
88 in an epoch window. We'd like to pass this as a parameter, but
89 every routine would need to take it. Perhaps we can encapsulate
90 this in the I/O stream once we have GNU stdio. */
96 /* Chain link to next auto-display item. */
98 /* Expression to be evaluated and displayed. */
99 struct expression
*exp
;
100 /* Item number of this auto-display item. */
102 /* Display format specified. */
103 struct format_data format
;
104 /* Innermost block required by this expression when evaluated */
106 /* Status of this display (enabled or disabled) */
110 /* Chain of expressions whose values should be displayed
111 automatically each time the program stops. */
113 static struct display
*display_chain
;
115 static int display_number
;
117 /* Prototypes for local functions */
120 delete_display
PARAMS ((int));
123 enable_display
PARAMS ((char *, int));
126 disable_display_command
PARAMS ((char *, int));
129 disassemble_command
PARAMS ((char *, int));
132 containing_function_bounds
PARAMS ((CORE_ADDR
, CORE_ADDR
*, CORE_ADDR
*));
135 printf_command
PARAMS ((char *, int));
138 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
142 display_info
PARAMS ((char *, int));
145 do_one_display
PARAMS ((struct display
*));
148 undisplay_command
PARAMS ((char *, int));
151 free_display
PARAMS ((struct display
*));
154 display_command
PARAMS ((char *, int));
157 x_command
PARAMS ((char *, int));
160 address_info
PARAMS ((char *, int));
163 set_command
PARAMS ((char *, int));
166 output_command
PARAMS ((char *, int));
169 call_command
PARAMS ((char *, int));
172 inspect_command
PARAMS ((char *, int));
175 print_command
PARAMS ((char *, int));
178 print_command_1
PARAMS ((char *, int, int));
181 validate_format
PARAMS ((struct format_data
, char *));
184 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
187 print_formatted
PARAMS ((value
, int, int));
189 static struct format_data
190 decode_format
PARAMS ((char **, int, int));
193 /* Decode a format specification. *STRING_PTR should point to it.
194 OFORMAT and OSIZE are used as defaults for the format and size
195 if none are given in the format specification.
196 If OSIZE is zero, then the size field of the returned value
197 should be set only if a size is explicitly specified by the
199 The structure returned describes all the data
200 found in the specification. In addition, *STRING_PTR is advanced
201 past the specification and past all whitespace following it. */
203 static struct format_data
204 decode_format (string_ptr
, oformat
, osize
)
209 struct format_data val
;
210 register char *p
= *string_ptr
;
216 if (*p
>= '0' && *p
<= '9')
217 val
.count
= atoi (p
);
218 while (*p
>= '0' && *p
<= '9') p
++;
220 /* Now process size or format letters that follow. */
224 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
226 #ifdef CC_HAS_LONG_LONG
233 else if (*p
>= 'a' && *p
<= 'z')
239 #ifndef CC_HAS_LONG_LONG
240 /* Make sure 'g' size is not used on integer types.
241 Well, actually, we can handle hex. */
242 if (val
.size
== 'g' && val
.format
!= 'f' && val
.format
!= 'x')
246 while (*p
== ' ' || *p
== '\t') p
++;
249 /* Set defaults for format and size if not specified. */
250 if (val
.format
== '?')
254 /* Neither has been specified. */
255 val
.format
= oformat
;
259 /* If a size is specified, any format makes a reasonable
260 default except 'i'. */
261 val
.format
= oformat
== 'i' ? 'x' : oformat
;
263 else if (val
.size
== '?')
268 /* Addresses must be words. */
269 val
.size
= osize
? 'w' : osize
;
272 /* Floating point has to be word or giantword. */
273 if (osize
== 'w' || osize
== 'g')
276 /* Default it to giantword if the last used size is not
278 val
.size
= osize
? 'g' : osize
;
281 /* Characters default to one byte. */
282 val
.size
= osize
? 'b' : osize
;
285 /* The default is the size most recently specified. */
292 /* Print value VAL on stdout according to FORMAT, a letter or 0.
293 Do not end with a newline.
294 0 means print VAL according to its own type.
295 SIZE is the letter for the size of datum being printed.
296 This is used to pad hex numbers so they line up. */
299 print_formatted (val
, format
, size
)
304 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
306 if (VALUE_LVAL (val
) == lval_memory
)
307 next_address
= VALUE_ADDRESS (val
) + len
;
312 next_address
= VALUE_ADDRESS (val
)
313 + value_print (value_addr (val
), stdout
, format
, Val_pretty_default
);
317 /* The old comment says
318 "Force output out, print_insn not using _filtered".
319 I'm not completely sure what that means, I suspect most print_insn
320 now do use _filtered, so I guess it's obsolete. */
321 /* We often wrap here if there are long symbolic names. */
323 next_address
= VALUE_ADDRESS (val
)
324 + print_insn (VALUE_ADDRESS (val
), stdout
);
329 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
330 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
331 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
332 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
333 || VALUE_REPEATED (val
))
334 value_print (val
, stdout
, format
, Val_pretty_default
);
336 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
337 format
, size
, stdout
);
341 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
342 according to letters FORMAT and SIZE on STREAM.
343 FORMAT may not be zero. Formats s and i are not supported at this level.
345 This is how the elements of an array or structure are printed
349 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
357 int len
= TYPE_LENGTH (type
);
359 if (len
> sizeof (LONGEST
)
367 /* We can't print it normally, but we can print it in hex.
368 Printing it in the wrong radix is more useful than saying
369 "use /x, you dummy". */
370 /* FIXME: we could also do octal or binary if that was the
372 /* FIXME: we should be using the size field to give us a minimum
373 field width to print. */
374 val_print_type_code_int (type
, valaddr
, stream
);
378 val_long
= unpack_long (type
, valaddr
);
380 /* If value is unsigned, truncate it in case negative. */
383 if (len
== sizeof (char))
384 val_long
&= (1 << 8 * sizeof(char)) - 1;
385 else if (len
== sizeof (short))
386 val_long
&= (1 << 8 * sizeof(short)) - 1;
387 else if (len
== sizeof (long))
388 val_long
&= (unsigned long) - 1;
396 /* no size specified, like in print. Print varying # of digits. */
397 print_longest (stream
, 'x', 1, val_long
);
406 print_longest (stream
, size
, 1, val_long
);
409 error ("Undefined output size \"%c\".", size
);
414 print_longest (stream
, 'd', 1, val_long
);
418 print_longest (stream
, 'u', 0, val_long
);
423 print_longest (stream
, 'o', 1, val_long
);
425 fprintf_filtered (stream
, "0");
429 print_address (unpack_pointer (type
, valaddr
), stream
);
433 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
438 if (len
== sizeof (float))
439 type
= builtin_type_float
;
440 else if (len
== sizeof (double))
441 type
= builtin_type_double
;
442 print_floating (valaddr
, type
, stream
);
449 /* Binary; 't' stands for "two". */
451 char bits
[8*(sizeof val_long
) + 1];
456 width
= 8*(sizeof val_long
);
473 error ("Undefined output size \"%c\".", size
);
479 bits
[width
] = (val_long
& 1) ? '1' : '0';
484 while (*cp
&& *cp
== '0')
489 fprintf_filtered (stream
, local_binary_format_prefix());
490 fprintf_filtered (stream
, cp
);
491 fprintf_filtered (stream
, local_binary_format_suffix());
496 error ("Undefined output format \"%c\".", format
);
500 /* Specify default address for `x' command.
501 `info lines' uses this. */
504 set_next_address (addr
)
509 /* Make address available to the user as $_. */
510 set_internalvar (lookup_internalvar ("_"),
511 value_from_longest (lookup_pointer_type (builtin_type_void
),
515 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
516 after LEADIN. Print nothing if no symbolic name is found nearby.
517 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
518 or to interpret it as a possible C++ name and convert it back to source
519 form. However note that DO_DEMANGLE can be overridden by the specific
520 settings of the demangle and asm_demangle variables. */
523 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
529 CORE_ADDR name_location
;
530 register struct symbol
*symbol
;
533 /* First try to find the address in the symbol tables to find
534 static functions. If that doesn't succeed we try the minimal symbol
535 vector for symbols in non-text space.
536 FIXME: Should find a way to get at the static non-text symbols too. */
538 symbol
= find_pc_function (addr
);
541 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
543 name
= SYMBOL_SOURCE_NAME (symbol
);
545 name
= SYMBOL_LINKAGE_NAME (symbol
);
549 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (addr
);
551 /* If nothing comes out, don't print anything symbolic. */
554 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
556 name
= SYMBOL_SOURCE_NAME (msymbol
);
558 name
= SYMBOL_LINKAGE_NAME (msymbol
);
561 /* If the nearest symbol is too far away, don't print anything symbolic. */
563 /* For when CORE_ADDR is larger than unsigned int, we do math in
564 CORE_ADDR. But when we detect unsigned wraparound in the
565 CORE_ADDR math, we ignore this test and print the offset,
566 because addr+max_symbolic_offset has wrapped through the end
567 of the address space back to the beginning, giving bogus comparison. */
568 if (addr
> name_location
+ max_symbolic_offset
569 && name_location
+ max_symbolic_offset
> name_location
)
572 fputs_filtered (leadin
, stream
);
573 fputs_filtered ("<", stream
);
574 fputs_filtered (name
, stream
);
575 if (addr
!= name_location
)
576 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
578 /* Append source filename and line number if desired. */
579 if (symbol
&& print_symbol_filename
)
581 struct symtab_and_line sal
;
583 sal
= find_pc_line (addr
, 0);
585 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
587 fputs_filtered (">", stream
);
590 /* Print address ADDR symbolically on STREAM.
591 First print it as a number. Then perhaps print
592 <SYMBOL + OFFSET> after the number. */
595 print_address (addr
, stream
)
599 #ifdef ADDR_BITS_REMOVE
600 fprintf_filtered (stream
, local_hex_format(), ADDR_BITS_REMOVE(addr
));
602 fprintf_filtered (stream
, local_hex_format(), addr
);
604 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
607 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
608 controls whether to print the symbolic name "raw" or demangled.
609 Global setting "addressprint" controls whether to print hex address
613 print_address_demangle (addr
, stream
, do_demangle
)
619 fprintf_filtered (stream
, "0");
620 } else if (addressprint
) {
621 fprintf_filtered (stream
, local_hex_format(), addr
);
622 print_address_symbolic (addr
, stream
, do_demangle
, " ");
624 print_address_symbolic (addr
, stream
, do_demangle
, "");
629 /* Examine data at address ADDR in format FMT.
630 Fetch it from memory and print on stdout. */
633 do_examine (fmt
, addr
)
634 struct format_data fmt
;
637 register char format
= 0;
639 register int count
= 1;
640 struct type
*val_type
;
642 register int maxelts
;
649 /* String or instruction format implies fetch single bytes
650 regardless of the specified size. */
651 if (format
== 's' || format
== 'i')
655 val_type
= builtin_type_char
;
656 else if (size
== 'h')
657 val_type
= builtin_type_short
;
658 else if (size
== 'w')
659 val_type
= builtin_type_long
;
660 else if (size
== 'g')
661 #ifndef CC_HAS_LONG_LONG
662 val_type
= builtin_type_double
;
664 val_type
= builtin_type_long_long
;
672 if (format
== 's' || format
== 'i')
675 /* Print as many objects as specified in COUNT, at most maxelts per line,
676 with the address of the next one at the start of each line. */
680 print_address (next_address
, stdout
);
681 printf_filtered (":");
686 printf_filtered ("\t");
687 /* Note that print_formatted sets next_address for the next
689 last_examine_address
= next_address
;
690 last_examine_value
= value_at (val_type
, next_address
);
691 print_formatted (last_examine_value
, format
, size
);
693 printf_filtered ("\n");
699 validate_format (fmt
, cmdname
)
700 struct format_data fmt
;
704 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
706 error ("Item count other than 1 is meaningless in \"%s\" command.",
708 if (fmt
.format
== 'i' || fmt
.format
== 's')
709 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
710 fmt
.format
, cmdname
);
713 /* Evaluate string EXP as an expression in the current language and
714 print the resulting value. EXP may contain a format specifier as the
715 first argument ("/x myvar" for example, to print myvar in hex).
719 print_command_1 (exp
, inspect
, voidprint
)
724 struct expression
*expr
;
725 register struct cleanup
*old_chain
= 0;
726 register char format
= 0;
728 struct format_data fmt
;
731 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
732 inspect_it
= inspect
;
734 if (exp
&& *exp
== '/')
737 fmt
= decode_format (&exp
, last_format
, 0);
738 validate_format (fmt
, "print");
739 last_format
= format
= fmt
.format
;
750 extern int objectprint
;
752 expr
= parse_expression (exp
);
753 old_chain
= make_cleanup (free_current_contents
, &expr
);
755 val
= evaluate_expression (expr
);
757 /* C++: figure out what type we actually want to print it as. */
758 type
= VALUE_TYPE (val
);
761 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
762 || TYPE_CODE (type
) == TYPE_CODE_REF
)
763 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
764 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
768 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
772 type
= VALUE_TYPE (val
);
777 val
= access_value_history (0);
779 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
780 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
782 int histindex
= record_latest_value (val
);
785 printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
787 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
789 print_formatted (val
, format
, fmt
.size
);
790 printf_filtered ("\n");
796 do_cleanups (old_chain
);
797 inspect_it
= 0; /* Reset print routines to normal */
802 print_command (exp
, from_tty
)
806 print_command_1 (exp
, 0, 1);
809 /* Same as print, except in epoch, it gets its own window */
812 inspect_command (exp
, from_tty
)
816 extern int epoch_interface
;
818 print_command_1 (exp
, epoch_interface
, 1);
821 /* Same as print, except it doesn't print void results. */
824 call_command (exp
, from_tty
)
828 print_command_1 (exp
, 0, 0);
833 output_command (exp
, from_tty
)
837 struct expression
*expr
;
838 register struct cleanup
*old_chain
;
839 register char format
= 0;
841 struct format_data fmt
;
843 if (exp
&& *exp
== '/')
846 fmt
= decode_format (&exp
, 0, 0);
847 validate_format (fmt
, "output");
851 expr
= parse_expression (exp
);
852 old_chain
= make_cleanup (free_current_contents
, &expr
);
854 val
= evaluate_expression (expr
);
856 print_formatted (val
, format
, fmt
.size
);
858 do_cleanups (old_chain
);
863 set_command (exp
, from_tty
)
867 struct expression
*expr
= parse_expression (exp
);
868 register struct cleanup
*old_chain
869 = make_cleanup (free_current_contents
, &expr
);
870 evaluate_expression (expr
);
871 do_cleanups (old_chain
);
876 address_info (exp
, from_tty
)
880 register struct symbol
*sym
;
881 register struct minimal_symbol
*msymbol
;
883 register long basereg
;
884 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
885 if exp is a field of `this'. */
888 error ("Argument required.");
890 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
891 &is_a_field_of_this
, (struct symtab
**)NULL
);
894 if (is_a_field_of_this
)
896 printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp
);
900 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
903 printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n",
904 exp
, local_hex_string(SYMBOL_VALUE_ADDRESS (msymbol
)));
906 error ("No symbol \"%s\" in current context.", exp
);
910 printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym
));
911 val
= SYMBOL_VALUE (sym
);
912 basereg
= SYMBOL_BASEREG (sym
);
914 switch (SYMBOL_CLASS (sym
))
917 case LOC_CONST_BYTES
:
922 printf ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym
)));
926 printf ("a variable in register %s", reg_names
[val
]);
930 printf ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym
)));
934 printf ("an argument in register %s", reg_names
[val
]);
937 case LOC_REGPARM_ADDR
:
938 printf ("address of an argument in register %s", reg_names
[val
]);
942 if (SYMBOL_BASEREG_VALID (sym
))
944 printf ("an argument at offset %ld from register %s",
945 val
, reg_names
[basereg
]);
949 printf ("an argument at offset %ld", val
);
954 if (SYMBOL_BASEREG_VALID (sym
))
956 printf ("an argument at offset %ld from register %s",
957 val
, reg_names
[basereg
]);
961 printf ("an argument at frame offset %ld", val
);
966 if (SYMBOL_BASEREG_VALID (sym
))
968 printf ("a local variable at offset %ld from register %s",
969 val
, reg_names
[basereg
]);
973 printf ("a local variable at frame offset %ld", val
);
978 printf ("a reference argument at offset %ld", val
);
982 printf ("a typedef");
986 printf ("a function at address %s",
987 local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym
))));
990 case LOC_OPTIMIZED_OUT
:
991 printf_filtered ("optimized out");
995 printf ("of unknown (botched) type");
1002 x_command (exp
, from_tty
)
1006 struct expression
*expr
;
1007 struct format_data fmt
;
1008 struct cleanup
*old_chain
;
1011 fmt
.format
= last_format
;
1012 fmt
.size
= last_size
;
1015 if (exp
&& *exp
== '/')
1018 fmt
= decode_format (&exp
, last_format
, last_size
);
1021 /* If we have an expression, evaluate it and use it as the address. */
1023 if (exp
!= 0 && *exp
!= 0)
1025 expr
= parse_expression (exp
);
1026 /* Cause expression not to be there any more
1027 if this command is repeated with Newline.
1028 But don't clobber a user-defined command's definition. */
1031 old_chain
= make_cleanup (free_current_contents
, &expr
);
1032 val
= evaluate_expression (expr
);
1033 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1034 val
= value_ind (val
);
1035 /* In rvalue contexts, such as this, functions are coerced into
1036 pointers to functions. This makes "x/i main" work. */
1037 if (/* last_format == 'i'
1038 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1039 && VALUE_LVAL (val
) == lval_memory
)
1040 next_address
= VALUE_ADDRESS (val
);
1042 next_address
= value_as_pointer (val
);
1043 do_cleanups (old_chain
);
1046 do_examine (fmt
, next_address
);
1048 /* If the examine succeeds, we remember its size and format for next time. */
1049 last_size
= fmt
.size
;
1050 last_format
= fmt
.format
;
1052 /* Set a couple of internal variables if appropriate. */
1053 if (last_examine_value
)
1055 /* Make last address examined available to the user as $_. Use
1056 the correct pointer type. */
1057 set_internalvar (lookup_internalvar ("_"),
1058 value_from_longest (
1059 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1060 (LONGEST
) last_examine_address
));
1062 /* Make contents of last address examined available to the user as $__.*/
1063 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1068 /* Add an expression to the auto-display chain.
1069 Specify the expression. */
1072 display_command (exp
, from_tty
)
1076 struct format_data fmt
;
1077 register struct expression
*expr
;
1078 register struct display
*new;
1089 fmt
= decode_format (&exp
, 0, 0);
1090 if (fmt
.size
&& fmt
.format
== 0)
1092 if (fmt
.format
== 'i' || fmt
.format
== 's')
1102 innermost_block
= 0;
1103 expr
= parse_expression (exp
);
1105 new = (struct display
*) xmalloc (sizeof (struct display
));
1108 new->block
= innermost_block
;
1109 new->next
= display_chain
;
1110 new->number
= ++display_number
;
1112 new->status
= enabled
;
1113 display_chain
= new;
1115 if (from_tty
&& target_has_execution
)
1116 do_one_display (new);
1129 /* Clear out the display_chain.
1130 Done when new symtabs are loaded, since this invalidates
1131 the types stored in many expressions. */
1136 register struct display
*d
;
1138 while ((d
= display_chain
) != NULL
)
1141 display_chain
= d
->next
;
1146 /* Delete the auto-display number NUM. */
1149 delete_display (num
)
1152 register struct display
*d1
, *d
;
1155 error ("No display number %d.", num
);
1157 if (display_chain
->number
== num
)
1160 display_chain
= d1
->next
;
1164 for (d
= display_chain
; ; d
= d
->next
)
1167 error ("No display number %d.", num
);
1168 if (d
->next
->number
== num
)
1178 /* Delete some values from the auto-display chain.
1179 Specify the element numbers. */
1182 undisplay_command (args
, from_tty
)
1186 register char *p
= args
;
1192 if (query ("Delete all auto-display expressions? "))
1201 while (*p1
>= '0' && *p1
<= '9') p1
++;
1202 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1203 error ("Arguments must be display numbers.");
1207 delete_display (num
);
1210 while (*p
== ' ' || *p
== '\t') p
++;
1215 /* Display a single auto-display.
1216 Do nothing if the display cannot be printed in the current context,
1217 or if the display is disabled. */
1223 int within_current_scope
;
1225 if (d
->status
== disabled
)
1229 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1231 within_current_scope
= 1;
1232 if (!within_current_scope
)
1235 current_display_number
= d
->number
;
1237 printf_filtered ("%d: ", d
->number
);
1242 printf_filtered ("x/");
1243 if (d
->format
.count
!= 1)
1244 printf_filtered ("%d", d
->format
.count
);
1245 printf_filtered ("%c", d
->format
.format
);
1246 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1247 printf_filtered ("%c", d
->format
.size
);
1248 printf_filtered (" ");
1249 print_expression (d
->exp
, stdout
);
1250 if (d
->format
.count
!= 1)
1251 printf_filtered ("\n");
1253 printf_filtered (" ");
1255 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1256 if (d
->format
.format
== 'i')
1257 addr
= ADDR_BITS_REMOVE (addr
);
1259 do_examine (d
->format
, addr
);
1263 if (d
->format
.format
)
1264 printf_filtered ("/%c ", d
->format
.format
);
1265 print_expression (d
->exp
, stdout
);
1266 printf_filtered (" = ");
1267 print_formatted (evaluate_expression (d
->exp
),
1268 d
->format
.format
, d
->format
.size
);
1269 printf_filtered ("\n");
1273 current_display_number
= -1;
1276 /* Display all of the values on the auto-display chain which can be
1277 evaluated in the current scope. */
1282 register struct display
*d
;
1284 for (d
= display_chain
; d
; d
= d
->next
)
1288 /* Delete the auto-display which we were in the process of displaying.
1289 This is done when there is an error or a signal. */
1292 disable_display (num
)
1295 register struct display
*d
;
1297 for (d
= display_chain
; d
; d
= d
->next
)
1298 if (d
->number
== num
)
1300 d
->status
= disabled
;
1303 printf ("No display number %d.\n", num
);
1307 disable_current_display ()
1309 if (current_display_number
>= 0)
1311 disable_display (current_display_number
);
1312 fprintf (stderr
, "Disabling display %d to avoid infinite recursion.\n",
1313 current_display_number
);
1315 current_display_number
= -1;
1319 display_info (ignore
, from_tty
)
1323 register struct display
*d
;
1326 printf ("There are no auto-display expressions now.\n");
1328 printf_filtered ("Auto-display expressions now in effect:\n\
1329 Num Enb Expression\n");
1331 for (d
= display_chain
; d
; d
= d
->next
)
1333 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1335 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1337 else if (d
->format
.format
)
1338 printf_filtered ("/%c ", d
->format
.format
);
1339 print_expression (d
->exp
, stdout
);
1340 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1341 printf_filtered (" (cannot be evaluated in the current context)");
1342 printf_filtered ("\n");
1348 enable_display (args
, from_tty
)
1352 register char *p
= args
;
1355 register struct display
*d
;
1359 for (d
= display_chain
; d
; d
= d
->next
)
1360 d
->status
= enabled
;
1366 while (*p1
>= '0' && *p1
<= '9')
1368 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1369 error ("Arguments must be display numbers.");
1373 for (d
= display_chain
; d
; d
= d
->next
)
1374 if (d
->number
== num
)
1376 d
->status
= enabled
;
1379 printf ("No display number %d.\n", num
);
1382 while (*p
== ' ' || *p
== '\t')
1389 disable_display_command (args
, from_tty
)
1393 register char *p
= args
;
1395 register struct display
*d
;
1399 for (d
= display_chain
; d
; d
= d
->next
)
1400 d
->status
= disabled
;
1406 while (*p1
>= '0' && *p1
<= '9')
1408 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1409 error ("Arguments must be display numbers.");
1411 disable_display (atoi (p
));
1414 while (*p
== ' ' || *p
== '\t')
1420 /* Print the value in stack frame FRAME of a variable
1421 specified by a struct symbol. */
1424 print_variable_value (var
, frame
, stream
)
1429 value val
= read_var_value (var
, frame
);
1430 value_print (val
, stream
, 0, Val_pretty_default
);
1433 /* Print the arguments of a stack frame, given the function FUNC
1434 running in that frame (as a symbol), the info on the frame,
1435 and the number of args according to the stack frame (or -1 if unknown). */
1437 /* References here and elsewhere to "number of args according to the
1438 stack frame" appear in all cases to refer to "number of ints of args
1439 according to the stack frame". At least for VAX, i386, isi. */
1442 print_frame_args (func
, fi
, num
, stream
)
1443 struct symbol
*func
;
1444 struct frame_info
*fi
;
1452 register struct symbol
*sym
;
1454 /* Offset of next stack argument beyond the one we have seen that is
1455 at the highest offset.
1456 -1 if we haven't come to a stack argument yet. */
1457 long highest_offset
= -1;
1459 /* Number of ints of arguments that we have printed so far. */
1460 int args_printed
= 0;
1464 b
= SYMBOL_BLOCK_VALUE (func
);
1465 nsyms
= BLOCK_NSYMS (b
);
1468 for (i
= 0; i
< nsyms
; i
++)
1471 sym
= BLOCK_SYM (b
, i
);
1473 /* Keep track of the highest stack argument offset seen, and
1474 skip over any kinds of symbols we don't care about. */
1476 switch (SYMBOL_CLASS (sym
)) {
1480 long current_offset
= SYMBOL_VALUE (sym
);
1482 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1484 /* Compute address of next argument by adding the size of
1485 this argument and rounding to an int boundary. */
1487 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1488 & ~(sizeof (int) - 1));
1490 /* If this is the highest offset seen yet, set highest_offset. */
1491 if (highest_offset
== -1
1492 || (current_offset
> highest_offset
))
1493 highest_offset
= current_offset
;
1495 /* Add the number of ints we're about to print to args_printed. */
1496 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1499 /* We care about types of symbols, but don't need to keep track of
1500 stack offsets in them. */
1502 case LOC_REGPARM_ADDR
:
1506 /* Other types of symbols we just skip over. */
1511 /* We have to look up the symbol because arguments can have
1512 two entries (one a parameter, one a local) and the one we
1513 want is the local, which lookup_symbol will find for us.
1514 This includes gcc1 (not gcc2) on the sparc when passing a
1515 small structure and gcc2 when the argument type is float
1516 and it is passed as a double and converted to float by
1517 the prologue (in the latter case the type of the LOC_ARG
1518 symbol is double and the type of the LOC_LOCAL symbol is
1519 float). There are also LOC_ARG/LOC_REGISTER pairs which
1520 are not combined in symbol-reading. */
1521 /* But if the parameter name is null, don't try it.
1522 Null parameter names occur on the RS/6000, for traceback tables.
1523 FIXME, should we even print them? */
1525 if (*SYMBOL_NAME (sym
))
1528 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1530 /* Print the current arg. */
1532 fprintf_filtered (stream
, ", ");
1534 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1535 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1536 fputs_filtered ("=", stream
);
1538 /* Avoid value_print because it will deref ref parameters. We just
1539 want to print their addresses. Print ??? for args whose address
1540 we do not know. We pass 2 as "recurse" to val_print because our
1541 standard indentation here is 4 spaces, and val_print indents
1542 2 for each recurse. */
1543 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1545 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1546 stream
, 0, 0, 2, Val_no_prettyprint
);
1548 fputs_filtered ("???", stream
);
1552 /* Don't print nameless args in situations where we don't know
1553 enough about the stack to find them. */
1558 if (highest_offset
== -1)
1559 start
= FRAME_ARGS_SKIP
;
1561 start
= highest_offset
;
1563 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1568 /* Print nameless args on STREAM.
1569 FI is the frameinfo for this frame, START is the offset
1570 of the first nameless arg, and NUM is the number of nameless args to
1571 print. FIRST is nonzero if this is the first argument (not just
1572 the first nameless arg). */
1574 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1575 struct frame_info
*fi
;
1585 for (i
= 0; i
< num
; i
++)
1588 #ifdef NAMELESS_ARG_VALUE
1589 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1591 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1595 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1599 fprintf_filtered (stream
, ", ");
1601 #ifdef PRINT_NAMELESS_INTEGER
1602 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1604 #ifdef PRINT_TYPELESS_INTEGER
1605 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1607 fprintf_filtered (stream
, "%d", arg_value
);
1608 #endif /* PRINT_TYPELESS_INTEGER */
1609 #endif /* PRINT_NAMELESS_INTEGER */
1611 start
+= sizeof (int);
1615 /* Make makeva* work on an __INT_VARARGS_H machine. */
1617 #if defined (__INT_VARARGS_H)
1618 /* This is used on an 88k. Not sure whether it is used by anything else. */
1619 #define MAKEVA_END(list) \
1621 retval.__va_arg = 0; \
1622 retval.__va_stk = (int *) (list)->arg_bytes; \
1623 retval.__va_reg = (int *) (list)->arg_bytes; \
1627 /* This is an interface which allows to us make a va_list. */
1630 unsigned int max_arg_size
;
1632 /* Current position in bytes. */
1633 unsigned int argindex
;
1638 /* Tell the caller how many bytes to allocate for a makeva_list with NARGS
1639 arguments and whose largest argument is MAX_ARG_SIZE bytes. This
1640 way the caller can use alloca, malloc, or some other allocator. */
1642 makeva_size (nargs
, max_arg_size
)
1644 unsigned int max_arg_size
;
1646 return sizeof (makeva_list
) + nargs
* max_arg_size
;
1649 /* Start working on LIST with NARGS arguments and whose largest
1650 argument is MAX_ARG_SIZE bytes. */
1652 makeva_start (list
, nargs
, max_arg_size
)
1655 unsigned int max_arg_size
;
1657 list
->nargs
= nargs
;
1658 list
->max_arg_size
= max_arg_size
;
1659 #if defined (MAKEVA_START)
1660 MAKEVA_START (list
);
1666 /* Add ARG to LIST. */
1668 makeva_arg (list
, argaddr
, argsize
)
1671 unsigned int argsize
;
1673 #if defined (MAKEVA_ARG)
1674 MAKEVA_ARG (list
, argaddr
, argsize
);
1676 memcpy (&list
->arg_bytes
[list
->argindex
], argaddr
, argsize
);
1677 list
->argindex
+= argsize
;
1681 /* From LIST, for which makeva_arg has been called for each arg,
1682 return a va_list containing the args. */
1687 #if defined (MAKEVA_END)
1690 /* This works if a va_list is just a pointer to the arguments. */
1691 return (va_list) list
->arg_bytes
;
1697 printf_command (arg
, from_tty
)
1702 register char *s
= arg
;
1706 int allocated_args
= 20;
1707 va_list args_to_vprintf
;
1709 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1712 error_no_arg ("format-control string and values to print");
1714 /* Skip white space before format string */
1715 while (*s
== ' ' || *s
== '\t') s
++;
1717 /* A format string should follow, enveloped in double quotes */
1719 error ("Bad format string, missing '\"'.");
1721 /* Parse the format-control string and copy it into the string STRING,
1722 processing some kinds of escape sequence. */
1724 f
= string
= (char *) alloca (strlen (s
) + 1);
1731 error ("Bad format string, non-terminated '\"'.");
1732 /* doesn't return */
1753 /* ??? TODO: handle other escape sequences */
1754 error ("Unrecognized \\ escape character in format string.");
1763 /* Skip over " and following space and comma. */
1766 while (*s
== ' ' || *s
== '\t') s
++;
1768 if (*s
!= ',' && *s
!= 0)
1769 error ("Invalid argument syntax");
1772 while (*s
== ' ' || *s
== '\t') s
++;
1775 /* Now scan the string for %-specs and see what kinds of args they want.
1776 argclass[I] classifies the %-specs so we can give vprintf something
1777 of the right size. */
1779 enum argclass
{int_arg
, string_arg
, double_arg
, long_long_arg
};
1780 enum argclass
*argclass
;
1784 makeva_list
*args_makeva
;
1786 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1793 while (strchr ("0123456789.hlL-+ #", *f
))
1795 if (*f
== 'l' || *f
== 'L')
1800 argclass
[nargs_wanted
++] = string_arg
;
1801 else if (*f
== 'e' || *f
== 'f' || *f
== 'g')
1802 argclass
[nargs_wanted
++] = double_arg
;
1803 else if (lcount
> 1)
1804 argclass
[nargs_wanted
++] = long_long_arg
;
1806 argclass
[nargs_wanted
++] = int_arg
;
1810 /* Now, parse all arguments and evaluate them.
1811 Store the VALUEs in VAL_ARGS. */
1816 if (nargs
== allocated_args
)
1817 val_args
= (value
*) xrealloc ((char *) val_args
,
1818 (allocated_args
*= 2)
1821 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1823 /* If format string wants a float, unchecked-convert the value to
1824 floating point of the same size */
1826 if (argclass
[nargs
] == double_arg
)
1828 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1829 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1830 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1831 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1839 if (nargs
!= nargs_wanted
)
1840 error ("Wrong number of arguments for specified format-string");
1842 /* Now lay out an argument-list containing the arguments
1843 as doubles, integers and C pointers. */
1845 args_makeva
= (makeva_list
*)
1846 alloca (makeva_size (nargs
, sizeof (double)));
1847 makeva_start (args_makeva
, nargs
, sizeof (double));
1848 for (i
= 0; i
< nargs
; i
++)
1850 if (argclass
[i
] == string_arg
)
1855 tem
= value_as_pointer (val_args
[i
]);
1857 /* This is a %s argument. Find the length of the string. */
1862 read_memory (tem
+ j
, &c
, 1);
1867 /* Copy the string contents into a string inside GDB. */
1868 str
= (char *) alloca (j
+ 1);
1869 read_memory (tem
, str
, j
);
1872 /* Pass address of internal copy as the arg to vprintf. */
1873 makeva_arg (args_makeva
, &str
, sizeof (str
));
1875 else if (VALUE_TYPE (val_args
[i
])->code
== TYPE_CODE_FLT
)
1877 double val
= value_as_double (val_args
[i
]);
1878 makeva_arg (args_makeva
, &val
, sizeof (val
));
1881 #ifdef CC_HAS_LONG_LONG
1882 if (argclass
[i
] == long_long_arg
)
1884 long long val
= value_as_long (val_args
[i
]);
1885 makeva_arg (args_makeva
, &val
, sizeof (val
));
1890 long val
= value_as_long (val_args
[i
]);
1891 makeva_arg (args_makeva
, &val
, sizeof (val
));
1894 args_to_vprintf
= makeva_end (args_makeva
);
1897 /* FIXME: We should be using vprintf_filtered, but as long as it has an
1898 arbitrary limit that is unacceptable. Correct fix is for vprintf_filtered
1899 to scan down the format string so it knows how big a buffer it needs.
1901 But for now, just force out any pending output, so at least the output
1902 appears in the correct order. */
1903 wrap_here ((char *)NULL
);
1904 vprintf (string
, args_to_vprintf
);
1907 /* Helper function for asdump_command. Finds the bounds of a function
1908 for a specified section of text. PC is an address within the
1909 function which you want bounds for; *LOW and *HIGH are set to the
1910 beginning (inclusive) and end (exclusive) of the function. This
1911 function returns 1 on success and 0 on failure. */
1914 containing_function_bounds (pc
, low
, high
)
1915 CORE_ADDR pc
, *low
, *high
;
1919 struct obj_section
*sec
;
1921 if (!find_pc_partial_function (pc
, 0, low
))
1924 sec
= find_pc_section (pc
);
1927 limit
= sec
->endaddr
;
1930 while (scan
< limit
)
1933 if (!find_pc_partial_function (scan
, 0, high
))
1942 /* Dump a specified section of assembly code. With no command line
1943 arguments, this command will dump the assembly code for the
1944 function surrounding the pc value in the selected frame. With one
1945 argument, it will dump the assembly code surrounding that pc value.
1946 Two arguments are interpeted as bounds within which to dump
1951 disassemble_command (arg
, from_tty
)
1955 CORE_ADDR low
, high
;
1961 if (!selected_frame
)
1962 error ("No frame selected.\n");
1964 pc
= get_frame_pc (selected_frame
);
1965 if (!containing_function_bounds (pc
, &low
, &high
))
1966 error ("No function contains pc specified by selected frame.\n");
1968 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1971 pc
= parse_and_eval_address (arg
);
1972 if (!containing_function_bounds (pc
, &low
, &high
))
1973 error ("No function contains specified pc.\n");
1977 /* Two arguments. */
1978 *space_index
= '\0';
1979 low
= parse_and_eval_address (arg
);
1980 high
= parse_and_eval_address (space_index
+ 1);
1983 printf_filtered ("Dump of assembler code ");
1987 find_pc_partial_function (pc
, &name
, 0);
1988 printf_filtered ("for function %s:\n", name
);
1992 printf_filtered ("from %s ", local_hex_string(low
));
1993 printf_filtered ("to %s:\n", local_hex_string(high
));
1996 /* Dump the specified range. */
1997 for (pc
= low
; pc
< high
; )
2000 print_address (pc
, stdout
);
2001 printf_filtered (":\t");
2002 pc
+= print_insn (pc
, stdout
);
2003 printf_filtered ("\n");
2005 printf_filtered ("End of assembler dump.\n");
2011 _initialize_printcmd ()
2013 current_display_number
= -1;
2015 add_info ("address", address_info
,
2016 "Describe where variable VAR is stored.");
2018 add_com ("x", class_vars
, x_command
,
2019 "Examine memory: x/FMT ADDRESS.\n\
2020 ADDRESS is an expression for the memory address to examine.\n\
2021 FMT is a repeat count followed by a format letter and a size letter.\n\
2022 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2023 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2024 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2025 The specified number of objects of the specified size are printed\n\
2026 according to the format.\n\n\
2027 Defaults for format and size letters are those previously used.\n\
2028 Default count is 1. Default address is following last thing printed\n\
2029 with this command or \"print\".");
2031 add_com ("disassemble", class_vars
, disassemble_command
,
2032 "Disassemble a specified section of memory.\n\
2033 Default is the function surrounding the pc of the selected frame.\n\
2034 With a single argument, the function surrounding that address is dumped.\n\
2035 Two arguments are taken as a range of memory to dump.");
2038 add_com ("whereis", class_vars
, whereis_command
,
2039 "Print line number and file of definition of variable.");
2042 add_info ("display", display_info
,
2043 "Expressions to display when program stops, with code numbers.");
2045 add_cmd ("undisplay", class_vars
, undisplay_command
,
2046 "Cancel some expressions to be displayed when program stops.\n\
2047 Arguments are the code numbers of the expressions to stop displaying.\n\
2048 No argument means cancel all automatic-display expressions.\n\
2049 \"delete display\" has the same effect as this command.\n\
2050 Do \"info display\" to see current list of code numbers.",
2053 add_com ("display", class_vars
, display_command
,
2054 "Print value of expression EXP each time the program stops.\n\
2055 /FMT may be used before EXP as in the \"print\" command.\n\
2056 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2057 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2058 and examining is done as in the \"x\" command.\n\n\
2059 With no argument, display all currently requested auto-display expressions.\n\
2060 Use \"undisplay\" to cancel display requests previously made.");
2062 add_cmd ("display", class_vars
, enable_display
,
2063 "Enable some expressions to be displayed when program stops.\n\
2064 Arguments are the code numbers of the expressions to resume displaying.\n\
2065 No argument means enable all automatic-display expressions.\n\
2066 Do \"info display\" to see current list of code numbers.", &enablelist
);
2068 add_cmd ("display", class_vars
, disable_display_command
,
2069 "Disable some expressions to be displayed when program stops.\n\
2070 Arguments are the code numbers of the expressions to stop displaying.\n\
2071 No argument means disable all automatic-display expressions.\n\
2072 Do \"info display\" to see current list of code numbers.", &disablelist
);
2074 add_cmd ("display", class_vars
, undisplay_command
,
2075 "Cancel some expressions to be displayed when program stops.\n\
2076 Arguments are the code numbers of the expressions to stop displaying.\n\
2077 No argument means cancel all automatic-display expressions.\n\
2078 Do \"info display\" to see current list of code numbers.", &deletelist
);
2080 add_com ("printf", class_vars
, printf_command
,
2081 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2082 This is useful for formatted output in user-defined commands.");
2083 add_com ("output", class_vars
, output_command
,
2084 "Like \"print\" but don't put in value history and don't print newline.\n\
2085 This is useful in user-defined commands.");
2087 add_prefix_cmd ("set", class_vars
, set_command
,
2088 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2089 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2090 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2091 with $), a register (a few standard names starting with $), or an actual\n\
2092 variable in the program being debugged. EXP is any valid expression.\n\
2093 Use \"set variable\" for variables with names identical to set subcommands.\n\
2094 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2095 You can see these environment settings with the \"show\" command.",
2096 &setlist
, "set ", 1, &cmdlist
);
2098 /* "call" is the same as "set", but handy for dbx users to call fns. */
2099 add_com ("call", class_vars
, call_command
,
2100 "Call a function in the program.\n\
2101 The argument is the function name and arguments, in the notation of the\n\
2102 current working language. The result is printed and saved in the value\n\
2103 history, if it is not void.");
2105 add_cmd ("variable", class_vars
, set_command
,
2106 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2107 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2108 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2109 with $), a register (a few standard names starting with $), or an actual\n\
2110 variable in the program being debugged. EXP is any valid expression.\n\
2111 This may usually be abbreviated to simply \"set\".",
2114 add_com ("print", class_vars
, print_command
,
2115 concat ("Print value of expression EXP.\n\
2116 Variables accessible are those of the lexical environment of the selected\n\
2117 stack frame, plus all those whose scope is global or an entire file.\n\
2119 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2120 $$NUM refers to NUM'th value back from the last one.\n\
2121 Names starting with $ refer to registers (with the values they would have\n\
2122 if the program were to return to the stack frame now selected, restoring\n\
2123 all registers saved by frames farther in) or else to debugger\n\
2124 \"convenience\" variables (any such name not a known register).\n\
2125 Use assignment expressions to give values to convenience variables.\n",
2127 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2128 @ is a binary operator for treating consecutive data objects\n\
2129 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2130 element is FOO, whose second element is stored in the space following\n\
2131 where FOO is stored, etc. FOO must be an expression whose value\n\
2132 resides in memory.\n",
2134 EXP may be preceded with /FMT, where FMT is a format letter\n\
2135 but no count or size letter (see \"x\" command).", NULL
));
2136 add_com_alias ("p", "print", class_vars
, 1);
2138 add_com ("inspect", class_vars
, inspect_command
,
2139 "Same as \"print\" command, except that if you are running in the epoch\n\
2140 environment, the value is printed in its own window.");
2143 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2144 (char *)&max_symbolic_offset
,
2145 "Set the largest offset that will be printed in <symbol+1234> form.",
2149 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2150 (char *)&print_symbol_filename
,
2151 "Set printing of source filename and line number with <symbol>.",