Commit | Line | Data |
---|---|---|
bd5635a1 RP |
1 | /* Print values for GNU debugger GDB. |
2 | Copyright (C) 1986-1991 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | GDB is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 1, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GDB is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GDB; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | #include "defs.h" | |
23 | #include "param.h" | |
24 | #include "frame.h" | |
25 | #include "symtab.h" | |
26 | #include "value.h" | |
27 | #include "expression.h" | |
28 | #include "gdbcore.h" | |
29 | #include "gdbcmd.h" | |
30 | #include "target.h" | |
31 | ||
32 | extern int asm_demangle; /* Whether to demangle syms in asm printouts */ | |
33 | ||
34 | extern struct block *get_current_block (); | |
35 | ||
36 | static void print_frame_nameless_args (); | |
37 | ||
38 | struct format_data | |
39 | { | |
40 | int count; | |
41 | char format; | |
42 | char size; | |
43 | }; | |
44 | ||
45 | /* Last specified output format. */ | |
46 | ||
47 | static char last_format = 'x'; | |
48 | ||
49 | /* Last specified examination size. 'b', 'h', 'w' or `q'. */ | |
50 | ||
51 | static char last_size = 'w'; | |
52 | ||
53 | /* Default address to examine next. */ | |
54 | ||
55 | static CORE_ADDR next_address; | |
56 | ||
57 | /* Last address examined. */ | |
58 | ||
59 | static CORE_ADDR last_examine_address; | |
60 | ||
61 | /* Contents of last address examined. | |
62 | This is not valid past the end of the `x' command! */ | |
63 | ||
64 | static value last_examine_value; | |
65 | ||
66 | /* Number of auto-display expression currently being displayed. | |
67 | So that we can deleted it if we get an error or a signal within it. | |
68 | -1 when not doing one. */ | |
69 | ||
70 | int current_display_number; | |
71 | ||
72 | /* Flag to low-level print routines that this value is being printed | |
73 | in an epoch window. We'd like to pass this as a parameter, but | |
74 | every routine would need to take it. Perhaps we can encapsulate | |
75 | this in the I/O stream once we have GNU stdio. */ | |
76 | ||
77 | int inspect_it = 0; | |
78 | ||
79 | static void do_one_display (); | |
80 | ||
81 | void do_displays (); | |
82 | void print_scalar_formatted (); | |
83 | ||
84 | \f | |
85 | /* Decode a format specification. *STRING_PTR should point to it. | |
86 | OFORMAT and OSIZE are used as defaults for the format and size | |
87 | if none are given in the format specification. | |
88 | If OSIZE is zero, then the size field of the returned value | |
89 | should be set only if a size is explicitly specified by the | |
90 | user. | |
91 | The structure returned describes all the data | |
92 | found in the specification. In addition, *STRING_PTR is advanced | |
93 | past the specification and past all whitespace following it. */ | |
94 | ||
95 | struct format_data | |
96 | decode_format (string_ptr, oformat, osize) | |
97 | char **string_ptr; | |
98 | char oformat; | |
99 | char osize; | |
100 | { | |
101 | struct format_data val; | |
102 | register char *p = *string_ptr; | |
103 | ||
104 | val.format = '?'; | |
105 | val.size = '?'; | |
106 | val.count = 1; | |
107 | ||
108 | if (*p >= '0' && *p <= '9') | |
109 | val.count = atoi (p); | |
110 | while (*p >= '0' && *p <= '9') p++; | |
111 | ||
112 | /* Now process size or format letters that follow. */ | |
113 | ||
114 | while (1) | |
115 | { | |
116 | if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g') | |
117 | val.size = *p++; | |
118 | #ifdef LONG_LONG | |
119 | else if (*p == 'l') | |
120 | { | |
121 | val.size = 'g'; | |
122 | p++; | |
123 | } | |
124 | #endif | |
125 | else if (*p >= 'a' && *p <= 'z') | |
126 | val.format = *p++; | |
127 | else | |
128 | break; | |
129 | } | |
130 | ||
131 | #ifndef LONG_LONG | |
132 | /* Make sure 'g' size is not used on integer types. | |
133 | Well, actually, we can handle hex. */ | |
134 | if (val.size == 'g' && val.format != 'f' && val.format != 'x') | |
135 | val.size = 'w'; | |
136 | #endif | |
137 | ||
138 | while (*p == ' ' || *p == '\t') p++; | |
139 | *string_ptr = p; | |
140 | ||
141 | /* Set defaults for format and size if not specified. */ | |
142 | if (val.format == '?') | |
143 | { | |
144 | if (val.size == '?') | |
145 | { | |
146 | /* Neither has been specified. */ | |
147 | val.format = oformat; | |
148 | val.size = osize; | |
149 | } | |
150 | else | |
151 | /* If a size is specified, any format makes a reasonable | |
152 | default except 'i'. */ | |
153 | val.format = oformat == 'i' ? 'x' : oformat; | |
154 | } | |
155 | else if (val.size == '?') | |
156 | switch (val.format) | |
157 | { | |
158 | case 'a': | |
159 | case 's': | |
160 | /* Addresses must be words. */ | |
161 | val.size = osize ? 'w' : osize; | |
162 | break; | |
163 | case 'f': | |
164 | /* Floating point has to be word or giantword. */ | |
165 | if (osize == 'w' || osize == 'g') | |
166 | val.size = osize; | |
167 | else | |
168 | /* Default it to giantword if the last used size is not | |
169 | appropriate. */ | |
170 | val.size = osize ? 'g' : osize; | |
171 | break; | |
172 | case 'c': | |
173 | /* Characters default to one byte. */ | |
174 | val.size = osize ? 'b' : osize; | |
175 | break; | |
176 | default: | |
177 | /* The default is the size most recently specified. */ | |
178 | val.size = osize; | |
179 | } | |
180 | ||
181 | return val; | |
182 | } | |
183 | \f | |
184 | /* Print value VAL on stdout according to FORMAT, a letter or 0. | |
185 | Do not end with a newline. | |
186 | 0 means print VAL according to its own type. | |
187 | SIZE is the letter for the size of datum being printed. | |
188 | This is used to pad hex numbers so they line up. */ | |
189 | ||
190 | static void | |
191 | print_formatted (val, format, size) | |
192 | register value val; | |
193 | register char format; | |
194 | char size; | |
195 | { | |
196 | int len = TYPE_LENGTH (VALUE_TYPE (val)); | |
197 | ||
198 | if (VALUE_LVAL (val) == lval_memory) | |
199 | next_address = VALUE_ADDRESS (val) + len; | |
200 | ||
201 | switch (format) | |
202 | { | |
203 | case 's': | |
204 | next_address = VALUE_ADDRESS (val) | |
205 | + value_print (value_addr (val), stdout, format, Val_pretty_default); | |
206 | break; | |
207 | ||
208 | case 'i': | |
209 | next_address = VALUE_ADDRESS (val) | |
210 | + print_insn (VALUE_ADDRESS (val), stdout); | |
211 | break; | |
212 | ||
213 | default: | |
214 | if (format == 0 | |
215 | || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY | |
216 | || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT | |
217 | || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION | |
218 | || VALUE_REPEATED (val)) | |
219 | value_print (val, stdout, format, Val_pretty_default); | |
220 | else | |
221 | print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val), | |
222 | format, size, stdout); | |
223 | } | |
224 | } | |
225 | ||
226 | /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR, | |
227 | according to letters FORMAT and SIZE on STREAM. | |
228 | FORMAT may not be zero. Formats s and i are not supported at this level. | |
229 | ||
230 | This is how the elements of an array or structure are printed | |
231 | with a format. */ | |
232 | ||
233 | void | |
234 | print_scalar_formatted (valaddr, type, format, size, stream) | |
235 | char *valaddr; | |
236 | struct type *type; | |
237 | char format; | |
238 | int size; | |
239 | FILE *stream; | |
240 | { | |
241 | LONGEST val_long; | |
242 | int len = TYPE_LENGTH (type); | |
243 | ||
244 | if (size == 'g' && sizeof (LONGEST) < 8 | |
245 | && format == 'x') | |
246 | { | |
247 | /* ok, we're going to have to get fancy here. Assumption: a | |
248 | long is four bytes. FIXME. */ | |
249 | unsigned long v1, v2, tmp; | |
250 | ||
251 | v1 = unpack_long (builtin_type_long, valaddr); | |
252 | v2 = unpack_long (builtin_type_long, valaddr + 4); | |
253 | ||
254 | #if TARGET_BYTE_ORDER == LITTLE_ENDIAN | |
255 | /* Swap the two for printing */ | |
256 | tmp = v1; | |
257 | v1 = v2; | |
258 | v2 = tmp; | |
259 | #endif | |
260 | ||
261 | switch (format) | |
262 | { | |
263 | case 'x': | |
264 | fprintf_filtered (stream, "0x%08x%08x", v1, v2); | |
265 | break; | |
266 | default: | |
267 | error ("Output size \"g\" unimplemented for format \"%c\".", | |
268 | format); | |
269 | } | |
270 | return; | |
271 | } | |
272 | ||
273 | val_long = unpack_long (type, valaddr); | |
274 | ||
275 | /* If value is unsigned, truncate it in case negative. */ | |
276 | if (format != 'd') | |
277 | { | |
278 | if (len == sizeof (char)) | |
279 | val_long &= (1 << 8 * sizeof(char)) - 1; | |
280 | else if (len == sizeof (short)) | |
281 | val_long &= (1 << 8 * sizeof(short)) - 1; | |
282 | else if (len == sizeof (long)) | |
283 | val_long &= (unsigned long) - 1; | |
284 | } | |
285 | ||
286 | switch (format) | |
287 | { | |
288 | case 'x': | |
289 | if (!size) | |
290 | { | |
291 | /* no size specified, like in print. Print varying # of digits. */ | |
292 | #if defined (LONG_LONG) | |
293 | fprintf_filtered (stream, "0x%llx", val_long); | |
294 | #else /* not LONG_LONG. */ | |
295 | fprintf_filtered (stream, "0x%lx", val_long); | |
296 | #endif /* not LONG_LONG. */ | |
297 | } | |
298 | else | |
299 | #if defined (LONG_LONG) | |
300 | switch (size) | |
301 | { | |
302 | case 'b': | |
303 | fprintf_filtered (stream, "0x%02llx", val_long); | |
304 | break; | |
305 | case 'h': | |
306 | fprintf_filtered (stream, "0x%04llx", val_long); | |
307 | break; | |
308 | case 'w': | |
309 | fprintf_filtered (stream, "0x%08llx", val_long); | |
310 | break; | |
311 | case 'g': | |
312 | fprintf_filtered (stream, "0x%016llx", val_long); | |
313 | break; | |
314 | default: | |
315 | error ("Undefined output size \"%c\".", size); | |
316 | } | |
317 | #else /* not LONG_LONG. */ | |
318 | switch (size) | |
319 | { | |
320 | case 'b': | |
321 | fprintf_filtered (stream, "0x%02x", val_long); | |
322 | break; | |
323 | case 'h': | |
324 | fprintf_filtered (stream, "0x%04x", val_long); | |
325 | break; | |
326 | case 'w': | |
327 | fprintf_filtered (stream, "0x%08x", val_long); | |
328 | break; | |
329 | case 'g': | |
330 | fprintf_filtered (stream, "0x%016x", val_long); | |
331 | break; | |
332 | default: | |
333 | error ("Undefined output size \"%c\".", size); | |
334 | } | |
335 | #endif /* not LONG_LONG */ | |
336 | break; | |
337 | ||
338 | case 'd': | |
339 | #ifdef LONG_LONG | |
340 | fprintf_filtered (stream, "%lld", val_long); | |
341 | #else | |
342 | fprintf_filtered (stream, "%d", val_long); | |
343 | #endif | |
344 | break; | |
345 | ||
346 | case 'u': | |
347 | #ifdef LONG_LONG | |
348 | fprintf_filtered (stream, "%llu", val_long); | |
349 | #else | |
350 | fprintf_filtered (stream, "%u", val_long); | |
351 | #endif | |
352 | break; | |
353 | ||
354 | case 'o': | |
355 | if (val_long) | |
356 | #ifdef LONG_LONG | |
357 | fprintf_filtered (stream, "0%llo", val_long); | |
358 | #else | |
359 | fprintf_filtered (stream, "0%o", val_long); | |
360 | #endif | |
361 | else | |
362 | fprintf_filtered (stream, "0"); | |
363 | break; | |
364 | ||
365 | case 'a': | |
366 | print_address ((CORE_ADDR) val_long, stream); | |
367 | break; | |
368 | ||
369 | case 'c': | |
370 | value_print (value_from_long (builtin_type_char, val_long), stream, 0, | |
371 | Val_pretty_default); | |
372 | break; | |
373 | ||
374 | case 'f': | |
375 | if (len == sizeof (float)) | |
376 | type = builtin_type_float; | |
377 | else if (len == sizeof (double)) | |
378 | type = builtin_type_double; | |
379 | print_floating (valaddr, type, stream); | |
380 | break; | |
381 | ||
382 | case 0: | |
383 | abort (); | |
384 | ||
385 | default: | |
386 | error ("Undefined output format \"%c\".", format); | |
387 | } | |
388 | } | |
389 | ||
390 | /* Specify default address for `x' command. | |
391 | `info lines' uses this. */ | |
392 | ||
393 | void | |
394 | set_next_address (addr) | |
395 | CORE_ADDR addr; | |
396 | { | |
397 | next_address = addr; | |
398 | ||
399 | /* Make address available to the user as $_. */ | |
400 | set_internalvar (lookup_internalvar ("_"), | |
401 | value_from_long (builtin_type_int, (LONGEST) addr)); | |
402 | } | |
403 | ||
404 | /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM. | |
405 | DO_DEMANGLE controls whether to print a symbol in its native "raw" form, | |
406 | or to interpret it as a possible C++ name and convert it back to source | |
407 | form. */ | |
408 | ||
409 | void | |
410 | print_address_symbolic (addr, stream, do_demangle) | |
411 | CORE_ADDR addr; | |
412 | FILE *stream; | |
413 | int do_demangle; | |
414 | { | |
415 | int name_location; | |
416 | register int i = find_pc_misc_function (addr); | |
417 | ||
418 | /* If nothing comes out, don't print anything symbolic. */ | |
419 | ||
420 | if (i < 0) | |
421 | return; | |
422 | ||
423 | fputs_filtered (" <", stream); | |
424 | if (do_demangle) | |
425 | fputs_demangled (misc_function_vector[i].name, stream, 1); | |
426 | else | |
427 | fputs_filtered (misc_function_vector[i].name, stream); | |
428 | name_location = misc_function_vector[i].address; | |
429 | if (addr - name_location) | |
430 | fprintf_filtered (stream, "+%d>", addr - name_location); | |
431 | else | |
432 | fputs_filtered (">", stream); | |
433 | } | |
434 | ||
435 | /* Print address ADDR symbolically on STREAM. | |
436 | First print it as a number. Then perhaps print | |
437 | <SYMBOL + OFFSET> after the number. */ | |
438 | ||
439 | void | |
440 | print_address (addr, stream) | |
441 | CORE_ADDR addr; | |
442 | FILE *stream; | |
443 | { | |
444 | fprintf_filtered (stream, "0x%x", addr); | |
445 | print_address_symbolic (addr, stream, asm_demangle); | |
446 | } | |
447 | ||
448 | /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE | |
449 | controls whether to print the symbolic name "raw" or demangled. */ | |
450 | ||
451 | void | |
452 | print_address_demangle (addr, stream, do_demangle) | |
453 | CORE_ADDR addr; | |
454 | FILE *stream; | |
455 | int do_demangle; | |
456 | { | |
457 | fprintf_filtered (stream, "0x%x", addr); | |
458 | print_address_symbolic (addr, stream, do_demangle); | |
459 | } | |
460 | ||
461 | \f | |
462 | ||
463 | /* Examine data at address ADDR in format FMT. | |
464 | Fetch it from memory and print on stdout. */ | |
465 | ||
466 | static void | |
467 | do_examine (fmt, addr) | |
468 | struct format_data fmt; | |
469 | CORE_ADDR addr; | |
470 | { | |
471 | register char format = 0; | |
472 | register char size; | |
473 | register int count = 1; | |
474 | struct type *val_type; | |
475 | register int i; | |
476 | register int maxelts; | |
477 | ||
478 | format = fmt.format; | |
479 | size = fmt.size; | |
480 | count = fmt.count; | |
481 | next_address = addr; | |
482 | ||
483 | /* String or instruction format implies fetch single bytes | |
484 | regardless of the specified size. */ | |
485 | if (format == 's' || format == 'i') | |
486 | size = 'b'; | |
487 | ||
488 | if (size == 'b') | |
489 | val_type = builtin_type_char; | |
490 | else if (size == 'h') | |
491 | val_type = builtin_type_short; | |
492 | else if (size == 'w') | |
493 | val_type = builtin_type_long; | |
494 | else if (size == 'g') | |
495 | #ifndef LONG_LONG | |
496 | val_type = builtin_type_double; | |
497 | #else | |
498 | val_type = builtin_type_long_long; | |
499 | #endif | |
500 | ||
501 | maxelts = 8; | |
502 | if (size == 'w') | |
503 | maxelts = 4; | |
504 | if (size == 'g') | |
505 | maxelts = 2; | |
506 | if (format == 's' || format == 'i') | |
507 | maxelts = 1; | |
508 | ||
509 | /* Print as many objects as specified in COUNT, at most maxelts per line, | |
510 | with the address of the next one at the start of each line. */ | |
511 | ||
512 | while (count > 0) | |
513 | { | |
514 | print_address (next_address, stdout); | |
515 | printf_filtered (":"); | |
516 | for (i = maxelts; | |
517 | i > 0 && count > 0; | |
518 | i--, count--) | |
519 | { | |
520 | printf_filtered ("\t"); | |
521 | /* Note that print_formatted sets next_address for the next | |
522 | object. */ | |
523 | last_examine_address = next_address; | |
524 | last_examine_value = value_at (val_type, next_address); | |
525 | print_formatted (last_examine_value, format, size); | |
526 | } | |
527 | printf_filtered ("\n"); | |
528 | fflush (stdout); | |
529 | } | |
530 | } | |
531 | \f | |
532 | static void | |
533 | validate_format (fmt, cmdname) | |
534 | struct format_data fmt; | |
535 | char *cmdname; | |
536 | { | |
537 | if (fmt.size != 0) | |
538 | error ("Size letters are meaningless in \"%s\" command.", cmdname); | |
539 | if (fmt.count != 1) | |
540 | error ("Item count other than 1 is meaningless in \"%s\" command.", | |
541 | cmdname); | |
542 | if (fmt.format == 'i' || fmt.format == 's') | |
543 | error ("Format letter \"%c\" is meaningless in \"%s\" command.", | |
544 | fmt.format, cmdname); | |
545 | } | |
546 | ||
547 | static void | |
548 | print_command_1 (exp, inspect, voidprint) | |
549 | char *exp; | |
550 | int inspect; | |
551 | int voidprint; | |
552 | { | |
553 | struct expression *expr; | |
554 | register struct cleanup *old_chain = 0; | |
555 | register char format = 0; | |
556 | register value val; | |
557 | struct format_data fmt; | |
558 | int cleanup = 0; | |
559 | ||
560 | /* Pass inspect flag to the rest of the print routines in a global (sigh). */ | |
561 | inspect_it = inspect; | |
562 | ||
563 | if (exp && *exp == '/') | |
564 | { | |
565 | exp++; | |
566 | fmt = decode_format (&exp, last_format, 0); | |
567 | validate_format (fmt, "print"); | |
568 | last_format = format = fmt.format; | |
569 | } | |
570 | else | |
571 | { | |
572 | fmt.count = 1; | |
573 | fmt.format = 0; | |
574 | fmt.size = 0; | |
575 | } | |
576 | ||
577 | if (exp && *exp) | |
578 | { | |
579 | expr = parse_c_expression (exp); | |
580 | old_chain = make_cleanup (free_current_contents, &expr); | |
581 | cleanup = 1; | |
582 | val = evaluate_expression (expr); | |
583 | } | |
584 | else | |
585 | val = access_value_history (0); | |
586 | ||
587 | if (voidprint || (val && VALUE_TYPE (val) && | |
588 | TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_VOID)) | |
589 | { | |
590 | int histindex = record_latest_value (val); | |
591 | ||
592 | if (inspect) | |
593 | printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex); | |
594 | else | |
595 | if (histindex >= 0) printf_filtered ("$%d = ", histindex); | |
596 | ||
597 | print_formatted (val, format, fmt.size); | |
598 | printf_filtered ("\n"); | |
599 | if (inspect) | |
600 | printf("\") )\030"); | |
601 | } | |
602 | ||
603 | if (cleanup) | |
604 | do_cleanups (old_chain); | |
605 | inspect_it = 0; /* Reset print routines to normal */ | |
606 | } | |
607 | ||
608 | static void | |
609 | print_command (exp, from_tty) | |
610 | char *exp; | |
611 | int from_tty; | |
612 | { | |
613 | print_command_1 (exp, 0, 1); | |
614 | } | |
615 | ||
616 | /* Same as print, except in epoch, it gets its own window */ | |
617 | static void | |
618 | inspect_command (exp, from_tty) | |
619 | char *exp; | |
620 | int from_tty; | |
621 | { | |
622 | extern int epoch_interface; | |
623 | ||
624 | print_command_1 (exp, epoch_interface, 1); | |
625 | } | |
626 | ||
627 | /* Same as print, except it doesn't print void results. */ | |
628 | static void | |
629 | call_command (exp, from_tty) | |
630 | char *exp; | |
631 | int from_tty; | |
632 | { | |
633 | print_command_1 (exp, 0, 0); | |
634 | } | |
635 | ||
636 | static void | |
637 | output_command (exp, from_tty) | |
638 | char *exp; | |
639 | int from_tty; | |
640 | { | |
641 | struct expression *expr; | |
642 | register struct cleanup *old_chain; | |
643 | register char format = 0; | |
644 | register value val; | |
645 | struct format_data fmt; | |
646 | ||
647 | if (exp && *exp == '/') | |
648 | { | |
649 | exp++; | |
650 | fmt = decode_format (&exp, 0, 0); | |
651 | validate_format (fmt, "print"); | |
652 | format = fmt.format; | |
653 | } | |
654 | ||
655 | expr = parse_c_expression (exp); | |
656 | old_chain = make_cleanup (free_current_contents, &expr); | |
657 | ||
658 | val = evaluate_expression (expr); | |
659 | ||
660 | print_formatted (val, format, fmt.size); | |
661 | ||
662 | do_cleanups (old_chain); | |
663 | } | |
664 | ||
665 | static void | |
666 | set_command (exp, from_tty) | |
667 | char *exp; | |
668 | int from_tty; | |
669 | { | |
670 | struct expression *expr = parse_c_expression (exp); | |
671 | register struct cleanup *old_chain | |
672 | = make_cleanup (free_current_contents, &expr); | |
673 | evaluate_expression (expr); | |
674 | do_cleanups (old_chain); | |
675 | } | |
676 | ||
677 | static void | |
678 | address_info (exp, from_tty) | |
679 | char *exp; | |
680 | int from_tty; | |
681 | { | |
682 | register struct symbol *sym; | |
683 | register CORE_ADDR val; | |
684 | int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero | |
685 | if exp is a field of `this'. */ | |
686 | ||
687 | if (exp == 0) | |
688 | error ("Argument required."); | |
689 | ||
690 | sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE, | |
691 | &is_a_field_of_this, (struct symtab **)NULL); | |
692 | if (sym == 0) | |
693 | { | |
694 | register int i; | |
695 | ||
696 | if (is_a_field_of_this) | |
697 | { | |
698 | printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); | |
699 | return; | |
700 | } | |
701 | ||
702 | for (i = 0; i < misc_function_count; i++) | |
703 | if (!strcmp (misc_function_vector[i].name, exp)) | |
704 | break; | |
705 | ||
706 | if (i < misc_function_count) | |
707 | printf ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n", | |
708 | exp, misc_function_vector[i].address); | |
709 | else | |
710 | error ("No symbol \"%s\" in current context.", exp); | |
711 | return; | |
712 | } | |
713 | ||
714 | printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym)); | |
715 | val = SYMBOL_VALUE (sym); | |
716 | ||
717 | switch (SYMBOL_CLASS (sym)) | |
718 | { | |
719 | case LOC_CONST: | |
720 | case LOC_CONST_BYTES: | |
721 | printf ("constant"); | |
722 | break; | |
723 | ||
724 | case LOC_LABEL: | |
725 | printf ("a label at address 0x%x", SYMBOL_VALUE_ADDRESS (sym)); | |
726 | break; | |
727 | ||
728 | case LOC_REGISTER: | |
729 | printf ("a variable in register %s", reg_names[val]); | |
730 | break; | |
731 | ||
732 | case LOC_STATIC: | |
733 | printf ("static at address 0x%x", SYMBOL_VALUE_ADDRESS (sym)); | |
734 | break; | |
735 | ||
736 | case LOC_REGPARM: | |
737 | printf ("an argument in register %s", reg_names[val]); | |
738 | break; | |
739 | ||
740 | case LOC_ARG: | |
741 | printf ("an argument at offset %d", (int)val); | |
742 | break; | |
743 | ||
744 | case LOC_LOCAL_ARG: | |
745 | printf ("an argument at frame offset %d", (int)val); | |
746 | break; | |
747 | ||
748 | case LOC_LOCAL: | |
749 | printf ("a local variable at frame offset %d", (int)val); | |
750 | break; | |
751 | ||
752 | case LOC_REF_ARG: | |
753 | printf ("a reference argument at offset %d", (int)val); | |
754 | break; | |
755 | ||
756 | case LOC_TYPEDEF: | |
757 | printf ("a typedef"); | |
758 | break; | |
759 | ||
760 | case LOC_BLOCK: | |
761 | printf ("a function at address 0x%x", | |
762 | BLOCK_START (SYMBOL_BLOCK_VALUE (sym))); | |
763 | break; | |
764 | ||
765 | case LOC_EXTERNAL: | |
766 | printf ("an external symbol at address 0x%x", | |
767 | SYMBOL_VALUE_ADDRESS (sym)); | |
768 | break; | |
769 | ||
770 | default: | |
771 | printf ("of unknown (botched) type"); | |
772 | break; | |
773 | } | |
774 | printf (".\n"); | |
775 | } | |
776 | \f | |
777 | static void | |
778 | x_command (exp, from_tty) | |
779 | char *exp; | |
780 | int from_tty; | |
781 | { | |
782 | struct expression *expr; | |
783 | struct format_data fmt; | |
784 | struct cleanup *old_chain; | |
785 | struct value *val; | |
786 | ||
787 | fmt.format = last_format; | |
788 | fmt.size = last_size; | |
789 | fmt.count = 1; | |
790 | ||
791 | if (exp && *exp == '/') | |
792 | { | |
793 | exp++; | |
794 | fmt = decode_format (&exp, last_format, last_size); | |
795 | last_size = fmt.size; | |
796 | last_format = fmt.format; | |
797 | } | |
798 | ||
799 | /* If we have an expression, evaluate it and use it as the address. */ | |
800 | ||
801 | if (exp != 0 && *exp != 0) | |
802 | { | |
803 | expr = parse_c_expression (exp); | |
804 | /* Cause expression not to be there any more | |
805 | if this command is repeated with Newline. | |
806 | But don't clobber a user-defined command's definition. */ | |
807 | if (from_tty) | |
808 | *exp = 0; | |
809 | old_chain = make_cleanup (free_current_contents, &expr); | |
810 | val = evaluate_expression (expr); | |
811 | /* In rvalue contexts, such as this, functions are coerced into | |
812 | pointers to functions. This makes "x/i main" work. */ | |
813 | if (/* last_format == 'i' | |
814 | && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC | |
815 | && VALUE_LVAL (val) == lval_memory) | |
816 | next_address = VALUE_ADDRESS (val); | |
817 | else | |
818 | next_address = (CORE_ADDR) value_as_long (val); | |
819 | do_cleanups (old_chain); | |
820 | } | |
821 | ||
822 | do_examine (fmt, next_address); | |
823 | ||
824 | /* Set a couple of internal variables if appropriate. */ | |
825 | if (last_examine_value) | |
826 | { | |
827 | /* Make last address examined available to the user as $_. */ | |
828 | set_internalvar (lookup_internalvar ("_"), | |
829 | value_from_long (builtin_type_int, | |
830 | (LONGEST) last_examine_address)); | |
831 | ||
832 | /* Make contents of last address examined available to the user as $__.*/ | |
833 | set_internalvar (lookup_internalvar ("__"), last_examine_value); | |
834 | } | |
835 | } | |
836 | \f | |
837 | /* Commands for printing types of things. */ | |
838 | ||
839 | /* Print type of EXP, or last thing in value history if EXP == NULL. | |
840 | show is passed to type_print. */ | |
841 | static void | |
842 | whatis_exp (exp, show) | |
843 | char *exp; | |
844 | int show; | |
845 | { | |
846 | struct expression *expr; | |
847 | register value val; | |
848 | register struct cleanup *old_chain; | |
849 | ||
850 | if (exp) | |
851 | { | |
852 | expr = parse_c_expression (exp); | |
853 | old_chain = make_cleanup (free_current_contents, &expr); | |
854 | val = evaluate_type (expr); | |
855 | } | |
856 | else | |
857 | val = access_value_history (0); | |
858 | ||
859 | printf_filtered ("type = "); | |
860 | type_print (VALUE_TYPE (val), "", stdout, show); | |
861 | printf_filtered ("\n"); | |
862 | ||
863 | if (exp) | |
864 | do_cleanups (old_chain); | |
865 | } | |
866 | ||
867 | static void | |
868 | whatis_command (exp, from_tty) | |
869 | char *exp; | |
870 | int from_tty; | |
871 | { | |
872 | /* Most of the time users do not want to see all the fields | |
873 | in a structure. If they do they can use the "ptype" command. | |
874 | Hence the "-1" below. */ | |
875 | whatis_exp (exp, -1); | |
876 | } | |
877 | ||
878 | /* TYPENAME is either the name of a type, or an expression. */ | |
879 | static void | |
880 | ptype_command (typename, from_tty) | |
881 | char *typename; | |
882 | int from_tty; | |
883 | { | |
884 | register char *p = typename; | |
885 | register int len; | |
886 | register struct block *b | |
887 | = target_has_stack ? get_current_block () : 0; | |
888 | register struct type *type; | |
889 | ||
890 | if (typename == 0) | |
891 | { | |
892 | whatis_exp (typename, 1); | |
893 | return; | |
894 | } | |
895 | ||
896 | while (*p && *p != ' ' && *p != '\t') p++; | |
897 | len = p - typename; | |
898 | while (*p == ' ' || *p == '\t') p++; | |
899 | ||
900 | if (len == 6 && !strncmp (typename, "struct", 6)) | |
901 | type = lookup_struct (p, b); | |
902 | else if (len == 5 && !strncmp (typename, "union", 5)) | |
903 | type = lookup_union (p, b); | |
904 | else if (len == 4 && !strncmp (typename, "enum", 4)) | |
905 | type = lookup_enum (p, b); | |
906 | else | |
907 | { | |
908 | type = lookup_typename (typename, b, 1); | |
909 | if (type == 0) | |
910 | { | |
911 | register struct symbol *sym | |
912 | = lookup_symbol (typename, b, STRUCT_NAMESPACE, 0, | |
913 | (struct symtab **)NULL); | |
914 | if (sym == 0) | |
915 | { | |
916 | whatis_exp (typename, 1 /* FIXME: right? */); | |
917 | return; | |
918 | } | |
919 | printf_filtered ("No type named %s, but there is a ", | |
920 | typename); | |
921 | switch (TYPE_CODE (SYMBOL_TYPE (sym))) | |
922 | { | |
923 | case TYPE_CODE_STRUCT: | |
924 | printf_filtered ("struct"); | |
925 | break; | |
926 | ||
927 | case TYPE_CODE_UNION: | |
928 | printf_filtered ("union"); | |
929 | break; | |
930 | ||
931 | case TYPE_CODE_ENUM: | |
932 | printf_filtered ("enum"); | |
933 | break; | |
934 | ||
935 | default: | |
936 | printf_filtered ("(Internal error in gdb)"); | |
937 | break; | |
938 | } | |
939 | printf_filtered (" %s. Type \"help ptype\".\n", typename); | |
940 | type = SYMBOL_TYPE (sym); | |
941 | } | |
942 | } | |
943 | ||
944 | type_print (type, "", stdout, 1); | |
945 | printf_filtered ("\n"); | |
946 | } | |
947 | \f | |
948 | #if 0 | |
949 | /* This is not necessary. Instead, decode_line_1 takes any variable, | |
950 | so "info line foo" is a close equivalent to "whereis foo". */ | |
951 | static void | |
952 | whereis_command (var, from_tty) | |
953 | char *var; | |
954 | int from_tty; | |
955 | { | |
956 | struct symtab *s; | |
957 | struct symbol *sym; | |
958 | ||
959 | if (var == NULL) | |
960 | error_no_arg ("Variable name."); | |
961 | ||
962 | sym = lookup_symbol (var, get_selected_block (), VAR_NAMESPACE, | |
963 | NULL, &s); | |
964 | ||
965 | if (sym != NULL && s != NULL) | |
966 | printf_filtered ("Symbol \"%s\" is at line %d of file %s\n", | |
967 | var, sym->line, s->filename); | |
968 | else | |
969 | { | |
970 | if (lookup_misc_func (var) >= 0) | |
971 | printf_filtered ("Symbol \"%s\" is in a file compiled without -g.", | |
972 | var); | |
973 | else | |
974 | error ("No symbol \"%s\" in current context.", var); | |
975 | } | |
976 | } | |
977 | #endif /* 0 */ | |
978 | \f | |
979 | enum display_status {disabled, enabled}; | |
980 | ||
981 | struct display | |
982 | { | |
983 | /* Chain link to next auto-display item. */ | |
984 | struct display *next; | |
985 | /* Expression to be evaluated and displayed. */ | |
986 | struct expression *exp; | |
987 | /* Item number of this auto-display item. */ | |
988 | int number; | |
989 | /* Display format specified. */ | |
990 | struct format_data format; | |
991 | /* Innermost block required by this expression when evaluated */ | |
992 | struct block *block; | |
993 | /* Status of this display (enabled or disabled) */ | |
994 | enum display_status status; | |
995 | }; | |
996 | ||
997 | /* Chain of expressions whose values should be displayed | |
998 | automatically each time the program stops. */ | |
999 | ||
1000 | static struct display *display_chain; | |
1001 | ||
1002 | static int display_number; | |
1003 | ||
1004 | /* Add an expression to the auto-display chain. | |
1005 | Specify the expression. */ | |
1006 | ||
1007 | static void | |
1008 | display_command (exp, from_tty) | |
1009 | char *exp; | |
1010 | int from_tty; | |
1011 | { | |
1012 | struct format_data fmt; | |
1013 | register struct expression *expr; | |
1014 | register struct display *new; | |
1015 | ||
1016 | if (exp == 0) | |
1017 | { | |
1018 | do_displays (); | |
1019 | return; | |
1020 | } | |
1021 | ||
1022 | if (*exp == '/') | |
1023 | { | |
1024 | exp++; | |
1025 | fmt = decode_format (&exp, 0, 0); | |
1026 | if (fmt.size && fmt.format == 0) | |
1027 | fmt.format = 'x'; | |
1028 | if (fmt.format == 'i' || fmt.format == 's') | |
1029 | fmt.size = 'b'; | |
1030 | } | |
1031 | else | |
1032 | { | |
1033 | fmt.format = 0; | |
1034 | fmt.size = 0; | |
1035 | fmt.count = 0; | |
1036 | } | |
1037 | ||
1038 | innermost_block = 0; | |
1039 | expr = parse_c_expression (exp); | |
1040 | ||
1041 | new = (struct display *) xmalloc (sizeof (struct display)); | |
1042 | ||
1043 | new->exp = expr; | |
1044 | new->block = innermost_block; | |
1045 | new->next = display_chain; | |
1046 | new->number = ++display_number; | |
1047 | new->format = fmt; | |
1048 | new->status = enabled; | |
1049 | display_chain = new; | |
1050 | ||
1051 | if (from_tty && target_has_execution) | |
1052 | do_one_display (new); | |
1053 | ||
1054 | dont_repeat (); | |
1055 | } | |
1056 | ||
1057 | static void | |
1058 | free_display (d) | |
1059 | struct display *d; | |
1060 | { | |
1061 | free (d->exp); | |
1062 | free (d); | |
1063 | } | |
1064 | ||
1065 | /* Clear out the display_chain. | |
1066 | Done when new symtabs are loaded, since this invalidates | |
1067 | the types stored in many expressions. */ | |
1068 | ||
1069 | void | |
1070 | clear_displays () | |
1071 | { | |
1072 | register struct display *d; | |
1073 | ||
1074 | while (d = display_chain) | |
1075 | { | |
1076 | free (d->exp); | |
1077 | display_chain = d->next; | |
1078 | free (d); | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | /* Delete the auto-display number NUM. */ | |
1083 | ||
1084 | void | |
1085 | delete_display (num) | |
1086 | int num; | |
1087 | { | |
1088 | register struct display *d1, *d; | |
1089 | ||
1090 | if (!display_chain) | |
1091 | error ("No display number %d.", num); | |
1092 | ||
1093 | if (display_chain->number == num) | |
1094 | { | |
1095 | d1 = display_chain; | |
1096 | display_chain = d1->next; | |
1097 | free_display (d1); | |
1098 | } | |
1099 | else | |
1100 | for (d = display_chain; ; d = d->next) | |
1101 | { | |
1102 | if (d->next == 0) | |
1103 | error ("No display number %d.", num); | |
1104 | if (d->next->number == num) | |
1105 | { | |
1106 | d1 = d->next; | |
1107 | d->next = d1->next; | |
1108 | free_display (d1); | |
1109 | break; | |
1110 | } | |
1111 | } | |
1112 | } | |
1113 | ||
1114 | /* Delete some values from the auto-display chain. | |
1115 | Specify the element numbers. */ | |
1116 | ||
1117 | static void | |
1118 | undisplay_command (args) | |
1119 | char *args; | |
1120 | { | |
1121 | register char *p = args; | |
1122 | register char *p1; | |
1123 | register int num; | |
1124 | ||
1125 | if (args == 0) | |
1126 | { | |
1127 | if (query ("Delete all auto-display expressions? ")) | |
1128 | clear_displays (); | |
1129 | dont_repeat (); | |
1130 | return; | |
1131 | } | |
1132 | ||
1133 | while (*p) | |
1134 | { | |
1135 | p1 = p; | |
1136 | while (*p1 >= '0' && *p1 <= '9') p1++; | |
1137 | if (*p1 && *p1 != ' ' && *p1 != '\t') | |
1138 | error ("Arguments must be display numbers."); | |
1139 | ||
1140 | num = atoi (p); | |
1141 | ||
1142 | delete_display (num); | |
1143 | ||
1144 | p = p1; | |
1145 | while (*p == ' ' || *p == '\t') p++; | |
1146 | } | |
1147 | dont_repeat (); | |
1148 | } | |
1149 | ||
1150 | /* Display a single auto-display. | |
1151 | Do nothing if the display cannot be printed in the current context, | |
1152 | or if the display is disabled. */ | |
1153 | ||
1154 | static void | |
1155 | do_one_display (d) | |
1156 | struct display *d; | |
1157 | { | |
1158 | int within_current_scope; | |
1159 | ||
1160 | if (d->status == disabled) | |
1161 | return; | |
1162 | ||
1163 | if (d->block) | |
1164 | within_current_scope = contained_in (get_selected_block (), d->block); | |
1165 | else | |
1166 | within_current_scope = 1; | |
1167 | if (!within_current_scope) | |
1168 | return; | |
1169 | ||
1170 | current_display_number = d->number; | |
1171 | ||
1172 | printf_filtered ("%d: ", d->number); | |
1173 | if (d->format.size) | |
1174 | { | |
1175 | CORE_ADDR addr; | |
1176 | ||
1177 | printf_filtered ("x/"); | |
1178 | if (d->format.count != 1) | |
1179 | printf_filtered ("%d", d->format.count); | |
1180 | printf_filtered ("%c", d->format.format); | |
1181 | if (d->format.format != 'i' && d->format.format != 's') | |
1182 | printf_filtered ("%c", d->format.size); | |
1183 | printf_filtered (" "); | |
1184 | print_expression (d->exp, stdout); | |
1185 | if (d->format.count != 1) | |
1186 | printf_filtered ("\n"); | |
1187 | else | |
1188 | printf_filtered (" "); | |
1189 | ||
1190 | addr = (CORE_ADDR) value_as_long (evaluate_expression (d->exp)); | |
1191 | if (d->format.format == 'i') | |
1192 | addr = ADDR_BITS_REMOVE (addr); | |
1193 | ||
1194 | do_examine (d->format, addr); | |
1195 | } | |
1196 | else | |
1197 | { | |
1198 | if (d->format.format) | |
1199 | printf_filtered ("/%c ", d->format.format); | |
1200 | print_expression (d->exp, stdout); | |
1201 | printf_filtered (" = "); | |
1202 | print_formatted (evaluate_expression (d->exp), | |
1203 | d->format.format, d->format.size); | |
1204 | printf_filtered ("\n"); | |
1205 | } | |
1206 | ||
1207 | fflush (stdout); | |
1208 | current_display_number = -1; | |
1209 | } | |
1210 | ||
1211 | /* Display all of the values on the auto-display chain which can be | |
1212 | evaluated in the current scope. */ | |
1213 | ||
1214 | void | |
1215 | do_displays () | |
1216 | { | |
1217 | register struct display *d; | |
1218 | ||
1219 | for (d = display_chain; d; d = d->next) | |
1220 | do_one_display (d); | |
1221 | } | |
1222 | ||
1223 | /* Delete the auto-display which we were in the process of displaying. | |
1224 | This is done when there is an error or a signal. */ | |
1225 | ||
1226 | void | |
1227 | disable_display (num) | |
1228 | int num; | |
1229 | { | |
1230 | register struct display *d; | |
1231 | ||
1232 | for (d = display_chain; d; d = d->next) | |
1233 | if (d->number == num) | |
1234 | { | |
1235 | d->status = disabled; | |
1236 | return; | |
1237 | } | |
1238 | printf ("No display number %d.\n", num); | |
1239 | } | |
1240 | ||
1241 | void | |
1242 | disable_current_display () | |
1243 | { | |
1244 | if (current_display_number >= 0) | |
1245 | { | |
1246 | disable_display (current_display_number); | |
1247 | fprintf (stderr, "Disabling display %d to avoid infinite recursion.\n", | |
1248 | current_display_number); | |
1249 | } | |
1250 | current_display_number = -1; | |
1251 | } | |
1252 | ||
1253 | static void | |
1254 | display_info () | |
1255 | { | |
1256 | register struct display *d; | |
1257 | ||
1258 | if (!display_chain) | |
1259 | printf ("There are no auto-display expressions now.\n"); | |
1260 | else | |
1261 | printf_filtered ("Auto-display expressions now in effect:\n\ | |
1262 | Num Enb Expression\n"); | |
1263 | ||
1264 | for (d = display_chain; d; d = d->next) | |
1265 | { | |
1266 | printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]); | |
1267 | if (d->format.size) | |
1268 | printf_filtered ("/%d%c%c ", d->format.count, d->format.size, | |
1269 | d->format.format); | |
1270 | else if (d->format.format) | |
1271 | printf_filtered ("/%c ", d->format.format); | |
1272 | print_expression (d->exp, stdout); | |
1273 | if (d->block && !contained_in (get_selected_block (), d->block)) | |
1274 | printf_filtered (" (cannot be evaluated in the current context)"); | |
1275 | printf_filtered ("\n"); | |
1276 | fflush (stdout); | |
1277 | } | |
1278 | } | |
1279 | ||
1280 | void | |
1281 | enable_display (args) | |
1282 | char *args; | |
1283 | { | |
1284 | register char *p = args; | |
1285 | register char *p1; | |
1286 | register int num; | |
1287 | register struct display *d; | |
1288 | ||
1289 | if (p == 0) | |
1290 | { | |
1291 | for (d = display_chain; d; d = d->next) | |
1292 | d->status = enabled; | |
1293 | } | |
1294 | else | |
1295 | while (*p) | |
1296 | { | |
1297 | p1 = p; | |
1298 | while (*p1 >= '0' && *p1 <= '9') | |
1299 | p1++; | |
1300 | if (*p1 && *p1 != ' ' && *p1 != '\t') | |
1301 | error ("Arguments must be display numbers."); | |
1302 | ||
1303 | num = atoi (p); | |
1304 | ||
1305 | for (d = display_chain; d; d = d->next) | |
1306 | if (d->number == num) | |
1307 | { | |
1308 | d->status = enabled; | |
1309 | goto win; | |
1310 | } | |
1311 | printf ("No display number %d.\n", num); | |
1312 | win: | |
1313 | p = p1; | |
1314 | while (*p == ' ' || *p == '\t') | |
1315 | p++; | |
1316 | } | |
1317 | } | |
1318 | ||
1319 | void | |
1320 | disable_display_command (args, from_tty) | |
1321 | char *args; | |
1322 | int from_tty; | |
1323 | { | |
1324 | register char *p = args; | |
1325 | register char *p1; | |
1326 | register struct display *d; | |
1327 | ||
1328 | if (p == 0) | |
1329 | { | |
1330 | for (d = display_chain; d; d = d->next) | |
1331 | d->status = disabled; | |
1332 | } | |
1333 | else | |
1334 | while (*p) | |
1335 | { | |
1336 | p1 = p; | |
1337 | while (*p1 >= '0' && *p1 <= '9') | |
1338 | p1++; | |
1339 | if (*p1 && *p1 != ' ' && *p1 != '\t') | |
1340 | error ("Arguments must be display numbers."); | |
1341 | ||
1342 | disable_display (atoi (p)); | |
1343 | ||
1344 | p = p1; | |
1345 | while (*p == ' ' || *p == '\t') | |
1346 | p++; | |
1347 | } | |
1348 | } | |
1349 | ||
1350 | \f | |
1351 | /* Print the value in stack frame FRAME of a variable | |
1352 | specified by a struct symbol. */ | |
1353 | ||
1354 | void | |
1355 | print_variable_value (var, frame, stream) | |
1356 | struct symbol *var; | |
1357 | FRAME frame; | |
1358 | FILE *stream; | |
1359 | { | |
1360 | value val = read_var_value (var, frame); | |
1361 | value_print (val, stream, 0, Val_pretty_default); | |
1362 | } | |
1363 | ||
1364 | /* Print the arguments of a stack frame, given the function FUNC | |
1365 | running in that frame (as a symbol), the info on the frame, | |
1366 | and the number of args according to the stack frame (or -1 if unknown). */ | |
1367 | ||
1368 | /* References here and elsewhere to "number of args according to the | |
1369 | stack frame" appear in all cases to refer to "number of ints of args | |
1370 | according to the stack frame". At least for VAX, i386, isi. */ | |
1371 | ||
1372 | void | |
1373 | print_frame_args (func, fi, num, stream) | |
1374 | struct symbol *func; | |
1375 | struct frame_info *fi; | |
1376 | int num; | |
1377 | FILE *stream; | |
1378 | { | |
1379 | struct block *b; | |
1380 | int nsyms = 0; | |
1381 | int first = 1; | |
1382 | register int i; | |
1383 | register struct symbol *sym; | |
1384 | register value val; | |
1385 | /* Offset of next stack argument beyond the one we have seen that is | |
1386 | at the highest offset. | |
1387 | -1 if we haven't come to a stack argument yet. */ | |
1388 | int highest_offset = -1; | |
1389 | int arg_size; | |
1390 | /* Number of ints of arguments that we have printed so far. */ | |
1391 | int args_printed = 0; | |
1392 | ||
1393 | if (func) | |
1394 | { | |
1395 | b = SYMBOL_BLOCK_VALUE (func); | |
1396 | nsyms = BLOCK_NSYMS (b); | |
1397 | } | |
1398 | ||
1399 | for (i = 0; i < nsyms; i++) | |
1400 | { | |
1401 | QUIT; | |
1402 | sym = BLOCK_SYM (b, i); | |
1403 | ||
1404 | if (SYMBOL_CLASS (sym) != LOC_REGPARM | |
1405 | && SYMBOL_CLASS (sym) != LOC_ARG | |
1406 | && SYMBOL_CLASS (sym) != LOC_LOCAL_ARG | |
1407 | && SYMBOL_CLASS (sym) != LOC_REF_ARG) | |
1408 | continue; | |
1409 | ||
1410 | /* We have to re-look-up the symbol because arguments often have | |
1411 | two entries (one a parameter, one a register or local), and the one | |
1412 | we want is the non-parm, which lookup_symbol will find for | |
1413 | us. After this, sym could be any SYMBOL_CLASS... */ | |
1414 | sym = lookup_symbol (SYMBOL_NAME (sym), | |
1415 | b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL); | |
1416 | ||
1417 | switch (SYMBOL_CLASS (sym)) { | |
1418 | ||
1419 | /* Keep track of the highest stack argument offset seen */ | |
1420 | case LOC_ARG: | |
1421 | case LOC_REF_ARG: | |
1422 | { | |
1423 | int current_offset = SYMBOL_VALUE (sym); | |
1424 | ||
1425 | arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); | |
1426 | ||
1427 | /* Compute address of next argument by adding the size of | |
1428 | this argument and rounding to an int boundary. */ | |
1429 | current_offset | |
1430 | = ((current_offset + arg_size + sizeof (int) - 1) | |
1431 | & ~(sizeof (int) - 1)); | |
1432 | ||
1433 | /* If this is the highest offset seen yet, set highest_offset. */ | |
1434 | if (highest_offset == -1 | |
1435 | || (current_offset > highest_offset)) | |
1436 | highest_offset = current_offset; | |
1437 | ||
1438 | /* Add the number of ints we're about to print to args_printed. */ | |
1439 | args_printed += (arg_size + sizeof (int) - 1) / sizeof (int); | |
1440 | } | |
1441 | ||
1442 | /* Other types of symbols don't need to be kept track of. */ | |
1443 | default: | |
1444 | break; | |
1445 | } | |
1446 | ||
1447 | /* Print the current arg. */ | |
1448 | if (! first) | |
1449 | fprintf_filtered (stream, ", "); | |
1450 | wrap_here (" "); | |
1451 | fprint_symbol (stream, SYMBOL_NAME (sym)); | |
1452 | fputs_filtered ("=", stream); | |
1453 | ||
1454 | /* Avoid value_print because it will deref ref parameters. We just | |
1455 | want to print their addresses. Print ??? for args whose address | |
1456 | we do not know. */ | |
1457 | val = read_var_value (sym, FRAME_INFO_ID (fi)); | |
1458 | if (val) | |
1459 | val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val), | |
1460 | stream, 0, 0, 0, Val_no_prettyprint); | |
1461 | else | |
1462 | fputs_filtered ("???", stream); | |
1463 | first = 0; | |
1464 | } | |
1465 | ||
1466 | /* Don't print nameless args in situations where we don't know | |
1467 | enough about the stack to find them. */ | |
1468 | if (num != -1) | |
1469 | { | |
1470 | int start; | |
1471 | CORE_ADDR addr; | |
1472 | ||
1473 | if (highest_offset == -1) | |
1474 | start = FRAME_ARGS_SKIP; | |
1475 | else | |
1476 | start = highest_offset; | |
1477 | ||
1478 | addr = FRAME_ARGS_ADDRESS (fi); | |
1479 | if (addr) | |
1480 | print_frame_nameless_args (addr, start, num - args_printed, | |
1481 | first, stream); | |
1482 | } | |
1483 | } | |
1484 | ||
1485 | /* Print nameless args on STREAM. | |
1486 | ARGSADDR is the address of the arglist, START is the offset | |
1487 | of the first nameless arg, and NUM is the number of nameless args to | |
1488 | print. FIRST is nonzero if this is the first argument (not just | |
1489 | the first nameless arg). */ | |
1490 | static void | |
1491 | print_frame_nameless_args (argsaddr, start, num, first, stream) | |
1492 | CORE_ADDR argsaddr; | |
1493 | int start; | |
1494 | int num; | |
1495 | int first; | |
1496 | FILE *stream; | |
1497 | { | |
1498 | int i; | |
1499 | for (i = 0; i < num; i++) | |
1500 | { | |
1501 | QUIT; | |
1502 | if (!first) | |
1503 | fprintf_filtered (stream, ", "); | |
1504 | #ifndef PRINT_TYPELESS_INTEGER | |
1505 | fprintf_filtered (stream, "%d", | |
1506 | read_memory_integer (argsaddr + start, sizeof (int))); | |
1507 | #else | |
1508 | PRINT_TYPELESS_INTEGER (stream, builtin_type_int, | |
1509 | (LONGEST) | |
1510 | read_memory_integer (argsaddr + start, | |
1511 | sizeof (int))); | |
1512 | #endif | |
1513 | first = 0; | |
1514 | start += sizeof (int); | |
1515 | } | |
1516 | } | |
1517 | \f | |
1518 | static void | |
1519 | printf_command (arg, from_tty) | |
1520 | char *arg; | |
1521 | int from_tty; | |
1522 | { | |
1523 | register char *f; | |
1524 | register char *s = arg; | |
1525 | char *string; | |
1526 | value *val_args; | |
1527 | int nargs = 0; | |
1528 | int allocated_args = 20; | |
1529 | char *arg_bytes; | |
1530 | ||
1531 | val_args = (value *) xmalloc (allocated_args * sizeof (value)); | |
1532 | ||
1533 | if (s == 0) | |
1534 | error_no_arg ("format-control string and values to print"); | |
1535 | ||
1536 | /* Skip white space before format string */ | |
1537 | while (*s == ' ' || *s == '\t') s++; | |
1538 | ||
1539 | /* A format string should follow, enveloped in double quotes */ | |
1540 | if (*s++ != '"') | |
1541 | error ("Bad format string, missing '\"'."); | |
1542 | ||
1543 | /* Parse the format-control string and copy it into the string STRING, | |
1544 | processing some kinds of escape sequence. */ | |
1545 | ||
1546 | f = string = (char *) alloca (strlen (s) + 1); | |
1547 | while (*s != '"') | |
1548 | { | |
1549 | int c = *s++; | |
1550 | switch (c) | |
1551 | { | |
1552 | case '\0': | |
1553 | error ("Bad format string, non-terminated '\"'."); | |
1554 | /* doesn't return */ | |
1555 | ||
1556 | case '\\': | |
1557 | switch (c = *s++) | |
1558 | { | |
1559 | case '\\': | |
1560 | *f++ = '\\'; | |
1561 | break; | |
1562 | case 'n': | |
1563 | *f++ = '\n'; | |
1564 | break; | |
1565 | case 't': | |
1566 | *f++ = '\t'; | |
1567 | break; | |
1568 | case 'r': | |
1569 | *f++ = '\r'; | |
1570 | break; | |
1571 | case '"': | |
1572 | *f++ = '"'; | |
1573 | break; | |
1574 | default: | |
1575 | /* ??? TODO: handle other escape sequences */ | |
1576 | error ("Unrecognized \\ escape character in format string."); | |
1577 | } | |
1578 | break; | |
1579 | ||
1580 | default: | |
1581 | *f++ = c; | |
1582 | } | |
1583 | } | |
1584 | ||
1585 | /* Skip over " and following space and comma. */ | |
1586 | s++; | |
1587 | *f++ = '\0'; | |
1588 | while (*s == ' ' || *s == '\t') s++; | |
1589 | ||
1590 | if (*s != ',' && *s != 0) | |
1591 | error ("Invalid argument syntax"); | |
1592 | ||
1593 | if (*s == ',') s++; | |
1594 | while (*s == ' ' || *s == '\t') s++; | |
1595 | ||
1596 | { | |
1597 | /* Now scan the string for %-specs and see what kinds of args they want. | |
1598 | argclass[I] classifies the %-specs so we can give vprintf something | |
1599 | of the right size. */ | |
1600 | ||
1601 | enum argclass {int_arg, string_arg, double_arg, long_long_arg}; | |
1602 | enum argclass *argclass; | |
1603 | int nargs_wanted; | |
1604 | int argindex; | |
1605 | int lcount; | |
1606 | int i; | |
1607 | ||
1608 | argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass); | |
1609 | nargs_wanted = 0; | |
1610 | f = string; | |
1611 | while (*f) | |
1612 | if (*f++ == '%') | |
1613 | { | |
1614 | lcount = 0; | |
1615 | while (strchr ("0123456789.hlL-+ #", *f)) | |
1616 | { | |
1617 | if (*f == 'l' || *f == 'L') | |
1618 | lcount++; | |
1619 | f++; | |
1620 | } | |
1621 | if (*f == 's') | |
1622 | argclass[nargs_wanted++] = string_arg; | |
1623 | else if (*f == 'e' || *f == 'f' || *f == 'g') | |
1624 | argclass[nargs_wanted++] = double_arg; | |
1625 | else if (lcount > 1) | |
1626 | argclass[nargs_wanted++] = long_long_arg; | |
1627 | else if (*f != '%') | |
1628 | argclass[nargs_wanted++] = int_arg; | |
1629 | f++; | |
1630 | } | |
1631 | ||
1632 | /* Now, parse all arguments and evaluate them. | |
1633 | Store the VALUEs in VAL_ARGS. */ | |
1634 | ||
1635 | while (*s != '\0') | |
1636 | { | |
1637 | char *s1; | |
1638 | if (nargs == allocated_args) | |
1639 | val_args = (value *) xrealloc (val_args, | |
1640 | (allocated_args *= 2) | |
1641 | * sizeof (value)); | |
1642 | s1 = s; | |
1643 | val_args[nargs] = parse_to_comma_and_eval (&s1); | |
1644 | ||
1645 | /* If format string wants a float, unchecked-convert the value to | |
1646 | floating point of the same size */ | |
1647 | ||
1648 | if (argclass[nargs] == double_arg) | |
1649 | { | |
1650 | if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float)) | |
1651 | VALUE_TYPE (val_args[nargs]) = builtin_type_float; | |
1652 | if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double)) | |
1653 | VALUE_TYPE (val_args[nargs]) = builtin_type_double; | |
1654 | } | |
1655 | nargs++; | |
1656 | s = s1; | |
1657 | if (*s == ',') | |
1658 | s++; | |
1659 | } | |
1660 | ||
1661 | if (nargs != nargs_wanted) | |
1662 | error ("Wrong number of arguments for specified format-string"); | |
1663 | ||
1664 | /* Now lay out an argument-list containing the arguments | |
1665 | as doubles, integers and C pointers. */ | |
1666 | ||
1667 | arg_bytes = (char *) alloca (sizeof (double) * nargs); | |
1668 | argindex = 0; | |
1669 | for (i = 0; i < nargs; i++) | |
1670 | { | |
1671 | if (argclass[i] == string_arg) | |
1672 | { | |
1673 | char *str; | |
1674 | int tem, j; | |
1675 | tem = value_as_long (val_args[i]); | |
1676 | ||
1677 | /* This is a %s argument. Find the length of the string. */ | |
1678 | for (j = 0; ; j++) | |
1679 | { | |
1680 | char c; | |
1681 | QUIT; | |
1682 | read_memory (tem + j, &c, 1); | |
1683 | if (c == 0) | |
1684 | break; | |
1685 | } | |
1686 | ||
1687 | /* Copy the string contents into a string inside GDB. */ | |
1688 | str = (char *) alloca (j + 1); | |
1689 | read_memory (tem, str, j); | |
1690 | str[j] = 0; | |
1691 | ||
1692 | /* Pass address of internal copy as the arg to vprintf. */ | |
1693 | *((int *) &arg_bytes[argindex]) = (int) str; | |
1694 | argindex += sizeof (int); | |
1695 | } | |
1696 | else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT) | |
1697 | { | |
1698 | *((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]); | |
1699 | argindex += sizeof (double); | |
1700 | } | |
1701 | else | |
1702 | #ifdef LONG_LONG | |
1703 | if (argclass[i] == long_long_arg) | |
1704 | { | |
1705 | *(long long *) &arg_bytes[argindex] = value_as_long (val_args[i]); | |
1706 | argindex += sizeof (long long); | |
1707 | } | |
1708 | else | |
1709 | #endif | |
1710 | { | |
1711 | *((int *) &arg_bytes[argindex]) = value_as_long (val_args[i]); | |
1712 | argindex += sizeof (int); | |
1713 | } | |
1714 | } | |
1715 | } | |
1716 | ||
1717 | /* There is not a standard way to make a va_list, so we need | |
1718 | to do various things for different systems. */ | |
1719 | #if defined (__INT_VARARGS_H) | |
1720 | { | |
1721 | va_list list; | |
1722 | ||
1723 | list.__va_arg = 0; | |
1724 | list.__va_stk = (int *) arg_bytes; | |
1725 | list.__va_reg = (int *) arg_bytes; | |
1726 | vprintf (string, list); | |
1727 | } | |
1728 | #else /* No __INT_VARARGS_H. */ | |
1729 | vprintf (string, arg_bytes); | |
1730 | #endif /* No __INT_VARARGS_H. */ | |
1731 | } | |
1732 | \f | |
1733 | /* Helper function for asdump_command. Finds the bounds of a function | |
1734 | for a specified section of text. PC is an address within the | |
1735 | function which you want bounds for; *LOW and *HIGH are set to the | |
1736 | beginning (inclusive) and end (exclusive) of the function. This | |
1737 | function returns 1 on success and 0 on failure. */ | |
1738 | ||
1739 | static int | |
1740 | containing_function_bounds (pc, low, high) | |
1741 | CORE_ADDR pc, *low, *high; | |
1742 | { | |
1743 | int scan; | |
1744 | ||
1745 | if (!find_pc_partial_function (pc, 0, low)) | |
1746 | return 0; | |
1747 | ||
1748 | scan = *low; | |
1749 | do { | |
1750 | scan++; | |
1751 | if (!find_pc_partial_function (scan, 0, high)) | |
1752 | return 0; | |
1753 | } while (*low == *high); | |
1754 | ||
1755 | return 1; | |
1756 | } | |
1757 | ||
1758 | /* Dump a specified section of assembly code. With no command line | |
1759 | arguments, this command will dump the assembly code for the | |
1760 | function surrounding the pc value in the selected frame. With one | |
1761 | argument, it will dump the assembly code surrounding that pc value. | |
1762 | Two arguments are interpeted as bounds within which to dump | |
1763 | assembly. */ | |
1764 | ||
1765 | static void | |
1766 | disassemble_command (arg, from_tty) | |
1767 | char *arg; | |
1768 | int from_tty; | |
1769 | { | |
1770 | CORE_ADDR low, high; | |
1771 | CORE_ADDR pc; | |
1772 | char *space_index; | |
1773 | ||
1774 | if (!arg) | |
1775 | { | |
1776 | if (!selected_frame) | |
1777 | error ("No frame selected.\n"); | |
1778 | ||
1779 | pc = get_frame_pc (selected_frame); | |
1780 | if (!containing_function_bounds (pc, &low, &high)) | |
1781 | error ("No function contains pc specified by selected frame.\n"); | |
1782 | } | |
1783 | else if (!(space_index = (char *) strchr (arg, ' '))) | |
1784 | { | |
1785 | /* One argument. */ | |
1786 | pc = parse_and_eval_address (arg); | |
1787 | if (!containing_function_bounds (pc, &low, &high)) | |
1788 | error ("No function contains specified pc.\n"); | |
1789 | } | |
1790 | else | |
1791 | { | |
1792 | /* Two arguments. */ | |
1793 | *space_index = '\0'; | |
1794 | low = parse_and_eval_address (arg); | |
1795 | high = parse_and_eval_address (space_index + 1); | |
1796 | } | |
1797 | ||
1798 | printf_filtered ("Dump of assembler code "); | |
1799 | if (!space_index) | |
1800 | { | |
1801 | char *name; | |
1802 | find_pc_partial_function (pc, &name, 0); | |
1803 | printf_filtered ("for function %s:\n", name); | |
1804 | } | |
1805 | else | |
1806 | printf_filtered ("from 0x%x to 0x%x:\n", low, high); | |
1807 | ||
1808 | /* Dump the specified range. */ | |
1809 | for (pc = low; pc < high; ) | |
1810 | { | |
1811 | QUIT; | |
1812 | print_address (pc, stdout); | |
1813 | printf_filtered (":\t"); | |
1814 | pc += print_insn (pc, stdout); | |
1815 | printf_filtered ("\n"); | |
1816 | } | |
1817 | printf_filtered ("End of assembler dump.\n"); | |
1818 | fflush (stdout); | |
1819 | } | |
1820 | ||
1821 | \f | |
1822 | void | |
1823 | _initialize_printcmd () | |
1824 | { | |
1825 | current_display_number = -1; | |
1826 | ||
1827 | add_info ("address", address_info, | |
1828 | "Describe where variable VAR is stored."); | |
1829 | ||
1830 | add_com ("x", class_vars, x_command, | |
1831 | "Examine memory: x/FMT ADDRESS.\n\ | |
1832 | ADDRESS is an expression for the memory address to examine.\n\ | |
1833 | FMT is a repeat count followed by a format letter and a size letter.\n\ | |
1834 | Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\ | |
1835 | f(float), a(address), i(instruction), c(char) and s(string).\n\ | |
1836 | Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\ | |
1837 | g is meaningful only with f, for type double.\n\ | |
1838 | The specified number of objects of the specified size are printed\n\ | |
1839 | according to the format.\n\n\ | |
1840 | Defaults for format and size letters are those previously used.\n\ | |
1841 | Default count is 1. Default address is following last thing printed\n\ | |
1842 | with this command or \"print\"."); | |
1843 | ||
1844 | add_com ("disassemble", class_vars, disassemble_command, | |
1845 | "Disassemble a specified section of memory.\n\ | |
1846 | Default is the function surrounding the pc of the selected frame.\n\ | |
1847 | With a single argument, the function surrounding that address is dumped.\n\ | |
1848 | Two arguments are taken as a range of memory to dump."); | |
1849 | ||
1850 | add_com ("ptype", class_vars, ptype_command, | |
1851 | "Print definition of type TYPE.\n\ | |
1852 | Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\ | |
1853 | or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\ | |
1854 | The selected stack frame's lexical context is used to look up the name."); | |
1855 | ||
1856 | add_com ("whatis", class_vars, whatis_command, | |
1857 | "Print data type of expression EXP."); | |
1858 | ||
1859 | #if 0 | |
1860 | add_com ("whereis", class_vars, whereis_command, | |
1861 | "Print line number and file of definition of variable."); | |
1862 | #endif | |
1863 | ||
1864 | add_info ("display", display_info, | |
1865 | "Expressions to display when program stops, with code numbers."); | |
1866 | ||
1867 | add_cmd ("undisplay", class_vars, undisplay_command, | |
1868 | "Cancel some expressions to be displayed when program stops.\n\ | |
1869 | Arguments are the code numbers of the expressions to stop displaying.\n\ | |
1870 | No argument means cancel all automatic-display expressions.\n\ | |
1871 | \"delete display\" has the same effect as this command.\n\ | |
1872 | Do \"info display\" to see current list of code numbers.", | |
1873 | &cmdlist); | |
1874 | ||
1875 | add_com ("display", class_vars, display_command, | |
1876 | "Print value of expression EXP each time the program stops.\n\ | |
1877 | /FMT may be used before EXP as in the \"print\" command.\n\ | |
1878 | /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\ | |
1879 | as in the \"x\" command, and then EXP is used to get the address to examine\n\ | |
1880 | and examining is done as in the \"x\" command.\n\n\ | |
1881 | With no argument, display all currently requested auto-display expressions.\n\ | |
1882 | Use \"undisplay\" to cancel display requests previously made."); | |
1883 | ||
1884 | add_cmd ("display", class_vars, enable_display, | |
1885 | "Enable some expressions to be displayed when program stops.\n\ | |
1886 | Arguments are the code numbers of the expressions to resume displaying.\n\ | |
1887 | No argument means enable all automatic-display expressions.\n\ | |
1888 | Do \"info display\" to see current list of code numbers.", &enablelist); | |
1889 | ||
1890 | add_cmd ("display", class_vars, disable_display_command, | |
1891 | "Disable some expressions to be displayed when program stops.\n\ | |
1892 | Arguments are the code numbers of the expressions to stop displaying.\n\ | |
1893 | No argument means disable all automatic-display expressions.\n\ | |
1894 | Do \"info display\" to see current list of code numbers.", &disablelist); | |
1895 | ||
1896 | add_cmd ("display", class_vars, undisplay_command, | |
1897 | "Cancel some expressions to be displayed when program stops.\n\ | |
1898 | Arguments are the code numbers of the expressions to stop displaying.\n\ | |
1899 | No argument means cancel all automatic-display expressions.\n\ | |
1900 | Do \"info display\" to see current list of code numbers.", &deletelist); | |
1901 | ||
1902 | add_com ("printf", class_vars, printf_command, | |
1903 | "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\ | |
1904 | This is useful for formatted output in user-defined commands."); | |
1905 | add_com ("output", class_vars, output_command, | |
1906 | "Like \"print\" but don't put in value history and don't print newline.\n\ | |
1907 | This is useful in user-defined commands."); | |
1908 | ||
1909 | add_prefix_cmd ("set", class_vars, set_command, | |
1910 | "Perform an assignment VAR = EXP.\n\ | |
1911 | You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ | |
1912 | (names starting with $), a register (a few standard names starting with $),\n\ | |
1913 | or an actual variable in the program being debugged. EXP is any expression.\n\ | |
1914 | Use \"set variable\" for variables with names identical to set subcommands.\n\ | |
1915 | \nWith a subcommand, this command modifies parts of the gdb environment.\n\ | |
1916 | You can see these environment settings with the \"show\" command.", | |
1917 | &setlist, "set ", 1, &cmdlist); | |
1918 | ||
1919 | /* "call" is the same as "set", but handy for dbx users to call fns. */ | |
1920 | add_com ("call", class_vars, call_command, | |
1921 | "Call a function in the inferior process.\n\ | |
1922 | The argument is the function name and arguments, in standard C notation.\n\ | |
1923 | The result is printed and saved in the value history, if it is not void."); | |
1924 | ||
1925 | add_cmd ("variable", class_vars, set_command, | |
1926 | "Perform an assignment VAR = EXP.\n\ | |
1927 | You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ | |
1928 | (names starting with $), a register (a few standard names starting with $),\n\ | |
1929 | or an actual variable in the program being debugged. EXP is any expression.\n\ | |
1930 | This may usually be abbreviated to simply \"set\".", | |
1931 | &setlist); | |
1932 | ||
1933 | add_com ("print", class_vars, print_command, | |
1934 | concat ("Print value of expression EXP.\n\ | |
1935 | Variables accessible are those of the lexical environment of the selected\n\ | |
1936 | stack frame, plus all those whose scope is global or an entire file.\n\ | |
1937 | \n\ | |
1938 | $NUM gets previous value number NUM. $ and $$ are the last two values.\n\ | |
1939 | $$NUM refers to NUM'th value back from the last one.\n\ | |
1940 | Names starting with $ refer to registers (with the values they would have\n\ | |
1941 | if the program were to return to the stack frame now selected, restoring\n\ | |
1942 | all registers saved by frames farther in) or else to debugger\n\ | |
1943 | \"convenience\" variables (any such name not a known register).\n\ | |
1944 | Use assignment expressions to give values to convenience variables.\n", | |
1945 | "\n\ | |
1946 | {TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\ | |
1947 | @ is a binary operator for treating consecutive data objects\n\ | |
1948 | anywhere in memory as an array. FOO@NUM gives an array whose first\n\ | |
1949 | element is FOO, whose second element is stored in the space following\n\ | |
1950 | where FOO is stored, etc. FOO must be an expression whose value\n\ | |
1951 | resides in memory.\n", | |
1952 | "\n\ | |
1953 | EXP may be preceded with /FMT, where FMT is a format letter\n\ | |
1954 | but no count or size letter (see \"x\" command).")); | |
1955 | add_com_alias ("p", "print", class_vars, 1); | |
1956 | ||
1957 | add_com ("inspect", class_vars, inspect_command, | |
1958 | "Same as \"print\" command, except that if you are running in the epoch\n\ | |
1959 | environment, the value is printed in its own window."); | |
1960 | } |