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