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"
37 extern int asm_demangle; /* Whether to demangle syms in asm printouts */
38 extern int addressprint; /* Whether to print hex addresses in HLL " */
47 /* Last specified output format. */
49 static char last_format = 'x';
51 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
53 static char last_size = 'w';
55 /* Default address to examine next. */
57 static CORE_ADDR next_address;
59 /* Last address examined. */
61 static CORE_ADDR last_examine_address;
63 /* Contents of last address examined.
64 This is not valid past the end of the `x' command! */
66 static value_ptr last_examine_value;
68 /* Largest offset between a symbolic value and an address, that will be
69 printed as `0x1234 <symbol+offset>'. */
71 static unsigned int max_symbolic_offset = UINT_MAX;
73 /* Append the source filename and linenumber of the symbol when
74 printing a symbolic value as `<symbol at filename:linenum>' if set. */
75 static int print_symbol_filename = 0;
77 /* Number of auto-display expression currently being displayed.
78 So that we can disable it if we get an error or a signal within it.
79 -1 when not doing one. */
81 int current_display_number;
83 /* Flag to low-level print routines that this value is being printed
84 in an epoch window. We'd like to pass this as a parameter, but
85 every routine would need to take it. Perhaps we can encapsulate
86 this in the I/O stream once we have GNU stdio. */
92 /* Chain link to next auto-display item. */
94 /* Expression to be evaluated and displayed. */
95 struct expression *exp;
96 /* Item number of this auto-display item. */
98 /* Display format specified. */
99 struct format_data format;
100 /* Innermost block required by this expression when evaluated */
102 /* Status of this display (enabled or disabled) */
106 /* Chain of expressions whose values should be displayed
107 automatically each time the program stops. */
109 static struct display *display_chain;
111 static int display_number;
113 /* Prototypes for local functions */
116 delete_display PARAMS ((int));
119 enable_display PARAMS ((char *, int));
122 disable_display_command PARAMS ((char *, int));
125 disassemble_command PARAMS ((char *, int));
128 printf_command PARAMS ((char *, int));
131 print_frame_nameless_args PARAMS ((struct frame_info *, long, int, int,
135 display_info PARAMS ((char *, int));
138 do_one_display PARAMS ((struct display *));
141 undisplay_command PARAMS ((char *, int));
144 free_display PARAMS ((struct display *));
147 display_command PARAMS ((char *, int));
150 x_command PARAMS ((char *, int));
153 address_info PARAMS ((char *, int));
156 set_command PARAMS ((char *, int));
159 output_command PARAMS ((char *, int));
162 call_command PARAMS ((char *, int));
165 inspect_command PARAMS ((char *, int));
168 print_command PARAMS ((char *, int));
171 print_command_1 PARAMS ((char *, int, int));
174 validate_format PARAMS ((struct format_data, char *));
177 do_examine PARAMS ((struct format_data, CORE_ADDR));
180 print_formatted PARAMS ((value_ptr, int, int));
182 static struct format_data
183 decode_format PARAMS ((char **, int, int));
186 /* Decode a format specification. *STRING_PTR should point to it.
187 OFORMAT and OSIZE are used as defaults for the format and size
188 if none are given in the format specification.
189 If OSIZE is zero, then the size field of the returned value
190 should be set only if a size is explicitly specified by the
192 The structure returned describes all the data
193 found in the specification. In addition, *STRING_PTR is advanced
194 past the specification and past all whitespace following it. */
196 static struct format_data
197 decode_format (string_ptr, oformat, osize)
202 struct format_data val;
203 register char *p = *string_ptr;
209 if (*p >= '0' && *p <= '9')
210 val.count = atoi (p);
211 while (*p >= '0' && *p <= '9') p++;
213 /* Now process size or format letters that follow. */
217 if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
219 else if (*p >= 'a' && *p <= 'z')
225 while (*p == ' ' || *p == '\t') p++;
228 /* Set defaults for format and size if not specified. */
229 if (val.format == '?')
233 /* Neither has been specified. */
234 val.format = oformat;
238 /* If a size is specified, any format makes a reasonable
239 default except 'i'. */
240 val.format = oformat == 'i' ? 'x' : oformat;
242 else if (val.size == '?')
247 /* Pick the appropriate size for an address. */
248 #if TARGET_PTR_BIT == 64
249 val.size = osize ? 'g' : osize;
252 #if TARGET_PTR_BIT == 32
253 val.size = osize ? 'w' : osize;
256 #if TARGET_PTR_BIT == 16
257 val.size = osize ? 'h' : osize;
260 #error Bad value for TARGET_PTR_BIT
266 /* Floating point has to be word or giantword. */
267 if (osize == 'w' || osize == 'g')
270 /* Default it to giantword if the last used size is not
272 val.size = osize ? 'g' : osize;
275 /* Characters default to one byte. */
276 val.size = osize ? 'b' : osize;
279 /* The default is the size most recently specified. */
286 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
287 Do not end with a newline.
288 0 means print VAL according to its own type.
289 SIZE is the letter for the size of datum being printed.
290 This is used to pad hex numbers so they line up. */
293 print_formatted (val, format, size)
294 register value_ptr val;
298 int len = TYPE_LENGTH (VALUE_TYPE (val));
300 if (VALUE_LVAL (val) == lval_memory)
301 next_address = VALUE_ADDRESS (val) + len;
306 next_address = VALUE_ADDRESS (val)
307 + value_print (value_addr (val), gdb_stdout, format, Val_pretty_default);
311 /* The old comment says
312 "Force output out, print_insn not using _filtered".
313 I'm not completely sure what that means, I suspect most print_insn
314 now do use _filtered, so I guess it's obsolete. */
315 /* We often wrap here if there are long symbolic names. */
317 next_address = VALUE_ADDRESS (val)
318 + print_insn (VALUE_ADDRESS (val), gdb_stdout);
323 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY
324 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRING
325 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT
326 || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION
327 || VALUE_REPEATED (val))
328 value_print (val, gdb_stdout, format, Val_pretty_default);
330 print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val),
331 format, size, gdb_stdout);
335 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
336 according to letters FORMAT and SIZE on STREAM.
337 FORMAT may not be zero. Formats s and i are not supported at this level.
339 This is how the elements of an array or structure are printed
343 print_scalar_formatted (valaddr, type, format, size, stream)
351 int len = TYPE_LENGTH (type);
353 if (len > sizeof (LONGEST)
361 /* We can't print it normally, but we can print it in hex.
362 Printing it in the wrong radix is more useful than saying
363 "use /x, you dummy". */
364 /* FIXME: we could also do octal or binary if that was the
366 /* FIXME: we should be using the size field to give us a minimum
367 field width to print. */
368 val_print_type_code_int (type, valaddr, stream);
373 val_long = unpack_long (type, valaddr);
375 /* If we are printing it as unsigned, truncate it in case it is actually
376 a negative signed value (e.g. "print/u (short)-1" should print 65535
377 (if shorts are 16 bits) instead of 4294967295). */
380 if (len < sizeof (LONGEST))
381 val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
389 /* no size specified, like in print. Print varying # of digits. */
390 print_longest (stream, 'x', 1, val_long);
399 print_longest (stream, size, 1, val_long);
402 error ("Undefined output size \"%c\".", size);
407 print_longest (stream, 'd', 1, val_long);
411 print_longest (stream, 'u', 0, val_long);
416 print_longest (stream, 'o', 1, val_long);
418 fprintf_filtered (stream, "0");
422 print_address (unpack_pointer (type, valaddr), stream);
426 value_print (value_from_longest (builtin_type_char, val_long), stream, 0,
431 if (len == sizeof (float))
432 type = builtin_type_float;
433 else if (len == sizeof (double))
434 type = builtin_type_double;
435 print_floating (valaddr, type, stream);
442 /* Binary; 't' stands for "two". */
444 char bits[8*(sizeof val_long) + 1];
449 width = 8*(sizeof val_long);
466 error ("Undefined output size \"%c\".", size);
472 bits[width] = (val_long & 1) ? '1' : '0';
477 while (*cp && *cp == '0')
482 fprintf_filtered (stream, local_binary_format_prefix());
483 fprintf_filtered (stream, cp);
484 fprintf_filtered (stream, local_binary_format_suffix());
489 error ("Undefined output format \"%c\".", format);
493 /* Specify default address for `x' command.
494 `info lines' uses this. */
497 set_next_address (addr)
502 /* Make address available to the user as $_. */
503 set_internalvar (lookup_internalvar ("_"),
504 value_from_longest (lookup_pointer_type (builtin_type_void),
508 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
509 after LEADIN. Print nothing if no symbolic name is found nearby.
510 Optionally also print source file and line number, if available.
511 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
512 or to interpret it as a possible C++ name and convert it back to source
513 form. However note that DO_DEMANGLE can be overridden by the specific
514 settings of the demangle and asm_demangle variables. */
517 print_address_symbolic (addr, stream, do_demangle, leadin)
523 struct minimal_symbol *msymbol;
524 struct symbol *symbol;
525 struct symtab *symtab = 0;
526 CORE_ADDR name_location = 0;
529 /* First try to find the address in the symbol table, then
530 in the minsyms. Take the closest one. */
532 /* This is defective in the sense that it only finds text symbols. So
533 really this is kind of pointless--we should make sure that the
534 minimal symbols have everything we need (by changing that we could
535 save some memory, but for many debug format--ELF/DWARF or
536 anything/stabs--it would be inconvenient to eliminate those minimal
538 symbol = find_pc_function (addr);
540 name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
545 name = SYMBOL_SOURCE_NAME (symbol);
547 name = SYMBOL_LINKAGE_NAME (symbol);
550 msymbol = lookup_minimal_symbol_by_pc (addr);
553 if (SYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL)
555 /* The msymbol is closer to the address than the symbol;
556 use the msymbol instead. */
559 name_location = SYMBOL_VALUE_ADDRESS (msymbol);
561 name = SYMBOL_SOURCE_NAME (msymbol);
563 name = SYMBOL_LINKAGE_NAME (msymbol);
566 if (symbol == NULL && msymbol == NULL)
569 /* If the nearest symbol is too far away, don't print anything symbolic. */
571 /* For when CORE_ADDR is larger than unsigned int, we do math in
572 CORE_ADDR. But when we detect unsigned wraparound in the
573 CORE_ADDR math, we ignore this test and print the offset,
574 because addr+max_symbolic_offset has wrapped through the end
575 of the address space back to the beginning, giving bogus comparison. */
576 if (addr > name_location + max_symbolic_offset
577 && name_location + max_symbolic_offset > name_location)
580 fputs_filtered (leadin, stream);
581 fputs_filtered ("<", stream);
582 fputs_filtered (name, stream);
583 if (addr != name_location)
584 fprintf_filtered (stream, "+%u", (unsigned int)(addr - name_location));
586 /* Append source filename and line number if desired. Give specific
587 line # of this addr, if we have it; else line # of the nearest symbol. */
588 if (print_symbol_filename)
590 struct symtab_and_line sal;
592 sal = find_pc_line (addr, 0);
594 fprintf_filtered (stream, " at %s:%d", sal.symtab->filename, sal.line);
595 else if (symtab && symbol && symbol->line)
596 fprintf_filtered (stream, " at %s:%d", symtab->filename, symbol->line);
598 fprintf_filtered (stream, " in %s", symtab->filename);
600 fputs_filtered (">", stream);
603 /* Print address ADDR on STREAM. */
605 print_address_numeric (addr, stream)
609 /* This assumes a CORE_ADDR can fit in a LONGEST. Probably a safe
610 assumption. We pass use_local but I'm not completely sure whether
611 that is correct. When (if ever) should we *not* use_local? */
612 print_longest (stream, 'x', 1, (unsigned LONGEST) addr);
615 /* Print address ADDR symbolically on STREAM.
616 First print it as a number. Then perhaps print
617 <SYMBOL + OFFSET> after the number. */
620 print_address (addr, stream)
624 print_address_numeric (addr, stream);
625 print_address_symbolic (addr, stream, asm_demangle, " ");
628 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
629 controls whether to print the symbolic name "raw" or demangled.
630 Global setting "addressprint" controls whether to print hex address
634 print_address_demangle (addr, stream, do_demangle)
641 fprintf_filtered (stream, "0");
643 else if (addressprint)
645 print_address_numeric (addr, stream);
646 print_address_symbolic (addr, stream, do_demangle, " ");
650 print_address_symbolic (addr, stream, do_demangle, "");
655 /* These are the types that $__ will get after an examine command of one
658 static struct type *examine_b_type;
659 static struct type *examine_h_type;
660 static struct type *examine_w_type;
661 static struct type *examine_g_type;
663 /* Examine data at address ADDR in format FMT.
664 Fetch it from memory and print on gdb_stdout. */
667 do_examine (fmt, addr)
668 struct format_data fmt;
671 register char format = 0;
673 register int count = 1;
674 struct type *val_type = NULL;
676 register int maxelts;
683 /* String or instruction format implies fetch single bytes
684 regardless of the specified size. */
685 if (format == 's' || format == 'i')
689 val_type = examine_b_type;
690 else if (size == 'h')
691 val_type = examine_h_type;
692 else if (size == 'w')
693 val_type = examine_w_type;
694 else if (size == 'g')
695 val_type = examine_g_type;
702 if (format == 's' || format == 'i')
705 /* Print as many objects as specified in COUNT, at most maxelts per line,
706 with the address of the next one at the start of each line. */
710 print_address (next_address, gdb_stdout);
711 printf_filtered (":");
716 printf_filtered ("\t");
717 /* Note that print_formatted sets next_address for the next
719 last_examine_address = next_address;
720 last_examine_value = value_at (val_type, next_address);
721 print_formatted (last_examine_value, format, size);
723 printf_filtered ("\n");
724 gdb_flush (gdb_stdout);
729 validate_format (fmt, cmdname)
730 struct format_data fmt;
734 error ("Size letters are meaningless in \"%s\" command.", cmdname);
736 error ("Item count other than 1 is meaningless in \"%s\" command.",
738 if (fmt.format == 'i' || fmt.format == 's')
739 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
740 fmt.format, cmdname);
743 /* Evaluate string EXP as an expression in the current language and
744 print the resulting value. EXP may contain a format specifier as the
745 first argument ("/x myvar" for example, to print myvar in hex).
749 print_command_1 (exp, inspect, voidprint)
754 struct expression *expr;
755 register struct cleanup *old_chain = 0;
756 register char format = 0;
757 register value_ptr val;
758 struct format_data fmt;
761 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
762 inspect_it = inspect;
764 if (exp && *exp == '/')
767 fmt = decode_format (&exp, last_format, 0);
768 validate_format (fmt, "print");
769 last_format = format = fmt.format;
780 extern int objectprint;
782 expr = parse_expression (exp);
783 old_chain = make_cleanup (free_current_contents, &expr);
785 val = evaluate_expression (expr);
787 /* C++: figure out what type we actually want to print it as. */
788 type = VALUE_TYPE (val);
791 && ( TYPE_CODE (type) == TYPE_CODE_PTR
792 || TYPE_CODE (type) == TYPE_CODE_REF)
793 && ( TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
794 || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION))
798 v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type));
802 type = VALUE_TYPE (val);
807 val = access_value_history (0);
809 if (voidprint || (val && VALUE_TYPE (val) &&
810 TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_VOID))
812 int histindex = record_latest_value (val);
815 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex);
817 if (histindex >= 0) printf_filtered ("$%d = ", histindex);
819 print_formatted (val, format, fmt.size);
820 printf_filtered ("\n");
822 printf_unfiltered("\") )\030");
826 do_cleanups (old_chain);
827 inspect_it = 0; /* Reset print routines to normal */
832 print_command (exp, from_tty)
836 print_command_1 (exp, 0, 1);
839 /* Same as print, except in epoch, it gets its own window */
842 inspect_command (exp, from_tty)
846 extern int epoch_interface;
848 print_command_1 (exp, epoch_interface, 1);
851 /* Same as print, except it doesn't print void results. */
854 call_command (exp, from_tty)
858 print_command_1 (exp, 0, 0);
863 output_command (exp, from_tty)
867 struct expression *expr;
868 register struct cleanup *old_chain;
869 register char format = 0;
870 register value_ptr val;
871 struct format_data fmt;
873 if (exp && *exp == '/')
876 fmt = decode_format (&exp, 0, 0);
877 validate_format (fmt, "output");
881 expr = parse_expression (exp);
882 old_chain = make_cleanup (free_current_contents, &expr);
884 val = evaluate_expression (expr);
886 print_formatted (val, format, fmt.size);
888 do_cleanups (old_chain);
893 set_command (exp, from_tty)
897 struct expression *expr = parse_expression (exp);
898 register struct cleanup *old_chain
899 = make_cleanup (free_current_contents, &expr);
900 evaluate_expression (expr);
901 do_cleanups (old_chain);
906 address_info (exp, from_tty)
910 register struct symbol *sym;
911 register struct minimal_symbol *msymbol;
913 register long basereg;
914 int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero
915 if exp is a field of `this'. */
918 error ("Argument required.");
920 sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
921 &is_a_field_of_this, (struct symtab **)NULL);
924 if (is_a_field_of_this)
926 printf_filtered ("Symbol \"");
927 fprintf_symbol_filtered (gdb_stdout, exp,
928 current_language->la_language, DMGL_ANSI);
929 printf_filtered ("\" is a field of the local class variable `this'\n");
933 msymbol = lookup_minimal_symbol (exp, (struct objfile *) NULL);
937 printf_filtered ("Symbol \"");
938 fprintf_symbol_filtered (gdb_stdout, exp,
939 current_language->la_language, DMGL_ANSI);
940 printf_filtered ("\" is at ");
941 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), gdb_stdout);
942 printf_filtered (" in a file compiled without debugging.\n");
945 error ("No symbol \"%s\" in current context.", exp);
949 printf_filtered ("Symbol \"");
950 fprintf_symbol_filtered (gdb_stdout, SYMBOL_NAME (sym),
951 current_language->la_language, DMGL_ANSI);
952 printf_filtered ("\" is ", SYMBOL_NAME (sym));
953 val = SYMBOL_VALUE (sym);
954 basereg = SYMBOL_BASEREG (sym);
956 switch (SYMBOL_CLASS (sym))
959 case LOC_CONST_BYTES:
960 printf_filtered ("constant");
964 printf_filtered ("a label at address ");
965 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), gdb_stdout);
969 printf_filtered ("a variable in register %s", reg_names[val]);
973 printf_filtered ("static storage at address ");
974 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), gdb_stdout);
978 printf_filtered ("an argument in register %s", reg_names[val]);
981 case LOC_REGPARM_ADDR:
982 printf_filtered ("address of an argument in register %s", reg_names[val]);
986 printf_filtered ("an argument at offset %ld", val);
990 printf_filtered ("an argument at frame offset %ld", val);
994 printf_filtered ("a local variable at frame offset %ld", val);
998 printf_filtered ("a reference argument at offset %ld", val);
1002 printf_filtered ("a variable at offset %ld from register %s",
1003 val, reg_names[basereg]);
1006 case LOC_BASEREG_ARG:
1007 printf_filtered ("an argument at offset %ld from register %s",
1008 val, reg_names[basereg]);
1012 printf_filtered ("a typedef");
1016 printf_filtered ("a function at address ");
1017 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
1021 case LOC_OPTIMIZED_OUT:
1022 printf_filtered ("optimized out");
1026 printf_filtered ("of unknown (botched) type");
1029 printf_filtered (".\n");
1033 x_command (exp, from_tty)
1037 struct expression *expr;
1038 struct format_data fmt;
1039 struct cleanup *old_chain;
1042 fmt.format = last_format;
1043 fmt.size = last_size;
1046 if (exp && *exp == '/')
1049 fmt = decode_format (&exp, last_format, last_size);
1052 /* If we have an expression, evaluate it and use it as the address. */
1054 if (exp != 0 && *exp != 0)
1056 expr = parse_expression (exp);
1057 /* Cause expression not to be there any more
1058 if this command is repeated with Newline.
1059 But don't clobber a user-defined command's definition. */
1062 old_chain = make_cleanup (free_current_contents, &expr);
1063 val = evaluate_expression (expr);
1064 if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)
1065 val = value_ind (val);
1066 /* In rvalue contexts, such as this, functions are coerced into
1067 pointers to functions. This makes "x/i main" work. */
1068 if (/* last_format == 'i'
1069 && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
1070 && VALUE_LVAL (val) == lval_memory)
1071 next_address = VALUE_ADDRESS (val);
1073 next_address = value_as_pointer (val);
1074 do_cleanups (old_chain);
1077 do_examine (fmt, next_address);
1079 /* If the examine succeeds, we remember its size and format for next time. */
1080 last_size = fmt.size;
1081 last_format = fmt.format;
1083 /* Set a couple of internal variables if appropriate. */
1084 if (last_examine_value)
1086 /* Make last address examined available to the user as $_. Use
1087 the correct pointer type. */
1088 set_internalvar (lookup_internalvar ("_"),
1089 value_from_longest (
1090 lookup_pointer_type (VALUE_TYPE (last_examine_value)),
1091 (LONGEST) last_examine_address));
1093 /* Make contents of last address examined available to the user as $__.*/
1094 set_internalvar (lookup_internalvar ("__"), last_examine_value);
1099 /* Add an expression to the auto-display chain.
1100 Specify the expression. */
1103 display_command (exp, from_tty)
1107 struct format_data fmt;
1108 register struct expression *expr;
1109 register struct display *new;
1120 fmt = decode_format (&exp, 0, 0);
1121 if (fmt.size && fmt.format == 0)
1123 if (fmt.format == 'i' || fmt.format == 's')
1133 innermost_block = 0;
1134 expr = parse_expression (exp);
1136 new = (struct display *) xmalloc (sizeof (struct display));
1139 new->block = innermost_block;
1140 new->next = display_chain;
1141 new->number = ++display_number;
1143 new->status = enabled;
1144 display_chain = new;
1146 if (from_tty && target_has_execution)
1147 do_one_display (new);
1160 /* Clear out the display_chain.
1161 Done when new symtabs are loaded, since this invalidates
1162 the types stored in many expressions. */
1167 register struct display *d;
1169 while ((d = display_chain) != NULL)
1172 display_chain = d->next;
1177 /* Delete the auto-display number NUM. */
1180 delete_display (num)
1183 register struct display *d1, *d;
1186 error ("No display number %d.", num);
1188 if (display_chain->number == num)
1191 display_chain = d1->next;
1195 for (d = display_chain; ; d = d->next)
1198 error ("No display number %d.", num);
1199 if (d->next->number == num)
1209 /* Delete some values from the auto-display chain.
1210 Specify the element numbers. */
1213 undisplay_command (args, from_tty)
1217 register char *p = args;
1223 if (query ("Delete all auto-display expressions? "))
1232 while (*p1 >= '0' && *p1 <= '9') p1++;
1233 if (*p1 && *p1 != ' ' && *p1 != '\t')
1234 error ("Arguments must be display numbers.");
1238 delete_display (num);
1241 while (*p == ' ' || *p == '\t') p++;
1246 /* Display a single auto-display.
1247 Do nothing if the display cannot be printed in the current context,
1248 or if the display is disabled. */
1254 int within_current_scope;
1256 if (d->status == disabled)
1260 within_current_scope = contained_in (get_selected_block (), d->block);
1262 within_current_scope = 1;
1263 if (!within_current_scope)
1266 current_display_number = d->number;
1268 printf_filtered ("%d: ", d->number);
1273 printf_filtered ("x/");
1274 if (d->format.count != 1)
1275 printf_filtered ("%d", d->format.count);
1276 printf_filtered ("%c", d->format.format);
1277 if (d->format.format != 'i' && d->format.format != 's')
1278 printf_filtered ("%c", d->format.size);
1279 printf_filtered (" ");
1280 print_expression (d->exp, gdb_stdout);
1281 if (d->format.count != 1)
1282 printf_filtered ("\n");
1284 printf_filtered (" ");
1286 addr = value_as_pointer (evaluate_expression (d->exp));
1287 if (d->format.format == 'i')
1288 addr = ADDR_BITS_REMOVE (addr);
1290 do_examine (d->format, addr);
1294 if (d->format.format)
1295 printf_filtered ("/%c ", d->format.format);
1296 print_expression (d->exp, gdb_stdout);
1297 printf_filtered (" = ");
1298 print_formatted (evaluate_expression (d->exp),
1299 d->format.format, d->format.size);
1300 printf_filtered ("\n");
1303 gdb_flush (gdb_stdout);
1304 current_display_number = -1;
1307 /* Display all of the values on the auto-display chain which can be
1308 evaluated in the current scope. */
1313 register struct display *d;
1315 for (d = display_chain; d; d = d->next)
1319 /* Delete the auto-display which we were in the process of displaying.
1320 This is done when there is an error or a signal. */
1323 disable_display (num)
1326 register struct display *d;
1328 for (d = display_chain; d; d = d->next)
1329 if (d->number == num)
1331 d->status = disabled;
1334 printf_unfiltered ("No display number %d.\n", num);
1338 disable_current_display ()
1340 if (current_display_number >= 0)
1342 disable_display (current_display_number);
1343 fprintf_unfiltered (gdb_stderr, "Disabling display %d to avoid infinite recursion.\n",
1344 current_display_number);
1346 current_display_number = -1;
1350 display_info (ignore, from_tty)
1354 register struct display *d;
1357 printf_unfiltered ("There are no auto-display expressions now.\n");
1359 printf_filtered ("Auto-display expressions now in effect:\n\
1360 Num Enb Expression\n");
1362 for (d = display_chain; d; d = d->next)
1364 printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]);
1366 printf_filtered ("/%d%c%c ", d->format.count, d->format.size,
1368 else if (d->format.format)
1369 printf_filtered ("/%c ", d->format.format);
1370 print_expression (d->exp, gdb_stdout);
1371 if (d->block && !contained_in (get_selected_block (), d->block))
1372 printf_filtered (" (cannot be evaluated in the current context)");
1373 printf_filtered ("\n");
1374 gdb_flush (gdb_stdout);
1379 enable_display (args, from_tty)
1383 register char *p = args;
1386 register struct display *d;
1390 for (d = display_chain; d; d = d->next)
1391 d->status = enabled;
1397 while (*p1 >= '0' && *p1 <= '9')
1399 if (*p1 && *p1 != ' ' && *p1 != '\t')
1400 error ("Arguments must be display numbers.");
1404 for (d = display_chain; d; d = d->next)
1405 if (d->number == num)
1407 d->status = enabled;
1410 printf_unfiltered ("No display number %d.\n", num);
1413 while (*p == ' ' || *p == '\t')
1420 disable_display_command (args, from_tty)
1424 register char *p = args;
1426 register struct display *d;
1430 for (d = display_chain; d; d = d->next)
1431 d->status = disabled;
1437 while (*p1 >= '0' && *p1 <= '9')
1439 if (*p1 && *p1 != ' ' && *p1 != '\t')
1440 error ("Arguments must be display numbers.");
1442 disable_display (atoi (p));
1445 while (*p == ' ' || *p == '\t')
1451 /* Print the value in stack frame FRAME of a variable
1452 specified by a struct symbol. */
1455 print_variable_value (var, frame, stream)
1460 value_ptr val = read_var_value (var, frame);
1461 value_print (val, stream, 0, Val_pretty_default);
1464 /* Print the arguments of a stack frame, given the function FUNC
1465 running in that frame (as a symbol), the info on the frame,
1466 and the number of args according to the stack frame (or -1 if unknown). */
1468 /* References here and elsewhere to "number of args according to the
1469 stack frame" appear in all cases to refer to "number of ints of args
1470 according to the stack frame". At least for VAX, i386, isi. */
1473 print_frame_args (func, fi, num, stream)
1474 struct symbol *func;
1475 struct frame_info *fi;
1479 struct block *b = NULL;
1483 register struct symbol *sym;
1484 register value_ptr val;
1485 /* Offset of next stack argument beyond the one we have seen that is
1486 at the highest offset.
1487 -1 if we haven't come to a stack argument yet. */
1488 long highest_offset = -1;
1490 /* Number of ints of arguments that we have printed so far. */
1491 int args_printed = 0;
1495 b = SYMBOL_BLOCK_VALUE (func);
1496 nsyms = BLOCK_NSYMS (b);
1499 for (i = 0; i < nsyms; i++)
1502 sym = BLOCK_SYM (b, i);
1504 /* Keep track of the highest stack argument offset seen, and
1505 skip over any kinds of symbols we don't care about. */
1507 switch (SYMBOL_CLASS (sym)) {
1511 long current_offset = SYMBOL_VALUE (sym);
1513 arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
1515 /* Compute address of next argument by adding the size of
1516 this argument and rounding to an int boundary. */
1518 = ((current_offset + arg_size + sizeof (int) - 1)
1519 & ~(sizeof (int) - 1));
1521 /* If this is the highest offset seen yet, set highest_offset. */
1522 if (highest_offset == -1
1523 || (current_offset > highest_offset))
1524 highest_offset = current_offset;
1526 /* Add the number of ints we're about to print to args_printed. */
1527 args_printed += (arg_size + sizeof (int) - 1) / sizeof (int);
1530 /* We care about types of symbols, but don't need to keep track of
1531 stack offsets in them. */
1533 case LOC_REGPARM_ADDR:
1535 case LOC_BASEREG_ARG:
1538 /* Other types of symbols we just skip over. */
1543 /* We have to look up the symbol because arguments can have
1544 two entries (one a parameter, one a local) and the one we
1545 want is the local, which lookup_symbol will find for us.
1546 This includes gcc1 (not gcc2) on the sparc when passing a
1547 small structure and gcc2 when the argument type is float
1548 and it is passed as a double and converted to float by
1549 the prologue (in the latter case the type of the LOC_ARG
1550 symbol is double and the type of the LOC_LOCAL symbol is
1552 /* But if the parameter name is null, don't try it.
1553 Null parameter names occur on the RS/6000, for traceback tables.
1554 FIXME, should we even print them? */
1556 if (*SYMBOL_NAME (sym))
1558 struct symbol *nsym;
1559 nsym = lookup_symbol
1561 b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
1562 if (SYMBOL_CLASS (nsym) == LOC_REGISTER)
1564 /* There is a LOC_ARG/LOC_REGISTER pair. This means that
1565 it was passed on the stack and loaded into a register,
1566 or passed in a register and stored in a stack slot.
1567 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
1569 Reasons for using the LOC_ARG:
1570 (1) because find_saved_registers may be slow for remote
1572 (2) because registers are often re-used and stack slots
1573 rarely (never?) are. Therefore using the stack slot is
1574 much less likely to print garbage.
1576 Reasons why we might want to use the LOC_REGISTER:
1577 (1) So that the backtrace prints the same value as
1578 "print foo". I see no compelling reason why this needs
1579 to be the case; having the backtrace print the value which
1580 was passed in, and "print foo" print the value as modified
1581 within the called function, makes perfect sense to me.
1583 Additional note: It might be nice if "info args" displayed
1585 One more note: There is a case with sparc sturcture passing
1586 where we need to use the LOC_REGISTER, but this is dealt with
1587 by creating a single LOC_REGPARM in symbol reading. */
1589 /* Leave sym (the LOC_ARG) alone. */
1596 /* Print the current arg. */
1598 fprintf_filtered (stream, ", ");
1600 fprintf_symbol_filtered (stream, SYMBOL_SOURCE_NAME (sym),
1601 SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI);
1602 fputs_filtered ("=", stream);
1604 /* Avoid value_print because it will deref ref parameters. We just
1605 want to print their addresses. Print ??? for args whose address
1606 we do not know. We pass 2 as "recurse" to val_print because our
1607 standard indentation here is 4 spaces, and val_print indents
1608 2 for each recurse. */
1609 val = read_var_value (sym, FRAME_INFO_ID (fi));
1611 val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val),
1612 stream, 0, 0, 2, Val_no_prettyprint);
1614 fputs_filtered ("???", stream);
1618 /* Don't print nameless args in situations where we don't know
1619 enough about the stack to find them. */
1624 if (highest_offset == -1)
1625 start = FRAME_ARGS_SKIP;
1627 start = highest_offset;
1629 print_frame_nameless_args (fi, start, num - args_printed,
1634 /* Print nameless args on STREAM.
1635 FI is the frameinfo for this frame, START is the offset
1636 of the first nameless arg, and NUM is the number of nameless args to
1637 print. FIRST is nonzero if this is the first argument (not just
1638 the first nameless arg). */
1640 print_frame_nameless_args (fi, start, num, first, stream)
1641 struct frame_info *fi;
1651 for (i = 0; i < num; i++)
1654 #ifdef NAMELESS_ARG_VALUE
1655 NAMELESS_ARG_VALUE (fi, start, &arg_value);
1657 argsaddr = FRAME_ARGS_ADDRESS (fi);
1661 arg_value = read_memory_integer (argsaddr + start, sizeof (int));
1665 fprintf_filtered (stream, ", ");
1667 #ifdef PRINT_NAMELESS_INTEGER
1668 PRINT_NAMELESS_INTEGER (stream, arg_value);
1670 #ifdef PRINT_TYPELESS_INTEGER
1671 PRINT_TYPELESS_INTEGER (stream, builtin_type_int, (LONGEST) arg_value);
1673 fprintf_filtered (stream, "%d", arg_value);
1674 #endif /* PRINT_TYPELESS_INTEGER */
1675 #endif /* PRINT_NAMELESS_INTEGER */
1677 start += sizeof (int);
1683 printf_command (arg, from_tty)
1688 register char *s = arg;
1690 value_ptr *val_args;
1692 char *current_substring;
1694 int allocated_args = 20;
1695 struct cleanup *old_cleanups;
1697 val_args = (value_ptr *) xmalloc (allocated_args * sizeof (value_ptr));
1698 old_cleanups = make_cleanup (free_current_contents, &val_args);
1701 error_no_arg ("format-control string and values to print");
1703 /* Skip white space before format string */
1704 while (*s == ' ' || *s == '\t') s++;
1706 /* A format string should follow, enveloped in double quotes */
1708 error ("Bad format string, missing '\"'.");
1710 /* Parse the format-control string and copy it into the string STRING,
1711 processing some kinds of escape sequence. */
1713 f = string = (char *) alloca (strlen (s) + 1);
1721 error ("Bad format string, non-terminated '\"'.");
1733 *f++ = '\007'; /* Bell */
1758 /* ??? TODO: handle other escape sequences */
1759 error ("Unrecognized escape character \\%c in format string.",
1769 /* Skip over " and following space and comma. */
1772 while (*s == ' ' || *s == '\t') s++;
1774 if (*s != ',' && *s != 0)
1775 error ("Invalid argument syntax");
1778 while (*s == ' ' || *s == '\t') s++;
1780 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1781 substrings = alloca (strlen (string) * 2);
1782 current_substring = substrings;
1785 /* Now scan the string for %-specs and see what kinds of args they want.
1786 argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
1787 of the right size. */
1789 enum argclass {no_arg, int_arg, string_arg, double_arg, long_long_arg};
1790 enum argclass *argclass;
1791 enum argclass this_argclass;
1797 argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass);
1805 while (strchr ("0123456789.hlL-+ #", *f))
1807 if (*f == 'l' || *f == 'L')
1814 this_argclass = string_arg;
1820 this_argclass = double_arg;
1824 error ("`*' not supported for precision or width in printf");
1827 error ("Format specifier `n' not supported in printf");
1830 this_argclass = no_arg;
1835 this_argclass = long_long_arg;
1837 this_argclass = int_arg;
1841 if (this_argclass != no_arg)
1843 strncpy (current_substring, last_arg, f - last_arg);
1844 current_substring += f - last_arg;
1845 *current_substring++ = '\0';
1847 argclass[nargs_wanted++] = this_argclass;
1851 /* Now, parse all arguments and evaluate them.
1852 Store the VALUEs in VAL_ARGS. */
1857 if (nargs == allocated_args)
1858 val_args = (value_ptr *) xrealloc ((char *) val_args,
1859 (allocated_args *= 2)
1860 * sizeof (value_ptr));
1862 val_args[nargs] = parse_to_comma_and_eval (&s1);
1864 /* If format string wants a float, unchecked-convert the value to
1865 floating point of the same size */
1867 if (argclass[nargs] == double_arg)
1869 if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float))
1870 VALUE_TYPE (val_args[nargs]) = builtin_type_float;
1871 if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double))
1872 VALUE_TYPE (val_args[nargs]) = builtin_type_double;
1880 if (nargs != nargs_wanted)
1881 error ("Wrong number of arguments for specified format-string");
1883 /* FIXME: We should be using vprintf_filtered, but as long as it
1884 has an arbitrary limit that is unacceptable. Correct fix is
1885 for vprintf_filtered to scan down the format string so it knows
1886 how big a buffer it needs (perhaps by putting a vasprintf (see
1887 GNU C library) in libiberty).
1889 But for now, just force out any pending output, so at least the output
1890 appears in the correct order. */
1891 wrap_here ((char *)NULL);
1893 /* Now actually print them. */
1894 current_substring = substrings;
1895 for (i = 0; i < nargs; i++)
1897 switch (argclass[i])
1904 tem = value_as_pointer (val_args[i]);
1906 /* This is a %s argument. Find the length of the string. */
1911 read_memory (tem + j, &c, 1);
1916 /* Copy the string contents into a string inside GDB. */
1917 str = (char *) alloca (j + 1);
1918 read_memory (tem, str, j);
1921 /* Don't use printf_filtered because of arbitrary limit. */
1922 printf_unfiltered (current_substring, str);
1927 double val = value_as_double (val_args[i]);
1928 /* Don't use printf_filtered because of arbitrary limit. */
1929 printf_unfiltered (current_substring, val);
1933 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1935 long long val = value_as_long (val_args[i]);
1936 /* Don't use printf_filtered because of arbitrary limit. */
1937 printf_unfiltered (current_substring, val);
1941 error ("long long not supported in printf");
1945 /* FIXME: there should be separate int_arg and long_arg. */
1946 long val = value_as_long (val_args[i]);
1947 /* Don't use printf_filtered because of arbitrary limit. */
1948 printf_unfiltered (current_substring, val);
1952 error ("internal error in printf_command");
1954 /* Skip to the next substring. */
1955 current_substring += strlen (current_substring) + 1;
1957 /* Print the portion of the format string after the last argument. */
1958 /* It would be OK to use printf_filtered here. */
1961 do_cleanups (old_cleanups);
1964 /* Dump a specified section of assembly code. With no command line
1965 arguments, this command will dump the assembly code for the
1966 function surrounding the pc value in the selected frame. With one
1967 argument, it will dump the assembly code surrounding that pc value.
1968 Two arguments are interpeted as bounds within which to dump
1973 disassemble_command (arg, from_tty)
1977 CORE_ADDR low, high;
1985 if (!selected_frame)
1986 error ("No frame selected.\n");
1988 pc = get_frame_pc (selected_frame);
1989 if (find_pc_partial_function (pc, &name, &low, &high) == 0)
1990 error ("No function contains program counter for selected frame.\n");
1992 else if (!(space_index = (char *) strchr (arg, ' ')))
1995 pc = parse_and_eval_address (arg);
1996 if (find_pc_partial_function (pc, &name, &low, &high) == 0)
1997 error ("No function contains specified address.\n");
2001 /* Two arguments. */
2002 *space_index = '\0';
2003 low = parse_and_eval_address (arg);
2004 high = parse_and_eval_address (space_index + 1);
2007 printf_filtered ("Dump of assembler code ");
2010 printf_filtered ("for function %s:\n", name);
2014 printf_filtered ("from ");
2015 print_address_numeric (low, gdb_stdout);
2016 printf_filtered (" to ");
2017 print_address_numeric (high, gdb_stdout);
2018 printf_filtered (":\n");
2021 /* Dump the specified range. */
2022 for (pc = low; pc < high; )
2025 print_address (pc, gdb_stdout);
2026 printf_filtered (":\t");
2027 /* We often wrap here if there are long symbolic names. */
2029 pc += print_insn (pc, gdb_stdout);
2030 printf_filtered ("\n");
2032 printf_filtered ("End of assembler dump.\n");
2033 gdb_flush (gdb_stdout);
2038 _initialize_printcmd ()
2040 current_display_number = -1;
2042 add_info ("address", address_info,
2043 "Describe where variable VAR is stored.");
2045 add_com ("x", class_vars, x_command,
2046 "Examine memory: x/FMT ADDRESS.\n\
2047 ADDRESS is an expression for the memory address to examine.\n\
2048 FMT is a repeat count followed by a format letter and a size letter.\n\
2049 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2050 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2051 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2052 The specified number of objects of the specified size are printed\n\
2053 according to the format.\n\n\
2054 Defaults for format and size letters are those previously used.\n\
2055 Default count is 1. Default address is following last thing printed\n\
2056 with this command or \"print\".");
2058 add_com ("disassemble", class_vars, disassemble_command,
2059 "Disassemble a specified section of memory.\n\
2060 Default is the function surrounding the pc of the selected frame.\n\
2061 With a single argument, the function surrounding that address is dumped.\n\
2062 Two arguments are taken as a range of memory to dump.");
2065 add_com ("whereis", class_vars, whereis_command,
2066 "Print line number and file of definition of variable.");
2069 add_info ("display", display_info,
2070 "Expressions to display when program stops, with code numbers.");
2072 add_cmd ("undisplay", class_vars, undisplay_command,
2073 "Cancel some expressions to be displayed when program stops.\n\
2074 Arguments are the code numbers of the expressions to stop displaying.\n\
2075 No argument means cancel all automatic-display expressions.\n\
2076 \"delete display\" has the same effect as this command.\n\
2077 Do \"info display\" to see current list of code numbers.",
2080 add_com ("display", class_vars, display_command,
2081 "Print value of expression EXP each time the program stops.\n\
2082 /FMT may be used before EXP as in the \"print\" command.\n\
2083 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2084 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2085 and examining is done as in the \"x\" command.\n\n\
2086 With no argument, display all currently requested auto-display expressions.\n\
2087 Use \"undisplay\" to cancel display requests previously made.");
2089 add_cmd ("display", class_vars, enable_display,
2090 "Enable some expressions to be displayed when program stops.\n\
2091 Arguments are the code numbers of the expressions to resume displaying.\n\
2092 No argument means enable all automatic-display expressions.\n\
2093 Do \"info display\" to see current list of code numbers.", &enablelist);
2095 add_cmd ("display", class_vars, disable_display_command,
2096 "Disable some expressions to be displayed when program stops.\n\
2097 Arguments are the code numbers of the expressions to stop displaying.\n\
2098 No argument means disable all automatic-display expressions.\n\
2099 Do \"info display\" to see current list of code numbers.", &disablelist);
2101 add_cmd ("display", class_vars, undisplay_command,
2102 "Cancel some expressions to be displayed when program stops.\n\
2103 Arguments are the code numbers of the expressions to stop displaying.\n\
2104 No argument means cancel all automatic-display expressions.\n\
2105 Do \"info display\" to see current list of code numbers.", &deletelist);
2107 add_com ("printf", class_vars, printf_command,
2108 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2109 This is useful for formatted output in user-defined commands.");
2110 add_com ("output", class_vars, output_command,
2111 "Like \"print\" but don't put in value history and don't print newline.\n\
2112 This is useful in user-defined commands.");
2114 add_prefix_cmd ("set", class_vars, set_command,
2115 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2116 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2117 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2118 with $), a register (a few standard names starting with $), or an actual\n\
2119 variable in the program being debugged. EXP is any valid expression.\n\
2120 Use \"set variable\" for variables with names identical to set subcommands.\n\
2121 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2122 You can see these environment settings with the \"show\" command.",
2123 &setlist, "set ", 1, &cmdlist);
2125 /* "call" is the same as "set", but handy for dbx users to call fns. */
2126 add_com ("call", class_vars, call_command,
2127 "Call a function in the program.\n\
2128 The argument is the function name and arguments, in the notation of the\n\
2129 current working language. The result is printed and saved in the value\n\
2130 history, if it is not void.");
2132 add_cmd ("variable", class_vars, set_command,
2133 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2134 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2135 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2136 with $), a register (a few standard names starting with $), or an actual\n\
2137 variable in the program being debugged. EXP is any valid expression.\n\
2138 This may usually be abbreviated to simply \"set\".",
2141 add_com ("print", class_vars, print_command,
2142 concat ("Print value of expression EXP.\n\
2143 Variables accessible are those of the lexical environment of the selected\n\
2144 stack frame, plus all those whose scope is global or an entire file.\n\
2146 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2147 $$NUM refers to NUM'th value back from the last one.\n\
2148 Names starting with $ refer to registers (with the values they would have\n\
2149 if the program were to return to the stack frame now selected, restoring\n\
2150 all registers saved by frames farther in) or else to debugger\n\
2151 \"convenience\" variables (any such name not a known register).\n\
2152 Use assignment expressions to give values to convenience variables.\n",
2154 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2155 @ is a binary operator for treating consecutive data objects\n\
2156 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2157 element is FOO, whose second element is stored in the space following\n\
2158 where FOO is stored, etc. FOO must be an expression whose value\n\
2159 resides in memory.\n",
2161 EXP may be preceded with /FMT, where FMT is a format letter\n\
2162 but no count or size letter (see \"x\" command).", NULL));
2163 add_com_alias ("p", "print", class_vars, 1);
2165 add_com ("inspect", class_vars, inspect_command,
2166 "Same as \"print\" command, except that if you are running in the epoch\n\
2167 environment, the value is printed in its own window.");
2170 add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,
2171 (char *)&max_symbolic_offset,
2172 "Set the largest offset that will be printed in <symbol+1234> form.",
2176 add_set_cmd ("symbol-filename", no_class, var_boolean,
2177 (char *)&print_symbol_filename,
2178 "Set printing of source filename and line number with <symbol>.",
2182 examine_b_type = init_type (TYPE_CODE_INT, 1, 0, NULL, NULL);
2183 examine_h_type = init_type (TYPE_CODE_INT, 2, 0, NULL, NULL);
2184 examine_w_type = init_type (TYPE_CODE_INT, 4, 0, NULL, NULL);
2185 examine_g_type = init_type (TYPE_CODE_INT, 8, 0, NULL, NULL);