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"
36 extern int asm_demangle
; /* Whether to demangle syms in asm printouts */
37 extern int addressprint
; /* Whether to print hex addresses in HLL " */
46 /* Last specified output format. */
48 static char last_format
= 'x';
50 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
52 static char last_size
= 'w';
54 /* Default address to examine next. */
56 static CORE_ADDR next_address
;
58 /* Last address examined. */
60 static CORE_ADDR last_examine_address
;
62 /* Contents of last address examined.
63 This is not valid past the end of the `x' command! */
65 static value last_examine_value
;
67 /* Largest offset between a symbolic value and an address, that will be
68 printed as `0x1234 <symbol+offset>'. */
70 static unsigned int max_symbolic_offset
= UINT_MAX
;
72 /* Append the source filename and linenumber of the symbol when
73 printing a symbolic value as `<symbol at filename:linenum>' if set. */
74 static int print_symbol_filename
= 0;
76 /* Number of auto-display expression currently being displayed.
77 So that we can disable it if we get an error or a signal within it.
78 -1 when not doing one. */
80 int current_display_number
;
82 /* Flag to low-level print routines that this value is being printed
83 in an epoch window. We'd like to pass this as a parameter, but
84 every routine would need to take it. Perhaps we can encapsulate
85 this in the I/O stream once we have GNU stdio. */
91 /* Chain link to next auto-display item. */
93 /* Expression to be evaluated and displayed. */
94 struct expression
*exp
;
95 /* Item number of this auto-display item. */
97 /* Display format specified. */
98 struct format_data format
;
99 /* Innermost block required by this expression when evaluated */
101 /* Status of this display (enabled or disabled) */
105 /* Chain of expressions whose values should be displayed
106 automatically each time the program stops. */
108 static struct display
*display_chain
;
110 static int display_number
;
112 /* Prototypes for local functions */
115 delete_display
PARAMS ((int));
118 enable_display
PARAMS ((char *, int));
121 disable_display_command
PARAMS ((char *, int));
124 disassemble_command
PARAMS ((char *, int));
127 printf_command
PARAMS ((char *, int));
130 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
134 display_info
PARAMS ((char *, int));
137 do_one_display
PARAMS ((struct display
*));
140 undisplay_command
PARAMS ((char *, int));
143 free_display
PARAMS ((struct display
*));
146 display_command
PARAMS ((char *, int));
149 x_command
PARAMS ((char *, int));
152 address_info
PARAMS ((char *, int));
155 set_command
PARAMS ((char *, int));
158 output_command
PARAMS ((char *, int));
161 call_command
PARAMS ((char *, int));
164 inspect_command
PARAMS ((char *, int));
167 print_command
PARAMS ((char *, int));
170 print_command_1
PARAMS ((char *, int, int));
173 validate_format
PARAMS ((struct format_data
, char *));
176 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
179 print_formatted
PARAMS ((value
, int, int));
181 static struct format_data
182 decode_format
PARAMS ((char **, int, int));
185 /* Decode a format specification. *STRING_PTR should point to it.
186 OFORMAT and OSIZE are used as defaults for the format and size
187 if none are given in the format specification.
188 If OSIZE is zero, then the size field of the returned value
189 should be set only if a size is explicitly specified by the
191 The structure returned describes all the data
192 found in the specification. In addition, *STRING_PTR is advanced
193 past the specification and past all whitespace following it. */
195 static struct format_data
196 decode_format (string_ptr
, oformat
, osize
)
201 struct format_data val
;
202 register char *p
= *string_ptr
;
208 if (*p
>= '0' && *p
<= '9')
209 val
.count
= atoi (p
);
210 while (*p
>= '0' && *p
<= '9') p
++;
212 /* Now process size or format letters that follow. */
216 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
218 else if (*p
>= 'a' && *p
<= 'z')
224 #ifndef CC_HAS_LONG_LONG
225 /* Make sure 'g' size is not used on integer types.
226 Well, actually, we can handle hex. */
227 if (val
.size
== 'g' && val
.format
!= 'f' && val
.format
!= 'x')
231 while (*p
== ' ' || *p
== '\t') p
++;
234 /* Set defaults for format and size if not specified. */
235 if (val
.format
== '?')
239 /* Neither has been specified. */
240 val
.format
= oformat
;
244 /* If a size is specified, any format makes a reasonable
245 default except 'i'. */
246 val
.format
= oformat
== 'i' ? 'x' : oformat
;
248 else if (val
.size
== '?')
253 /* Addresses must be words. */
254 val
.size
= osize
? 'w' : osize
;
257 /* Floating point has to be word or giantword. */
258 if (osize
== 'w' || osize
== 'g')
261 /* Default it to giantword if the last used size is not
263 val
.size
= osize
? 'g' : osize
;
266 /* Characters default to one byte. */
267 val
.size
= osize
? 'b' : osize
;
270 /* The default is the size most recently specified. */
277 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
278 Do not end with a newline.
279 0 means print VAL according to its own type.
280 SIZE is the letter for the size of datum being printed.
281 This is used to pad hex numbers so they line up. */
284 print_formatted (val
, format
, size
)
289 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
291 if (VALUE_LVAL (val
) == lval_memory
)
292 next_address
= VALUE_ADDRESS (val
) + len
;
297 next_address
= VALUE_ADDRESS (val
)
298 + value_print (value_addr (val
), gdb_stdout
, format
, Val_pretty_default
);
302 /* The old comment says
303 "Force output out, print_insn not using _filtered".
304 I'm not completely sure what that means, I suspect most print_insn
305 now do use _filtered, so I guess it's obsolete. */
306 /* We often wrap here if there are long symbolic names. */
308 next_address
= VALUE_ADDRESS (val
)
309 + print_insn (VALUE_ADDRESS (val
), gdb_stdout
);
314 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
315 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
316 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
317 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
318 || VALUE_REPEATED (val
))
319 value_print (val
, gdb_stdout
, format
, Val_pretty_default
);
321 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
322 format
, size
, gdb_stdout
);
326 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
327 according to letters FORMAT and SIZE on STREAM.
328 FORMAT may not be zero. Formats s and i are not supported at this level.
330 This is how the elements of an array or structure are printed
334 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
342 int len
= TYPE_LENGTH (type
);
344 if (len
> sizeof (LONGEST
)
352 /* We can't print it normally, but we can print it in hex.
353 Printing it in the wrong radix is more useful than saying
354 "use /x, you dummy". */
355 /* FIXME: we could also do octal or binary if that was the
357 /* FIXME: we should be using the size field to give us a minimum
358 field width to print. */
359 val_print_type_code_int (type
, valaddr
, stream
);
363 val_long
= unpack_long (type
, valaddr
);
365 /* If we are printing it as unsigned, truncate it in case it is actually
366 a negative signed value (e.g. "print/u (short)-1" should print 65535
367 (if shorts are 16 bits) instead of 4294967295). */
370 if (len
< sizeof (LONGEST
))
371 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
379 /* no size specified, like in print. Print varying # of digits. */
380 print_longest (stream
, 'x', 1, val_long
);
389 print_longest (stream
, size
, 1, val_long
);
392 error ("Undefined output size \"%c\".", size
);
397 print_longest (stream
, 'd', 1, val_long
);
401 print_longest (stream
, 'u', 0, val_long
);
406 print_longest (stream
, 'o', 1, val_long
);
408 fprintf_filtered (stream
, "0");
412 print_address (unpack_pointer (type
, valaddr
), stream
);
416 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
421 if (len
== sizeof (float))
422 type
= builtin_type_float
;
423 else if (len
== sizeof (double))
424 type
= builtin_type_double
;
425 print_floating (valaddr
, type
, stream
);
432 /* Binary; 't' stands for "two". */
434 char bits
[8*(sizeof val_long
) + 1];
439 width
= 8*(sizeof val_long
);
456 error ("Undefined output size \"%c\".", size
);
462 bits
[width
] = (val_long
& 1) ? '1' : '0';
467 while (*cp
&& *cp
== '0')
472 fprintf_filtered (stream
, local_binary_format_prefix());
473 fprintf_filtered (stream
, cp
);
474 fprintf_filtered (stream
, local_binary_format_suffix());
479 error ("Undefined output format \"%c\".", format
);
483 /* Specify default address for `x' command.
484 `info lines' uses this. */
487 set_next_address (addr
)
492 /* Make address available to the user as $_. */
493 set_internalvar (lookup_internalvar ("_"),
494 value_from_longest (lookup_pointer_type (builtin_type_void
),
498 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
499 after LEADIN. Print nothing if no symbolic name is found nearby.
500 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
501 or to interpret it as a possible C++ name and convert it back to source
502 form. However note that DO_DEMANGLE can be overridden by the specific
503 settings of the demangle and asm_demangle variables. */
506 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
512 CORE_ADDR name_location
;
513 register struct symbol
*symbol
;
516 /* First try to find the address in the symbol tables to find
517 static functions. If that doesn't succeed we try the minimal symbol
518 vector for symbols in non-text space.
519 FIXME: Should find a way to get at the static non-text symbols too. */
521 symbol
= find_pc_function (addr
);
524 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
526 name
= SYMBOL_SOURCE_NAME (symbol
);
528 name
= SYMBOL_LINKAGE_NAME (symbol
);
532 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (addr
);
534 /* If nothing comes out, don't print anything symbolic. */
537 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
539 name
= SYMBOL_SOURCE_NAME (msymbol
);
541 name
= SYMBOL_LINKAGE_NAME (msymbol
);
544 /* If the nearest symbol is too far away, don't print anything symbolic. */
546 /* For when CORE_ADDR is larger than unsigned int, we do math in
547 CORE_ADDR. But when we detect unsigned wraparound in the
548 CORE_ADDR math, we ignore this test and print the offset,
549 because addr+max_symbolic_offset has wrapped through the end
550 of the address space back to the beginning, giving bogus comparison. */
551 if (addr
> name_location
+ max_symbolic_offset
552 && name_location
+ max_symbolic_offset
> name_location
)
555 fputs_filtered (leadin
, stream
);
556 fputs_filtered ("<", stream
);
557 fputs_filtered (name
, stream
);
558 if (addr
!= name_location
)
559 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
561 /* Append source filename and line number if desired. */
562 if (symbol
&& print_symbol_filename
)
564 struct symtab_and_line sal
;
566 sal
= find_pc_line (addr
, 0);
568 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
570 fputs_filtered (">", stream
);
573 /* Print address ADDR symbolically on STREAM.
574 First print it as a number. Then perhaps print
575 <SYMBOL + OFFSET> after the number. */
578 print_address (addr
, stream
)
582 #if 0 && defined (ADDR_BITS_REMOVE)
583 /* This is wrong for pointer to char, in which we do want to print
585 fprintf_filtered (stream
, local_hex_format(),
586 (unsigned long) ADDR_BITS_REMOVE(addr
));
588 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
590 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
593 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
594 controls whether to print the symbolic name "raw" or demangled.
595 Global setting "addressprint" controls whether to print hex address
599 print_address_demangle (addr
, stream
, do_demangle
)
605 fprintf_filtered (stream
, "0");
606 } else if (addressprint
) {
607 fprintf_filtered (stream
, local_hex_format(), (unsigned long) addr
);
608 print_address_symbolic (addr
, stream
, do_demangle
, " ");
610 print_address_symbolic (addr
, stream
, do_demangle
, "");
615 /* These are the types that $__ will get after an examine command of one
618 static struct type
*examine_b_type
;
619 static struct type
*examine_h_type
;
620 static struct type
*examine_w_type
;
621 static struct type
*examine_g_type
;
623 /* Examine data at address ADDR in format FMT.
624 Fetch it from memory and print on gdb_stdout. */
627 do_examine (fmt
, addr
)
628 struct format_data fmt
;
631 register char format
= 0;
633 register int count
= 1;
634 struct type
*val_type
= NULL
;
636 register int maxelts
;
643 /* String or instruction format implies fetch single bytes
644 regardless of the specified size. */
645 if (format
== 's' || format
== 'i')
649 val_type
= examine_b_type
;
650 else if (size
== 'h')
651 val_type
= examine_h_type
;
652 else if (size
== 'w')
653 val_type
= examine_w_type
;
654 else if (size
== 'g')
655 val_type
= examine_g_type
;
662 if (format
== 's' || format
== 'i')
665 /* Print as many objects as specified in COUNT, at most maxelts per line,
666 with the address of the next one at the start of each line. */
670 print_address (next_address
, gdb_stdout
);
671 printf_filtered (":");
676 printf_filtered ("\t");
677 /* Note that print_formatted sets next_address for the next
679 last_examine_address
= next_address
;
680 last_examine_value
= value_at (val_type
, next_address
);
681 print_formatted (last_examine_value
, format
, size
);
683 printf_filtered ("\n");
684 gdb_flush (gdb_stdout
);
689 validate_format (fmt
, cmdname
)
690 struct format_data fmt
;
694 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
696 error ("Item count other than 1 is meaningless in \"%s\" command.",
698 if (fmt
.format
== 'i' || fmt
.format
== 's')
699 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
700 fmt
.format
, cmdname
);
703 /* Evaluate string EXP as an expression in the current language and
704 print the resulting value. EXP may contain a format specifier as the
705 first argument ("/x myvar" for example, to print myvar in hex).
709 print_command_1 (exp
, inspect
, voidprint
)
714 struct expression
*expr
;
715 register struct cleanup
*old_chain
= 0;
716 register char format
= 0;
718 struct format_data fmt
;
721 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
722 inspect_it
= inspect
;
724 if (exp
&& *exp
== '/')
727 fmt
= decode_format (&exp
, last_format
, 0);
728 validate_format (fmt
, "print");
729 last_format
= format
= fmt
.format
;
740 extern int objectprint
;
742 expr
= parse_expression (exp
);
743 old_chain
= make_cleanup (free_current_contents
, &expr
);
745 val
= evaluate_expression (expr
);
747 /* C++: figure out what type we actually want to print it as. */
748 type
= VALUE_TYPE (val
);
751 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
752 || TYPE_CODE (type
) == TYPE_CODE_REF
)
753 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
754 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
758 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
762 type
= VALUE_TYPE (val
);
767 val
= access_value_history (0);
769 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
770 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
772 int histindex
= record_latest_value (val
);
775 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
777 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
779 print_formatted (val
, format
, fmt
.size
);
780 printf_filtered ("\n");
782 printf_unfiltered("\") )\030");
786 do_cleanups (old_chain
);
787 inspect_it
= 0; /* Reset print routines to normal */
792 print_command (exp
, from_tty
)
796 print_command_1 (exp
, 0, 1);
799 /* Same as print, except in epoch, it gets its own window */
802 inspect_command (exp
, from_tty
)
806 extern int epoch_interface
;
808 print_command_1 (exp
, epoch_interface
, 1);
811 /* Same as print, except it doesn't print void results. */
814 call_command (exp
, from_tty
)
818 print_command_1 (exp
, 0, 0);
823 output_command (exp
, from_tty
)
827 struct expression
*expr
;
828 register struct cleanup
*old_chain
;
829 register char format
= 0;
831 struct format_data fmt
;
833 if (exp
&& *exp
== '/')
836 fmt
= decode_format (&exp
, 0, 0);
837 validate_format (fmt
, "output");
841 expr
= parse_expression (exp
);
842 old_chain
= make_cleanup (free_current_contents
, &expr
);
844 val
= evaluate_expression (expr
);
846 print_formatted (val
, format
, fmt
.size
);
848 do_cleanups (old_chain
);
853 set_command (exp
, from_tty
)
857 struct expression
*expr
= parse_expression (exp
);
858 register struct cleanup
*old_chain
859 = make_cleanup (free_current_contents
, &expr
);
860 evaluate_expression (expr
);
861 do_cleanups (old_chain
);
866 address_info (exp
, from_tty
)
870 register struct symbol
*sym
;
871 register struct minimal_symbol
*msymbol
;
873 register long basereg
;
874 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
875 if exp is a field of `this'. */
878 error ("Argument required.");
880 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
881 &is_a_field_of_this
, (struct symtab
**)NULL
);
884 if (is_a_field_of_this
)
886 printf_unfiltered ("Symbol \"");
887 fprintf_symbol_filtered (gdb_stdout
, exp
,
888 current_language
->la_language
, DMGL_ANSI
);
889 printf_unfiltered ("\" is a field of the local class variable `this'\n");
893 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
897 printf_unfiltered ("Symbol \"");
898 fprintf_symbol_filtered (gdb_stdout
, exp
,
899 current_language
->la_language
, DMGL_ANSI
);
900 printf_unfiltered ("\" is at %s in a file compiled without debugging.\n",
901 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (msymbol
)));
904 error ("No symbol \"%s\" in current context.", exp
);
908 printf_unfiltered ("Symbol \"");
909 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_NAME (sym
),
910 current_language
->la_language
, DMGL_ANSI
);
911 printf_unfiltered ("\" is ", SYMBOL_NAME (sym
));
912 val
= SYMBOL_VALUE (sym
);
913 basereg
= SYMBOL_BASEREG (sym
);
915 switch (SYMBOL_CLASS (sym
))
918 case LOC_CONST_BYTES
:
919 printf_unfiltered ("constant");
923 printf_unfiltered ("a label at address %s",
924 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
928 printf_unfiltered ("a variable in register %s", reg_names
[val
]);
932 printf_unfiltered ("static storage at address %s",
933 local_hex_string((unsigned long) SYMBOL_VALUE_ADDRESS (sym
)));
937 printf_unfiltered ("an argument in register %s", reg_names
[val
]);
940 case LOC_REGPARM_ADDR
:
941 printf_unfiltered ("address of an argument in register %s", reg_names
[val
]);
945 printf_unfiltered ("an argument at offset %ld", val
);
949 printf_unfiltered ("an argument at frame offset %ld", val
);
953 printf_unfiltered ("a local variable at frame offset %ld", val
);
957 printf_unfiltered ("a reference argument at offset %ld", val
);
961 printf_unfiltered ("a variable at offset %ld from register %s",
962 val
, reg_names
[basereg
]);
965 case LOC_BASEREG_ARG
:
966 printf_unfiltered ("an argument at offset %ld from register %s",
967 val
, reg_names
[basereg
]);
971 printf_unfiltered ("a typedef");
975 printf_unfiltered ("a function at address %s",
976 local_hex_string((unsigned long) BLOCK_START (SYMBOL_BLOCK_VALUE (sym
))));
979 case LOC_OPTIMIZED_OUT
:
980 printf_filtered ("optimized out");
984 printf_unfiltered ("of unknown (botched) type");
987 printf_unfiltered (".\n");
991 x_command (exp
, from_tty
)
995 struct expression
*expr
;
996 struct format_data fmt
;
997 struct cleanup
*old_chain
;
1000 fmt
.format
= last_format
;
1001 fmt
.size
= last_size
;
1004 if (exp
&& *exp
== '/')
1007 fmt
= decode_format (&exp
, last_format
, last_size
);
1010 /* If we have an expression, evaluate it and use it as the address. */
1012 if (exp
!= 0 && *exp
!= 0)
1014 expr
= parse_expression (exp
);
1015 /* Cause expression not to be there any more
1016 if this command is repeated with Newline.
1017 But don't clobber a user-defined command's definition. */
1020 old_chain
= make_cleanup (free_current_contents
, &expr
);
1021 val
= evaluate_expression (expr
);
1022 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1023 val
= value_ind (val
);
1024 /* In rvalue contexts, such as this, functions are coerced into
1025 pointers to functions. This makes "x/i main" work. */
1026 if (/* last_format == 'i'
1027 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1028 && VALUE_LVAL (val
) == lval_memory
)
1029 next_address
= VALUE_ADDRESS (val
);
1031 next_address
= value_as_pointer (val
);
1032 do_cleanups (old_chain
);
1035 do_examine (fmt
, next_address
);
1037 /* If the examine succeeds, we remember its size and format for next time. */
1038 last_size
= fmt
.size
;
1039 last_format
= fmt
.format
;
1041 /* Set a couple of internal variables if appropriate. */
1042 if (last_examine_value
)
1044 /* Make last address examined available to the user as $_. Use
1045 the correct pointer type. */
1046 set_internalvar (lookup_internalvar ("_"),
1047 value_from_longest (
1048 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1049 (LONGEST
) last_examine_address
));
1051 /* Make contents of last address examined available to the user as $__.*/
1052 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1057 /* Add an expression to the auto-display chain.
1058 Specify the expression. */
1061 display_command (exp
, from_tty
)
1065 struct format_data fmt
;
1066 register struct expression
*expr
;
1067 register struct display
*new;
1078 fmt
= decode_format (&exp
, 0, 0);
1079 if (fmt
.size
&& fmt
.format
== 0)
1081 if (fmt
.format
== 'i' || fmt
.format
== 's')
1091 innermost_block
= 0;
1092 expr
= parse_expression (exp
);
1094 new = (struct display
*) xmalloc (sizeof (struct display
));
1097 new->block
= innermost_block
;
1098 new->next
= display_chain
;
1099 new->number
= ++display_number
;
1101 new->status
= enabled
;
1102 display_chain
= new;
1104 if (from_tty
&& target_has_execution
)
1105 do_one_display (new);
1118 /* Clear out the display_chain.
1119 Done when new symtabs are loaded, since this invalidates
1120 the types stored in many expressions. */
1125 register struct display
*d
;
1127 while ((d
= display_chain
) != NULL
)
1130 display_chain
= d
->next
;
1135 /* Delete the auto-display number NUM. */
1138 delete_display (num
)
1141 register struct display
*d1
, *d
;
1144 error ("No display number %d.", num
);
1146 if (display_chain
->number
== num
)
1149 display_chain
= d1
->next
;
1153 for (d
= display_chain
; ; d
= d
->next
)
1156 error ("No display number %d.", num
);
1157 if (d
->next
->number
== num
)
1167 /* Delete some values from the auto-display chain.
1168 Specify the element numbers. */
1171 undisplay_command (args
, from_tty
)
1175 register char *p
= args
;
1181 if (query ("Delete all auto-display expressions? "))
1190 while (*p1
>= '0' && *p1
<= '9') p1
++;
1191 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1192 error ("Arguments must be display numbers.");
1196 delete_display (num
);
1199 while (*p
== ' ' || *p
== '\t') p
++;
1204 /* Display a single auto-display.
1205 Do nothing if the display cannot be printed in the current context,
1206 or if the display is disabled. */
1212 int within_current_scope
;
1214 if (d
->status
== disabled
)
1218 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1220 within_current_scope
= 1;
1221 if (!within_current_scope
)
1224 current_display_number
= d
->number
;
1226 printf_filtered ("%d: ", d
->number
);
1231 printf_filtered ("x/");
1232 if (d
->format
.count
!= 1)
1233 printf_filtered ("%d", d
->format
.count
);
1234 printf_filtered ("%c", d
->format
.format
);
1235 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1236 printf_filtered ("%c", d
->format
.size
);
1237 printf_filtered (" ");
1238 print_expression (d
->exp
, gdb_stdout
);
1239 if (d
->format
.count
!= 1)
1240 printf_filtered ("\n");
1242 printf_filtered (" ");
1244 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1245 if (d
->format
.format
== 'i')
1246 addr
= ADDR_BITS_REMOVE (addr
);
1248 do_examine (d
->format
, addr
);
1252 if (d
->format
.format
)
1253 printf_filtered ("/%c ", d
->format
.format
);
1254 print_expression (d
->exp
, gdb_stdout
);
1255 printf_filtered (" = ");
1256 print_formatted (evaluate_expression (d
->exp
),
1257 d
->format
.format
, d
->format
.size
);
1258 printf_filtered ("\n");
1261 gdb_flush (gdb_stdout
);
1262 current_display_number
= -1;
1265 /* Display all of the values on the auto-display chain which can be
1266 evaluated in the current scope. */
1271 register struct display
*d
;
1273 for (d
= display_chain
; d
; d
= d
->next
)
1277 /* Delete the auto-display which we were in the process of displaying.
1278 This is done when there is an error or a signal. */
1281 disable_display (num
)
1284 register struct display
*d
;
1286 for (d
= display_chain
; d
; d
= d
->next
)
1287 if (d
->number
== num
)
1289 d
->status
= disabled
;
1292 printf_unfiltered ("No display number %d.\n", num
);
1296 disable_current_display ()
1298 if (current_display_number
>= 0)
1300 disable_display (current_display_number
);
1301 fprintf_unfiltered (gdb_stderr
, "Disabling display %d to avoid infinite recursion.\n",
1302 current_display_number
);
1304 current_display_number
= -1;
1308 display_info (ignore
, from_tty
)
1312 register struct display
*d
;
1315 printf_unfiltered ("There are no auto-display expressions now.\n");
1317 printf_filtered ("Auto-display expressions now in effect:\n\
1318 Num Enb Expression\n");
1320 for (d
= display_chain
; d
; d
= d
->next
)
1322 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1324 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1326 else if (d
->format
.format
)
1327 printf_filtered ("/%c ", d
->format
.format
);
1328 print_expression (d
->exp
, gdb_stdout
);
1329 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1330 printf_filtered (" (cannot be evaluated in the current context)");
1331 printf_filtered ("\n");
1332 gdb_flush (gdb_stdout
);
1337 enable_display (args
, from_tty
)
1341 register char *p
= args
;
1344 register struct display
*d
;
1348 for (d
= display_chain
; d
; d
= d
->next
)
1349 d
->status
= enabled
;
1355 while (*p1
>= '0' && *p1
<= '9')
1357 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1358 error ("Arguments must be display numbers.");
1362 for (d
= display_chain
; d
; d
= d
->next
)
1363 if (d
->number
== num
)
1365 d
->status
= enabled
;
1368 printf_unfiltered ("No display number %d.\n", num
);
1371 while (*p
== ' ' || *p
== '\t')
1378 disable_display_command (args
, from_tty
)
1382 register char *p
= args
;
1384 register struct display
*d
;
1388 for (d
= display_chain
; d
; d
= d
->next
)
1389 d
->status
= disabled
;
1395 while (*p1
>= '0' && *p1
<= '9')
1397 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1398 error ("Arguments must be display numbers.");
1400 disable_display (atoi (p
));
1403 while (*p
== ' ' || *p
== '\t')
1409 /* Print the value in stack frame FRAME of a variable
1410 specified by a struct symbol. */
1413 print_variable_value (var
, frame
, stream
)
1418 value val
= read_var_value (var
, frame
);
1419 value_print (val
, stream
, 0, Val_pretty_default
);
1422 /* Print the arguments of a stack frame, given the function FUNC
1423 running in that frame (as a symbol), the info on the frame,
1424 and the number of args according to the stack frame (or -1 if unknown). */
1426 /* References here and elsewhere to "number of args according to the
1427 stack frame" appear in all cases to refer to "number of ints of args
1428 according to the stack frame". At least for VAX, i386, isi. */
1431 print_frame_args (func
, fi
, num
, stream
)
1432 struct symbol
*func
;
1433 struct frame_info
*fi
;
1437 struct block
*b
= NULL
;
1441 register struct symbol
*sym
;
1443 /* Offset of next stack argument beyond the one we have seen that is
1444 at the highest offset.
1445 -1 if we haven't come to a stack argument yet. */
1446 long highest_offset
= -1;
1448 /* Number of ints of arguments that we have printed so far. */
1449 int args_printed
= 0;
1453 b
= SYMBOL_BLOCK_VALUE (func
);
1454 nsyms
= BLOCK_NSYMS (b
);
1457 for (i
= 0; i
< nsyms
; i
++)
1460 sym
= BLOCK_SYM (b
, i
);
1462 /* Keep track of the highest stack argument offset seen, and
1463 skip over any kinds of symbols we don't care about. */
1465 switch (SYMBOL_CLASS (sym
)) {
1469 long current_offset
= SYMBOL_VALUE (sym
);
1471 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1473 /* Compute address of next argument by adding the size of
1474 this argument and rounding to an int boundary. */
1476 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1477 & ~(sizeof (int) - 1));
1479 /* If this is the highest offset seen yet, set highest_offset. */
1480 if (highest_offset
== -1
1481 || (current_offset
> highest_offset
))
1482 highest_offset
= current_offset
;
1484 /* Add the number of ints we're about to print to args_printed. */
1485 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1488 /* We care about types of symbols, but don't need to keep track of
1489 stack offsets in them. */
1491 case LOC_REGPARM_ADDR
:
1493 case LOC_BASEREG_ARG
:
1496 /* Other types of symbols we just skip over. */
1501 /* We have to look up the symbol because arguments can have
1502 two entries (one a parameter, one a local) and the one we
1503 want is the local, which lookup_symbol will find for us.
1504 This includes gcc1 (not gcc2) on the sparc when passing a
1505 small structure and gcc2 when the argument type is float
1506 and it is passed as a double and converted to float by
1507 the prologue (in the latter case the type of the LOC_ARG
1508 symbol is double and the type of the LOC_LOCAL symbol is
1509 float). There are also LOC_ARG/LOC_REGISTER pairs which
1510 are not combined in symbol-reading. */
1511 /* But if the parameter name is null, don't try it.
1512 Null parameter names occur on the RS/6000, for traceback tables.
1513 FIXME, should we even print them? */
1515 if (*SYMBOL_NAME (sym
))
1518 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1520 /* Print the current arg. */
1522 fprintf_filtered (stream
, ", ");
1524 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1525 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1526 fputs_filtered ("=", stream
);
1528 /* Avoid value_print because it will deref ref parameters. We just
1529 want to print their addresses. Print ??? for args whose address
1530 we do not know. We pass 2 as "recurse" to val_print because our
1531 standard indentation here is 4 spaces, and val_print indents
1532 2 for each recurse. */
1533 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1535 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1536 stream
, 0, 0, 2, Val_no_prettyprint
);
1538 fputs_filtered ("???", stream
);
1542 /* Don't print nameless args in situations where we don't know
1543 enough about the stack to find them. */
1548 if (highest_offset
== -1)
1549 start
= FRAME_ARGS_SKIP
;
1551 start
= highest_offset
;
1553 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1558 /* Print nameless args on STREAM.
1559 FI is the frameinfo for this frame, START is the offset
1560 of the first nameless arg, and NUM is the number of nameless args to
1561 print. FIRST is nonzero if this is the first argument (not just
1562 the first nameless arg). */
1564 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1565 struct frame_info
*fi
;
1575 for (i
= 0; i
< num
; i
++)
1578 #ifdef NAMELESS_ARG_VALUE
1579 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1581 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1585 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1589 fprintf_filtered (stream
, ", ");
1591 #ifdef PRINT_NAMELESS_INTEGER
1592 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1594 #ifdef PRINT_TYPELESS_INTEGER
1595 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1597 fprintf_filtered (stream
, "%d", arg_value
);
1598 #endif /* PRINT_TYPELESS_INTEGER */
1599 #endif /* PRINT_NAMELESS_INTEGER */
1601 start
+= sizeof (int);
1607 printf_command (arg
, from_tty
)
1612 register char *s
= arg
;
1616 char *current_substring
;
1618 int allocated_args
= 20;
1619 struct cleanup
*old_cleanups
;
1621 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1622 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1625 error_no_arg ("format-control string and values to print");
1627 /* Skip white space before format string */
1628 while (*s
== ' ' || *s
== '\t') s
++;
1630 /* A format string should follow, enveloped in double quotes */
1632 error ("Bad format string, missing '\"'.");
1634 /* Parse the format-control string and copy it into the string STRING,
1635 processing some kinds of escape sequence. */
1637 f
= string
= (char *) alloca (strlen (s
) + 1);
1645 error ("Bad format string, non-terminated '\"'.");
1666 /* ??? TODO: handle other escape sequences */
1667 error ("Unrecognized \\ escape character in format string.");
1676 /* Skip over " and following space and comma. */
1679 while (*s
== ' ' || *s
== '\t') s
++;
1681 if (*s
!= ',' && *s
!= 0)
1682 error ("Invalid argument syntax");
1685 while (*s
== ' ' || *s
== '\t') s
++;
1687 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1688 substrings
= alloca (strlen (string
) * 2);
1689 current_substring
= substrings
;
1692 /* Now scan the string for %-specs and see what kinds of args they want.
1693 argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
1694 of the right size. */
1696 enum argclass
{no_arg
, int_arg
, string_arg
, double_arg
, long_long_arg
};
1697 enum argclass
*argclass
;
1698 enum argclass this_argclass
;
1704 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1712 while (strchr ("0123456789.hlL-+ #", *f
))
1714 if (*f
== 'l' || *f
== 'L')
1721 this_argclass
= string_arg
;
1727 this_argclass
= double_arg
;
1731 error ("`*' not supported for precision or width in printf");
1734 error ("Format specifier `n' not supported in printf");
1737 this_argclass
= no_arg
;
1742 this_argclass
= long_long_arg
;
1744 this_argclass
= int_arg
;
1748 if (this_argclass
!= no_arg
)
1750 strncpy (current_substring
, last_arg
, f
- last_arg
);
1751 current_substring
+= f
- last_arg
;
1752 *current_substring
++ = '\0';
1754 argclass
[nargs_wanted
++] = this_argclass
;
1758 /* Now, parse all arguments and evaluate them.
1759 Store the VALUEs in VAL_ARGS. */
1764 if (nargs
== allocated_args
)
1765 val_args
= (value
*) xrealloc ((char *) val_args
,
1766 (allocated_args
*= 2)
1769 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1771 /* If format string wants a float, unchecked-convert the value to
1772 floating point of the same size */
1774 if (argclass
[nargs
] == double_arg
)
1776 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1777 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1778 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1779 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1787 if (nargs
!= nargs_wanted
)
1788 error ("Wrong number of arguments for specified format-string");
1790 /* FIXME: We should be using vprintf_filtered, but as long as it
1791 has an arbitrary limit that is unacceptable. Correct fix is
1792 for vprintf_filtered to scan down the format string so it knows
1793 how big a buffer it needs (perhaps by putting a vasprintf (see
1794 GNU C library) in libiberty).
1796 But for now, just force out any pending output, so at least the output
1797 appears in the correct order. */
1798 wrap_here ((char *)NULL
);
1800 /* Now actually print them. */
1801 current_substring
= substrings
;
1802 for (i
= 0; i
< nargs
; i
++)
1804 switch (argclass
[i
])
1811 tem
= value_as_pointer (val_args
[i
]);
1813 /* This is a %s argument. Find the length of the string. */
1818 read_memory (tem
+ j
, &c
, 1);
1823 /* Copy the string contents into a string inside GDB. */
1824 str
= (char *) alloca (j
+ 1);
1825 read_memory (tem
, str
, j
);
1828 /* Don't use printf_filtered because of arbitrary limit. */
1829 printf_unfiltered (current_substring
, str
);
1834 double val
= value_as_double (val_args
[i
]);
1835 /* Don't use printf_filtered because of arbitrary limit. */
1836 printf_unfiltered (current_substring
, val
);
1840 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1842 long long val
= value_as_long (val_args
[i
]);
1843 /* Don't use printf_filtered because of arbitrary limit. */
1844 printf_unfiltered (current_substring
, val
);
1848 error ("long long not supported in printf");
1852 /* FIXME: there should be separate int_arg and long_arg. */
1853 long val
= value_as_long (val_args
[i
]);
1854 /* Don't use printf_filtered because of arbitrary limit. */
1855 printf_unfiltered (current_substring
, val
);
1859 error ("internal error in printf_command");
1861 /* Skip to the next substring. */
1862 current_substring
+= strlen (current_substring
) + 1;
1864 /* Print the portion of the format string after the last argument. */
1865 /* It would be OK to use printf_filtered here. */
1868 do_cleanups (old_cleanups
);
1871 /* Dump a specified section of assembly code. With no command line
1872 arguments, this command will dump the assembly code for the
1873 function surrounding the pc value in the selected frame. With one
1874 argument, it will dump the assembly code surrounding that pc value.
1875 Two arguments are interpeted as bounds within which to dump
1880 disassemble_command (arg
, from_tty
)
1884 CORE_ADDR low
, high
;
1892 if (!selected_frame
)
1893 error ("No frame selected.\n");
1895 pc
= get_frame_pc (selected_frame
);
1896 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1897 error ("No function contains program counter for selected frame.\n");
1899 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1902 pc
= parse_and_eval_address (arg
);
1903 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1904 error ("No function contains specified address.\n");
1908 /* Two arguments. */
1909 *space_index
= '\0';
1910 low
= parse_and_eval_address (arg
);
1911 high
= parse_and_eval_address (space_index
+ 1);
1914 printf_filtered ("Dump of assembler code ");
1917 printf_filtered ("for function %s:\n", name
);
1921 printf_filtered ("from %s ", local_hex_string((unsigned long) low
));
1922 printf_filtered ("to %s:\n", local_hex_string((unsigned long) high
));
1925 /* Dump the specified range. */
1926 for (pc
= low
; pc
< high
; )
1929 print_address (pc
, gdb_stdout
);
1930 printf_filtered (":\t");
1931 pc
+= print_insn (pc
, gdb_stdout
);
1932 printf_filtered ("\n");
1934 printf_filtered ("End of assembler dump.\n");
1935 gdb_flush (gdb_stdout
);
1940 _initialize_printcmd ()
1942 current_display_number
= -1;
1944 add_info ("address", address_info
,
1945 "Describe where variable VAR is stored.");
1947 add_com ("x", class_vars
, x_command
,
1948 "Examine memory: x/FMT ADDRESS.\n\
1949 ADDRESS is an expression for the memory address to examine.\n\
1950 FMT is a repeat count followed by a format letter and a size letter.\n\
1951 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
1952 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
1953 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
1954 The specified number of objects of the specified size are printed\n\
1955 according to the format.\n\n\
1956 Defaults for format and size letters are those previously used.\n\
1957 Default count is 1. Default address is following last thing printed\n\
1958 with this command or \"print\".");
1960 add_com ("disassemble", class_vars
, disassemble_command
,
1961 "Disassemble a specified section of memory.\n\
1962 Default is the function surrounding the pc of the selected frame.\n\
1963 With a single argument, the function surrounding that address is dumped.\n\
1964 Two arguments are taken as a range of memory to dump.");
1967 add_com ("whereis", class_vars
, whereis_command
,
1968 "Print line number and file of definition of variable.");
1971 add_info ("display", display_info
,
1972 "Expressions to display when program stops, with code numbers.");
1974 add_cmd ("undisplay", class_vars
, undisplay_command
,
1975 "Cancel some expressions to be displayed when program stops.\n\
1976 Arguments are the code numbers of the expressions to stop displaying.\n\
1977 No argument means cancel all automatic-display expressions.\n\
1978 \"delete display\" has the same effect as this command.\n\
1979 Do \"info display\" to see current list of code numbers.",
1982 add_com ("display", class_vars
, display_command
,
1983 "Print value of expression EXP each time the program stops.\n\
1984 /FMT may be used before EXP as in the \"print\" command.\n\
1985 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
1986 as in the \"x\" command, and then EXP is used to get the address to examine\n\
1987 and examining is done as in the \"x\" command.\n\n\
1988 With no argument, display all currently requested auto-display expressions.\n\
1989 Use \"undisplay\" to cancel display requests previously made.");
1991 add_cmd ("display", class_vars
, enable_display
,
1992 "Enable some expressions to be displayed when program stops.\n\
1993 Arguments are the code numbers of the expressions to resume displaying.\n\
1994 No argument means enable all automatic-display expressions.\n\
1995 Do \"info display\" to see current list of code numbers.", &enablelist
);
1997 add_cmd ("display", class_vars
, disable_display_command
,
1998 "Disable some expressions to be displayed when program stops.\n\
1999 Arguments are the code numbers of the expressions to stop displaying.\n\
2000 No argument means disable all automatic-display expressions.\n\
2001 Do \"info display\" to see current list of code numbers.", &disablelist
);
2003 add_cmd ("display", 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 Do \"info display\" to see current list of code numbers.", &deletelist
);
2009 add_com ("printf", class_vars
, printf_command
,
2010 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2011 This is useful for formatted output in user-defined commands.");
2012 add_com ("output", class_vars
, output_command
,
2013 "Like \"print\" but don't put in value history and don't print newline.\n\
2014 This is useful in user-defined commands.");
2016 add_prefix_cmd ("set", class_vars
, set_command
,
2017 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2018 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2019 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2020 with $), a register (a few standard names starting with $), or an actual\n\
2021 variable in the program being debugged. EXP is any valid expression.\n\
2022 Use \"set variable\" for variables with names identical to set subcommands.\n\
2023 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2024 You can see these environment settings with the \"show\" command.",
2025 &setlist
, "set ", 1, &cmdlist
);
2027 /* "call" is the same as "set", but handy for dbx users to call fns. */
2028 add_com ("call", class_vars
, call_command
,
2029 "Call a function in the program.\n\
2030 The argument is the function name and arguments, in the notation of the\n\
2031 current working language. The result is printed and saved in the value\n\
2032 history, if it is not void.");
2034 add_cmd ("variable", class_vars
, set_command
,
2035 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2036 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2037 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2038 with $), a register (a few standard names starting with $), or an actual\n\
2039 variable in the program being debugged. EXP is any valid expression.\n\
2040 This may usually be abbreviated to simply \"set\".",
2043 add_com ("print", class_vars
, print_command
,
2044 concat ("Print value of expression EXP.\n\
2045 Variables accessible are those of the lexical environment of the selected\n\
2046 stack frame, plus all those whose scope is global or an entire file.\n\
2048 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2049 $$NUM refers to NUM'th value back from the last one.\n\
2050 Names starting with $ refer to registers (with the values they would have\n\
2051 if the program were to return to the stack frame now selected, restoring\n\
2052 all registers saved by frames farther in) or else to debugger\n\
2053 \"convenience\" variables (any such name not a known register).\n\
2054 Use assignment expressions to give values to convenience variables.\n",
2056 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2057 @ is a binary operator for treating consecutive data objects\n\
2058 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2059 element is FOO, whose second element is stored in the space following\n\
2060 where FOO is stored, etc. FOO must be an expression whose value\n\
2061 resides in memory.\n",
2063 EXP may be preceded with /FMT, where FMT is a format letter\n\
2064 but no count or size letter (see \"x\" command).", NULL
));
2065 add_com_alias ("p", "print", class_vars
, 1);
2067 add_com ("inspect", class_vars
, inspect_command
,
2068 "Same as \"print\" command, except that if you are running in the epoch\n\
2069 environment, the value is printed in its own window.");
2072 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2073 (char *)&max_symbolic_offset
,
2074 "Set the largest offset that will be printed in <symbol+1234> form.",
2078 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2079 (char *)&print_symbol_filename
,
2080 "Set printing of source filename and line number with <symbol>.",
2084 examine_b_type
= init_type (TYPE_CODE_INT
, 1, 0, NULL
, NULL
);
2085 examine_h_type
= init_type (TYPE_CODE_INT
, 2, 0, NULL
, NULL
);
2086 examine_w_type
= init_type (TYPE_CODE_INT
, 4, 0, NULL
, NULL
);
2087 examine_g_type
= init_type (TYPE_CODE_INT
, 8, 0, NULL
, NULL
);