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