1 /* Print values for GNU debugger GDB.
2 Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
23 #include "initialize.h"
27 #include "expression.h"
36 /* Last specified output format. */
38 static char last_format
= 'x';
40 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
42 static char last_size
= 'w';
44 /* Default address to examine next. */
46 static CORE_ADDR next_address
;
48 /* Last address examined. */
50 static CORE_ADDR last_examine_address
;
52 /* Contents of last address examined.
53 This is not valid past the end of the `x' command! */
55 static value last_examine_value
;
57 /* Number of auto-display expression currently being displayed.
58 So that we can deleted it if we get an error or a signal within it.
59 -1 when not doing one. */
61 int current_display_number
;
63 static void do_one_display ();
66 void print_address ();
67 void print_scalar_formatted ();
71 /* Decode a format specification. *STRING_PTR should point to it.
72 OFORMAT and OSIZE are used as defaults for the format and size
73 if none are given in the format specification.
74 The structure returned describes all the data
75 found in the specification. In addition, *STRING_PTR is advanced
76 past the specification and past all whitespace following it. */
79 decode_format (string_ptr
, oformat
, osize
)
84 struct format_data val
;
85 register char *p
= *string_ptr
;
91 if (*p
>= '0' && *p
<= '9')
93 while (*p
>= '0' && *p
<= '9') p
++;
95 /* Now process size or format letters that follow. */
99 if (*p
== 'b' || *p
== 'h' || *p
== 'w' || *p
== 'g')
101 else if (*p
>= 'a' && *p
<= 'z')
107 /* Make sure 'g' size is not used on integer types. */
108 if (val
.size
== 'g' && val
.format
!= 'f')
111 while (*p
== ' ' || *p
== '\t') p
++;
117 /* Print value VAL on stdout according to FORMAT, a letter or 0.
118 Do not end with a newline.
119 0 means print VAL according to its own type.
120 SIZE is the letter for the size of datum being printed.
121 This is used to pad hex numbers so they line up. */
124 print_formatted (val
, format
, size
)
126 register char format
;
129 register CORE_ADDR val_long
;
130 int len
= TYPE_LENGTH (VALUE_TYPE (val
));
132 if (VALUE_LVAL (val
) == lval_memory
)
133 next_address
= VALUE_ADDRESS (val
) + len
;
138 next_address
= VALUE_ADDRESS (val
)
139 + value_print (value_addr (val
), stdout
, 0);
143 next_address
= VALUE_ADDRESS (val
)
144 + print_insn (VALUE_ADDRESS (val
), stdout
);
149 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_ARRAY
150 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_STRUCT
151 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_UNION
)
152 value_print (val
, stdout
, format
);
154 print_scalar_formatted (VALUE_CONTENTS (val
), VALUE_TYPE (val
),
155 format
, size
, stdout
);
159 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
160 according to letters FORMAT and SIZE on STREAM.
161 FORMAT may not be zero. Formats s and i are not supported at this level.
163 This is how the elements of an array or structure are printed
167 print_scalar_formatted (valaddr
, type
, format
, size
, stream
)
175 int len
= TYPE_LENGTH (type
);
177 val_long
= unpack_long (type
, valaddr
);
179 /* If value is unsigned, truncate it in case negative. */
182 if (len
== sizeof (char))
183 val_long
&= (1 << 8 * sizeof(char)) - 1;
184 else if (len
== sizeof (short))
185 val_long
&= (1 << 8 * sizeof(short)) - 1;
194 printf ("0x%02x", val_long
);
197 printf ("0x%04x", val_long
);
199 case 0: /* no size specified, like in print */
201 printf ("0x%08x", val_long
);
204 printf ("0x%16x", val_long
);
207 error ("Undefined output size \"%c\".", size
);
212 printf ("%d", val_long
);
216 printf ("%u", val_long
);
221 printf ("0%o", val_long
);
227 print_address (val_long
, stream
);
231 value_print (value_from_long (builtin_type_char
, val_long
), stream
, 0);
235 if (len
== sizeof (float))
236 type
= builtin_type_float
;
237 if (len
== sizeof (double))
238 type
= builtin_type_double
;
240 if (is_nan (unpack_double (type
, valaddr
)))
246 printf ("%g", unpack_double (type
, valaddr
));
253 error ("Undefined output format \"%c\".", format
);
257 /* Specify default address for `x' command.
258 `info lines' uses this. */
261 set_next_address (addr
)
266 /* Make address available to the user as $_. */
267 set_internalvar (lookup_internalvar ("_"),
268 value_from_long (builtin_type_int
, addr
));
271 /* Print address ADDR symbolically on STREAM.
272 First print it as a number. Then perhaps print
273 <SYMBOL + OFFSET> after the number. */
276 print_address (addr
, stream
)
282 fprintf (stream
, "0x%x", addr
);
284 i
= find_pc_misc_function (addr
);
286 if (misc_function_vector
[i
].address
!= addr
)
287 fprintf (stream
, " <%s+%d>",
288 misc_function_vector
[i
].name
,
289 addr
- misc_function_vector
[i
].address
);
291 fprintf (stream
, " <%s>", misc_function_vector
[i
].name
);
295 /* Examine data at address ADDR in format FMT.
296 Fetch it from memory and print on stdout. */
299 do_examine (fmt
, addr
)
300 struct format_data fmt
;
303 register char format
= 0;
305 register int count
= 1;
306 struct type
*val_type
;
308 register int maxelts
;
315 /* String or instruction format implies fetch single bytes
316 regardless of the specified size. */
317 if (format
== 's' || format
== 'i')
321 val_type
= builtin_type_char
;
322 else if (size
== 'h')
323 val_type
= builtin_type_short
;
324 else if (size
== 'w')
325 val_type
= builtin_type_long
;
326 else if (size
== 'g')
327 val_type
= builtin_type_double
;
334 if (format
== 's' || format
== 'i')
337 /* Print as many objects as specified in COUNT, at most maxelts per line,
338 with the address of the next one at the start of each line. */
342 print_address (next_address
, stdout
);
348 fputc ('\t', stdout
);
349 /* Note that this sets next_address for the next object. */
350 last_examine_address
= next_address
;
351 last_examine_value
= value_at (val_type
, next_address
);
352 print_formatted (last_examine_value
, format
, size
);
354 fputc ('\n', stdout
);
360 validate_format (fmt
, cmdname
)
361 struct format_data fmt
;
365 error ("Size letters are meaningless in \"%s\" command.", cmdname
);
367 error ("Item count other than 1 is meaningless in \"%s\" command.",
369 if (fmt
.format
== 'i' || fmt
.format
== 's')
370 error ("Format letter \"%c\" is meaningless in \"%s\" command.",
371 fmt
.format
, cmdname
);
378 struct expression
*expr
;
379 register struct cleanup
*old_chain
= 0;
380 register char format
= 0;
382 struct format_data fmt
;
386 if (exp
&& *exp
== '/')
389 fmt
= decode_format (&exp
, last_format
, 0);
390 validate_format (fmt
, "print");
391 last_format
= format
= fmt
.format
;
396 expr
= parse_c_expression (exp
);
397 old_chain
= make_cleanup (free_current_contents
, &expr
);
399 val
= evaluate_expression (expr
);
402 val
= access_value_history (0);
404 histindex
= record_latest_value (val
);
405 printf ("$%d = ", histindex
);
407 print_formatted (val
, format
, fmt
.size
);
411 do_cleanups (old_chain
);
418 struct expression
*expr
;
419 register struct cleanup
*old_chain
;
420 register char format
= 0;
422 struct format_data fmt
;
424 if (exp
&& *exp
== '/')
427 fmt
= decode_format (&exp
, 0, 0);
428 validate_format (fmt
, "print");
432 expr
= parse_c_expression (exp
);
433 old_chain
= make_cleanup (free_current_contents
, &expr
);
435 val
= evaluate_expression (expr
);
437 print_formatted (val
, format
, fmt
.size
);
439 do_cleanups (old_chain
);
446 struct expression
*expr
= parse_c_expression (exp
);
447 register struct cleanup
*old_chain
448 = make_cleanup (free_current_contents
, &expr
);
449 evaluate_expression (expr
);
450 do_cleanups (old_chain
);
457 register struct symbol
*sym
;
458 register CORE_ADDR val
;
461 error ("Argument required.");
463 sym
= lookup_symbol (exp
, get_selected_block (), VAR_NAMESPACE
);
468 for (i
= 0; i
< misc_function_count
; i
++)
469 if (!strcmp (misc_function_vector
[i
].name
, exp
))
472 if (i
< misc_function_count
)
473 printf ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n",
474 exp
, misc_function_vector
[i
].address
);
476 error ("No symbol \"%s\" in current context.", exp
);
480 printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym
));
481 val
= SYMBOL_VALUE (sym
);
483 switch (SYMBOL_CLASS (sym
))
486 case LOC_CONST_BYTES
:
491 printf ("a label at address 0x%x", val
);
495 printf ("a variable in register %s", reg_names
[val
]);
499 printf ("static at address 0x%x", val
);
503 printf ("an argument in register %s", reg_names
[val
]);
507 printf ("an argument at offset %d", val
);
511 printf ("a local variable at frame offset %d", val
);
515 printf ("a typedef");
519 printf ("a function at address 0x%x",
520 BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)));
527 x_command (exp
, from_tty
)
531 struct expression
*expr
;
532 struct format_data fmt
;
533 struct cleanup
*old_chain
;
535 fmt
.format
= last_format
;
536 fmt
.size
= last_size
;
539 if (exp
&& *exp
== '/')
542 fmt
= decode_format (&exp
, last_format
, last_size
);
543 last_size
= fmt
.size
;
544 last_format
= fmt
.format
;
547 /* If we have an expression, evaluate it and use it as the address. */
549 if (exp
!= 0 && *exp
!= 0)
551 expr
= parse_c_expression (exp
);
552 /* Cause expression not to be there any more
553 if this command is repeated with Newline.
554 But don't clobber a user-defined command's definition. */
557 old_chain
= make_cleanup (free_current_contents
, &expr
);
558 next_address
= value_as_long (evaluate_expression (expr
));
559 do_cleanups (old_chain
);
562 do_examine (fmt
, next_address
);
564 /* Make last address examined available to the user as $_. */
565 set_internalvar (lookup_internalvar ("_"),
566 value_from_long (builtin_type_int
, last_examine_address
));
568 /* Make contents of last address examined available to the user as $__. */
569 set_internalvar (lookup_internalvar ("__"), last_examine_value
);
572 /* Commands for printing types of things. */
578 struct expression
*expr
;
580 register struct cleanup
*old_chain
;
584 expr
= parse_c_expression (exp
);
585 old_chain
= make_cleanup (free_current_contents
, &expr
);
586 val
= evaluate_type (expr
);
589 val
= access_value_history (0);
592 type_print (VALUE_TYPE (val
), "", stdout
, 1);
596 do_cleanups (old_chain
);
600 ptype_command (typename
)
603 register char *p
= typename
;
605 extern struct block
*get_current_block ();
606 register struct block
*b
607 = (have_inferior_p () || have_core_file_p ()) ? get_current_block () : 0;
608 register struct type
*type
;
611 error_no_arg ("type name");
613 while (*p
&& *p
!= ' ' && *p
!= '\t') p
++;
615 while (*p
== ' ' || *p
== '\t') p
++;
617 if (len
== 6 && !strncmp (typename
, "struct", 6))
618 type
= lookup_struct (p
, b
);
619 else if (len
== 5 && !strncmp (typename
, "union", 5))
620 type
= lookup_union (p
, b
);
621 else if (len
== 4 && !strncmp (typename
, "enum", 4))
622 type
= lookup_enum (p
, b
);
625 type
= lookup_typename (typename
, b
, 1);
628 register struct symbol
*sym
629 = lookup_symbol (typename
, b
, STRUCT_NAMESPACE
);
631 error ("No type named %s.", typename
);
632 printf ("No type named %s, but there is a ",
634 switch (TYPE_CODE (SYMBOL_TYPE (sym
)))
636 case TYPE_CODE_STRUCT
:
640 case TYPE_CODE_UNION
:
647 printf (" %s. Type \"help ptype\".\n", typename
);
648 type
= SYMBOL_TYPE (sym
);
652 type_print (type
, "", stdout
, 1);
658 /* Chain link to next auto-display item. */
659 struct display
*next
;
660 /* Expression to be evaluated and displayed. */
661 struct expression
*exp
;
662 /* Item number of this auto-display item. */
664 /* Display format specified. */
665 struct format_data format
;
666 /* Block in which expression is to be evaluated. */
670 /* Chain of expressions whose values should be displayed
671 automatically each time the program stops. */
673 static struct display
*display_chain
;
675 static int display_number
;
677 /* Add an expression to the auto-display chain.
678 Specify the expression. */
681 display_command (exp
, from_tty
)
685 struct format_data fmt
;
686 register struct expression
*expr
;
687 register struct display
*new;
698 fmt
= decode_format (&exp
, 0, 0);
699 if (fmt
.size
&& fmt
.format
== 0)
701 if (fmt
.format
== 'i' || fmt
.format
== 's')
711 expr
= parse_c_expression (exp
);
713 new = (struct display
*) xmalloc (sizeof (struct display
));
716 new->next
= display_chain
;
717 new->number
= ++display_number
;
722 do_one_display (new);
735 /* Clear out the display_chain.
736 Done when new symtabs are loaded, since this invalidates
737 the types stored in many expressions. */
742 register struct display
*d
;
744 while (d
= display_chain
)
747 display_chain
= d
->next
;
752 /* Delete the auto-display number NUM. */
758 register struct display
*d1
, *d
;
761 error ("No display number %d.", num
);
763 if (display_chain
->number
== num
)
766 display_chain
= d1
->next
;
770 for (d
= display_chain
; ; d
= d
->next
)
773 error ("No display number %d.", num
);
774 if (d
->next
->number
== num
)
784 /* Delete some values from the auto-display chain.
785 Specify the element numbers. */
788 undisplay_command (args
)
791 register char *p
= args
;
794 register struct display
*d
, *d1
;
798 if (query ("Delete all auto-display expressions? "))
807 while (*p1
>= '0' && *p1
<= '9') p1
++;
808 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
809 error ("Arguments must be display numbers.");
813 delete_display (num
);
816 while (*p
== ' ' || *p
== '\t') p
++;
821 /* Display a single auto-display. */
827 current_display_number
= d
->number
;
829 printf ("%d: ", d
->number
);
833 if (d
->format
.count
!= 1)
834 printf ("%d", d
->format
.count
);
835 printf ("%c", d
->format
.format
);
836 if (d
->format
.format
!= 'i' && d
->format
.format
!= 's')
837 printf ("%c", d
->format
.size
);
839 print_expression (d
->exp
, stdout
);
840 if (d
->format
.count
!= 1)
844 do_examine (d
->format
,
845 value_as_long (evaluate_expression (d
->exp
)));
849 if (d
->format
.format
)
850 printf ("/%c ", d
->format
.format
);
851 print_expression (d
->exp
, stdout
);
853 print_formatted (evaluate_expression (d
->exp
),
854 d
->format
.format
, d
->format
.size
);
859 current_display_number
= -1;
862 /* Display all of the values on the auto-display chain. */
867 register struct display
*d
;
869 for (d
= display_chain
; d
; d
= d
->next
)
873 /* Delete the auto-display which we were in the process of displaying.
874 This is done when there is an error or a signal. */
877 delete_current_display ()
879 if (current_display_number
>= 0)
881 delete_display (current_display_number
);
882 fprintf (stderr
, "Deleting display %d to avoid infinite recursion.\n",
883 current_display_number
);
885 current_display_number
= -1;
891 register struct display
*d
;
894 printf ("There are no auto-display expressions now.\n");
896 printf ("Auto-display expressions now in effect:\n");
897 for (d
= display_chain
; d
; d
= d
->next
)
899 printf ("%d: ", d
->number
);
901 printf ("/%d%c%c ", d
->format
.count
, d
->format
.size
,
903 else if (d
->format
.format
)
904 printf ("/%c ", d
->format
.format
);
905 print_expression (d
->exp
, stdout
);
911 /* Print the value in stack frame FRAME of a variable
912 specified by a struct symbol. */
915 print_variable_value (var
, frame
, stream
)
920 value val
= read_var_value (var
, frame
);
921 value_print (val
, stream
, 0);
924 /* Print the arguments of a stack frame, given the function FUNC
925 running in that frame (as a symbol), the address of the arglist,
926 and the number of args according to the stack frame (or -1 if unknown). */
928 static void print_frame_nameless_args ();
930 print_frame_args (func
, addr
, num
, stream
)
932 register CORE_ADDR addr
;
940 register int last_offset
= FRAME_ARGS_SKIP
;
941 register int last_regparm
= 0;
942 register struct symbol
*sym
, *nextsym
;
947 b
= SYMBOL_BLOCK_VALUE (func
);
948 nsyms
= BLOCK_NSYMS (b
);
953 /* Find first arg that is not before LAST_OFFSET. */
955 for (i
= 0; i
< nsyms
; i
++)
958 sym
= BLOCK_SYM (b
, i
);
959 if (SYMBOL_CLASS (sym
) == LOC_ARG
)
961 if (SYMBOL_VALUE (sym
) >= last_offset
963 || SYMBOL_VALUE (sym
) < SYMBOL_VALUE (nextsym
)))
966 else if (SYMBOL_CLASS (sym
) == LOC_REGPARM
)
968 if (SYMBOL_VALUE (sym
) >= last_regparm
970 || SYMBOL_VALUE (sym
) < SYMBOL_VALUE (nextsym
)))
977 /* Print any nameless args between the last arg printed
979 if (SYMBOL_CLASS (sym
) == LOC_ARG
980 && last_offset
!= (SYMBOL_VALUE (sym
) / sizeof (int)) * sizeof (int))
982 print_frame_nameless_args (addr
, last_offset
, SYMBOL_VALUE (sym
),
986 /* Print the next arg. */
987 if (SYMBOL_CLASS (sym
) == LOC_REGPARM
)
989 unsigned char raw_buffer
[MAX_REGISTER_RAW_SIZE
];
990 unsigned char virtual_buffer
[MAX_REGISTER_VIRTUAL_SIZE
];
992 read_relative_register_raw_bytes (SYMBOL_VALUE (sym
), raw_buffer
);
993 if (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_FLT
)
994 val
= value_from_double (SYMBOL_TYPE (sym
), *(double *)raw_buffer
);
995 else if (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
996 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_ENUM
)
997 val
= value_from_long (SYMBOL_TYPE (sym
), *(int *)raw_buffer
);
998 else if (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_PTR
)
1000 if (sizeof (char *) == sizeof (int))
1001 val
= value_from_long (builtin_type_int
, *(int *)raw_buffer
);
1002 else if (sizeof (char *) == sizeof (long))
1003 val
= value_from_long (builtin_type_long
, *(long *)raw_buffer
);
1005 error ("pointer size not sizeof (int) or sizeof (long)");
1006 VALUE_TYPE (val
) = SYMBOL_TYPE (sym
);
1009 error ("can't extract non-scalar from register");
1012 val
= value_at (SYMBOL_TYPE (sym
), addr
+ SYMBOL_VALUE (sym
));
1015 fprintf (stream
, ", ");
1016 fprintf (stream
, "%s=", SYMBOL_NAME (sym
));
1017 value_print (val
, stream
, 0);
1019 if (SYMBOL_CLASS (sym
) == LOC_ARG
)
1020 last_offset
= SYMBOL_VALUE (sym
) + TYPE_LENGTH (SYMBOL_TYPE (sym
));
1023 last_regparm
= SYMBOL_VALUE (sym
) + 1;
1024 last_offset
+= TYPE_LENGTH (SYMBOL_TYPE (sym
));
1026 /* Round up address of next arg to multiple of size of int. */
1028 = ((last_offset
+ sizeof (int) - 1) / sizeof (int)) * sizeof (int);
1030 if (num
>= 0 && num
* sizeof (int) + FRAME_ARGS_SKIP
> last_offset
)
1031 print_frame_nameless_args (addr
, last_offset
,
1032 num
* sizeof (int) + FRAME_ARGS_SKIP
, stream
);
1036 print_frame_nameless_args (argsaddr
, start
, end
, stream
)
1045 if (start
!= FRAME_ARGS_SKIP
)
1046 fprintf (stream
, ", ");
1047 fprintf (stream
, "%d",
1048 read_memory_integer (argsaddr
+ start
, sizeof (int)));
1049 start
+= sizeof (int);
1054 printf_command (arg
)
1058 register char *s
= arg
;
1062 int allocated_args
= 20;
1069 val_args
= (value
*) xmalloc (allocated_args
* sizeof (value
));
1072 error_no_arg ("format-control string and values to print");
1074 /* Skip white space before format string */
1075 while (*s
== ' ' || *s
== '\t') s
++;
1077 /* A format string should follow, enveloped in double quotes */
1079 error ("Bad format string, missing '\"'.");
1081 /* Parse the format-control string and copy it into the string STRING,
1082 processing some kinds of escape sequence. */
1084 f
= string
= (char *) alloca (strlen (s
) + 1);
1091 error ("Bad format string, non-terminated '\"'.");
1092 /* doesn't return */
1113 /* ??? TODO: handle other escape sequences */
1114 error ("Unrecognized \\ escape character in format string.");
1123 /* Skip over " and following space and comma. */
1126 while (*s
== ' ' || *s
== '\t') s
++;
1128 if (*s
!= ',' && *s
!= 0)
1129 error ("Invalid argument syntax");
1132 while (*s
== ' ' || *s
== '\t') s
++;
1134 /* Now scan the string for %-specs and see what kinds of args they want.
1135 argclass[I] is set to 1 if the Ith arg should be a string. */
1137 argclass
= (char *) alloca (strlen (s
));
1143 while (index ("0123456789.hlL-+ #", *f
)) f
++;
1145 argclass
[nargs_wanted
++] = 1;
1147 argclass
[nargs_wanted
++] = 0;
1151 /* Now, parse all arguments and evaluate them.
1152 Store the VALUEs in VAL_ARGS. */
1157 if (nargs
== allocated_args
)
1158 val_args
= (value
*) xrealloc (val_args
,
1159 (allocated_args
*= 2)
1162 val_args
[nargs
++] = parse_to_comma_and_eval (&s1
);
1168 if (nargs
!= nargs_wanted
)
1169 error ("Wrong number of arguments for specified format-string");
1171 /* Now lay out an argument-list containing the arguments
1172 as doubles, integers and C pointers. */
1174 arg_bytes
= (char *) alloca (sizeof (double) * nargs
);
1176 for (i
= 0; i
< nargs
; i
++)
1182 tem
= value_as_long (val_args
[i
]);
1184 /* This is a %s argument. Find the length of the string. */
1189 read_memory (tem
+ j
, &c
, 1);
1194 /* Copy the string contents into a string inside GDB. */
1195 str
= (char *) alloca (j
+ 1);
1196 read_memory (tem
, str
, j
);
1199 /* Pass address of internal copy as the arg to vprintf. */
1200 *((int *) &arg_bytes
[argindex
]) = (int) str
;
1201 argindex
+= sizeof (int);
1203 else if (VALUE_TYPE (val_args
[i
])->code
== TYPE_CODE_FLT
)
1205 *((double *) &arg_bytes
[argindex
]) = value_as_double (val_args
[i
]);
1206 argindex
+= sizeof (double);
1210 *((int *) &arg_bytes
[argindex
]) = value_as_long (val_args
[i
]);
1211 argindex
+= sizeof (int);
1215 vprintf (string
, arg_bytes
);
1221 current_display_number
= -1;
1223 add_info ("address", address_info
,
1224 "Describe where variable VAR is stored.");
1226 add_com ("x", class_vars
, x_command
,
1227 "Examine memory: x/FMT ADDRESS.\n\
1228 ADDRESS is an expression for the memory address to examine.\n\
1229 FMT is a repeat count followed by a format letter and a size letter.\n\
1230 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
1231 f(float), a(address), i(instruction), c(char) and s(string).\n\
1232 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
1233 g is meaningful only with f, for type double.\n\
1234 The specified number of objects of the specified size are printed\n\
1235 according to the format.\n\n\
1236 Defaults for format and size letters are those previously used.\n\
1237 Default count is 1. Default address is following last thing printed\n\
1238 with this command or \"print\".");
1240 add_com ("ptype", class_vars
, ptype_command
,
1241 "Print definition of type TYPE.\n\
1242 Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\
1243 or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\
1244 The selected stack frame's lexical context is used to look up the name.");
1246 add_com ("whatis", class_vars
, whatis_command
,
1247 "Print data type of expression EXP.");
1249 add_info ("display", display_info
,
1250 "Expressions to display when program stops, with code numbers.");
1251 add_com ("undisplay", class_vars
, undisplay_command
,
1252 "Cancel some expressions to be displayed whenever program stops.\n\
1253 Arguments are the code numbers of the expressions to stop displaying.\n\
1254 No argument means cancel all automatic-display expressions.\n\
1255 Do \"info display\" to see current list of code numbers.");
1256 add_com ("display", class_vars
, display_command
,
1257 "Print value of expression EXP each time the program stops.\n\
1258 /FMT may be used before EXP as in the \"print\" command.\n\
1259 /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
1260 as in the \"x\" command, and then EXP is used to get the address to examine\n\
1261 and examining is done as in the \"x\" command.\n\n\
1262 With no argument, display all currently requested auto-display expressions.\n\
1263 Use \"undisplay\" to cancel display requests previously made.");
1265 add_com ("printf", class_vars
, printf_command
,
1266 "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
1267 This is useful for formatted output in user-defined commands.");
1268 add_com ("output", class_vars
, output_command
,
1269 "Like \"print\" but don't put in value history and don't print newline.\n\
1270 This is useful in user-defined commands.");
1272 add_com ("set", class_vars
, set_command
,
1273 "Perform an assignment VAR = EXP. You must type the \"=\".\n\
1274 VAR may be a debugger \"convenience\" variables (names starting with $),\n\
1275 a register (a few standard names starting with $), or an actual variable\n\
1276 in the program being debugger. EXP is any expression.");
1278 add_com ("print", class_vars
, print_command
,
1279 concat ("Print value of expression EXP.\n\
1280 Variables accessible are those of the lexical environment of the selected\n\
1281 stack frame, plus all those whose scope is global or an entire file.\n\
1283 $NUM gets previous value number NUM. $ and $$ are the last two values.\n\
1284 $$NUM refers to NUM'th value back from the last one.\n\
1285 Names starting with $ refer to registers (with the values they would have\n\
1286 if the program were to return to the stack frame now selected, restoring\n\
1287 all registers saved by frames farther in) or else to debugger\n\
1288 \"convenience\" variables (any such name not a known register).\n\
1289 Use assignment expressions to give values to convenience variables.\n",
1291 \{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
1292 @ is a binary operator for treating consecutive data objects\n\
1293 anywhere in memory as an array. FOO@NUM gives an array whose first\n\
1294 element is FOO, whose second element is stored in the space following\n\
1295 where FOO is stored, etc. FOO must be an expression whose value\n\
1296 resides in memory.\n",
1298 EXP may be preceded with /FMT, where FMT is a format letter\n\
1299 but no count or size letter (see \"x\" command)."));
1300 add_com_alias ("p", "print", class_vars
, 1);