1 /* Print values for GNU debugger GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
29 #include "expression.h"
33 #include "breakpoint.h"
38 extern int asm_demangle; /* Whether to demangle syms in asm printouts */
39 extern int addressprint; /* Whether to print hex addresses in HLL " */
48 /* Last specified output format. */
50 static char last_format = 'x';
52 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
54 static char last_size = 'w';
56 /* Default address to examine next. */
58 static CORE_ADDR next_address;
60 /* Last address examined. */
62 static CORE_ADDR last_examine_address;
64 /* Contents of last address examined.
65 This is not valid past the end of the `x' command! */
67 static value_ptr last_examine_value;
69 /* Largest offset between a symbolic value and an address, that will be
70 printed as `0x1234 <symbol+offset>'. */
72 static unsigned int max_symbolic_offset = UINT_MAX;
74 /* Append the source filename and linenumber of the symbol when
75 printing a symbolic value as `<symbol at filename:linenum>' if set. */
76 static int print_symbol_filename = 0;
78 /* Number of auto-display expression currently being displayed.
79 So that we can disable it if we get an error or a signal within it.
80 -1 when not doing one. */
82 int current_display_number;
84 /* Flag to low-level print routines that this value is being printed
85 in an epoch window. We'd like to pass this as a parameter, but
86 every routine would need to take it. Perhaps we can encapsulate
87 this in the I/O stream once we have GNU stdio. */
93 /* Chain link to next auto-display item. */
95 /* Expression to be evaluated and displayed. */
96 struct expression *exp;
97 /* Item number of this auto-display item. */
99 /* Display format specified. */
100 struct format_data format;
101 /* Innermost block required by this expression when evaluated */
103 /* Status of this display (enabled or disabled) */
107 /* Chain of expressions whose values should be displayed
108 automatically each time the program stops. */
110 static struct display *display_chain;
112 static int display_number;
114 /* Prototypes for local functions */
117 delete_display PARAMS ((int));
120 enable_display PARAMS ((char *, int));
123 disable_display_command PARAMS ((char *, int));
126 disassemble_command PARAMS ((char *, int));
129 printf_command PARAMS ((char *, int));
132 print_frame_nameless_args PARAMS ((struct frame_info *, long, int, int,
136 display_info PARAMS ((char *, int));
139 do_one_display PARAMS ((struct display *));
142 undisplay_command PARAMS ((char *, int));
145 free_display PARAMS ((struct display *));
148 display_command PARAMS ((char *, int));
151 x_command PARAMS ((char *, int));
154 address_info PARAMS ((char *, int));
157 set_command PARAMS ((char *, int));
160 output_command PARAMS ((char *, int));
163 call_command PARAMS ((char *, int));
166 inspect_command PARAMS ((char *, int));
169 print_command PARAMS ((char *, int));
172 print_command_1 PARAMS ((char *, int, int));
175 validate_format PARAMS ((struct format_data, char *));
178 do_examine PARAMS ((struct format_data, CORE_ADDR));
181 print_formatted PARAMS ((value_ptr, int, int));
183 static struct format_data
184 decode_format PARAMS ((char **, int, int));
187 /* Decode a format specification. *STRING_PTR should point to it.
188 OFORMAT and OSIZE are used as defaults for the format and size
189 if none are given in the format specification.
190 If OSIZE is zero, then the size field of the returned value
191 should be set only if a size is explicitly specified by the
193 The structure returned describes all the data
194 found in the specification. In addition, *STRING_PTR is advanced
195 past the specification and past all whitespace following it. */
197 static struct format_data
198 decode_format (string_ptr, oformat, osize)
203 struct format_data val;
204 register char *p = *string_ptr;
210 if (*p >= '0' && *p <= '9')
211 val.count = atoi (p);
212 while (*p >= '0' && *p <= '9') p++;
214 /* Now process size or format letters that follow. */
218 if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
220 else if (*p >= 'a' && *p <= 'z')
226 while (*p == ' ' || *p == '\t') p++;
229 /* Set defaults for format and size if not specified. */
230 if (val.format == '?')
234 /* Neither has been specified. */
235 val.format = oformat;
239 /* If a size is specified, any format makes a reasonable
240 default except 'i'. */
241 val.format = oformat == 'i' ? 'x' : oformat;
243 else if (val.size == '?')
248 /* Pick the appropriate size for an address. */
249 #if TARGET_PTR_BIT == 64
250 val.size = osize ? 'g' : osize;
253 #if TARGET_PTR_BIT == 32
254 val.size = osize ? 'w' : osize;
257 #if TARGET_PTR_BIT == 16
258 val.size = osize ? 'h' : osize;
261 #error Bad value for TARGET_PTR_BIT
267 /* Floating point has to be word or giantword. */
268 if (osize == 'w' || osize == 'g')
271 /* Default it to giantword if the last used size is not
273 val.size = osize ? 'g' : osize;
276 /* Characters default to one byte. */
277 val.size = osize ? 'b' : osize;
280 /* The default is the size most recently specified. */
287 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
288 Do not end with a newline.
289 0 means print VAL according to its own type.
290 SIZE is the letter for the size of datum being printed.
291 This is used to pad hex numbers so they line up. */
294 print_formatted (val, format, size)
295 register value_ptr val;
299 int len = TYPE_LENGTH (VALUE_TYPE (val));
301 if (VALUE_LVAL (val) == lval_memory)
302 next_address = VALUE_ADDRESS (val) + len;
307 next_address = VALUE_ADDRESS (val)
308 + value_print (value_addr (val), gdb_stdout, format, Val_pretty_default);
312 /* The old comment says
313 "Force output out, print_insn not using _filtered".
314 I'm not completely sure what that means, I suspect most print_insn
315 now do use _filtered, so I guess it's obsolete. */
316 /* We often wrap here if there are long symbolic names. */
318 next_address = VALUE_ADDRESS (val)
319 + print_insn (VALUE_ADDRESS (val), gdb_stdout);
324 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY
325 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRING
326 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT
327 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION
328 || VALUE_REPEATED (val))
329 value_print (val, gdb_stdout, format, Val_pretty_default);
331 print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val),
332 format, size, gdb_stdout);
336 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
337 according to letters FORMAT and SIZE on STREAM.
338 FORMAT may not be zero. Formats s and i are not supported at this level.
340 This is how the elements of an array or structure are printed
344 print_scalar_formatted (valaddr, type, format, size, stream)
352 int len = TYPE_LENGTH (type);
354 if (len > sizeof (LONGEST)
362 /* We can't print it normally, but we can print it in hex.
363 Printing it in the wrong radix is more useful than saying
364 "use /x, you dummy". */
365 /* FIXME: we could also do octal or binary if that was the
367 /* FIXME: we should be using the size field to give us a minimum
368 field width to print. */
369 val_print_type_code_int (type, valaddr, stream);
374 val_long = unpack_long (type, valaddr);
376 /* If we are printing it as unsigned, truncate it in case it is actually
377 a negative signed value (e.g. "print/u (short)-1" should print 65535
378 (if shorts are 16 bits) instead of 4294967295). */
381 if (len < sizeof (LONGEST))
382 val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
390 /* no size specified, like in print. Print varying # of digits. */
391 print_longest (stream, 'x', 1, val_long);
400 print_longest (stream, size, 1, val_long);
403 error ("Undefined output size \"%c\".", size);
408 print_longest (stream, 'd', 1, val_long);
412 print_longest (stream, 'u', 0, val_long);
417 print_longest (stream, 'o', 1, val_long);
419 fprintf_filtered (stream, "0");
423 print_address (unpack_pointer (type, valaddr), stream);
427 value_print (value_from_longest (builtin_type_char, val_long), stream, 0,
432 if (len == sizeof (float))
433 type = builtin_type_float;
434 else if (len == sizeof (double))
435 type = builtin_type_double;
436 print_floating (valaddr, type, stream);
443 /* Binary; 't' stands for "two". */
445 char bits[8*(sizeof val_long) + 1];
450 width = 8*(sizeof val_long);
467 error ("Undefined output size \"%c\".", size);
473 bits[width] = (val_long & 1) ? '1' : '0';
478 while (*cp && *cp == '0')
483 fprintf_filtered (stream, local_binary_format_prefix());
484 fprintf_filtered (stream, cp);
485 fprintf_filtered (stream, local_binary_format_suffix());
490 error ("Undefined output format \"%c\".", format);
494 /* Specify default address for `x' command.
495 `info lines' uses this. */
498 set_next_address (addr)
503 /* Make address available to the user as $_. */
504 set_internalvar (lookup_internalvar ("_"),
505 value_from_longest (lookup_pointer_type (builtin_type_void),
509 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
510 after LEADIN. Print nothing if no symbolic name is found nearby.
511 Optionally also print source file and line number, if available.
512 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
513 or to interpret it as a possible C++ name and convert it back to source
514 form. However note that DO_DEMANGLE can be overridden by the specific
515 settings of the demangle and asm_demangle variables. */
518 print_address_symbolic (addr, stream, do_demangle, leadin)
524 struct minimal_symbol *msymbol;
525 struct symbol *symbol;
526 struct symtab *symtab = 0;
527 CORE_ADDR name_location = 0;
530 /* First try to find the address in the symbol table, then
531 in the minsyms. Take the closest one. */
533 /* This is defective in the sense that it only finds text symbols. So
534 really this is kind of pointless--we should make sure that the
535 minimal symbols have everything we need (by changing that we could
536 save some memory, but for many debug format--ELF/DWARF or
537 anything/stabs--it would be inconvenient to eliminate those minimal
539 symbol = find_pc_function (addr);
541 name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
546 name = SYMBOL_SOURCE_NAME (symbol);
548 name = SYMBOL_LINKAGE_NAME (symbol);
551 msymbol = lookup_minimal_symbol_by_pc (addr);
554 if (SYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL)
556 /* The msymbol is closer to the address than the symbol;
557 use the msymbol instead. */
560 name_location = SYMBOL_VALUE_ADDRESS (msymbol);
562 name = SYMBOL_SOURCE_NAME (msymbol);
564 name = SYMBOL_LINKAGE_NAME (msymbol);
567 if (symbol == NULL && msymbol == NULL)
570 /* If the nearest symbol is too far away, don't print anything symbolic. */
572 /* For when CORE_ADDR is larger than unsigned int, we do math in
573 CORE_ADDR. But when we detect unsigned wraparound in the
574 CORE_ADDR math, we ignore this test and print the offset,
575 because addr+max_symbolic_offset has wrapped through the end
576 of the address space back to the beginning, giving bogus comparison. */
577 if (addr > name_location + max_symbolic_offset
578 && name_location + max_symbolic_offset > name_location)
581 fputs_filtered (leadin, stream);
582 fputs_filtered ("<", stream);
583 fputs_filtered (name, stream);
584 if (addr != name_location)
585 fprintf_filtered (stream, "+%u", (unsigned int)(addr - name_location));
587 /* Append source filename and line number if desired. Give specific
588 line # of this addr, if we have it; else line # of the nearest symbol. */
589 if (print_symbol_filename)
591 struct symtab_and_line sal;
593 sal = find_pc_line (addr, 0);
595 fprintf_filtered (stream, " at %s:%d", sal.symtab->filename, sal.line);
596 else if (symtab && symbol && symbol->line)
597 fprintf_filtered (stream, " at %s:%d", symtab->filename, symbol->line);
599 fprintf_filtered (stream, " in %s", symtab->filename);
601 fputs_filtered (">", stream);
604 /* Print address ADDR on STREAM. USE_LOCAL means the same thing as for
607 print_address_numeric (addr, use_local, stream)
612 /* This assumes a CORE_ADDR can fit in a LONGEST. Probably a safe
613 assumption. We pass use_local but I'm not completely sure whether
614 that is correct. When (if ever) should we *not* use_local? */
615 print_longest (stream, 'x', 1, (unsigned LONGEST) addr);
618 /* Print address ADDR symbolically on STREAM.
619 First print it as a number. Then perhaps print
620 <SYMBOL + OFFSET> after the number. */
623 print_address (addr, stream)
627 print_address_numeric (addr, 1, stream);
628 print_address_symbolic (addr, stream, asm_demangle, " ");
631 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
632 controls whether to print the symbolic name "raw" or demangled.
633 Global setting "addressprint" controls whether to print hex address
637 print_address_demangle (addr, stream, do_demangle)
644 fprintf_filtered (stream, "0");
646 else if (addressprint)
648 print_address_numeric (addr, 1, stream);
649 print_address_symbolic (addr, stream, do_demangle, " ");
653 print_address_symbolic (addr, stream, do_demangle, "");
658 /* These are the types that $__ will get after an examine command of one
661 static struct type *examine_b_type;
662 static struct type *examine_h_type;
663 static struct type *examine_w_type;
664 static struct type *examine_g_type;
666 /* Examine data at address ADDR in format FMT.
667 Fetch it from memory and print on gdb_stdout. */
670 do_examine (fmt, addr)
671 struct format_data fmt;
674 register char format = 0;
676 register int count = 1;
677 struct type *val_type = NULL;
679 register int maxelts;
686 /* String or instruction format implies fetch single bytes
687 regardless of the specified size. */
688 if (format == 's' || format == 'i')
692 val_type = examine_b_type;
693 else if (size == 'h')
694 val_type = examine_h_type;
695 else if (size == 'w')
696 val_type = examine_w_type;
697 else if (size == 'g')
698 val_type = examine_g_type;
705 if (format == 's' || format == 'i')
708 /* Print as many objects as specified in COUNT, at most maxelts per line,
709 with the address of the next one at the start of each line. */
713 print_address (next_address, gdb_stdout);
714 printf_filtered (":");
719 printf_filtered ("\t");
720 /* Note that print_formatted sets next_address for the next
722 last_examine_address = next_address;
723 last_examine_value = value_at (val_type, next_address);
724 print_formatted (last_examine_value, format, size);
726 printf_filtered ("\n");
727 gdb_flush (gdb_stdout);
732 validate_format (fmt, cmdname)
733 struct format_data fmt;
737 error ("Size letters are meaningless in \"%s\" command.", cmdname);
739 error ("Item count other than 1 is meaningless in \"%s\" command.",
741 if (fmt.format == 'i' || fmt.format == 's')
742 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
743 fmt.format, cmdname);
746 /* Evaluate string EXP as an expression in the current language and
747 print the resulting value. EXP may contain a format specifier as the
748 first argument ("/x myvar" for example, to print myvar in hex).
752 print_command_1 (exp, inspect, voidprint)
757 struct expression *expr;
758 register struct cleanup *old_chain = 0;
759 register char format = 0;
760 register value_ptr val;
761 struct format_data fmt;
764 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
765 inspect_it = inspect;
767 if (exp && *exp == '/')
770 fmt = decode_format (&exp, last_format, 0);
771 validate_format (fmt, "print");
772 last_format = format = fmt.format;
783 extern int objectprint;
785 expr = parse_expression (exp);
786 old_chain = make_cleanup (free_current_contents, &expr);
788 val = evaluate_expression (expr);
790 /* C++: figure out what type we actually want to print it as. */
791 type = VALUE_TYPE (val);
794 && ( TYPE_CODE (type) == TYPE_CODE_PTR
795 || TYPE_CODE (type) == TYPE_CODE_REF)
796 && ( TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
797 || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION))
801 v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type));
805 type = VALUE_TYPE (val);
810 val = access_value_history (0);
812 if (voidprint || (val && VALUE_TYPE (val) &&
813 TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_VOID))
815 int histindex = record_latest_value (val);
818 annotate_value_history_begin (histindex, VALUE_TYPE (val));
820 annotate_value_begin (VALUE_TYPE (val));
823 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex);
825 if (histindex >= 0) printf_filtered ("$%d = ", histindex);
828 annotate_value_history_value ();
830 print_formatted (val, format, fmt.size);
831 printf_filtered ("\n");
834 annotate_value_history_end ();
836 annotate_value_end ();
839 printf_unfiltered("\") )\030");
843 do_cleanups (old_chain);
844 inspect_it = 0; /* Reset print routines to normal */
849 print_command (exp, from_tty)
853 print_command_1 (exp, 0, 1);
856 /* Same as print, except in epoch, it gets its own window */
859 inspect_command (exp, from_tty)
863 extern int epoch_interface;
865 print_command_1 (exp, epoch_interface, 1);
868 /* Same as print, except it doesn't print void results. */
871 call_command (exp, from_tty)
875 print_command_1 (exp, 0, 0);
880 output_command (exp, from_tty)
884 struct expression *expr;
885 register struct cleanup *old_chain;
886 register char format = 0;
887 register value_ptr val;
888 struct format_data fmt;
890 if (exp && *exp == '/')
893 fmt = decode_format (&exp, 0, 0);
894 validate_format (fmt, "output");
898 expr = parse_expression (exp);
899 old_chain = make_cleanup (free_current_contents, &expr);
901 val = evaluate_expression (expr);
903 annotate_value_begin (VALUE_TYPE (val));
905 print_formatted (val, format, fmt.size);
907 annotate_value_end ();
909 do_cleanups (old_chain);
914 set_command (exp, from_tty)
918 struct expression *expr = parse_expression (exp);
919 register struct cleanup *old_chain
920 = make_cleanup (free_current_contents, &expr);
921 evaluate_expression (expr);
922 do_cleanups (old_chain);
927 address_info (exp, from_tty)
931 register struct symbol *sym;
932 register struct minimal_symbol *msymbol;
934 register long basereg;
935 int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero
936 if exp is a field of `this'. */
939 error ("Argument required.");
941 sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
942 &is_a_field_of_this, (struct symtab **)NULL);
945 if (is_a_field_of_this)
947 printf_filtered ("Symbol \"");
948 fprintf_symbol_filtered (gdb_stdout, exp,
949 current_language->la_language, DMGL_ANSI);
950 printf_filtered ("\" is a field of the local class variable `this'\n");
954 msymbol = lookup_minimal_symbol (exp, (struct objfile *) NULL);
958 printf_filtered ("Symbol \"");
959 fprintf_symbol_filtered (gdb_stdout, exp,
960 current_language->la_language, DMGL_ANSI);
961 printf_filtered ("\" is at ");
962 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1,
964 printf_filtered (" in a file compiled without debugging.\n");
967 error ("No symbol \"%s\" in current context.", exp);
971 printf_filtered ("Symbol \"");
972 fprintf_symbol_filtered (gdb_stdout, SYMBOL_NAME (sym),
973 current_language->la_language, DMGL_ANSI);
974 printf_filtered ("\" is ", SYMBOL_NAME (sym));
975 val = SYMBOL_VALUE (sym);
976 basereg = SYMBOL_BASEREG (sym);
978 switch (SYMBOL_CLASS (sym))
981 case LOC_CONST_BYTES:
982 printf_filtered ("constant");
986 printf_filtered ("a label at address ");
987 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
991 printf_filtered ("a variable in register %s", reg_names[val]);
995 printf_filtered ("static storage at address ");
996 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
1000 printf_filtered ("an argument in register %s", reg_names[val]);
1003 case LOC_REGPARM_ADDR:
1004 printf_filtered ("address of an argument in register %s", reg_names[val]);
1008 printf_filtered ("an argument at offset %ld", val);
1012 printf_filtered ("an argument at frame offset %ld", val);
1016 printf_filtered ("a local variable at frame offset %ld", val);
1020 printf_filtered ("a reference argument at offset %ld", val);
1024 printf_filtered ("a variable at offset %ld from register %s",
1025 val, reg_names[basereg]);
1028 case LOC_BASEREG_ARG:
1029 printf_filtered ("an argument at offset %ld from register %s",
1030 val, reg_names[basereg]);
1034 printf_filtered ("a typedef");
1038 printf_filtered ("a function at address ");
1039 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), 1,
1043 case LOC_OPTIMIZED_OUT:
1044 printf_filtered ("optimized out");
1048 printf_filtered ("of unknown (botched) type");
1051 printf_filtered (".\n");
1055 x_command (exp, from_tty)
1059 struct expression *expr;
1060 struct format_data fmt;
1061 struct cleanup *old_chain;
1064 fmt.format = last_format;
1065 fmt.size = last_size;
1068 if (exp && *exp == '/')
1071 fmt = decode_format (&exp, last_format, last_size);
1074 /* If we have an expression, evaluate it and use it as the address. */
1076 if (exp != 0 && *exp != 0)
1078 expr = parse_expression (exp);
1079 /* Cause expression not to be there any more
1080 if this command is repeated with Newline.
1081 But don't clobber a user-defined command's definition. */
1084 old_chain = make_cleanup (free_current_contents, &expr);
1085 val = evaluate_expression (expr);
1086 if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)
1087 val = value_ind (val);
1088 /* In rvalue contexts, such as this, functions are coerced into
1089 pointers to functions. This makes "x/i main" work. */
1090 if (/* last_format == 'i'
1091 && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
1092 && VALUE_LVAL (val) == lval_memory)
1093 next_address = VALUE_ADDRESS (val);
1095 next_address = value_as_pointer (val);
1096 do_cleanups (old_chain);
1099 do_examine (fmt, next_address);
1101 /* If the examine succeeds, we remember its size and format for next time. */
1102 last_size = fmt.size;
1103 last_format = fmt.format;
1105 /* Set a couple of internal variables if appropriate. */
1106 if (last_examine_value)
1108 /* Make last address examined available to the user as $_. Use
1109 the correct pointer type. */
1110 set_internalvar (lookup_internalvar ("_"),
1111 value_from_longest (
1112 lookup_pointer_type (VALUE_TYPE (last_examine_value)),
1113 (LONGEST) last_examine_address));
1115 /* Make contents of last address examined available to the user as $__.*/
1116 set_internalvar (lookup_internalvar ("__"), last_examine_value);
1121 /* Add an expression to the auto-display chain.
1122 Specify the expression. */
1125 display_command (exp, from_tty)
1129 struct format_data fmt;
1130 register struct expression *expr;
1131 register struct display *new;
1142 fmt = decode_format (&exp, 0, 0);
1143 if (fmt.size && fmt.format == 0)
1145 if (fmt.format == 'i' || fmt.format == 's')
1155 innermost_block = 0;
1156 expr = parse_expression (exp);
1158 new = (struct display *) xmalloc (sizeof (struct display));
1161 new->block = innermost_block;
1162 new->next = display_chain;
1163 new->number = ++display_number;
1165 new->status = enabled;
1166 display_chain = new;
1168 if (from_tty && target_has_execution)
1169 do_one_display (new);
1182 /* Clear out the display_chain.
1183 Done when new symtabs are loaded, since this invalidates
1184 the types stored in many expressions. */
1189 register struct display *d;
1191 while ((d = display_chain) != NULL)
1194 display_chain = d->next;
1199 /* Delete the auto-display number NUM. */
1202 delete_display (num)
1205 register struct display *d1, *d;
1208 error ("No display number %d.", num);
1210 if (display_chain->number == num)
1213 display_chain = d1->next;
1217 for (d = display_chain; ; d = d->next)
1220 error ("No display number %d.", num);
1221 if (d->next->number == num)
1231 /* Delete some values from the auto-display chain.
1232 Specify the element numbers. */
1235 undisplay_command (args, from_tty)
1239 register char *p = args;
1245 if (query ("Delete all auto-display expressions? "))
1254 while (*p1 >= '0' && *p1 <= '9') p1++;
1255 if (*p1 && *p1 != ' ' && *p1 != '\t')
1256 error ("Arguments must be display numbers.");
1260 delete_display (num);
1263 while (*p == ' ' || *p == '\t') p++;
1268 /* Display a single auto-display.
1269 Do nothing if the display cannot be printed in the current context,
1270 or if the display is disabled. */
1276 int within_current_scope;
1278 if (d->status == disabled)
1282 within_current_scope = contained_in (get_selected_block (), d->block);
1284 within_current_scope = 1;
1285 if (!within_current_scope)
1288 current_display_number = d->number;
1290 annotate_display_begin ();
1291 printf_filtered ("%d", d->number);
1292 annotate_display_number_end ();
1293 printf_filtered (": ");
1298 annotate_display_format ();
1300 printf_filtered ("x/");
1301 if (d->format.count != 1)
1302 printf_filtered ("%d", d->format.count);
1303 printf_filtered ("%c", d->format.format);
1304 if (d->format.format != 'i' && d->format.format != 's')
1305 printf_filtered ("%c", d->format.size);
1306 printf_filtered (" ");
1308 annotate_display_expression ();
1310 print_expression (d->exp, gdb_stdout);
1311 annotate_display_expression_end ();
1313 if (d->format.count != 1)
1314 printf_filtered ("\n");
1316 printf_filtered (" ");
1318 addr = value_as_pointer (evaluate_expression (d->exp));
1319 if (d->format.format == 'i')
1320 addr = ADDR_BITS_REMOVE (addr);
1322 annotate_display_value ();
1324 do_examine (d->format, addr);
1328 annotate_display_format ();
1330 if (d->format.format)
1331 printf_filtered ("/%c ", d->format.format);
1333 annotate_display_expression ();
1335 print_expression (d->exp, gdb_stdout);
1336 annotate_display_expression_end ();
1338 printf_filtered (" = ");
1340 annotate_display_expression ();
1342 print_formatted (evaluate_expression (d->exp),
1343 d->format.format, d->format.size);
1344 printf_filtered ("\n");
1347 annotate_display_end ();
1349 gdb_flush (gdb_stdout);
1350 current_display_number = -1;
1353 /* Display all of the values on the auto-display chain which can be
1354 evaluated in the current scope. */
1359 register struct display *d;
1361 for (d = display_chain; d; d = d->next)
1365 /* Delete the auto-display which we were in the process of displaying.
1366 This is done when there is an error or a signal. */
1369 disable_display (num)
1372 register struct display *d;
1374 for (d = display_chain; d; d = d->next)
1375 if (d->number == num)
1377 d->status = disabled;
1380 printf_unfiltered ("No display number %d.\n", num);
1384 disable_current_display ()
1386 if (current_display_number >= 0)
1388 disable_display (current_display_number);
1389 fprintf_unfiltered (gdb_stderr, "Disabling display %d to avoid infinite recursion.\n",
1390 current_display_number);
1392 current_display_number = -1;
1396 display_info (ignore, from_tty)
1400 register struct display *d;
1403 printf_unfiltered ("There are no auto-display expressions now.\n");
1405 printf_filtered ("Auto-display expressions now in effect:\n\
1406 Num Enb Expression\n");
1408 for (d = display_chain; d; d = d->next)
1410 printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]);
1412 printf_filtered ("/%d%c%c ", d->format.count, d->format.size,
1414 else if (d->format.format)
1415 printf_filtered ("/%c ", d->format.format);
1416 print_expression (d->exp, gdb_stdout);
1417 if (d->block && !contained_in (get_selected_block (), d->block))
1418 printf_filtered (" (cannot be evaluated in the current context)");
1419 printf_filtered ("\n");
1420 gdb_flush (gdb_stdout);
1425 enable_display (args, from_tty)
1429 register char *p = args;
1432 register struct display *d;
1436 for (d = display_chain; d; d = d->next)
1437 d->status = enabled;
1443 while (*p1 >= '0' && *p1 <= '9')
1445 if (*p1 && *p1 != ' ' && *p1 != '\t')
1446 error ("Arguments must be display numbers.");
1450 for (d = display_chain; d; d = d->next)
1451 if (d->number == num)
1453 d->status = enabled;
1456 printf_unfiltered ("No display number %d.\n", num);
1459 while (*p == ' ' || *p == '\t')
1466 disable_display_command (args, from_tty)
1470 register char *p = args;
1472 register struct display *d;
1476 for (d = display_chain; d; d = d->next)
1477 d->status = disabled;
1483 while (*p1 >= '0' && *p1 <= '9')
1485 if (*p1 && *p1 != ' ' && *p1 != '\t')
1486 error ("Arguments must be display numbers.");
1488 disable_display (atoi (p));
1491 while (*p == ' ' || *p == '\t')
1497 /* Print the value in stack frame FRAME of a variable
1498 specified by a struct symbol. */
1501 print_variable_value (var, frame, stream)
1506 value_ptr val = read_var_value (var, frame);
1507 value_print (val, stream, 0, Val_pretty_default);
1510 /* Print the arguments of a stack frame, given the function FUNC
1511 running in that frame (as a symbol), the info on the frame,
1512 and the number of args according to the stack frame (or -1 if unknown). */
1514 /* References here and elsewhere to "number of args according to the
1515 stack frame" appear in all cases to refer to "number of ints of args
1516 according to the stack frame". At least for VAX, i386, isi. */
1519 print_frame_args (func, fi, num, stream)
1520 struct symbol *func;
1521 struct frame_info *fi;
1525 struct block *b = NULL;
1529 register struct symbol *sym;
1530 register value_ptr val;
1531 /* Offset of next stack argument beyond the one we have seen that is
1532 at the highest offset.
1533 -1 if we haven't come to a stack argument yet. */
1534 long highest_offset = -1;
1536 /* Number of ints of arguments that we have printed so far. */
1537 int args_printed = 0;
1541 b = SYMBOL_BLOCK_VALUE (func);
1542 nsyms = BLOCK_NSYMS (b);
1545 for (i = 0; i < nsyms; i++)
1548 sym = BLOCK_SYM (b, i);
1550 /* Keep track of the highest stack argument offset seen, and
1551 skip over any kinds of symbols we don't care about. */
1553 switch (SYMBOL_CLASS (sym)) {
1557 long current_offset = SYMBOL_VALUE (sym);
1559 arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
1561 /* Compute address of next argument by adding the size of
1562 this argument and rounding to an int boundary. */
1564 = ((current_offset + arg_size + sizeof (int) - 1)
1565 & ~(sizeof (int) - 1));
1567 /* If this is the highest offset seen yet, set highest_offset. */
1568 if (highest_offset == -1
1569 || (current_offset > highest_offset))
1570 highest_offset = current_offset;
1572 /* Add the number of ints we're about to print to args_printed. */
1573 args_printed += (arg_size + sizeof (int) - 1) / sizeof (int);
1576 /* We care about types of symbols, but don't need to keep track of
1577 stack offsets in them. */
1579 case LOC_REGPARM_ADDR:
1581 case LOC_BASEREG_ARG:
1584 /* Other types of symbols we just skip over. */
1589 /* We have to look up the symbol because arguments can have
1590 two entries (one a parameter, one a local) and the one we
1591 want is the local, which lookup_symbol will find for us.
1592 This includes gcc1 (not gcc2) on the sparc when passing a
1593 small structure and gcc2 when the argument type is float
1594 and it is passed as a double and converted to float by
1595 the prologue (in the latter case the type of the LOC_ARG
1596 symbol is double and the type of the LOC_LOCAL symbol is
1598 /* But if the parameter name is null, don't try it.
1599 Null parameter names occur on the RS/6000, for traceback tables.
1600 FIXME, should we even print them? */
1602 if (*SYMBOL_NAME (sym))
1604 struct symbol *nsym;
1605 nsym = lookup_symbol
1607 b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
1608 if (SYMBOL_CLASS (nsym) == LOC_REGISTER)
1610 /* There is a LOC_ARG/LOC_REGISTER pair. This means that
1611 it was passed on the stack and loaded into a register,
1612 or passed in a register and stored in a stack slot.
1613 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
1615 Reasons for using the LOC_ARG:
1616 (1) because find_saved_registers may be slow for remote
1618 (2) because registers are often re-used and stack slots
1619 rarely (never?) are. Therefore using the stack slot is
1620 much less likely to print garbage.
1622 Reasons why we might want to use the LOC_REGISTER:
1623 (1) So that the backtrace prints the same value as
1624 "print foo". I see no compelling reason why this needs
1625 to be the case; having the backtrace print the value which
1626 was passed in, and "print foo" print the value as modified
1627 within the called function, makes perfect sense to me.
1629 Additional note: It might be nice if "info args" displayed
1631 One more note: There is a case with sparc structure passing
1632 where we need to use the LOC_REGISTER, but this is dealt with
1633 by creating a single LOC_REGPARM in symbol reading. */
1635 /* Leave sym (the LOC_ARG) alone. */
1642 /* Print the current arg. */
1644 fprintf_filtered (stream, ", ");
1647 annotate_arg_begin ();
1649 fprintf_symbol_filtered (stream, SYMBOL_SOURCE_NAME (sym),
1650 SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI);
1651 annotate_arg_name_end ();
1652 fputs_filtered ("=", stream);
1654 /* Avoid value_print because it will deref ref parameters. We just
1655 want to print their addresses. Print ??? for args whose address
1656 we do not know. We pass 2 as "recurse" to val_print because our
1657 standard indentation here is 4 spaces, and val_print indents
1658 2 for each recurse. */
1659 val = read_var_value (sym, FRAME_INFO_ID (fi));
1661 annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
1664 val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val),
1665 stream, 0, 0, 2, Val_no_prettyprint);
1667 fputs_filtered ("???", stream);
1669 annotate_arg_end ();
1674 /* Don't print nameless args in situations where we don't know
1675 enough about the stack to find them. */
1680 if (highest_offset == -1)
1681 start = FRAME_ARGS_SKIP;
1683 start = highest_offset;
1685 print_frame_nameless_args (fi, start, num - args_printed,
1690 /* Print nameless args on STREAM.
1691 FI is the frameinfo for this frame, START is the offset
1692 of the first nameless arg, and NUM is the number of nameless args to
1693 print. FIRST is nonzero if this is the first argument (not just
1694 the first nameless arg). */
1696 print_frame_nameless_args (fi, start, num, first, stream)
1697 struct frame_info *fi;
1707 for (i = 0; i < num; i++)
1710 #ifdef NAMELESS_ARG_VALUE
1711 NAMELESS_ARG_VALUE (fi, start, &arg_value);
1713 argsaddr = FRAME_ARGS_ADDRESS (fi);
1717 arg_value = read_memory_integer (argsaddr + start, sizeof (int));
1721 fprintf_filtered (stream, ", ");
1723 #ifdef PRINT_NAMELESS_INTEGER
1724 PRINT_NAMELESS_INTEGER (stream, arg_value);
1726 #ifdef PRINT_TYPELESS_INTEGER
1727 PRINT_TYPELESS_INTEGER (stream, builtin_type_int, (LONGEST) arg_value);
1729 fprintf_filtered (stream, "%d", arg_value);
1730 #endif /* PRINT_TYPELESS_INTEGER */
1731 #endif /* PRINT_NAMELESS_INTEGER */
1733 start += sizeof (int);
1739 printf_command (arg, from_tty)
1744 register char *s = arg;
1746 value_ptr *val_args;
1748 char *current_substring;
1750 int allocated_args = 20;
1751 struct cleanup *old_cleanups;
1753 val_args = (value_ptr *) xmalloc (allocated_args * sizeof (value_ptr));
1754 old_cleanups = make_cleanup (free_current_contents, &val_args);
1757 error_no_arg ("format-control string and values to print");
1759 /* Skip white space before format string */
1760 while (*s == ' ' || *s == '\t') s++;
1762 /* A format string should follow, enveloped in double quotes */
1764 error ("Bad format string, missing '\"'.");
1766 /* Parse the format-control string and copy it into the string STRING,
1767 processing some kinds of escape sequence. */
1769 f = string = (char *) alloca (strlen (s) + 1);
1777 error ("Bad format string, non-terminated '\"'.");
1789 *f++ = '\007'; /* Bell */
1814 /* ??? TODO: handle other escape sequences */
1815 error ("Unrecognized escape character \\%c in format string.",
1825 /* Skip over " and following space and comma. */
1828 while (*s == ' ' || *s == '\t') s++;
1830 if (*s != ',' && *s != 0)
1831 error ("Invalid argument syntax");
1834 while (*s == ' ' || *s == '\t') s++;
1836 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1837 substrings = alloca (strlen (string) * 2);
1838 current_substring = substrings;
1841 /* Now scan the string for %-specs and see what kinds of args they want.
1842 argclass[I] classifies the %-specs so we can give printf_filtered
1843 something of the right size. */
1845 enum argclass {no_arg, int_arg, string_arg, double_arg, long_long_arg};
1846 enum argclass *argclass;
1847 enum argclass this_argclass;
1853 argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass);
1861 while (strchr ("0123456789.hlL-+ #", *f))
1863 if (*f == 'l' || *f == 'L')
1870 this_argclass = string_arg;
1876 this_argclass = double_arg;
1880 error ("`*' not supported for precision or width in printf");
1883 error ("Format specifier `n' not supported in printf");
1886 this_argclass = no_arg;
1891 this_argclass = long_long_arg;
1893 this_argclass = int_arg;
1897 if (this_argclass != no_arg)
1899 strncpy (current_substring, last_arg, f - last_arg);
1900 current_substring += f - last_arg;
1901 *current_substring++ = '\0';
1903 argclass[nargs_wanted++] = this_argclass;
1907 /* Now, parse all arguments and evaluate them.
1908 Store the VALUEs in VAL_ARGS. */
1913 if (nargs == allocated_args)
1914 val_args = (value_ptr *) xrealloc ((char *) val_args,
1915 (allocated_args *= 2)
1916 * sizeof (value_ptr));
1918 val_args[nargs] = parse_to_comma_and_eval (&s1);
1920 /* If format string wants a float, unchecked-convert the value to
1921 floating point of the same size */
1923 if (argclass[nargs] == double_arg)
1925 if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float))
1926 VALUE_TYPE (val_args[nargs]) = builtin_type_float;
1927 if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double))
1928 VALUE_TYPE (val_args[nargs]) = builtin_type_double;
1936 if (nargs != nargs_wanted)
1937 error ("Wrong number of arguments for specified format-string");
1939 /* Now actually print them. */
1940 current_substring = substrings;
1941 for (i = 0; i < nargs; i++)
1943 switch (argclass[i])
1950 tem = value_as_pointer (val_args[i]);
1952 /* This is a %s argument. Find the length of the string. */
1957 read_memory (tem + j, &c, 1);
1962 /* Copy the string contents into a string inside GDB. */
1963 str = (char *) alloca (j + 1);
1964 read_memory (tem, str, j);
1967 printf_filtered (current_substring, str);
1972 double val = value_as_double (val_args[i]);
1973 printf_filtered (current_substring, val);
1977 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1979 long long val = value_as_long (val_args[i]);
1980 printf_filtered (current_substring, val);
1984 error ("long long not supported in printf");
1988 /* FIXME: there should be separate int_arg and long_arg. */
1989 long val = value_as_long (val_args[i]);
1990 printf_filtered (current_substring, val);
1994 error ("internal error in printf_command");
1996 /* Skip to the next substring. */
1997 current_substring += strlen (current_substring) + 1;
1999 /* Print the portion of the format string after the last argument. */
2000 printf_filtered (last_arg);
2002 do_cleanups (old_cleanups);
2005 /* Dump a specified section of assembly code. With no command line
2006 arguments, this command will dump the assembly code for the
2007 function surrounding the pc value in the selected frame. With one
2008 argument, it will dump the assembly code surrounding that pc value.
2009 Two arguments are interpeted as bounds within which to dump
2014 disassemble_command (arg, from_tty)
2018 CORE_ADDR low, high;
2026 if (!selected_frame)
2027 error ("No frame selected.\n");
2029 pc = get_frame_pc (selected_frame);
2030 if (find_pc_partial_function (pc, &name, &low, &high) == 0)
2031 error ("No function contains program counter for selected frame.\n");
2033 else if (!(space_index = (char *) strchr (arg, ' ')))
2036 pc = parse_and_eval_address (arg);
2037 if (find_pc_partial_function (pc, &name, &low, &high) == 0)
2038 error ("No function contains specified address.\n");
2042 /* Two arguments. */
2043 *space_index = '\0';
2044 low = parse_and_eval_address (arg);
2045 high = parse_and_eval_address (space_index + 1);
2048 printf_filtered ("Dump of assembler code ");
2051 printf_filtered ("for function %s:\n", name);
2055 printf_filtered ("from ");
2056 print_address_numeric (low, 1, gdb_stdout);
2057 printf_filtered (" to ");
2058 print_address_numeric (high, 1, gdb_stdout);
2059 printf_filtered (":\n");
2062 /* Dump the specified range. */
2063 for (pc = low; pc < high; )
2066 print_address (pc, gdb_stdout);
2067 printf_filtered (":\t");
2068 /* We often wrap here if there are long symbolic names. */
2070 pc += print_insn (pc, gdb_stdout);
2071 printf_filtered ("\n");
2073 printf_filtered ("End of assembler dump.\n");
2074 gdb_flush (gdb_stdout);
2079 _initialize_printcmd ()
2081 current_display_number = -1;
2083 add_info ("address", address_info,
2084 "Describe where variable VAR is stored.");
2086 add_com ("x", class_vars, x_command,
2087 "Examine memory: x/FMT ADDRESS.\n\
2088 ADDRESS is an expression for the memory address to examine.\n\
2089 FMT is a repeat count followed by a format letter and a size letter.\n\
2090 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2091 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2092 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2093 The specified number of objects of the specified size are printed\n\
2094 according to the format.\n\n\
2095 Defaults for format and size letters are those previously used.\n\
2096 Default count is 1. Default address is following last thing printed\n\
2097 with this command or \"print\".");
2099 add_com ("disassemble", class_vars, disassemble_command,
2100 "Disassemble a specified section of memory.\n\
2101 Default is the function surrounding the pc of the selected frame.\n\
2102 With a single argument, the function surrounding that address is dumped.\n\
2103 Two arguments are taken as a range of memory to dump.");
2106 add_com ("whereis", class_vars, whereis_command,
2107 "Print line number and file of definition of variable.");
2110 add_info ("display", display_info,
2111 "Expressions to display when program stops, with code numbers.");
2113 add_cmd ("undisplay", class_vars, undisplay_command,
2114 "Cancel some expressions to be displayed when program stops.\n\
2115 Arguments are the code numbers of the expressions to stop displaying.\n\
2116 No argument means cancel all automatic-display expressions.\n\
2117 \"delete display\" has the same effect as this command.\n\
2118 Do \"info display\" to see current list of code numbers.",
2121 add_com ("display", class_vars, display_command,
2122 "Print value of expression EXP each time the program stops.\n\
2123 /FMT may be used before EXP as in the \"print\" command.\n\
2124 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2125 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2126 and examining is done as in the \"x\" command.\n\n\
2127 With no argument, display all currently requested auto-display expressions.\n\
2128 Use \"undisplay\" to cancel display requests previously made.");
2130 add_cmd ("display", class_vars, enable_display,
2131 "Enable some expressions to be displayed when program stops.\n\
2132 Arguments are the code numbers of the expressions to resume displaying.\n\
2133 No argument means enable all automatic-display expressions.\n\
2134 Do \"info display\" to see current list of code numbers.", &enablelist);
2136 add_cmd ("display", class_vars, disable_display_command,
2137 "Disable some expressions to be displayed when program stops.\n\
2138 Arguments are the code numbers of the expressions to stop displaying.\n\
2139 No argument means disable all automatic-display expressions.\n\
2140 Do \"info display\" to see current list of code numbers.", &disablelist);
2142 add_cmd ("display", class_vars, undisplay_command,
2143 "Cancel some expressions to be displayed when program stops.\n\
2144 Arguments are the code numbers of the expressions to stop displaying.\n\
2145 No argument means cancel all automatic-display expressions.\n\
2146 Do \"info display\" to see current list of code numbers.", &deletelist);
2148 add_com ("printf", class_vars, printf_command,
2149 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2150 This is useful for formatted output in user-defined commands.");
2151 add_com ("output", class_vars, output_command,
2152 "Like \"print\" but don't put in value history and don't print newline.\n\
2153 This is useful in user-defined commands.");
2155 add_prefix_cmd ("set", class_vars, set_command,
2156 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2157 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2158 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2159 with $), a register (a few standard names starting with $), or an actual\n\
2160 variable in the program being debugged. EXP is any valid expression.\n\
2161 Use \"set variable\" for variables with names identical to set subcommands.\n\
2162 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2163 You can see these environment settings with the \"show\" command.",
2164 &setlist, "set ", 1, &cmdlist);
2166 /* "call" is the same as "set", but handy for dbx users to call fns. */
2167 add_com ("call", class_vars, call_command,
2168 "Call a function in the program.\n\
2169 The argument is the function name and arguments, in the notation of the\n\
2170 current working language. The result is printed and saved in the value\n\
2171 history, if it is not void.");
2173 add_cmd ("variable", class_vars, set_command,
2174 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2175 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2176 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2177 with $), a register (a few standard names starting with $), or an actual\n\
2178 variable in the program being debugged. EXP is any valid expression.\n\
2179 This may usually be abbreviated to simply \"set\".",
2182 add_com ("print", class_vars, print_command,
2183 concat ("Print value of expression EXP.\n\
2184 Variables accessible are those of the lexical environment of the selected\n\
2185 stack frame, plus all those whose scope is global or an entire file.\n\
2187 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2188 $$NUM refers to NUM'th value back from the last one.\n\
2189 Names starting with $ refer to registers (with the values they would have\n\
2190 if the program were to return to the stack frame now selected, restoring\n\
2191 all registers saved by frames farther in) or else to debugger\n\
2192 \"convenience\" variables (any such name not a known register).\n\
2193 Use assignment expressions to give values to convenience variables.\n",
2195 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2196 @ is a binary operator for treating consecutive data objects\n\
2197 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2198 element is FOO, whose second element is stored in the space following\n\
2199 where FOO is stored, etc. FOO must be an expression whose value\n\
2200 resides in memory.\n",
2202 EXP may be preceded with /FMT, where FMT is a format letter\n\
2203 but no count or size letter (see \"x\" command).", NULL));
2204 add_com_alias ("p", "print", class_vars, 1);
2206 add_com ("inspect", class_vars, inspect_command,
2207 "Same as \"print\" command, except that if you are running in the epoch\n\
2208 environment, the value is printed in its own window.");
2211 add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,
2212 (char *)&max_symbolic_offset,
2213 "Set the largest offset that will be printed in <symbol+1234> form.",
2217 add_set_cmd ("symbol-filename", no_class, var_boolean,
2218 (char *)&print_symbol_filename,
2219 "Set printing of source filename and line number with <symbol>.",
2223 examine_b_type = init_type (TYPE_CODE_INT, 1, 0, NULL, NULL);
2224 examine_h_type = init_type (TYPE_CODE_INT, 2, 0, NULL, NULL);
2225 examine_w_type = init_type (TYPE_CODE_INT, 4, 0, NULL, NULL);
2226 examine_g_type = init_type (TYPE_CODE_INT, 8, 0, NULL, NULL);