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