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. */
94 /* FIXME: Should we be printing * for references as well as pointers? */
96 && TYPE_CODE (t
) == TYPE_CODE_PTR
97 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
)
98 printf_filtered ("*");
100 printf_filtered ("-");
105 /* Chain link to next auto-display item. */
106 struct display
*next
;
107 /* Expression to be evaluated and displayed. */
108 struct expression
*exp
;
109 /* Item number of this auto-display item. */
111 /* Display format specified. */
112 struct format_data format
;
113 /* Innermost block required by this expression when evaluated */
115 /* Status of this display (enabled or disabled) */
119 /* Chain of expressions whose values should be displayed
120 automatically each time the program stops. */
122 static struct display
*display_chain
;
124 static int display_number
;
126 /* Prototypes for local functions */
129 delete_display
PARAMS ((int));
132 enable_display
PARAMS ((char *, int));
135 disable_display_command
PARAMS ((char *, int));
138 disassemble_command
PARAMS ((char *, int));
141 printf_command
PARAMS ((char *, int));
144 print_frame_nameless_args
PARAMS ((struct frame_info
*, long, int, int,
148 display_info
PARAMS ((char *, int));
151 do_one_display
PARAMS ((struct display
*));
154 undisplay_command
PARAMS ((char *, int));
157 free_display
PARAMS ((struct display
*));
160 display_command
PARAMS ((char *, int));
163 x_command
PARAMS ((char *, int));
166 address_info
PARAMS ((char *, int));
169 set_command
PARAMS ((char *, int));
172 output_command
PARAMS ((char *, int));
175 call_command
PARAMS ((char *, int));
178 inspect_command
PARAMS ((char *, int));
181 print_command
PARAMS ((char *, int));
184 print_command_1
PARAMS ((char *, int, int));
187 validate_format
PARAMS ((struct format_data
, char *));
190 do_examine
PARAMS ((struct format_data
, CORE_ADDR
));
193 print_formatted
PARAMS ((value_ptr
, int, int));
195 static struct format_data
196 decode_format
PARAMS ((char **, int, int));
199 /* Decode a format specification. *STRING_PTR should point to it.
200 OFORMAT and OSIZE are used as defaults for the format and size
201 if none are given in the format specification.
202 If OSIZE is zero, then the size field of the returned value
203 should be set only if a size is explicitly specified by the
205 The structure returned describes all the data
206 found in the specification. In addition, *STRING_PTR is advanced
207 past the specification and past all whitespace following it. */
209 static struct format_data
210 decode_format (string_ptr
, oformat
, osize
)
215 struct format_data val
;
216 register char *p
= *string_ptr
;
222 if (*p
>= '0' && *p
<= '9')
223 val
.count
= atoi (p
);
224 while (*p
>= '0' && *p
<= '9') p
++;
226 /* Now process size or format letters that follow. */
230 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
232 else if (*p
>= 'a' && *p
<= 'z')
238 while (*p
== ' ' || *p
== '\t') p
++;
241 /* Set defaults for format and size if not specified. */
242 if (val
.format
== '?')
246 /* Neither has been specified. */
247 val
.format
= oformat
;
251 /* If a size is specified, any format makes a reasonable
252 default except 'i'. */
253 val
.format
= oformat
== 'i' ? 'x' : oformat
;
255 else if (val
.size
== '?')
260 /* Pick the appropriate size for an address. */
261 #if TARGET_PTR_BIT == 64
262 val
.size
= osize
? 'g' : osize
;
265 #if TARGET_PTR_BIT == 32
266 val
.size
= osize
? 'w' : osize
;
269 #if TARGET_PTR_BIT == 16
270 val
.size
= osize
? 'h' : osize
;
273 #error Bad value for TARGET_PTR_BIT
279 /* Floating point has to be word or giantword. */
280 if (osize
== 'w' || osize
== 'g')
283 /* Default it to giantword if the last used size is not
285 val
.size
= osize
? 'g' : osize
;
288 /* Characters default to one byte. */
289 val
.size
= osize
? 'b' : osize
;
292 /* The default is the size most recently specified. */
299 /* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
300 Do not end with a newline.
301 0 means print VAL according to its own type.
302 SIZE is the letter for the size of datum being printed.
303 This is used to pad hex numbers so they line up. */
306 print_formatted (val
, format
, size
)
307 register value_ptr val
;
311 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
313 if (VALUE_LVAL (val
) == lval_memory
)
314 next_address
= VALUE_ADDRESS (val
) + len
;
319 next_address
= VALUE_ADDRESS (val
)
320 + value_print (value_addr (val
), gdb_stdout
, format
, Val_pretty_default
);
324 /* The old comment says
325 "Force output out, print_insn not using _filtered".
326 I'm not completely sure what that means, I suspect most print_insn
327 now do use _filtered, so I guess it's obsolete. */
328 /* We often wrap here if there are long symbolic names. */
330 next_address
= VALUE_ADDRESS (val
)
331 + print_insn (VALUE_ADDRESS (val
), gdb_stdout
);
336 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
337 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRING
338 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
339 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
340 || VALUE_REPEATED (val
))
341 value_print (val
, gdb_stdout
, format
, Val_pretty_default
);
343 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
344 format
, size
, gdb_stdout
);
348 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
349 according to letters FORMAT and SIZE on STREAM.
350 FORMAT may not be zero. Formats s and i are not supported at this level.
352 This is how the elements of an array or structure are printed
356 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
364 int len
= TYPE_LENGTH (type
);
366 if (len
> sizeof (LONGEST
)
374 /* We can't print it normally, but we can print it in hex.
375 Printing it in the wrong radix is more useful than saying
376 "use /x, you dummy". */
377 /* FIXME: we could also do octal or binary if that was the
379 /* FIXME: we should be using the size field to give us a minimum
380 field width to print. */
381 val_print_type_code_int (type
, valaddr
, stream
);
386 val_long
= unpack_long (type
, valaddr
);
388 /* If we are printing it as unsigned, truncate it in case it is actually
389 a negative signed value (e.g. "print/u (short)-1" should print 65535
390 (if shorts are 16 bits) instead of 4294967295). */
393 if (len
< sizeof (LONGEST
))
394 val_long
&= ((LONGEST
) 1 << HOST_CHAR_BIT
* len
) - 1;
402 /* no size specified, like in print. Print varying # of digits. */
403 print_longest (stream
, 'x', 1, val_long
);
412 print_longest (stream
, size
, 1, val_long
);
415 error ("Undefined output size \"%c\".", size
);
420 print_longest (stream
, 'd', 1, val_long
);
424 print_longest (stream
, 'u', 0, val_long
);
429 print_longest (stream
, 'o', 1, val_long
);
431 fprintf_filtered (stream
, "0");
435 print_address (unpack_pointer (type
, valaddr
), stream
);
439 value_print (value_from_longest (builtin_type_char
, val_long
), stream
, 0,
444 if (len
== sizeof (float))
445 type
= builtin_type_float
;
446 else if (len
== sizeof (double))
447 type
= builtin_type_double
;
448 print_floating (valaddr
, type
, stream
);
455 /* Binary; 't' stands for "two". */
457 char bits
[8*(sizeof val_long
) + 1];
462 width
= 8*(sizeof val_long
);
479 error ("Undefined output size \"%c\".", size
);
485 bits
[width
] = (val_long
& 1) ? '1' : '0';
490 while (*cp
&& *cp
== '0')
495 fprintf_filtered (stream
, local_binary_format_prefix());
496 fprintf_filtered (stream
, cp
);
497 fprintf_filtered (stream
, local_binary_format_suffix());
502 error ("Undefined output format \"%c\".", format
);
506 /* Specify default address for `x' command.
507 `info lines' uses this. */
510 set_next_address (addr
)
515 /* Make address available to the user as $_. */
516 set_internalvar (lookup_internalvar ("_"),
517 value_from_longest (lookup_pointer_type (builtin_type_void
),
521 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
522 after LEADIN. Print nothing if no symbolic name is found nearby.
523 Optionally also print source file and line number, if available.
524 DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
525 or to interpret it as a possible C++ name and convert it back to source
526 form. However note that DO_DEMANGLE can be overridden by the specific
527 settings of the demangle and asm_demangle variables. */
530 print_address_symbolic (addr
, stream
, do_demangle
, leadin
)
536 struct minimal_symbol
*msymbol
;
537 struct symbol
*symbol
;
538 struct symtab
*symtab
= 0;
539 CORE_ADDR name_location
= 0;
542 /* First try to find the address in the symbol table, then
543 in the minsyms. Take the closest one. */
545 /* This is defective in the sense that it only finds text symbols. So
546 really this is kind of pointless--we should make sure that the
547 minimal symbols have everything we need (by changing that we could
548 save some memory, but for many debug format--ELF/DWARF or
549 anything/stabs--it would be inconvenient to eliminate those minimal
551 symbol
= find_pc_function (addr
);
553 name_location
= BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
));
558 name
= SYMBOL_SOURCE_NAME (symbol
);
560 name
= SYMBOL_LINKAGE_NAME (symbol
);
563 msymbol
= lookup_minimal_symbol_by_pc (addr
);
566 if (SYMBOL_VALUE_ADDRESS (msymbol
) > name_location
|| symbol
== NULL
)
568 /* The msymbol is closer to the address than the symbol;
569 use the msymbol instead. */
572 name_location
= SYMBOL_VALUE_ADDRESS (msymbol
);
574 name
= SYMBOL_SOURCE_NAME (msymbol
);
576 name
= SYMBOL_LINKAGE_NAME (msymbol
);
579 if (symbol
== NULL
&& msymbol
== NULL
)
582 /* If the nearest symbol is too far away, don't print anything symbolic. */
584 /* For when CORE_ADDR is larger than unsigned int, we do math in
585 CORE_ADDR. But when we detect unsigned wraparound in the
586 CORE_ADDR math, we ignore this test and print the offset,
587 because addr+max_symbolic_offset has wrapped through the end
588 of the address space back to the beginning, giving bogus comparison. */
589 if (addr
> name_location
+ max_symbolic_offset
590 && name_location
+ max_symbolic_offset
> name_location
)
593 fputs_filtered (leadin
, stream
);
594 fputs_filtered ("<", stream
);
595 fputs_filtered (name
, stream
);
596 if (addr
!= name_location
)
597 fprintf_filtered (stream
, "+%u", (unsigned int)(addr
- name_location
));
599 /* Append source filename and line number if desired. Give specific
600 line # of this addr, if we have it; else line # of the nearest symbol. */
601 if (print_symbol_filename
)
603 struct symtab_and_line sal
;
605 sal
= find_pc_line (addr
, 0);
607 fprintf_filtered (stream
, " at %s:%d", sal
.symtab
->filename
, sal
.line
);
608 else if (symtab
&& symbol
&& symbol
->line
)
609 fprintf_filtered (stream
, " at %s:%d", symtab
->filename
, symbol
->line
);
611 fprintf_filtered (stream
, " in %s", symtab
->filename
);
613 fputs_filtered (">", stream
);
616 /* Print address ADDR on STREAM. */
618 print_address_numeric (addr
, stream
)
622 /* This assumes a CORE_ADDR can fit in a LONGEST. Probably a safe
623 assumption. We pass use_local but I'm not completely sure whether
624 that is correct. When (if ever) should we *not* use_local? */
625 print_longest (stream
, 'x', 1, (unsigned LONGEST
) addr
);
628 /* Print address ADDR symbolically on STREAM.
629 First print it as a number. Then perhaps print
630 <SYMBOL + OFFSET> after the number. */
633 print_address (addr
, stream
)
637 print_address_numeric (addr
, stream
);
638 print_address_symbolic (addr
, stream
, asm_demangle
, " ");
641 /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
642 controls whether to print the symbolic name "raw" or demangled.
643 Global setting "addressprint" controls whether to print hex address
647 print_address_demangle (addr
, stream
, do_demangle
)
654 fprintf_filtered (stream
, "0");
656 else if (addressprint
)
658 print_address_numeric (addr
, stream
);
659 print_address_symbolic (addr
, stream
, do_demangle
, " ");
663 print_address_symbolic (addr
, stream
, do_demangle
, "");
668 /* These are the types that $__ will get after an examine command of one
671 static struct type
*examine_b_type
;
672 static struct type
*examine_h_type
;
673 static struct type
*examine_w_type
;
674 static struct type
*examine_g_type
;
676 /* Examine data at address ADDR in format FMT.
677 Fetch it from memory and print on gdb_stdout. */
680 do_examine (fmt
, addr
)
681 struct format_data fmt
;
684 register char format
= 0;
686 register int count
= 1;
687 struct type
*val_type
= NULL
;
689 register int maxelts
;
696 /* String or instruction format implies fetch single bytes
697 regardless of the specified size. */
698 if (format
== 's' || format
== 'i')
702 val_type
= examine_b_type
;
703 else if (size
== 'h')
704 val_type
= examine_h_type
;
705 else if (size
== 'w')
706 val_type
= examine_w_type
;
707 else if (size
== 'g')
708 val_type
= examine_g_type
;
715 if (format
== 's' || format
== 'i')
718 /* Print as many objects as specified in COUNT, at most maxelts per line,
719 with the address of the next one at the start of each line. */
723 print_address (next_address
, gdb_stdout
);
724 printf_filtered (":");
729 printf_filtered ("\t");
730 /* Note that print_formatted sets next_address for the next
732 last_examine_address
= next_address
;
733 last_examine_value
= value_at (val_type
, next_address
);
734 print_formatted (last_examine_value
, format
, size
);
736 printf_filtered ("\n");
737 gdb_flush (gdb_stdout
);
742 validate_format (fmt
, cmdname
)
743 struct format_data fmt
;
747 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
749 error ("Item count other than 1 is meaningless in \"%s\" command.",
751 if (fmt
.format
== 'i' || fmt
.format
== 's')
752 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
753 fmt
.format
, cmdname
);
756 /* Evaluate string EXP as an expression in the current language and
757 print the resulting value. EXP may contain a format specifier as the
758 first argument ("/x myvar" for example, to print myvar in hex).
762 print_command_1 (exp
, inspect
, voidprint
)
767 struct expression
*expr
;
768 register struct cleanup
*old_chain
= 0;
769 register char format
= 0;
770 register value_ptr val
;
771 struct format_data fmt
;
774 /* Pass inspect flag to the rest of the print routines in a global (sigh). */
775 inspect_it
= inspect
;
777 if (exp
&& *exp
== '/')
780 fmt
= decode_format (&exp
, last_format
, 0);
781 validate_format (fmt
, "print");
782 last_format
= format
= fmt
.format
;
793 extern int objectprint
;
795 expr
= parse_expression (exp
);
796 old_chain
= make_cleanup (free_current_contents
, &expr
);
798 val
= evaluate_expression (expr
);
800 /* C++: figure out what type we actually want to print it as. */
801 type
= VALUE_TYPE (val
);
804 && ( TYPE_CODE (type
) == TYPE_CODE_PTR
805 || TYPE_CODE (type
) == TYPE_CODE_REF
)
806 && ( TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_STRUCT
807 || TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_UNION
))
811 v
= value_from_vtable_info (val
, TYPE_TARGET_TYPE (type
));
815 type
= VALUE_TYPE (val
);
820 val
= access_value_history (0);
822 if (voidprint
|| (val
&& VALUE_TYPE (val
) &&
823 TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_VOID
))
825 int histindex
= record_latest_value (val
);
827 if (annotation_level
> 1)
830 printf_filtered ("\n\032\032value-history-begin %d ", histindex
);
832 printf_filtered ("\n\032\032value-begin ");
833 print_value_flags (VALUE_TYPE (val
));
834 printf_filtered ("\n");
838 printf_unfiltered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp
, histindex
);
840 if (histindex
>= 0) printf_filtered ("$%d = ", histindex
);
842 if (annotation_level
> 1 && histindex
>= 0)
843 printf_filtered ("\n\032\032value-history-value\n");
845 print_formatted (val
, format
, fmt
.size
);
846 printf_filtered ("\n");
848 if (annotation_level
> 1)
851 printf_filtered ("\n\032\032value-history-end\n");
853 printf_filtered ("\n\032\032value-end\n");
857 printf_unfiltered("\") )\030");
861 do_cleanups (old_chain
);
862 inspect_it
= 0; /* Reset print routines to normal */
867 print_command (exp
, from_tty
)
871 print_command_1 (exp
, 0, 1);
874 /* Same as print, except in epoch, it gets its own window */
877 inspect_command (exp
, from_tty
)
881 extern int epoch_interface
;
883 print_command_1 (exp
, epoch_interface
, 1);
886 /* Same as print, except it doesn't print void results. */
889 call_command (exp
, from_tty
)
893 print_command_1 (exp
, 0, 0);
898 output_command (exp
, from_tty
)
902 struct expression
*expr
;
903 register struct cleanup
*old_chain
;
904 register char format
= 0;
905 register value_ptr val
;
906 struct format_data fmt
;
908 if (exp
&& *exp
== '/')
911 fmt
= decode_format (&exp
, 0, 0);
912 validate_format (fmt
, "output");
916 expr
= parse_expression (exp
);
917 old_chain
= make_cleanup (free_current_contents
, &expr
);
919 val
= evaluate_expression (expr
);
921 if (annotation_level
> 1)
923 printf_filtered ("\n\032\032value-begin ");
924 print_value_flags (VALUE_TYPE (val
));
925 printf_filtered ("\n");
928 print_formatted (val
, format
, fmt
.size
);
930 if (annotation_level
> 1)
931 printf_filtered ("\n\032\032value-end\n");
933 do_cleanups (old_chain
);
938 set_command (exp
, from_tty
)
942 struct expression
*expr
= parse_expression (exp
);
943 register struct cleanup
*old_chain
944 = make_cleanup (free_current_contents
, &expr
);
945 evaluate_expression (expr
);
946 do_cleanups (old_chain
);
951 address_info (exp
, from_tty
)
955 register struct symbol
*sym
;
956 register struct minimal_symbol
*msymbol
;
958 register long basereg
;
959 int is_a_field_of_this
; /* C++: lookup_symbol sets this to nonzero
960 if exp is a field of `this'. */
963 error ("Argument required.");
965 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
,
966 &is_a_field_of_this
, (struct symtab
**)NULL
);
969 if (is_a_field_of_this
)
971 printf_filtered ("Symbol \"");
972 fprintf_symbol_filtered (gdb_stdout
, exp
,
973 current_language
->la_language
, DMGL_ANSI
);
974 printf_filtered ("\" is a field of the local class variable `this'\n");
978 msymbol
= lookup_minimal_symbol (exp
, (struct objfile
*) NULL
);
982 printf_filtered ("Symbol \"");
983 fprintf_symbol_filtered (gdb_stdout
, exp
,
984 current_language
->la_language
, DMGL_ANSI
);
985 printf_filtered ("\" is at ");
986 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol
), gdb_stdout
);
987 printf_filtered (" in a file compiled without debugging.\n");
990 error ("No symbol \"%s\" in current context.", exp
);
994 printf_filtered ("Symbol \"");
995 fprintf_symbol_filtered (gdb_stdout
, SYMBOL_NAME (sym
),
996 current_language
->la_language
, DMGL_ANSI
);
997 printf_filtered ("\" is ", SYMBOL_NAME (sym
));
998 val
= SYMBOL_VALUE (sym
);
999 basereg
= SYMBOL_BASEREG (sym
);
1001 switch (SYMBOL_CLASS (sym
))
1004 case LOC_CONST_BYTES
:
1005 printf_filtered ("constant");
1009 printf_filtered ("a label at address ");
1010 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), gdb_stdout
);
1014 printf_filtered ("a variable in register %s", reg_names
[val
]);
1018 printf_filtered ("static storage at address ");
1019 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), gdb_stdout
);
1023 printf_filtered ("an argument in register %s", reg_names
[val
]);
1026 case LOC_REGPARM_ADDR
:
1027 printf_filtered ("address of an argument in register %s", reg_names
[val
]);
1031 printf_filtered ("an argument at offset %ld", val
);
1035 printf_filtered ("an argument at frame offset %ld", val
);
1039 printf_filtered ("a local variable at frame offset %ld", val
);
1043 printf_filtered ("a reference argument at offset %ld", val
);
1047 printf_filtered ("a variable at offset %ld from register %s",
1048 val
, reg_names
[basereg
]);
1051 case LOC_BASEREG_ARG
:
1052 printf_filtered ("an argument at offset %ld from register %s",
1053 val
, reg_names
[basereg
]);
1057 printf_filtered ("a typedef");
1061 printf_filtered ("a function at address ");
1062 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)),
1066 case LOC_OPTIMIZED_OUT
:
1067 printf_filtered ("optimized out");
1071 printf_filtered ("of unknown (botched) type");
1074 printf_filtered (".\n");
1078 x_command (exp
, from_tty
)
1082 struct expression
*expr
;
1083 struct format_data fmt
;
1084 struct cleanup
*old_chain
;
1087 fmt
.format
= last_format
;
1088 fmt
.size
= last_size
;
1091 if (exp
&& *exp
== '/')
1094 fmt
= decode_format (&exp
, last_format
, last_size
);
1097 /* If we have an expression, evaluate it and use it as the address. */
1099 if (exp
!= 0 && *exp
!= 0)
1101 expr
= parse_expression (exp
);
1102 /* Cause expression not to be there any more
1103 if this command is repeated with Newline.
1104 But don't clobber a user-defined command's definition. */
1107 old_chain
= make_cleanup (free_current_contents
, &expr
);
1108 val
= evaluate_expression (expr
);
1109 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
1110 val
= value_ind (val
);
1111 /* In rvalue contexts, such as this, functions are coerced into
1112 pointers to functions. This makes "x/i main" work. */
1113 if (/* last_format == 'i'
1114 && */ TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_FUNC
1115 && VALUE_LVAL (val
) == lval_memory
)
1116 next_address
= VALUE_ADDRESS (val
);
1118 next_address
= value_as_pointer (val
);
1119 do_cleanups (old_chain
);
1122 do_examine (fmt
, next_address
);
1124 /* If the examine succeeds, we remember its size and format for next time. */
1125 last_size
= fmt
.size
;
1126 last_format
= fmt
.format
;
1128 /* Set a couple of internal variables if appropriate. */
1129 if (last_examine_value
)
1131 /* Make last address examined available to the user as $_. Use
1132 the correct pointer type. */
1133 set_internalvar (lookup_internalvar ("_"),
1134 value_from_longest (
1135 lookup_pointer_type (VALUE_TYPE (last_examine_value
)),
1136 (LONGEST
) last_examine_address
));
1138 /* Make contents of last address examined available to the user as $__.*/
1139 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
1144 /* Add an expression to the auto-display chain.
1145 Specify the expression. */
1148 display_command (exp
, from_tty
)
1152 struct format_data fmt
;
1153 register struct expression
*expr
;
1154 register struct display
*new;
1165 fmt
= decode_format (&exp
, 0, 0);
1166 if (fmt
.size
&& fmt
.format
== 0)
1168 if (fmt
.format
== 'i' || fmt
.format
== 's')
1178 innermost_block
= 0;
1179 expr
= parse_expression (exp
);
1181 new = (struct display
*) xmalloc (sizeof (struct display
));
1184 new->block
= innermost_block
;
1185 new->next
= display_chain
;
1186 new->number
= ++display_number
;
1188 new->status
= enabled
;
1189 display_chain
= new;
1191 if (from_tty
&& target_has_execution
)
1192 do_one_display (new);
1205 /* Clear out the display_chain.
1206 Done when new symtabs are loaded, since this invalidates
1207 the types stored in many expressions. */
1212 register struct display
*d
;
1214 while ((d
= display_chain
) != NULL
)
1217 display_chain
= d
->next
;
1222 /* Delete the auto-display number NUM. */
1225 delete_display (num
)
1228 register struct display
*d1
, *d
;
1231 error ("No display number %d.", num
);
1233 if (display_chain
->number
== num
)
1236 display_chain
= d1
->next
;
1240 for (d
= display_chain
; ; d
= d
->next
)
1243 error ("No display number %d.", num
);
1244 if (d
->next
->number
== num
)
1254 /* Delete some values from the auto-display chain.
1255 Specify the element numbers. */
1258 undisplay_command (args
, from_tty
)
1262 register char *p
= args
;
1268 if (query ("Delete all auto-display expressions? "))
1277 while (*p1
>= '0' && *p1
<= '9') p1
++;
1278 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1279 error ("Arguments must be display numbers.");
1283 delete_display (num
);
1286 while (*p
== ' ' || *p
== '\t') p
++;
1291 /* Display a single auto-display.
1292 Do nothing if the display cannot be printed in the current context,
1293 or if the display is disabled. */
1299 int within_current_scope
;
1301 if (d
->status
== disabled
)
1305 within_current_scope
= contained_in (get_selected_block (), d
->block
);
1307 within_current_scope
= 1;
1308 if (!within_current_scope
)
1311 current_display_number
= d
->number
;
1313 printf_filtered ("%d: ", d
->number
);
1318 printf_filtered ("x/");
1319 if (d
->format
.count
!= 1)
1320 printf_filtered ("%d", d
->format
.count
);
1321 printf_filtered ("%c", d
->format
.format
);
1322 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
1323 printf_filtered ("%c", d
->format
.size
);
1324 printf_filtered (" ");
1325 print_expression (d
->exp
, gdb_stdout
);
1326 if (d
->format
.count
!= 1)
1327 printf_filtered ("\n");
1329 printf_filtered (" ");
1331 addr
= value_as_pointer (evaluate_expression (d
->exp
));
1332 if (d
->format
.format
== 'i')
1333 addr
= ADDR_BITS_REMOVE (addr
);
1335 do_examine (d
->format
, addr
);
1339 if (d
->format
.format
)
1340 printf_filtered ("/%c ", d
->format
.format
);
1341 print_expression (d
->exp
, gdb_stdout
);
1342 printf_filtered (" = ");
1343 print_formatted (evaluate_expression (d
->exp
),
1344 d
->format
.format
, d
->format
.size
);
1345 printf_filtered ("\n");
1348 gdb_flush (gdb_stdout
);
1349 current_display_number
= -1;
1352 /* Display all of the values on the auto-display chain which can be
1353 evaluated in the current scope. */
1358 register struct display
*d
;
1360 for (d
= display_chain
; d
; d
= d
->next
)
1364 /* Delete the auto-display which we were in the process of displaying.
1365 This is done when there is an error or a signal. */
1368 disable_display (num
)
1371 register struct display
*d
;
1373 for (d
= display_chain
; d
; d
= d
->next
)
1374 if (d
->number
== num
)
1376 d
->status
= disabled
;
1379 printf_unfiltered ("No display number %d.\n", num
);
1383 disable_current_display ()
1385 if (current_display_number
>= 0)
1387 disable_display (current_display_number
);
1388 fprintf_unfiltered (gdb_stderr
, "Disabling display %d to avoid infinite recursion.\n",
1389 current_display_number
);
1391 current_display_number
= -1;
1395 display_info (ignore
, from_tty
)
1399 register struct display
*d
;
1402 printf_unfiltered ("There are no auto-display expressions now.\n");
1404 printf_filtered ("Auto-display expressions now in effect:\n\
1405 Num Enb Expression\n");
1407 for (d
= display_chain
; d
; d
= d
->next
)
1409 printf_filtered ("%d: %c ", d
->number
, "ny"[(int)d
->status
]);
1411 printf_filtered ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
1413 else if (d
->format
.format
)
1414 printf_filtered ("/%c ", d
->format
.format
);
1415 print_expression (d
->exp
, gdb_stdout
);
1416 if (d
->block
&& !contained_in (get_selected_block (), d
->block
))
1417 printf_filtered (" (cannot be evaluated in the current context)");
1418 printf_filtered ("\n");
1419 gdb_flush (gdb_stdout
);
1424 enable_display (args
, from_tty
)
1428 register char *p
= args
;
1431 register struct display
*d
;
1435 for (d
= display_chain
; d
; d
= d
->next
)
1436 d
->status
= enabled
;
1442 while (*p1
>= '0' && *p1
<= '9')
1444 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1445 error ("Arguments must be display numbers.");
1449 for (d
= display_chain
; d
; d
= d
->next
)
1450 if (d
->number
== num
)
1452 d
->status
= enabled
;
1455 printf_unfiltered ("No display number %d.\n", num
);
1458 while (*p
== ' ' || *p
== '\t')
1465 disable_display_command (args
, from_tty
)
1469 register char *p
= args
;
1471 register struct display
*d
;
1475 for (d
= display_chain
; d
; d
= d
->next
)
1476 d
->status
= disabled
;
1482 while (*p1
>= '0' && *p1
<= '9')
1484 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1485 error ("Arguments must be display numbers.");
1487 disable_display (atoi (p
));
1490 while (*p
== ' ' || *p
== '\t')
1496 /* Print the value in stack frame FRAME of a variable
1497 specified by a struct symbol. */
1500 print_variable_value (var
, frame
, stream
)
1505 value_ptr val
= read_var_value (var
, frame
);
1506 value_print (val
, stream
, 0, Val_pretty_default
);
1509 /* Print the arguments of a stack frame, given the function FUNC
1510 running in that frame (as a symbol), the info on the frame,
1511 and the number of args according to the stack frame (or -1 if unknown). */
1513 /* References here and elsewhere to "number of args according to the
1514 stack frame" appear in all cases to refer to "number of ints of args
1515 according to the stack frame". At least for VAX, i386, isi. */
1518 print_frame_args (func
, fi
, num
, stream
)
1519 struct symbol
*func
;
1520 struct frame_info
*fi
;
1524 struct block
*b
= NULL
;
1528 register struct symbol
*sym
;
1529 register value_ptr val
;
1530 /* Offset of next stack argument beyond the one we have seen that is
1531 at the highest offset.
1532 -1 if we haven't come to a stack argument yet. */
1533 long highest_offset
= -1;
1535 /* Number of ints of arguments that we have printed so far. */
1536 int args_printed
= 0;
1540 b
= SYMBOL_BLOCK_VALUE (func
);
1541 nsyms
= BLOCK_NSYMS (b
);
1544 for (i
= 0; i
< nsyms
; i
++)
1547 sym
= BLOCK_SYM (b
, i
);
1549 /* Keep track of the highest stack argument offset seen, and
1550 skip over any kinds of symbols we don't care about. */
1552 switch (SYMBOL_CLASS (sym
)) {
1556 long current_offset
= SYMBOL_VALUE (sym
);
1558 arg_size
= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1560 /* Compute address of next argument by adding the size of
1561 this argument and rounding to an int boundary. */
1563 = ((current_offset
+ arg_size
+ sizeof (int) - 1)
1564 & ~(sizeof (int) - 1));
1566 /* If this is the highest offset seen yet, set highest_offset. */
1567 if (highest_offset
== -1
1568 || (current_offset
> highest_offset
))
1569 highest_offset
= current_offset
;
1571 /* Add the number of ints we're about to print to args_printed. */
1572 args_printed
+= (arg_size
+ sizeof (int) - 1) / sizeof (int);
1575 /* We care about types of symbols, but don't need to keep track of
1576 stack offsets in them. */
1578 case LOC_REGPARM_ADDR
:
1580 case LOC_BASEREG_ARG
:
1583 /* Other types of symbols we just skip over. */
1588 /* We have to look up the symbol because arguments can have
1589 two entries (one a parameter, one a local) and the one we
1590 want is the local, which lookup_symbol will find for us.
1591 This includes gcc1 (not gcc2) on the sparc when passing a
1592 small structure and gcc2 when the argument type is float
1593 and it is passed as a double and converted to float by
1594 the prologue (in the latter case the type of the LOC_ARG
1595 symbol is double and the type of the LOC_LOCAL symbol is
1597 /* But if the parameter name is null, don't try it.
1598 Null parameter names occur on the RS/6000, for traceback tables.
1599 FIXME, should we even print them? */
1601 if (*SYMBOL_NAME (sym
))
1603 struct symbol
*nsym
;
1604 nsym
= lookup_symbol
1606 b
, VAR_NAMESPACE
, (int *)NULL
, (struct symtab
**)NULL
);
1607 if (SYMBOL_CLASS (nsym
) == LOC_REGISTER
)
1609 /* There is a LOC_ARG/LOC_REGISTER pair. This means that
1610 it was passed on the stack and loaded into a register,
1611 or passed in a register and stored in a stack slot.
1612 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER.
1614 Reasons for using the LOC_ARG:
1615 (1) because find_saved_registers may be slow for remote
1617 (2) because registers are often re-used and stack slots
1618 rarely (never?) are. Therefore using the stack slot is
1619 much less likely to print garbage.
1621 Reasons why we might want to use the LOC_REGISTER:
1622 (1) So that the backtrace prints the same value as
1623 "print foo". I see no compelling reason why this needs
1624 to be the case; having the backtrace print the value which
1625 was passed in, and "print foo" print the value as modified
1626 within the called function, makes perfect sense to me.
1628 Additional note: It might be nice if "info args" displayed
1630 One more note: There is a case with sparc structure passing
1631 where we need to use the LOC_REGISTER, but this is dealt with
1632 by creating a single LOC_REGPARM in symbol reading. */
1634 /* Leave sym (the LOC_ARG) alone. */
1641 /* Print the current arg. */
1643 fprintf_filtered (stream
, ", ");
1646 if (annotation_level
> 1)
1647 printf_filtered ("\n\032\032arg-begin\n");
1649 fprintf_symbol_filtered (stream
, SYMBOL_SOURCE_NAME (sym
),
1650 SYMBOL_LANGUAGE (sym
), DMGL_PARAMS
| DMGL_ANSI
);
1651 if (annotation_level
> 1)
1652 printf_filtered ("\n\032\032arg-name-end\n");
1653 fputs_filtered ("=", stream
);
1655 /* Avoid value_print because it will deref ref parameters. We just
1656 want to print their addresses. Print ??? for args whose address
1657 we do not know. We pass 2 as "recurse" to val_print because our
1658 standard indentation here is 4 spaces, and val_print indents
1659 2 for each recurse. */
1660 val
= read_var_value (sym
, FRAME_INFO_ID (fi
));
1662 if (annotation_level
> 1)
1664 printf_filtered ("\n\032\032arg-value ");
1665 print_value_flags (val
== NULL
? NULL
: VALUE_TYPE (val
));
1666 printf_filtered ("\n");
1670 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
), VALUE_ADDRESS (val
),
1671 stream
, 0, 0, 2, Val_no_prettyprint
);
1673 fputs_filtered ("???", stream
);
1675 if (annotation_level
> 1)
1676 printf_filtered ("\n\032\032arg-end\n");
1681 /* Don't print nameless args in situations where we don't know
1682 enough about the stack to find them. */
1687 if (highest_offset
== -1)
1688 start
= FRAME_ARGS_SKIP
;
1690 start
= highest_offset
;
1692 print_frame_nameless_args (fi
, start
, num
- args_printed
,
1697 /* Print nameless args on STREAM.
1698 FI is the frameinfo for this frame, START is the offset
1699 of the first nameless arg, and NUM is the number of nameless args to
1700 print. FIRST is nonzero if this is the first argument (not just
1701 the first nameless arg). */
1703 print_frame_nameless_args (fi
, start
, num
, first
, stream
)
1704 struct frame_info
*fi
;
1714 for (i
= 0; i
< num
; i
++)
1717 #ifdef NAMELESS_ARG_VALUE
1718 NAMELESS_ARG_VALUE (fi
, start
, &arg_value
);
1720 argsaddr
= FRAME_ARGS_ADDRESS (fi
);
1724 arg_value
= read_memory_integer (argsaddr
+ start
, sizeof (int));
1728 fprintf_filtered (stream
, ", ");
1730 #ifdef PRINT_NAMELESS_INTEGER
1731 PRINT_NAMELESS_INTEGER (stream
, arg_value
);
1733 #ifdef PRINT_TYPELESS_INTEGER
1734 PRINT_TYPELESS_INTEGER (stream
, builtin_type_int
, (LONGEST
) arg_value
);
1736 fprintf_filtered (stream
, "%d", arg_value
);
1737 #endif /* PRINT_TYPELESS_INTEGER */
1738 #endif /* PRINT_NAMELESS_INTEGER */
1740 start
+= sizeof (int);
1746 printf_command (arg
, from_tty
)
1751 register char *s
= arg
;
1753 value_ptr
*val_args
;
1755 char *current_substring
;
1757 int allocated_args
= 20;
1758 struct cleanup
*old_cleanups
;
1760 val_args
= (value_ptr
*) xmalloc (allocated_args
* sizeof (value_ptr
));
1761 old_cleanups
= make_cleanup (free_current_contents
, &val_args
);
1764 error_no_arg ("format-control string and values to print");
1766 /* Skip white space before format string */
1767 while (*s
== ' ' || *s
== '\t') s
++;
1769 /* A format string should follow, enveloped in double quotes */
1771 error ("Bad format string, missing '\"'.");
1773 /* Parse the format-control string and copy it into the string STRING,
1774 processing some kinds of escape sequence. */
1776 f
= string
= (char *) alloca (strlen (s
) + 1);
1784 error ("Bad format string, non-terminated '\"'.");
1796 *f
++ = '\007'; /* Bell */
1821 /* ??? TODO: handle other escape sequences */
1822 error ("Unrecognized escape character \\%c in format string.",
1832 /* Skip over " and following space and comma. */
1835 while (*s
== ' ' || *s
== '\t') s
++;
1837 if (*s
!= ',' && *s
!= 0)
1838 error ("Invalid argument syntax");
1841 while (*s
== ' ' || *s
== '\t') s
++;
1843 /* Need extra space for the '\0's. Doubling the size is sufficient. */
1844 substrings
= alloca (strlen (string
) * 2);
1845 current_substring
= substrings
;
1848 /* Now scan the string for %-specs and see what kinds of args they want.
1849 argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
1850 of the right size. */
1852 enum argclass
{no_arg
, int_arg
, string_arg
, double_arg
, long_long_arg
};
1853 enum argclass
*argclass
;
1854 enum argclass this_argclass
;
1860 argclass
= (enum argclass
*) alloca (strlen (s
) * sizeof *argclass
);
1868 while (strchr ("0123456789.hlL-+ #", *f
))
1870 if (*f
== 'l' || *f
== 'L')
1877 this_argclass
= string_arg
;
1883 this_argclass
= double_arg
;
1887 error ("`*' not supported for precision or width in printf");
1890 error ("Format specifier `n' not supported in printf");
1893 this_argclass
= no_arg
;
1898 this_argclass
= long_long_arg
;
1900 this_argclass
= int_arg
;
1904 if (this_argclass
!= no_arg
)
1906 strncpy (current_substring
, last_arg
, f
- last_arg
);
1907 current_substring
+= f
- last_arg
;
1908 *current_substring
++ = '\0';
1910 argclass
[nargs_wanted
++] = this_argclass
;
1914 /* Now, parse all arguments and evaluate them.
1915 Store the VALUEs in VAL_ARGS. */
1920 if (nargs
== allocated_args
)
1921 val_args
= (value_ptr
*) xrealloc ((char *) val_args
,
1922 (allocated_args
*= 2)
1923 * sizeof (value_ptr
));
1925 val_args
[nargs
] = parse_to_comma_and_eval (&s1
);
1927 /* If format string wants a float, unchecked-convert the value to
1928 floating point of the same size */
1930 if (argclass
[nargs
] == double_arg
)
1932 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (float))
1933 VALUE_TYPE (val_args
[nargs
]) = builtin_type_float
;
1934 if (TYPE_LENGTH (VALUE_TYPE (val_args
[nargs
])) == sizeof (double))
1935 VALUE_TYPE (val_args
[nargs
]) = builtin_type_double
;
1943 if (nargs
!= nargs_wanted
)
1944 error ("Wrong number of arguments for specified format-string");
1946 /* FIXME: We should be using vprintf_filtered, but as long as it
1947 has an arbitrary limit that is unacceptable. Correct fix is
1948 for vprintf_filtered to scan down the format string so it knows
1949 how big a buffer it needs (perhaps by putting a vasprintf (see
1950 GNU C library) in libiberty).
1952 But for now, just force out any pending output, so at least the output
1953 appears in the correct order. */
1954 wrap_here ((char *)NULL
);
1956 /* Now actually print them. */
1957 current_substring
= substrings
;
1958 for (i
= 0; i
< nargs
; i
++)
1960 switch (argclass
[i
])
1967 tem
= value_as_pointer (val_args
[i
]);
1969 /* This is a %s argument. Find the length of the string. */
1974 read_memory (tem
+ j
, &c
, 1);
1979 /* Copy the string contents into a string inside GDB. */
1980 str
= (char *) alloca (j
+ 1);
1981 read_memory (tem
, str
, j
);
1984 /* Don't use printf_filtered because of arbitrary limit. */
1985 printf_unfiltered (current_substring
, str
);
1990 double val
= value_as_double (val_args
[i
]);
1991 /* Don't use printf_filtered because of arbitrary limit. */
1992 printf_unfiltered (current_substring
, val
);
1996 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
1998 long long val
= value_as_long (val_args
[i
]);
1999 /* Don't use printf_filtered because of arbitrary limit. */
2000 printf_unfiltered (current_substring
, val
);
2004 error ("long long not supported in printf");
2008 /* FIXME: there should be separate int_arg and long_arg. */
2009 long val
= value_as_long (val_args
[i
]);
2010 /* Don't use printf_filtered because of arbitrary limit. */
2011 printf_unfiltered (current_substring
, val
);
2015 error ("internal error in printf_command");
2017 /* Skip to the next substring. */
2018 current_substring
+= strlen (current_substring
) + 1;
2020 /* Print the portion of the format string after the last argument. */
2021 /* It would be OK to use printf_filtered here. */
2024 do_cleanups (old_cleanups
);
2027 /* Dump a specified section of assembly code. With no command line
2028 arguments, this command will dump the assembly code for the
2029 function surrounding the pc value in the selected frame. With one
2030 argument, it will dump the assembly code surrounding that pc value.
2031 Two arguments are interpeted as bounds within which to dump
2036 disassemble_command (arg
, from_tty
)
2040 CORE_ADDR low
, high
;
2048 if (!selected_frame
)
2049 error ("No frame selected.\n");
2051 pc
= get_frame_pc (selected_frame
);
2052 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
2053 error ("No function contains program counter for selected frame.\n");
2055 else if (!(space_index
= (char *) strchr (arg
, ' ')))
2058 pc
= parse_and_eval_address (arg
);
2059 if (find_pc_partial_function (pc
, &name
, &low
, &high
) == 0)
2060 error ("No function contains specified address.\n");
2064 /* Two arguments. */
2065 *space_index
= '\0';
2066 low
= parse_and_eval_address (arg
);
2067 high
= parse_and_eval_address (space_index
+ 1);
2070 printf_filtered ("Dump of assembler code ");
2073 printf_filtered ("for function %s:\n", name
);
2077 printf_filtered ("from ");
2078 print_address_numeric (low
, gdb_stdout
);
2079 printf_filtered (" to ");
2080 print_address_numeric (high
, gdb_stdout
);
2081 printf_filtered (":\n");
2084 /* Dump the specified range. */
2085 for (pc
= low
; pc
< high
; )
2088 print_address (pc
, gdb_stdout
);
2089 printf_filtered (":\t");
2090 /* We often wrap here if there are long symbolic names. */
2092 pc
+= print_insn (pc
, gdb_stdout
);
2093 printf_filtered ("\n");
2095 printf_filtered ("End of assembler dump.\n");
2096 gdb_flush (gdb_stdout
);
2101 _initialize_printcmd ()
2103 current_display_number
= -1;
2105 add_info ("address", address_info
,
2106 "Describe where variable VAR is stored.");
2108 add_com ("x", class_vars
, x_command
,
2109 "Examine memory: x/FMT ADDRESS.\n\
2110 ADDRESS is an expression for the memory address to examine.\n\
2111 FMT is a repeat count followed by a format letter and a size letter.\n\
2112 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
2113 t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
2114 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
2115 The specified number of objects of the specified size are printed\n\
2116 according to the format.\n\n\
2117 Defaults for format and size letters are those previously used.\n\
2118 Default count is 1. Default address is following last thing printed\n\
2119 with this command or \"print\".");
2121 add_com ("disassemble", class_vars
, disassemble_command
,
2122 "Disassemble a specified section of memory.\n\
2123 Default is the function surrounding the pc of the selected frame.\n\
2124 With a single argument, the function surrounding that address is dumped.\n\
2125 Two arguments are taken as a range of memory to dump.");
2128 add_com ("whereis", class_vars
, whereis_command
,
2129 "Print line number and file of definition of variable.");
2132 add_info ("display", display_info
,
2133 "Expressions to display when program stops, with code numbers.");
2135 add_cmd ("undisplay", class_vars
, undisplay_command
,
2136 "Cancel some expressions to be displayed when program stops.\n\
2137 Arguments are the code numbers of the expressions to stop displaying.\n\
2138 No argument means cancel all automatic-display expressions.\n\
2139 \"delete display\" has the same effect as this command.\n\
2140 Do \"info display\" to see current list of code numbers.",
2143 add_com ("display", class_vars
, display_command
,
2144 "Print value of expression EXP each time the program stops.\n\
2145 /FMT may be used before EXP as in the \"print\" command.\n\
2146 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
2147 as in the \"x\" command, and then EXP is used to get the address to examine\n\
2148 and examining is done as in the \"x\" command.\n\n\
2149 With no argument, display all currently requested auto-display expressions.\n\
2150 Use \"undisplay\" to cancel display requests previously made.");
2152 add_cmd ("display", class_vars
, enable_display
,
2153 "Enable some expressions to be displayed when program stops.\n\
2154 Arguments are the code numbers of the expressions to resume displaying.\n\
2155 No argument means enable all automatic-display expressions.\n\
2156 Do \"info display\" to see current list of code numbers.", &enablelist
);
2158 add_cmd ("display", class_vars
, disable_display_command
,
2159 "Disable some expressions to be displayed when program stops.\n\
2160 Arguments are the code numbers of the expressions to stop displaying.\n\
2161 No argument means disable all automatic-display expressions.\n\
2162 Do \"info display\" to see current list of code numbers.", &disablelist
);
2164 add_cmd ("display", class_vars
, undisplay_command
,
2165 "Cancel some expressions to be displayed when program stops.\n\
2166 Arguments are the code numbers of the expressions to stop displaying.\n\
2167 No argument means cancel all automatic-display expressions.\n\
2168 Do \"info display\" to see current list of code numbers.", &deletelist
);
2170 add_com ("printf", class_vars
, printf_command
,
2171 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
2172 This is useful for formatted output in user-defined commands.");
2173 add_com ("output", class_vars
, output_command
,
2174 "Like \"print\" but don't put in value history and don't print newline.\n\
2175 This is useful in user-defined commands.");
2177 add_prefix_cmd ("set", class_vars
, set_command
,
2178 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2179 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2180 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2181 with $), a register (a few standard names starting with $), or an actual\n\
2182 variable in the program being debugged. EXP is any valid expression.\n\
2183 Use \"set variable\" for variables with names identical to set subcommands.\n\
2184 \nWith a subcommand, this command modifies parts of the gdb environment.\n\
2185 You can see these environment settings with the \"show\" command.",
2186 &setlist
, "set ", 1, &cmdlist
);
2188 /* "call" is the same as "set", but handy for dbx users to call fns. */
2189 add_com ("call", class_vars
, call_command
,
2190 "Call a function in the program.\n\
2191 The argument is the function name and arguments, in the notation of the\n\
2192 current working language. The result is printed and saved in the value\n\
2193 history, if it is not void.");
2195 add_cmd ("variable", class_vars
, set_command
,
2196 "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2197 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2198 example). VAR may be a debugger \"convenience\" variable (names starting\n\
2199 with $), a register (a few standard names starting with $), or an actual\n\
2200 variable in the program being debugged. EXP is any valid expression.\n\
2201 This may usually be abbreviated to simply \"set\".",
2204 add_com ("print", class_vars
, print_command
,
2205 concat ("Print value of expression EXP.\n\
2206 Variables accessible are those of the lexical environment of the selected\n\
2207 stack frame, plus all those whose scope is global or an entire file.\n\
2209 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
2210 $$NUM refers to NUM'th value back from the last one.\n\
2211 Names starting with $ refer to registers (with the values they would have\n\
2212 if the program were to return to the stack frame now selected, restoring\n\
2213 all registers saved by frames farther in) or else to debugger\n\
2214 \"convenience\" variables (any such name not a known register).\n\
2215 Use assignment expressions to give values to convenience variables.\n",
2217 {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
2218 @ is a binary operator for treating consecutive data objects\n\
2219 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
2220 element is FOO, whose second element is stored in the space following\n\
2221 where FOO is stored, etc. FOO must be an expression whose value\n\
2222 resides in memory.\n",
2224 EXP may be preceded with /FMT, where FMT is a format letter\n\
2225 but no count or size letter (see \"x\" command).", NULL
));
2226 add_com_alias ("p", "print", class_vars
, 1);
2228 add_com ("inspect", class_vars
, inspect_command
,
2229 "Same as \"print\" command, except that if you are running in the epoch\n\
2230 environment, the value is printed in its own window.");
2233 add_set_cmd ("max-symbolic-offset", no_class
, var_uinteger
,
2234 (char *)&max_symbolic_offset
,
2235 "Set the largest offset that will be printed in <symbol+1234> form.",
2239 add_set_cmd ("symbol-filename", no_class
, var_boolean
,
2240 (char *)&print_symbol_filename
,
2241 "Set printing of source filename and line number with <symbol>.",
2245 examine_b_type
= init_type (TYPE_CODE_INT
, 1, 0, NULL
, NULL
);
2246 examine_h_type
= init_type (TYPE_CODE_INT
, 2, 0, NULL
, NULL
);
2247 examine_w_type
= init_type (TYPE_CODE_INT
, 4, 0, NULL
, NULL
);
2248 examine_g_type
= init_type (TYPE_CODE_INT
, 8, 0, NULL
, NULL
);