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 /* Switch for quick display of symbolic addresses -- only uses minsyms,
78 not full search of symtabs. */
80 int fast_symbolic_addr
= 1;
82 /* Number of auto-display expression currently being displayed.
83 So that we can disable it if we get an error or a signal within it.
84 -1 when not doing one. */
86 int current_display_number
;
88 /* Flag to low-level print routines that this value is being printed
89 in an epoch window. We'd like to pass this as a parameter, but
90 every routine would need to take it. Perhaps we can encapsulate
91 this in the I/O stream once we have GNU stdio. */
97 /* Chain link to next auto-display item. */
99 /* Expression to be evaluated and displayed. */
100 struct expression
*exp
;
101 /* Item number of this auto-display item. */
103 /* Display format specified. */
104 struct format_data format
;
105 /* Innermost block required by this expression when evaluated */
107 /* Status of this display (enabled or disabled) */
111 /* Chain of expressions whose values should be displayed
112 automatically each time the program stops. */
114 static struct display
*display_chain
;
116 static int display_number
;
118 /* Prototypes for local functions */
121 delete_display
PARAMS ((int));
124 enable_display
PARAMS ((char *, int));
127 disable_display_command
PARAMS ((char *, int));
130 disassemble_command
PARAMS ((char *, int));
133 printf_command
PARAMS ((char *, int));
136 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
140 display_info
PARAMS ((char *, int));
143 do_one_display
PARAMS ((struct display
*));
146 undisplay_command
PARAMS ((char *, int));
149 free_display
PARAMS ((struct display
*));
152 display_command
PARAMS ((char *, int));
155 x_command
PARAMS ((char *, int));
158 address_info
PARAMS ((char *, int));
161 set_command
PARAMS ((char *, int));
164 output_command
PARAMS ((char *, int));
167 call_command
PARAMS ((char *, int));
170 inspect_command
PARAMS ((char *, int));
173 print_command
PARAMS ((char *, int));
176 print_command_1
PARAMS ((char *, int, int));
179 validate_format
PARAMS ((struct format_data
, char *));
182 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
185 print_formatted
PARAMS ((value_ptr
, int, int));
187 static struct format_data
188 decode_format
PARAMS ((char **, int, int));
191 /* Decode a format specification. *STRING_PTR should point to it.
192 OFORMAT and OSIZE are used as defaults for the format and size
193 if none are given in the format specification.
194 If OSIZE is zero, then the size field of the returned value
195 should be set only if a size is explicitly specified by the
197 The structure returned describes all the data
198 found in the specification. In addition, *STRING_PTR is advanced
199 past the specification and past all whitespace following it. */
201 static struct format_data
202 decode_format (string_ptr
, oformat
, osize
)
207 struct format_data val
;
208 register char *p
= *string_ptr
;
214 if (*p
>= '0' && *p
<= '9')
215 val
.count
= atoi (p
);
216 while (*p
>= '0' && *p
<= '9') p
++;
218 /* Now process size or format letters that follow. */
222 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
224 else if (*p
>= 'a' && *p
<= 'z')
230 while (*p
== ' ' || *p
== '\t') p
++;
233 /* Set defaults for format and size if not specified. */
234 if (val
.format
== '?')
238 /* Neither has been specified. */
239 val
.format
= oformat
;
243 /* If a size is specified, any format makes a reasonable
244 default except 'i'. */
245 val
.format
= oformat
== 'i' ? 'x' : oformat
;
247 else if (val
.size
== '?')
252 /* Pick the appropriate size for an address. */
253 #if TARGET_PTR_BIT == 64
254 val
.size
= osize
? 'g' : osize
;
257 #if TARGET_PTR_BIT == 32
258 val
.size
= osize
? 'w' : osize
;
261 #if TARGET_PTR_BIT == 16
262 val
.size
= osize
? 'h' : osize
;
265 #error Bad value for TARGET_PTR_BIT
271 /* Floating point has to be word or giantword. */
272 if (osize
== 'w' || osize
== 'g')
275 /* Default it to giantword if the last used size is not
277 val
.size
= osize
? 'g' : osize
;
280 /* Characters default to one byte. */
281 val
.size
= osize
? 'b' : osize
;
284 /* The default is the size most recently specified. */
291 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
292 Do not end with a newline.
293 0 means print VAL according to its own type.
294 SIZE is the letter for the size of datum being printed.
295 This is used to pad hex numbers so they line up. */
298 print_formatted (val
, format
, size
)
299 register value_ptr val
;
303 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
305 if (VALUE_LVAL (val
) == lval_memory
)
306 next_address
= VALUE_ADDRESS (val
) + len
;
311 next_address
= VALUE_ADDRESS (val
)
312 + value_print (value_addr (val
), gdb_stdout
, format
, Val_pretty_default
);
316 /* The old comment says
317 "Force output out, print_insn not using _filtered".
318 I'm not completely sure what that means, I suspect most print_insn
319 now do use _filtered, so I guess it's obsolete. */
320 /* We often wrap here if there are long symbolic names. */
322 next_address
= VALUE_ADDRESS (val
)
323 + print_insn (VALUE_ADDRESS (val
), gdb_stdout
);
328 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
329 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
330 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
331 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
332 || VALUE_REPEATED (val
))
333 value_print (val
, gdb_stdout
, format
, Val_pretty_default
);
335 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
336 format
, size
, gdb_stdout
);
340 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
341 according to letters FORMAT and SIZE on STREAM.
342 FORMAT may not be zero. Formats s and i are not supported at this level.
344 This is how the elements of an array or structure are printed
348 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
356 int len
= TYPE_LENGTH (type
);
358 if (len
> sizeof (LONGEST
)
366 /* We can't print it normally, but we can print it in hex.
367 Printing it in the wrong radix is more useful than saying
368 "use /x, you dummy". */
369 /* FIXME: we could also do octal or binary if that was the
371 /* FIXME: we should be using the size field to give us a minimum
372 field width to print. */
373 val_print_type_code_int (type
, valaddr
, stream
);
377 val_long
= unpack_long (type
, valaddr
);
379 /* If we are printing it as unsigned, truncate it in case it is actually
380 a negative signed value (e.g. "print/u (short)-1" should print 65535
381 (if shorts are 16 bits) instead of 4294967295). */
384 if (len
< sizeof (LONGEST
))
385 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
393 /* no size specified, like in print. Print varying # of digits. */
394 print_longest (stream
, 'x', 1, val_long
);
403 print_longest (stream
, size
, 1, val_long
);
406 error ("Undefined output size \"%c\".", size
);
411 print_longest (stream
, 'd', 1, val_long
);
415 print_longest (stream
, 'u', 0, val_long
);
420 print_longest (stream
, 'o', 1, val_long
);
422 fprintf_filtered (stream
, "0");
426 print_address (unpack_pointer (type
, valaddr
), stream
);
430 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
435 if (len
== sizeof (float))
436 type
= builtin_type_float
;
437 else if (len
== sizeof (double))
438 type
= builtin_type_double
;
439 print_floating (valaddr
, type
, stream
);
446 /* Binary; 't' stands for "two". */
448 char bits
[8*(sizeof val_long
) + 1];
453 width
= 8*(sizeof val_long
);
470 error ("Undefined output size \"%c\".", size
);
476 bits
[width
] = (val_long
& 1) ? '1' : '0';
481 while (*cp
&& *cp
== '0')
486 fprintf_filtered (stream
, local_binary_format_prefix());
487 fprintf_filtered (stream
, cp
);
488 fprintf_filtered (stream
, local_binary_format_suffix());
493 error ("Undefined output format \"%c\".", format
);
497 /* Specify default address for `x' command.
498 `info lines' uses this. */
501 set_next_address (addr
)
506 /* Make address available to the user as $_. */
507 set_internalvar (lookup_internalvar ("_"),
508 value_from_longest (lookup_pointer_type (builtin_type_void
),
512 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
513 after LEADIN. Print nothing if no symbolic name is found nearby.
514 Optionally also print source file and line number, if available.
515 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
516 or to interpret it as a possible C++ name and convert it back to source
517 form. However note that DO_DEMANGLE can be overridden by the specific
518 settings of the demangle and asm_demangle variables. */
521 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
527 struct minimal_symbol
*msymbol
;
528 struct symbol
*symbol
;
529 struct symtab
*symtab
= 0;
530 CORE_ADDR name_location
= 0;
533 /* First try to find the address in the symbol table, then
534 in the minsyms. Take the closest one. */
536 if (fast_symbolic_addr
)
538 /* This is defective in the sense that it only finds text symbols. */
539 symbol
= find_pc_function (addr
);
541 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
544 find_addr_symbol (addr
, &symtab
, &name_location
);
549 name
= SYMBOL_SOURCE_NAME (symbol
);
551 name
= SYMBOL_LINKAGE_NAME (symbol
);
554 msymbol
= lookup_minimal_symbol_by_pc (addr
);
557 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
|| symbol
== NULL
)
559 /* The msymbol is closer to the address than the symbol;
560 use the msymbol instead. */
563 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
565 name
= SYMBOL_SOURCE_NAME (msymbol
);
567 name
= SYMBOL_LINKAGE_NAME (msymbol
);
570 if (symbol
== NULL
&& msymbol
== NULL
)
573 /* If the nearest symbol is too far away, don't print anything symbolic. */
575 /* For when CORE_ADDR is larger than unsigned int, we do math in
576 CORE_ADDR. But when we detect unsigned wraparound in the
577 CORE_ADDR math, we ignore this test and print the offset,
578 because addr+max_symbolic_offset has wrapped through the end
579 of the address space back to the beginning, giving bogus comparison. */
580 if (addr
> name_location
+ max_symbolic_offset
581 && name_location
+ max_symbolic_offset
> name_location
)
584 fputs_filtered (leadin
, stream
);
585 fputs_filtered ("<", stream
);
586 fputs_filtered (name
, stream
);
587 if (addr
!= name_location
)
588 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
590 /* Append source filename and line number if desired. Give specific
591 line # of this addr, if we have it; else line # of the nearest symbol. */
592 if (print_symbol_filename
)
594 struct symtab_and_line sal
;
596 sal
= find_pc_line (addr
, 0);
598 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
599 else if (symtab
&& symbol
&& symbol
->line
)
600 fprintf_filtered (stream
, " at %s:%d", symtab
->filename
, symbol
->line
);
602 fprintf_filtered (stream
, " in %s", symtab
->filename
);
604 fputs_filtered (">", stream
);
607 /* Print address ADDR on STREAM. */
609 print_address_numeric (addr
, stream
)
613 /* This assumes a CORE_ADDR can fit in a LONGEST. Probably a safe
614 assumption. We pass use_local but I'm not completely sure whether
615 that is correct. When (if ever) should we *not* use_local? */
616 print_longest (stream
, 'x', 1, (unsigned LONGEST
) addr
);
619 /* Print address ADDR symbolically on STREAM.
620 First print it as a number. Then perhaps print
621 <SYMBOL + OFFSET> after the number. */
624 print_address (addr
, stream
)
628 print_address_numeric (addr
, stream
);
629 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
632 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
633 controls whether to print the symbolic name "raw" or demangled.
634 Global setting "addressprint" controls whether to print hex address
638 print_address_demangle (addr
, stream
, do_demangle
)
645 fprintf_filtered (stream
, "0");
647 else if (addressprint
)
649 print_address_numeric (addr
, stream
);
650 print_address_symbolic (addr
, stream
, do_demangle
, " ");
654 print_address_symbolic (addr
, stream
, do_demangle
, "");
659 /* These are the types that $__ will get after an examine command of one
662 static struct type
*examine_b_type
;
663 static struct type
*examine_h_type
;
664 static struct type
*examine_w_type
;
665 static struct type
*examine_g_type
;
667 /* Examine data at address ADDR in format FMT.
668 Fetch it from memory and print on gdb_stdout. */
671 do_examine (fmt
, addr
)
672 struct format_data fmt
;
675 register char format
= 0;
677 register int count
= 1;
678 struct type
*val_type
= NULL
;
680 register int maxelts
;
687 /* String or instruction format implies fetch single bytes
688 regardless of the specified size. */
689 if (format
== 's' || format
== 'i')
693 val_type
= examine_b_type
;
694 else if (size
== 'h')
695 val_type
= examine_h_type
;
696 else if (size
== 'w')
697 val_type
= examine_w_type
;
698 else if (size
== 'g')
699 val_type
= examine_g_type
;
706 if (format
== 's' || format
== 'i')
709 /* Print as many objects as specified in COUNT, at most maxelts per line,
710 with the address of the next one at the start of each line. */
714 print_address (next_address
, gdb_stdout
);
715 printf_filtered (":");
720 printf_filtered ("\t");
721 /* Note that print_formatted sets next_address for the next
723 last_examine_address
= next_address
;
724 last_examine_value
= value_at (val_type
, next_address
);
725 print_formatted (last_examine_value
, format
, size
);
727 printf_filtered ("\n");
728 gdb_flush (gdb_stdout
);
733 validate_format (fmt
, cmdname
)
734 struct format_data fmt
;
738 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
740 error ("Item count other than 1 is meaningless in \"%s\" command.",
742 if (fmt
.format
== 'i' || fmt
.format
== 's')
743 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
744 fmt
.format
, cmdname
);
747 /* Evaluate string EXP as an expression in the current language and
748 print the resulting value. EXP may contain a format specifier as the
749 first argument ("/x myvar" for example, to print myvar in hex).
753 print_command_1 (exp
, inspect
, voidprint
)
758 struct expression
*expr
;
759 register struct cleanup
*old_chain
= 0;
760 register char format
= 0;
761 register value_ptr val
;
762 struct format_data fmt
;
765 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
766 inspect_it
= inspect
;
768 if (exp
&& *exp
== '/')
771 fmt
= decode_format (&exp
, last_format
, 0);
772 validate_format (fmt
, "print");
773 last_format
= format
= fmt
.format
;
784 extern int objectprint
;
786 expr
= parse_expression (exp
);
787 old_chain
= make_cleanup (free_current_contents
, &expr
);
789 val
= evaluate_expression (expr
);
791 /* C++: figure out what type we actually want to print it as. */
792 type
= VALUE_TYPE (val
);
795 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
796 || TYPE_CODE (type
) == TYPE_CODE_REF
)
797 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
798 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
802 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
806 type
= VALUE_TYPE (val
);
811 val
= access_value_history (0);
813 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
814 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
816 int histindex
= record_latest_value (val
);
819 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
821 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
823 print_formatted (val
, format
, fmt
.size
);
824 printf_filtered ("\n");
826 printf_unfiltered("\") )\030");
830 do_cleanups (old_chain
);
831 inspect_it
= 0; /* Reset print routines to normal */
836 print_command (exp
, from_tty
)
840 print_command_1 (exp
, 0, 1);
843 /* Same as print, except in epoch, it gets its own window */
846 inspect_command (exp
, from_tty
)
850 extern int epoch_interface
;
852 print_command_1 (exp
, epoch_interface
, 1);
855 /* Same as print, except it doesn't print void results. */
858 call_command (exp
, from_tty
)
862 print_command_1 (exp
, 0, 0);
867 output_command (exp
, from_tty
)
871 struct expression
*expr
;
872 register struct cleanup
*old_chain
;
873 register char format
= 0;
874 register value_ptr val
;
875 struct format_data fmt
;
877 if (exp
&& *exp
== '/')
880 fmt
= decode_format (&exp
, 0, 0);
881 validate_format (fmt
, "output");
885 expr
= parse_expression (exp
);
886 old_chain
= make_cleanup (free_current_contents
, &expr
);
888 val
= evaluate_expression (expr
);
890 print_formatted (val
, format
, fmt
.size
);
892 do_cleanups (old_chain
);
897 set_command (exp
, from_tty
)
901 struct expression
*expr
= parse_expression (exp
);
902 register struct cleanup
*old_chain
903 = make_cleanup (free_current_contents
, &expr
);
904 evaluate_expression (expr
);
905 do_cleanups (old_chain
);
910 address_info (exp
, from_tty
)
914 register struct symbol
*sym
;
915 register struct minimal_symbol
*msymbol
;
917 register long basereg
;
918 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
919 if exp is a field of `this'. */
922 error ("Argument required.");
924 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
925 &is_a_field_of_this
, (struct symtab
**)NULL
);
928 if (is_a_field_of_this
)
930 printf_filtered ("Symbol \"");
931 fprintf_symbol_filtered (gdb_stdout
, exp
,
932 current_language
->la_language
, DMGL_ANSI
);
933 printf_filtered ("\" is a field of the local class variable `this'\n");
937 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
941 printf_filtered ("Symbol \"");
942 fprintf_symbol_filtered (gdb_stdout
, exp
,
943 current_language
->la_language
, DMGL_ANSI
);
944 printf_filtered ("\" is at ");
945 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol
), gdb_stdout
);
946 printf_filtered (" in a file compiled without debugging.\n");
949 error ("No symbol \"%s\" in current context.", exp
);
953 printf_filtered ("Symbol \"");
954 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_NAME (sym
),
955 current_language
->la_language
, DMGL_ANSI
);
956 printf_filtered ("\" is ", SYMBOL_NAME (sym
));
957 val
= SYMBOL_VALUE (sym
);
958 basereg
= SYMBOL_BASEREG (sym
);
960 switch (SYMBOL_CLASS (sym
))
963 case LOC_CONST_BYTES
:
964 printf_filtered ("constant");
968 printf_filtered ("a label at address ");
969 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), gdb_stdout
);
973 printf_filtered ("a variable in register %s", reg_names
[val
]);
977 printf_filtered ("static storage at address ");
978 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), gdb_stdout
);
982 printf_filtered ("an argument in register %s", reg_names
[val
]);
985 case LOC_REGPARM_ADDR
:
986 printf_filtered ("address of an argument in register %s", reg_names
[val
]);
990 printf_filtered ("an argument at offset %ld", val
);
994 printf_filtered ("an argument at frame offset %ld", val
);
998 printf_filtered ("a local variable at frame offset %ld", val
);
1002 printf_filtered ("a reference argument at offset %ld", val
);
1006 printf_filtered ("a variable at offset %ld from register %s",
1007 val
, reg_names
[basereg
]);
1010 case LOC_BASEREG_ARG
:
1011 printf_filtered ("an argument at offset %ld from register %s",
1012 val
, reg_names
[basereg
]);
1016 printf_filtered ("a typedef");
1020 printf_filtered ("a function at address ");
1021 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)),
1025 case LOC_OPTIMIZED_OUT
:
1026 printf_filtered ("optimized out");
1030 printf_filtered ("of unknown (botched) type");
1033 printf_filtered (".\n");
1037 x_command (exp
, from_tty
)
1041 struct expression
*expr
;
1042 struct format_data fmt
;
1043 struct cleanup
*old_chain
;
1046 fmt
.format
= last_format
;
1047 fmt
.size
= last_size
;
1050 if (exp
&& *exp
== '/')
1053 fmt
= decode_format (&exp
, last_format
, last_size
);
1056 /* If we have an expression, evaluate it and use it as the address. */
1058 if (exp
!= 0 && *exp
!= 0)
1060 expr
= parse_expression (exp
);
1061 /* Cause expression not to be there any more
1062 if this command is repeated with Newline.
1063 But don't clobber a user-defined command's definition. */
1066 old_chain
= make_cleanup (free_current_contents
, &expr
);
1067 val
= evaluate_expression (expr
);
1068 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1069 val
= value_ind (val
);
1070 /* In rvalue contexts, such as this, functions are coerced into
1071 pointers to functions. This makes "x/i main" work. */
1072 if (/* last_format == 'i'
1073 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1074 && VALUE_LVAL (val
) == lval_memory
)
1075 next_address
= VALUE_ADDRESS (val
);
1077 next_address
= value_as_pointer (val
);
1078 do_cleanups (old_chain
);
1081 do_examine (fmt
, next_address
);
1083 /* If the examine succeeds, we remember its size and format for next time. */
1084 last_size
= fmt
.size
;
1085 last_format
= fmt
.format
;
1087 /* Set a couple of internal variables if appropriate. */
1088 if (last_examine_value
)
1090 /* Make last address examined available to the user as $_. Use
1091 the correct pointer type. */
1092 set_internalvar (lookup_internalvar ("_"),
1093 value_from_longest (
1094 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1095 (LONGEST
) last_examine_address
));
1097 /* Make contents of last address examined available to the user as $__.*/
1098 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1103 /* Add an expression to the auto-display chain.
1104 Specify the expression. */
1107 display_command (exp
, from_tty
)
1111 struct format_data fmt
;
1112 register struct expression
*expr
;
1113 register struct display
*new;
1124 fmt
= decode_format (&exp
, 0, 0);
1125 if (fmt
.size
&& fmt
.format
== 0)
1127 if (fmt
.format
== 'i' || fmt
.format
== 's')
1137 innermost_block
= 0;
1138 expr
= parse_expression (exp
);
1140 new = (struct display
*) xmalloc (sizeof (struct display
));
1143 new->block
= innermost_block
;
1144 new->next
= display_chain
;
1145 new->number
= ++display_number
;
1147 new->status
= enabled
;
1148 display_chain
= new;
1150 if (from_tty
&& target_has_execution
)
1151 do_one_display (new);
1164 /* Clear out the display_chain.
1165 Done when new symtabs are loaded, since this invalidates
1166 the types stored in many expressions. */
1171 register struct display
*d
;
1173 while ((d
= display_chain
) != NULL
)
1176 display_chain
= d
->next
;
1181 /* Delete the auto-display number NUM. */
1184 delete_display (num
)
1187 register struct display
*d1
, *d
;
1190 error ("No display number %d.", num
);
1192 if (display_chain
->number
== num
)
1195 display_chain
= d1
->next
;
1199 for (d
= display_chain
; ; d
= d
->next
)
1202 error ("No display number %d.", num
);
1203 if (d
->next
->number
== num
)
1213 /* Delete some values from the auto-display chain.
1214 Specify the element numbers. */
1217 undisplay_command (args
, from_tty
)
1221 register char *p
= args
;
1227 if (query ("Delete all auto-display expressions? "))
1236 while (*p1
>= '0' && *p1
<= '9') p1
++;
1237 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1238 error ("Arguments must be display numbers.");
1242 delete_display (num
);
1245 while (*p
== ' ' || *p
== '\t') p
++;
1250 /* Display a single auto-display.
1251 Do nothing if the display cannot be printed in the current context,
1252 or if the display is disabled. */
1258 int within_current_scope
;
1260 if (d
->status
== disabled
)
1264 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1266 within_current_scope
= 1;
1267 if (!within_current_scope
)
1270 current_display_number
= d
->number
;
1272 printf_filtered ("%d: ", d
->number
);
1277 printf_filtered ("x/");
1278 if (d
->format
.count
!= 1)
1279 printf_filtered ("%d", d
->format
.count
);
1280 printf_filtered ("%c", d
->format
.format
);
1281 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1282 printf_filtered ("%c", d
->format
.size
);
1283 printf_filtered (" ");
1284 print_expression (d
->exp
, gdb_stdout
);
1285 if (d
->format
.count
!= 1)
1286 printf_filtered ("\n");
1288 printf_filtered (" ");
1290 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1291 if (d
->format
.format
== 'i')
1292 addr
= ADDR_BITS_REMOVE (addr
);
1294 do_examine (d
->format
, addr
);
1298 if (d
->format
.format
)
1299 printf_filtered ("/%c ", d
->format
.format
);
1300 print_expression (d
->exp
, gdb_stdout
);
1301 printf_filtered (" = ");
1302 print_formatted (evaluate_expression (d
->exp
),
1303 d
->format
.format
, d
->format
.size
);
1304 printf_filtered ("\n");
1307 gdb_flush (gdb_stdout
);
1308 current_display_number
= -1;
1311 /* Display all of the values on the auto-display chain which can be
1312 evaluated in the current scope. */
1317 register struct display
*d
;
1319 for (d
= display_chain
; d
; d
= d
->next
)
1323 /* Delete the auto-display which we were in the process of displaying.
1324 This is done when there is an error or a signal. */
1327 disable_display (num
)
1330 register struct display
*d
;
1332 for (d
= display_chain
; d
; d
= d
->next
)
1333 if (d
->number
== num
)
1335 d
->status
= disabled
;
1338 printf_unfiltered ("No display number %d.\n", num
);
1342 disable_current_display ()
1344 if (current_display_number
>= 0)
1346 disable_display (current_display_number
);
1347 fprintf_unfiltered (gdb_stderr
, "Disabling display %d to avoid infinite recursion.\n",
1348 current_display_number
);
1350 current_display_number
= -1;
1354 display_info (ignore
, from_tty
)
1358 register struct display
*d
;
1361 printf_unfiltered ("There are no auto-display expressions now.\n");
1363 printf_filtered ("Auto-display expressions now in effect:\n\
1364 Num Enb Expression\n");
1366 for (d
= display_chain
; d
; d
= d
->next
)
1368 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1370 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1372 else if (d
->format
.format
)
1373 printf_filtered ("/%c ", d
->format
.format
);
1374 print_expression (d
->exp
, gdb_stdout
);
1375 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1376 printf_filtered (" (cannot be evaluated in the current context)");
1377 printf_filtered ("\n");
1378 gdb_flush (gdb_stdout
);
1383 enable_display (args
, from_tty
)
1387 register char *p
= args
;
1390 register struct display
*d
;
1394 for (d
= display_chain
; d
; d
= d
->next
)
1395 d
->status
= enabled
;
1401 while (*p1
>= '0' && *p1
<= '9')
1403 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1404 error ("Arguments must be display numbers.");
1408 for (d
= display_chain
; d
; d
= d
->next
)
1409 if (d
->number
== num
)
1411 d
->status
= enabled
;
1414 printf_unfiltered ("No display number %d.\n", num
);
1417 while (*p
== ' ' || *p
== '\t')
1424 disable_display_command (args
, from_tty
)
1428 register char *p
= args
;
1430 register struct display
*d
;
1434 for (d
= display_chain
; d
; d
= d
->next
)
1435 d
->status
= disabled
;
1441 while (*p1
>= '0' && *p1
<= '9')
1443 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1444 error ("Arguments must be display numbers.");
1446 disable_display (atoi (p
));
1449 while (*p
== ' ' || *p
== '\t')
1455 /* Print the value in stack frame FRAME of a variable
1456 specified by a struct symbol. */
1459 print_variable_value (var
, frame
, stream
)
1464 value_ptr val
= read_var_value (var
, frame
);
1465 value_print (val
, stream
, 0, Val_pretty_default
);
1468 /* Print the arguments of a stack frame, given the function FUNC
1469 running in that frame (as a symbol), the info on the frame,
1470 and the number of args according to the stack frame (or -1 if unknown). */
1472 /* References here and elsewhere to "number of args according to the
1473 stack frame" appear in all cases to refer to "number of ints of args
1474 according to the stack frame". At least for VAX, i386, isi. */
1477 print_frame_args (func
, fi
, num
, stream
)
1478 struct symbol
*func
;
1479 struct frame_info
*fi
;
1483 struct block
*b
= NULL
;
1487 register struct symbol
*sym
;
1488 register value_ptr val
;
1489 /* Offset of next stack argument beyond the one we have seen that is
1490 at the highest offset.
1491 -1 if we haven't come to a stack argument yet. */
1492 long highest_offset
= -1;
1494 /* Number of ints of arguments that we have printed so far. */
1495 int args_printed
= 0;
1499 b
= SYMBOL_BLOCK_VALUE (func
);
1500 nsyms
= BLOCK_NSYMS (b
);
1503 for (i
= 0; i
< nsyms
; i
++)
1506 sym
= BLOCK_SYM (b
, i
);
1508 /* Keep track of the highest stack argument offset seen, and
1509 skip over any kinds of symbols we don't care about. */
1511 switch (SYMBOL_CLASS (sym
)) {
1515 long current_offset
= SYMBOL_VALUE (sym
);
1517 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1519 /* Compute address of next argument by adding the size of
1520 this argument and rounding to an int boundary. */
1522 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1523 & ~(sizeof (int) - 1));
1525 /* If this is the highest offset seen yet, set highest_offset. */
1526 if (highest_offset
== -1
1527 || (current_offset
> highest_offset
))
1528 highest_offset
= current_offset
;
1530 /* Add the number of ints we're about to print to args_printed. */
1531 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1534 /* We care about types of symbols, but don't need to keep track of
1535 stack offsets in them. */
1537 case LOC_REGPARM_ADDR
:
1539 case LOC_BASEREG_ARG
:
1542 /* Other types of symbols we just skip over. */
1547 /* We have to look up the symbol because arguments can have
1548 two entries (one a parameter, one a local) and the one we
1549 want is the local, which lookup_symbol will find for us.
1550 This includes gcc1 (not gcc2) on the sparc when passing a
1551 small structure and gcc2 when the argument type is float
1552 and it is passed as a double and converted to float by
1553 the prologue (in the latter case the type of the LOC_ARG
1554 symbol is double and the type of the LOC_LOCAL symbol is
1556 /* But if the parameter name is null, don't try it.
1557 Null parameter names occur on the RS/6000, for traceback tables.
1558 FIXME, should we even print them? */
1560 if (*SYMBOL_NAME (sym
))
1562 struct symbol
*nsym
;
1563 nsym
= lookup_symbol
1565 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1566 if (SYMBOL_CLASS (nsym
) == LOC_REGISTER
)
1568 /* There is a LOC_ARG/LOC_REGISTER pair. This means that
1569 it was passed on the stack and loaded into a register,
1570 or passed in a register and stored in a stack slot.
1571 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
1573 Reasons for using the LOC_ARG:
1574 (1) because find_saved_registers may be slow for remote
1576 (2) because registers are often re-used and stack slots
1577 rarely (never?) are. Therefore using the stack slot is
1578 much less likely to print garbage.
1580 Reasons why we might want to use the LOC_REGISTER:
1581 (1) So that the backtrace prints the same value as
1582 "print foo". I see no compelling reason why this needs
1583 to be the case; having the backtrace print the value which
1584 was passed in, and "print foo" print the value as modified
1585 within the called function, makes perfect sense to me.
1587 Additional note: It might be nice if "info args" displayed
1589 One more note: There is a case with sparc sturcture passing
1590 where we need to use the LOC_REGISTER, but this is dealt with
1591 by creating a single LOC_REGPARM in symbol reading. */
1593 /* Leave sym (the LOC_ARG) alone. */
1600 /* Print the current arg. */
1602 fprintf_filtered (stream
, ", ");
1604 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1605 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1606 fputs_filtered ("=", stream
);
1608 /* Avoid value_print because it will deref ref parameters. We just
1609 want to print their addresses. Print ??? for args whose address
1610 we do not know. We pass 2 as "recurse" to val_print because our
1611 standard indentation here is 4 spaces, and val_print indents
1612 2 for each recurse. */
1613 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1615 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1616 stream
, 0, 0, 2, Val_no_prettyprint
);
1618 fputs_filtered ("???", stream
);
1622 /* Don't print nameless args in situations where we don't know
1623 enough about the stack to find them. */
1628 if (highest_offset
== -1)
1629 start
= FRAME_ARGS_SKIP
;
1631 start
= highest_offset
;
1633 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1638 /* Print nameless args on STREAM.
1639 FI is the frameinfo for this frame, START is the offset
1640 of the first nameless arg, and NUM is the number of nameless args to
1641 print. FIRST is nonzero if this is the first argument (not just
1642 the first nameless arg). */
1644 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1645 struct frame_info
*fi
;
1655 for (i
= 0; i
< num
; i
++)
1658 #ifdef NAMELESS_ARG_VALUE
1659 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1661 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1665 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1669 fprintf_filtered (stream
, ", ");
1671 #ifdef PRINT_NAMELESS_INTEGER
1672 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1674 #ifdef PRINT_TYPELESS_INTEGER
1675 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1677 fprintf_filtered (stream
, "%d", arg_value
);
1678 #endif /* PRINT_TYPELESS_INTEGER */
1679 #endif /* PRINT_NAMELESS_INTEGER */
1681 start
+= sizeof (int);
1687 printf_command (arg
, from_tty
)
1692 register char *s
= arg
;
1694 value_ptr
*val_args
;
1696 char *current_substring
;
1698 int allocated_args
= 20;
1699 struct cleanup
*old_cleanups
;
1701 val_args
= (value_ptr
*) xmalloc (allocated_args
* sizeof (value_ptr
));
1702 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1705 error_no_arg ("format-control string and values to print");
1707 /* Skip white space before format string */
1708 while (*s
== ' ' || *s
== '\t') s
++;
1710 /* A format string should follow, enveloped in double quotes */
1712 error ("Bad format string, missing '\"'.");
1714 /* Parse the format-control string and copy it into the string STRING,
1715 processing some kinds of escape sequence. */
1717 f
= string
= (char *) alloca (strlen (s
) + 1);
1725 error ("Bad format string, non-terminated '\"'.");
1737 *f
++ = '\007'; /* Bell */
1762 /* ??? TODO: handle other escape sequences */
1763 error ("Unrecognized escape character \\%c in format string.",
1773 /* Skip over " and following space and comma. */
1776 while (*s
== ' ' || *s
== '\t') s
++;
1778 if (*s
!= ',' && *s
!= 0)
1779 error ("Invalid argument syntax");
1782 while (*s
== ' ' || *s
== '\t') s
++;
1784 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1785 substrings
= alloca (strlen (string
) * 2);
1786 current_substring
= substrings
;
1789 /* Now scan the string for %-specs and see what kinds of args they want.
1790 argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
1791 of the right size. */
1793 enum argclass
{no_arg
, int_arg
, string_arg
, double_arg
, long_long_arg
};
1794 enum argclass
*argclass
;
1795 enum argclass this_argclass
;
1801 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1809 while (strchr ("0123456789.hlL-+ #", *f
))
1811 if (*f
== 'l' || *f
== 'L')
1818 this_argclass
= string_arg
;
1824 this_argclass
= double_arg
;
1828 error ("`*' not supported for precision or width in printf");
1831 error ("Format specifier `n' not supported in printf");
1834 this_argclass
= no_arg
;
1839 this_argclass
= long_long_arg
;
1841 this_argclass
= int_arg
;
1845 if (this_argclass
!= no_arg
)
1847 strncpy (current_substring
, last_arg
, f
- last_arg
);
1848 current_substring
+= f
- last_arg
;
1849 *current_substring
++ = '\0';
1851 argclass
[nargs_wanted
++] = this_argclass
;
1855 /* Now, parse all arguments and evaluate them.
1856 Store the VALUEs in VAL_ARGS. */
1861 if (nargs
== allocated_args
)
1862 val_args
= (value_ptr
*) xrealloc ((char *) val_args
,
1863 (allocated_args
*= 2)
1864 * sizeof (value_ptr
));
1866 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1868 /* If format string wants a float, unchecked-convert the value to
1869 floating point of the same size */
1871 if (argclass
[nargs
] == double_arg
)
1873 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1874 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1875 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1876 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1884 if (nargs
!= nargs_wanted
)
1885 error ("Wrong number of arguments for specified format-string");
1887 /* FIXME: We should be using vprintf_filtered, but as long as it
1888 has an arbitrary limit that is unacceptable. Correct fix is
1889 for vprintf_filtered to scan down the format string so it knows
1890 how big a buffer it needs (perhaps by putting a vasprintf (see
1891 GNU C library) in libiberty).
1893 But for now, just force out any pending output, so at least the output
1894 appears in the correct order. */
1895 wrap_here ((char *)NULL
);
1897 /* Now actually print them. */
1898 current_substring
= substrings
;
1899 for (i
= 0; i
< nargs
; i
++)
1901 switch (argclass
[i
])
1908 tem
= value_as_pointer (val_args
[i
]);
1910 /* This is a %s argument. Find the length of the string. */
1915 read_memory (tem
+ j
, &c
, 1);
1920 /* Copy the string contents into a string inside GDB. */
1921 str
= (char *) alloca (j
+ 1);
1922 read_memory (tem
, str
, j
);
1925 /* Don't use printf_filtered because of arbitrary limit. */
1926 printf_unfiltered (current_substring
, str
);
1931 double val
= value_as_double (val_args
[i
]);
1932 /* Don't use printf_filtered because of arbitrary limit. */
1933 printf_unfiltered (current_substring
, val
);
1937 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1939 long long val
= value_as_long (val_args
[i
]);
1940 /* Don't use printf_filtered because of arbitrary limit. */
1941 printf_unfiltered (current_substring
, val
);
1945 error ("long long not supported in printf");
1949 /* FIXME: there should be separate int_arg and long_arg. */
1950 long val
= value_as_long (val_args
[i
]);
1951 /* Don't use printf_filtered because of arbitrary limit. */
1952 printf_unfiltered (current_substring
, val
);
1956 error ("internal error in printf_command");
1958 /* Skip to the next substring. */
1959 current_substring
+= strlen (current_substring
) + 1;
1961 /* Print the portion of the format string after the last argument. */
1962 /* It would be OK to use printf_filtered here. */
1965 do_cleanups (old_cleanups
);
1968 /* Dump a specified section of assembly code. With no command line
1969 arguments, this command will dump the assembly code for the
1970 function surrounding the pc value in the selected frame. With one
1971 argument, it will dump the assembly code surrounding that pc value.
1972 Two arguments are interpeted as bounds within which to dump
1977 disassemble_command (arg
, from_tty
)
1981 CORE_ADDR low
, high
;
1989 if (!selected_frame
)
1990 error ("No frame selected.\n");
1992 pc
= get_frame_pc (selected_frame
);
1993 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
1994 error ("No function contains program counter for selected frame.\n");
1996 else if (!(space_index
= (char *) strchr (arg
, ' ')))
1999 pc
= parse_and_eval_address (arg
);
2000 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
2001 error ("No function contains specified address.\n");
2005 /* Two arguments. */
2006 *space_index
= '\0';
2007 low
= parse_and_eval_address (arg
);
2008 high
= parse_and_eval_address (space_index
+ 1);
2011 printf_filtered ("Dump of assembler code ");
2014 printf_filtered ("for function %s:\n", name
);
2018 printf_filtered ("from ");
2019 print_address_numeric (low
, gdb_stdout
);
2020 printf_filtered (" to ");
2021 print_address_numeric (high
, gdb_stdout
);
2022 printf_filtered (":\n");
2025 /* Dump the specified range. */
2026 for (pc
= low
; pc
< high
; )
2029 print_address (pc
, gdb_stdout
);
2030 printf_filtered (":\t");
2031 /* We often wrap here if there are long symbolic names. */
2033 pc
+= print_insn (pc
, gdb_stdout
);
2034 printf_filtered ("\n");
2036 printf_filtered ("End of assembler dump.\n");
2037 gdb_flush (gdb_stdout
);
2042 _initialize_printcmd ()
2044 current_display_number
= -1;
2046 add_info ("address", address_info
,
2047 "Describe where variable VAR is stored.");
2049 add_com ("x", class_vars
, x_command
,
2050 "Examine memory: x/FMT ADDRESS.\n\
2051 ADDRESS is an expression for the memory address to examine.\n\
2052 FMT is a repeat count followed by a format letter and a size letter.\n\
2053 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2054 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2055 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2056 The specified number of objects of the specified size are printed\n\
2057 according to the format.\n\n\
2058 Defaults for format and size letters are those previously used.\n\
2059 Default count is 1. Default address is following last thing printed\n\
2060 with this command or \"print\".");
2062 add_com ("disassemble", class_vars
, disassemble_command
,
2063 "Disassemble a specified section of memory.\n\
2064 Default is the function surrounding the pc of the selected frame.\n\
2065 With a single argument, the function surrounding that address is dumped.\n\
2066 Two arguments are taken as a range of memory to dump.");
2069 add_com ("whereis", class_vars
, whereis_command
,
2070 "Print line number and file of definition of variable.");
2073 add_info ("display", display_info
,
2074 "Expressions to display when program stops, with code numbers.");
2076 add_cmd ("undisplay", class_vars
, undisplay_command
,
2077 "Cancel some expressions to be displayed when program stops.\n\
2078 Arguments are the code numbers of the expressions to stop displaying.\n\
2079 No argument means cancel all automatic-display expressions.\n\
2080 \"delete display\" has the same effect as this command.\n\
2081 Do \"info display\" to see current list of code numbers.",
2084 add_com ("display", class_vars
, display_command
,
2085 "Print value of expression EXP each time the program stops.\n\
2086 /FMT may be used before EXP as in the \"print\" command.\n\
2087 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2088 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2089 and examining is done as in the \"x\" command.\n\n\
2090 With no argument, display all currently requested auto-display expressions.\n\
2091 Use \"undisplay\" to cancel display requests previously made.");
2093 add_cmd ("display", class_vars
, enable_display
,
2094 "Enable some expressions to be displayed when program stops.\n\
2095 Arguments are the code numbers of the expressions to resume displaying.\n\
2096 No argument means enable all automatic-display expressions.\n\
2097 Do \"info display\" to see current list of code numbers.", &enablelist
);
2099 add_cmd ("display", class_vars
, disable_display_command
,
2100 "Disable some expressions to be displayed when program stops.\n\
2101 Arguments are the code numbers of the expressions to stop displaying.\n\
2102 No argument means disable all automatic-display expressions.\n\
2103 Do \"info display\" to see current list of code numbers.", &disablelist
);
2105 add_cmd ("display", class_vars
, undisplay_command
,
2106 "Cancel some expressions to be displayed when program stops.\n\
2107 Arguments are the code numbers of the expressions to stop displaying.\n\
2108 No argument means cancel all automatic-display expressions.\n\
2109 Do \"info display\" to see current list of code numbers.", &deletelist
);
2111 add_com ("printf", class_vars
, printf_command
,
2112 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2113 This is useful for formatted output in user-defined commands.");
2114 add_com ("output", class_vars
, output_command
,
2115 "Like \"print\" but don't put in value history and don't print newline.\n\
2116 This is useful in user-defined commands.");
2118 add_prefix_cmd ("set", class_vars
, set_command
,
2119 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2120 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2121 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2122 with $), a register (a few standard names starting with $), or an actual\n\
2123 variable in the program being debugged. EXP is any valid expression.\n\
2124 Use \"set variable\" for variables with names identical to set subcommands.\n\
2125 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2126 You can see these environment settings with the \"show\" command.",
2127 &setlist
, "set ", 1, &cmdlist
);
2129 /* "call" is the same as "set", but handy for dbx users to call fns. */
2130 add_com ("call", class_vars
, call_command
,
2131 "Call a function in the program.\n\
2132 The argument is the function name and arguments, in the notation of the\n\
2133 current working language. The result is printed and saved in the value\n\
2134 history, if it is not void.");
2136 add_cmd ("variable", class_vars
, set_command
,
2137 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2138 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2139 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2140 with $), a register (a few standard names starting with $), or an actual\n\
2141 variable in the program being debugged. EXP is any valid expression.\n\
2142 This may usually be abbreviated to simply \"set\".",
2145 add_com ("print", class_vars
, print_command
,
2146 concat ("Print value of expression EXP.\n\
2147 Variables accessible are those of the lexical environment of the selected\n\
2148 stack frame, plus all those whose scope is global or an entire file.\n\
2150 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2151 $$NUM refers to NUM'th value back from the last one.\n\
2152 Names starting with $ refer to registers (with the values they would have\n\
2153 if the program were to return to the stack frame now selected, restoring\n\
2154 all registers saved by frames farther in) or else to debugger\n\
2155 \"convenience\" variables (any such name not a known register).\n\
2156 Use assignment expressions to give values to convenience variables.\n",
2158 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2159 @ is a binary operator for treating consecutive data objects\n\
2160 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2161 element is FOO, whose second element is stored in the space following\n\
2162 where FOO is stored, etc. FOO must be an expression whose value\n\
2163 resides in memory.\n",
2165 EXP may be preceded with /FMT, where FMT is a format letter\n\
2166 but no count or size letter (see \"x\" command).", NULL
));
2167 add_com_alias ("p", "print", class_vars
, 1);
2169 add_com ("inspect", class_vars
, inspect_command
,
2170 "Same as \"print\" command, except that if you are running in the epoch\n\
2171 environment, the value is printed in its own window.");
2174 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2175 (char *)&max_symbolic_offset
,
2176 "Set the largest offset that will be printed in <symbol+1234> form.",
2180 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2181 (char *)&print_symbol_filename
,
2182 "Set printing of source filename and line number with <symbol>.",
2187 add_set_cmd ("fast-symbolic-addr", no_class
, var_boolean
,
2188 (char *)&fast_symbolic_addr
,
2189 "Set fast printing of symbolic addresses (using minimal symbols).",
2193 examine_b_type
= init_type (TYPE_CODE_INT
, 1, 0, NULL
, NULL
);
2194 examine_h_type
= init_type (TYPE_CODE_INT
, 2, 0, NULL
, NULL
);
2195 examine_w_type
= init_type (TYPE_CODE_INT
, 4, 0, NULL
, NULL
);
2196 examine_g_type
= init_type (TYPE_CODE_INT
, 8, 0, NULL
, NULL
);