| 1 | /* dwarf.c -- display DWARF contents of a BFD binary file |
| 2 | Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
| 3 | Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GNU Binutils. |
| 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA |
| 20 | 02110-1301, USA. */ |
| 21 | |
| 22 | #include "sysdep.h" |
| 23 | #include "libiberty.h" |
| 24 | #include "bfd.h" |
| 25 | #include "bfd_stdint.h" |
| 26 | #include "bucomm.h" |
| 27 | #include "elfcomm.h" |
| 28 | #include "elf/common.h" |
| 29 | #include "dwarf2.h" |
| 30 | #include "dwarf.h" |
| 31 | |
| 32 | static const char *regname (unsigned int regno, int row); |
| 33 | |
| 34 | static int have_frame_base; |
| 35 | static int need_base_address; |
| 36 | |
| 37 | static unsigned int last_pointer_size = 0; |
| 38 | static int warned_about_missing_comp_units = FALSE; |
| 39 | |
| 40 | static unsigned int num_debug_info_entries = 0; |
| 41 | static debug_info *debug_information = NULL; |
| 42 | /* Special value for num_debug_info_entries to indicate |
| 43 | that the .debug_info section could not be loaded/parsed. */ |
| 44 | #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 |
| 45 | |
| 46 | int eh_addr_size; |
| 47 | |
| 48 | int do_debug_info; |
| 49 | int do_debug_abbrevs; |
| 50 | int do_debug_lines; |
| 51 | int do_debug_pubnames; |
| 52 | int do_debug_pubtypes; |
| 53 | int do_debug_aranges; |
| 54 | int do_debug_ranges; |
| 55 | int do_debug_frames; |
| 56 | int do_debug_frames_interp; |
| 57 | int do_debug_macinfo; |
| 58 | int do_debug_str; |
| 59 | int do_debug_loc; |
| 60 | int do_gdb_index; |
| 61 | int do_trace_info; |
| 62 | int do_trace_abbrevs; |
| 63 | int do_trace_aranges; |
| 64 | int do_wide; |
| 65 | |
| 66 | int dwarf_cutoff_level = -1; |
| 67 | unsigned long dwarf_start_die; |
| 68 | |
| 69 | /* Values for do_debug_lines. */ |
| 70 | #define FLAG_DEBUG_LINES_RAW 1 |
| 71 | #define FLAG_DEBUG_LINES_DECODED 2 |
| 72 | |
| 73 | static int |
| 74 | size_of_encoded_value (int encoding) |
| 75 | { |
| 76 | switch (encoding & 0x7) |
| 77 | { |
| 78 | default: /* ??? */ |
| 79 | case 0: return eh_addr_size; |
| 80 | case 2: return 2; |
| 81 | case 3: return 4; |
| 82 | case 4: return 8; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | static dwarf_vma |
| 87 | get_encoded_value (unsigned char *data, |
| 88 | int encoding, |
| 89 | struct dwarf_section *section) |
| 90 | { |
| 91 | int size = size_of_encoded_value (encoding); |
| 92 | dwarf_vma val; |
| 93 | |
| 94 | if (encoding & DW_EH_PE_signed) |
| 95 | val = byte_get_signed (data, size); |
| 96 | else |
| 97 | val = byte_get (data, size); |
| 98 | |
| 99 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
| 100 | val += section->address + (data - section->start); |
| 101 | return val; |
| 102 | } |
| 103 | |
| 104 | /* Print a dwarf_vma value (typically an address, offset or length) in |
| 105 | hexadecimal format, followed by a space. The length of the value (and |
| 106 | hence the precision displayed) is determined by the byte_size parameter. */ |
| 107 | |
| 108 | static void |
| 109 | print_dwarf_vma (dwarf_vma val, unsigned byte_size) |
| 110 | { |
| 111 | static char buff[18]; |
| 112 | int offset = 0; |
| 113 | |
| 114 | /* Printf does not have a way of specifiying a maximum field width for an |
| 115 | integer value, so we print the full value into a buffer and then select |
| 116 | the precision we need. */ |
| 117 | #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) |
| 118 | #ifndef __MINGW32__ |
| 119 | snprintf (buff, sizeof (buff), "%16.16llx ", val); |
| 120 | #else |
| 121 | snprintf (buff, sizeof (buff), "%016I64x ", val); |
| 122 | #endif |
| 123 | #else |
| 124 | snprintf (buff, sizeof (buff), "%16.16lx ", val); |
| 125 | #endif |
| 126 | |
| 127 | if (byte_size != 0) |
| 128 | { |
| 129 | if (byte_size > 0 && byte_size <= 8) |
| 130 | offset = 16 - 2 * byte_size; |
| 131 | else |
| 132 | error (_("Wrong size in print_dwarf_vma")); |
| 133 | } |
| 134 | |
| 135 | fputs (buff + offset, stdout); |
| 136 | } |
| 137 | |
| 138 | #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) |
| 139 | #ifndef __MINGW32__ |
| 140 | #define DWARF_VMA_FMT "ll" |
| 141 | #else |
| 142 | #define DWARF_VMA_FMT "I64" |
| 143 | #endif |
| 144 | #else |
| 145 | #define DWARF_VMA_FMT "l" |
| 146 | #endif |
| 147 | |
| 148 | static const char * |
| 149 | dwarf_vmatoa (const char *fmtch, dwarf_vma value) |
| 150 | { |
| 151 | /* As dwarf_vmatoa is used more then once in a printf call |
| 152 | for output, we are cycling through an fixed array of pointers |
| 153 | for return address. */ |
| 154 | static int buf_pos = 0; |
| 155 | static struct dwarf_vmatoa_buf |
| 156 | { |
| 157 | char place[64]; |
| 158 | } buf[16]; |
| 159 | char fmt[32]; |
| 160 | char *ret; |
| 161 | |
| 162 | sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); |
| 163 | |
| 164 | ret = buf[buf_pos++].place; |
| 165 | buf_pos %= ARRAY_SIZE (buf); |
| 166 | |
| 167 | snprintf (ret, sizeof (buf[0].place), fmt, value); |
| 168 | |
| 169 | return ret; |
| 170 | } |
| 171 | |
| 172 | dwarf_vma |
| 173 | read_leb128 (unsigned char *data, unsigned int *length_return, int sign) |
| 174 | { |
| 175 | dwarf_vma result = 0; |
| 176 | unsigned int num_read = 0; |
| 177 | unsigned int shift = 0; |
| 178 | unsigned char byte; |
| 179 | |
| 180 | do |
| 181 | { |
| 182 | byte = *data++; |
| 183 | num_read++; |
| 184 | |
| 185 | result |= ((dwarf_vma) (byte & 0x7f)) << shift; |
| 186 | |
| 187 | shift += 7; |
| 188 | |
| 189 | } |
| 190 | while (byte & 0x80); |
| 191 | |
| 192 | if (length_return != NULL) |
| 193 | *length_return = num_read; |
| 194 | |
| 195 | if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) |
| 196 | result |= -1L << shift; |
| 197 | |
| 198 | return result; |
| 199 | } |
| 200 | |
| 201 | /* Create a signed version to avoid painful typecasts. */ |
| 202 | static dwarf_signed_vma |
| 203 | read_sleb128 (unsigned char *data, unsigned int *length_return) |
| 204 | { |
| 205 | return (dwarf_signed_vma) read_leb128 (data, length_return, 1); |
| 206 | } |
| 207 | |
| 208 | typedef struct State_Machine_Registers |
| 209 | { |
| 210 | dwarf_vma address; |
| 211 | unsigned int file; |
| 212 | unsigned int line; |
| 213 | unsigned int column; |
| 214 | int is_stmt; |
| 215 | int basic_block; |
| 216 | unsigned char op_index; |
| 217 | unsigned char end_sequence; |
| 218 | /* This variable hold the number of the last entry seen |
| 219 | in the File Table. */ |
| 220 | unsigned int last_file_entry; |
| 221 | } SMR; |
| 222 | |
| 223 | static SMR state_machine_regs; |
| 224 | |
| 225 | static void |
| 226 | reset_state_machine (int is_stmt) |
| 227 | { |
| 228 | state_machine_regs.address = 0; |
| 229 | state_machine_regs.op_index = 0; |
| 230 | state_machine_regs.file = 1; |
| 231 | state_machine_regs.line = 1; |
| 232 | state_machine_regs.column = 0; |
| 233 | state_machine_regs.is_stmt = is_stmt; |
| 234 | state_machine_regs.basic_block = 0; |
| 235 | state_machine_regs.end_sequence = 0; |
| 236 | state_machine_regs.last_file_entry = 0; |
| 237 | } |
| 238 | |
| 239 | /* Handled an extend line op. |
| 240 | Returns the number of bytes read. */ |
| 241 | |
| 242 | static int |
| 243 | process_extended_line_op (unsigned char *data, int is_stmt) |
| 244 | { |
| 245 | unsigned char op_code; |
| 246 | unsigned int bytes_read; |
| 247 | unsigned int len; |
| 248 | unsigned char *name; |
| 249 | dwarf_vma adr; |
| 250 | |
| 251 | len = read_leb128 (data, & bytes_read, 0); |
| 252 | data += bytes_read; |
| 253 | |
| 254 | if (len == 0) |
| 255 | { |
| 256 | warn (_("badly formed extended line op encountered!\n")); |
| 257 | return bytes_read; |
| 258 | } |
| 259 | |
| 260 | len += bytes_read; |
| 261 | op_code = *data++; |
| 262 | |
| 263 | printf (_(" Extended opcode %d: "), op_code); |
| 264 | |
| 265 | switch (op_code) |
| 266 | { |
| 267 | case DW_LNE_end_sequence: |
| 268 | printf (_("End of Sequence\n\n")); |
| 269 | reset_state_machine (is_stmt); |
| 270 | break; |
| 271 | |
| 272 | case DW_LNE_set_address: |
| 273 | adr = byte_get (data, len - bytes_read - 1); |
| 274 | printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); |
| 275 | state_machine_regs.address = adr; |
| 276 | state_machine_regs.op_index = 0; |
| 277 | break; |
| 278 | |
| 279 | case DW_LNE_define_file: |
| 280 | printf (_(" define new File Table entry\n")); |
| 281 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
| 282 | |
| 283 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
| 284 | name = data; |
| 285 | data += strlen ((char *) data) + 1; |
| 286 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 287 | data += bytes_read; |
| 288 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 289 | data += bytes_read; |
| 290 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 291 | printf ("%s\n\n", name); |
| 292 | break; |
| 293 | |
| 294 | case DW_LNE_set_discriminator: |
| 295 | printf (_("set Discriminator to %s\n"), |
| 296 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 297 | break; |
| 298 | |
| 299 | /* HP extensions. */ |
| 300 | case DW_LNE_HP_negate_is_UV_update: |
| 301 | printf ("DW_LNE_HP_negate_is_UV_update\n"); |
| 302 | break; |
| 303 | case DW_LNE_HP_push_context: |
| 304 | printf ("DW_LNE_HP_push_context\n"); |
| 305 | break; |
| 306 | case DW_LNE_HP_pop_context: |
| 307 | printf ("DW_LNE_HP_pop_context\n"); |
| 308 | break; |
| 309 | case DW_LNE_HP_set_file_line_column: |
| 310 | printf ("DW_LNE_HP_set_file_line_column\n"); |
| 311 | break; |
| 312 | case DW_LNE_HP_set_routine_name: |
| 313 | printf ("DW_LNE_HP_set_routine_name\n"); |
| 314 | break; |
| 315 | case DW_LNE_HP_set_sequence: |
| 316 | printf ("DW_LNE_HP_set_sequence\n"); |
| 317 | break; |
| 318 | case DW_LNE_HP_negate_post_semantics: |
| 319 | printf ("DW_LNE_HP_negate_post_semantics\n"); |
| 320 | break; |
| 321 | case DW_LNE_HP_negate_function_exit: |
| 322 | printf ("DW_LNE_HP_negate_function_exit\n"); |
| 323 | break; |
| 324 | case DW_LNE_HP_negate_front_end_logical: |
| 325 | printf ("DW_LNE_HP_negate_front_end_logical\n"); |
| 326 | break; |
| 327 | case DW_LNE_HP_define_proc: |
| 328 | printf ("DW_LNE_HP_define_proc\n"); |
| 329 | break; |
| 330 | case DW_LNE_HP_source_file_correlation: |
| 331 | { |
| 332 | unsigned char *edata = data + len - bytes_read - 1; |
| 333 | |
| 334 | printf ("DW_LNE_HP_source_file_correlation\n"); |
| 335 | |
| 336 | while (data < edata) |
| 337 | { |
| 338 | unsigned int opc; |
| 339 | |
| 340 | opc = read_leb128 (data, & bytes_read, 0); |
| 341 | data += bytes_read; |
| 342 | |
| 343 | switch (opc) |
| 344 | { |
| 345 | case DW_LNE_HP_SFC_formfeed: |
| 346 | printf (" DW_LNE_HP_SFC_formfeed\n"); |
| 347 | break; |
| 348 | case DW_LNE_HP_SFC_set_listing_line: |
| 349 | printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", |
| 350 | dwarf_vmatoa ("u", |
| 351 | read_leb128 (data, & bytes_read, 0))); |
| 352 | data += bytes_read; |
| 353 | break; |
| 354 | case DW_LNE_HP_SFC_associate: |
| 355 | printf (" DW_LNE_HP_SFC_associate "); |
| 356 | printf ("(%s", |
| 357 | dwarf_vmatoa ("u", |
| 358 | read_leb128 (data, & bytes_read, 0))); |
| 359 | data += bytes_read; |
| 360 | printf (",%s", |
| 361 | dwarf_vmatoa ("u", |
| 362 | read_leb128 (data, & bytes_read, 0))); |
| 363 | data += bytes_read; |
| 364 | printf (",%s)\n", |
| 365 | dwarf_vmatoa ("u", |
| 366 | read_leb128 (data, & bytes_read, 0))); |
| 367 | data += bytes_read; |
| 368 | break; |
| 369 | default: |
| 370 | printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc); |
| 371 | data = edata; |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | break; |
| 377 | |
| 378 | default: |
| 379 | { |
| 380 | unsigned int rlen = len - bytes_read - 1; |
| 381 | |
| 382 | if (op_code >= DW_LNE_lo_user |
| 383 | /* The test against DW_LNW_hi_user is redundant due to |
| 384 | the limited range of the unsigned char data type used |
| 385 | for op_code. */ |
| 386 | /*&& op_code <= DW_LNE_hi_user*/) |
| 387 | printf (_("user defined: ")); |
| 388 | else |
| 389 | printf (_("UNKNOWN: ")); |
| 390 | printf (_("length %d ["), rlen); |
| 391 | for (; rlen; rlen--) |
| 392 | printf (" %02x", *data++); |
| 393 | printf ("]\n"); |
| 394 | } |
| 395 | break; |
| 396 | } |
| 397 | |
| 398 | return len; |
| 399 | } |
| 400 | |
| 401 | static const char * |
| 402 | fetch_indirect_string (dwarf_vma offset) |
| 403 | { |
| 404 | struct dwarf_section *section = &debug_displays [str].section; |
| 405 | |
| 406 | if (section->start == NULL) |
| 407 | return _("<no .debug_str section>"); |
| 408 | |
| 409 | /* DWARF sections under Mach-O have non-zero addresses. */ |
| 410 | offset -= section->address; |
| 411 | if (offset > section->size) |
| 412 | { |
| 413 | warn (_("DW_FORM_strp offset too big: %s\n"), |
| 414 | dwarf_vmatoa ("x", offset)); |
| 415 | return _("<offset is too big>"); |
| 416 | } |
| 417 | |
| 418 | return (const char *) section->start + offset; |
| 419 | } |
| 420 | |
| 421 | /* FIXME: There are better and more efficient ways to handle |
| 422 | these structures. For now though, I just want something that |
| 423 | is simple to implement. */ |
| 424 | typedef struct abbrev_attr |
| 425 | { |
| 426 | unsigned long attribute; |
| 427 | unsigned long form; |
| 428 | struct abbrev_attr *next; |
| 429 | } |
| 430 | abbrev_attr; |
| 431 | |
| 432 | typedef struct abbrev_entry |
| 433 | { |
| 434 | unsigned long entry; |
| 435 | unsigned long tag; |
| 436 | int children; |
| 437 | struct abbrev_attr *first_attr; |
| 438 | struct abbrev_attr *last_attr; |
| 439 | struct abbrev_entry *next; |
| 440 | } |
| 441 | abbrev_entry; |
| 442 | |
| 443 | static abbrev_entry *first_abbrev = NULL; |
| 444 | static abbrev_entry *last_abbrev = NULL; |
| 445 | |
| 446 | static void |
| 447 | free_abbrevs (void) |
| 448 | { |
| 449 | abbrev_entry *abbrv; |
| 450 | |
| 451 | for (abbrv = first_abbrev; abbrv;) |
| 452 | { |
| 453 | abbrev_entry *next_abbrev = abbrv->next; |
| 454 | abbrev_attr *attr; |
| 455 | |
| 456 | for (attr = abbrv->first_attr; attr;) |
| 457 | { |
| 458 | abbrev_attr *next_attr = attr->next; |
| 459 | |
| 460 | free (attr); |
| 461 | attr = next_attr; |
| 462 | } |
| 463 | |
| 464 | free (abbrv); |
| 465 | abbrv = next_abbrev; |
| 466 | } |
| 467 | |
| 468 | last_abbrev = first_abbrev = NULL; |
| 469 | } |
| 470 | |
| 471 | static void |
| 472 | add_abbrev (unsigned long number, unsigned long tag, int children) |
| 473 | { |
| 474 | abbrev_entry *entry; |
| 475 | |
| 476 | entry = (abbrev_entry *) malloc (sizeof (*entry)); |
| 477 | if (entry == NULL) |
| 478 | /* ugg */ |
| 479 | return; |
| 480 | |
| 481 | entry->entry = number; |
| 482 | entry->tag = tag; |
| 483 | entry->children = children; |
| 484 | entry->first_attr = NULL; |
| 485 | entry->last_attr = NULL; |
| 486 | entry->next = NULL; |
| 487 | |
| 488 | if (first_abbrev == NULL) |
| 489 | first_abbrev = entry; |
| 490 | else |
| 491 | last_abbrev->next = entry; |
| 492 | |
| 493 | last_abbrev = entry; |
| 494 | } |
| 495 | |
| 496 | static void |
| 497 | add_abbrev_attr (unsigned long attribute, unsigned long form) |
| 498 | { |
| 499 | abbrev_attr *attr; |
| 500 | |
| 501 | attr = (abbrev_attr *) malloc (sizeof (*attr)); |
| 502 | if (attr == NULL) |
| 503 | /* ugg */ |
| 504 | return; |
| 505 | |
| 506 | attr->attribute = attribute; |
| 507 | attr->form = form; |
| 508 | attr->next = NULL; |
| 509 | |
| 510 | if (last_abbrev->first_attr == NULL) |
| 511 | last_abbrev->first_attr = attr; |
| 512 | else |
| 513 | last_abbrev->last_attr->next = attr; |
| 514 | |
| 515 | last_abbrev->last_attr = attr; |
| 516 | } |
| 517 | |
| 518 | /* Processes the (partial) contents of a .debug_abbrev section. |
| 519 | Returns NULL if the end of the section was encountered. |
| 520 | Returns the address after the last byte read if the end of |
| 521 | an abbreviation set was found. */ |
| 522 | |
| 523 | static unsigned char * |
| 524 | process_abbrev_section (unsigned char *start, unsigned char *end) |
| 525 | { |
| 526 | if (first_abbrev != NULL) |
| 527 | return NULL; |
| 528 | |
| 529 | while (start < end) |
| 530 | { |
| 531 | unsigned int bytes_read; |
| 532 | unsigned long entry; |
| 533 | unsigned long tag; |
| 534 | unsigned long attribute; |
| 535 | int children; |
| 536 | |
| 537 | entry = read_leb128 (start, & bytes_read, 0); |
| 538 | start += bytes_read; |
| 539 | |
| 540 | /* A single zero is supposed to end the section according |
| 541 | to the standard. If there's more, then signal that to |
| 542 | the caller. */ |
| 543 | if (entry == 0) |
| 544 | return start == end ? NULL : start; |
| 545 | |
| 546 | tag = read_leb128 (start, & bytes_read, 0); |
| 547 | start += bytes_read; |
| 548 | |
| 549 | children = *start++; |
| 550 | |
| 551 | add_abbrev (entry, tag, children); |
| 552 | |
| 553 | do |
| 554 | { |
| 555 | unsigned long form; |
| 556 | |
| 557 | attribute = read_leb128 (start, & bytes_read, 0); |
| 558 | start += bytes_read; |
| 559 | |
| 560 | form = read_leb128 (start, & bytes_read, 0); |
| 561 | start += bytes_read; |
| 562 | |
| 563 | if (attribute != 0) |
| 564 | add_abbrev_attr (attribute, form); |
| 565 | } |
| 566 | while (attribute != 0); |
| 567 | } |
| 568 | |
| 569 | return NULL; |
| 570 | } |
| 571 | |
| 572 | static char * |
| 573 | get_TAG_name (unsigned long tag) |
| 574 | { |
| 575 | switch (tag) |
| 576 | { |
| 577 | case DW_TAG_padding: return "DW_TAG_padding"; |
| 578 | case DW_TAG_array_type: return "DW_TAG_array_type"; |
| 579 | case DW_TAG_class_type: return "DW_TAG_class_type"; |
| 580 | case DW_TAG_entry_point: return "DW_TAG_entry_point"; |
| 581 | case DW_TAG_enumeration_type: return "DW_TAG_enumeration_type"; |
| 582 | case DW_TAG_formal_parameter: return "DW_TAG_formal_parameter"; |
| 583 | case DW_TAG_imported_declaration: return "DW_TAG_imported_declaration"; |
| 584 | case DW_TAG_label: return "DW_TAG_label"; |
| 585 | case DW_TAG_lexical_block: return "DW_TAG_lexical_block"; |
| 586 | case DW_TAG_member: return "DW_TAG_member"; |
| 587 | case DW_TAG_pointer_type: return "DW_TAG_pointer_type"; |
| 588 | case DW_TAG_reference_type: return "DW_TAG_reference_type"; |
| 589 | case DW_TAG_compile_unit: return "DW_TAG_compile_unit"; |
| 590 | case DW_TAG_string_type: return "DW_TAG_string_type"; |
| 591 | case DW_TAG_structure_type: return "DW_TAG_structure_type"; |
| 592 | case DW_TAG_subroutine_type: return "DW_TAG_subroutine_type"; |
| 593 | case DW_TAG_typedef: return "DW_TAG_typedef"; |
| 594 | case DW_TAG_union_type: return "DW_TAG_union_type"; |
| 595 | case DW_TAG_unspecified_parameters: return "DW_TAG_unspecified_parameters"; |
| 596 | case DW_TAG_variant: return "DW_TAG_variant"; |
| 597 | case DW_TAG_common_block: return "DW_TAG_common_block"; |
| 598 | case DW_TAG_common_inclusion: return "DW_TAG_common_inclusion"; |
| 599 | case DW_TAG_inheritance: return "DW_TAG_inheritance"; |
| 600 | case DW_TAG_inlined_subroutine: return "DW_TAG_inlined_subroutine"; |
| 601 | case DW_TAG_module: return "DW_TAG_module"; |
| 602 | case DW_TAG_ptr_to_member_type: return "DW_TAG_ptr_to_member_type"; |
| 603 | case DW_TAG_set_type: return "DW_TAG_set_type"; |
| 604 | case DW_TAG_subrange_type: return "DW_TAG_subrange_type"; |
| 605 | case DW_TAG_with_stmt: return "DW_TAG_with_stmt"; |
| 606 | case DW_TAG_access_declaration: return "DW_TAG_access_declaration"; |
| 607 | case DW_TAG_base_type: return "DW_TAG_base_type"; |
| 608 | case DW_TAG_catch_block: return "DW_TAG_catch_block"; |
| 609 | case DW_TAG_const_type: return "DW_TAG_const_type"; |
| 610 | case DW_TAG_constant: return "DW_TAG_constant"; |
| 611 | case DW_TAG_enumerator: return "DW_TAG_enumerator"; |
| 612 | case DW_TAG_file_type: return "DW_TAG_file_type"; |
| 613 | case DW_TAG_friend: return "DW_TAG_friend"; |
| 614 | case DW_TAG_namelist: return "DW_TAG_namelist"; |
| 615 | case DW_TAG_namelist_item: return "DW_TAG_namelist_item"; |
| 616 | case DW_TAG_packed_type: return "DW_TAG_packed_type"; |
| 617 | case DW_TAG_subprogram: return "DW_TAG_subprogram"; |
| 618 | case DW_TAG_template_type_param: return "DW_TAG_template_type_param"; |
| 619 | case DW_TAG_template_value_param: return "DW_TAG_template_value_param"; |
| 620 | case DW_TAG_thrown_type: return "DW_TAG_thrown_type"; |
| 621 | case DW_TAG_try_block: return "DW_TAG_try_block"; |
| 622 | case DW_TAG_variant_part: return "DW_TAG_variant_part"; |
| 623 | case DW_TAG_variable: return "DW_TAG_variable"; |
| 624 | case DW_TAG_volatile_type: return "DW_TAG_volatile_type"; |
| 625 | case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; |
| 626 | case DW_TAG_format_label: return "DW_TAG_format_label"; |
| 627 | case DW_TAG_function_template: return "DW_TAG_function_template"; |
| 628 | case DW_TAG_class_template: return "DW_TAG_class_template"; |
| 629 | /* DWARF 2.1 values. */ |
| 630 | case DW_TAG_dwarf_procedure: return "DW_TAG_dwarf_procedure"; |
| 631 | case DW_TAG_restrict_type: return "DW_TAG_restrict_type"; |
| 632 | case DW_TAG_interface_type: return "DW_TAG_interface_type"; |
| 633 | case DW_TAG_namespace: return "DW_TAG_namespace"; |
| 634 | case DW_TAG_imported_module: return "DW_TAG_imported_module"; |
| 635 | case DW_TAG_unspecified_type: return "DW_TAG_unspecified_type"; |
| 636 | case DW_TAG_partial_unit: return "DW_TAG_partial_unit"; |
| 637 | case DW_TAG_imported_unit: return "DW_TAG_imported_unit"; |
| 638 | case DW_TAG_condition: return "DW_TAG_condition"; |
| 639 | case DW_TAG_shared_type: return "DW_TAG_shared_type"; |
| 640 | /* DWARF 4 values. */ |
| 641 | case DW_TAG_type_unit: return "DW_TAG_type_unit"; |
| 642 | case DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type"; |
| 643 | case DW_TAG_template_alias: return "DW_TAG_template_alias"; |
| 644 | /* UPC values. */ |
| 645 | case DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type"; |
| 646 | case DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type"; |
| 647 | case DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type"; |
| 648 | /* GNU values. */ |
| 649 | case DW_TAG_GNU_call_site: return "DW_TAG_GNU_call_site"; |
| 650 | case DW_TAG_GNU_call_site_parameter:return "DW_TAG_GNU_call_site_parameter"; |
| 651 | default: |
| 652 | { |
| 653 | static char buffer[100]; |
| 654 | |
| 655 | snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag); |
| 656 | return buffer; |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | static char * |
| 662 | get_FORM_name (unsigned long form) |
| 663 | { |
| 664 | switch (form) |
| 665 | { |
| 666 | case DW_FORM_addr: return "DW_FORM_addr"; |
| 667 | case DW_FORM_block2: return "DW_FORM_block2"; |
| 668 | case DW_FORM_block4: return "DW_FORM_block4"; |
| 669 | case DW_FORM_data2: return "DW_FORM_data2"; |
| 670 | case DW_FORM_data4: return "DW_FORM_data4"; |
| 671 | case DW_FORM_data8: return "DW_FORM_data8"; |
| 672 | case DW_FORM_string: return "DW_FORM_string"; |
| 673 | case DW_FORM_block: return "DW_FORM_block"; |
| 674 | case DW_FORM_block1: return "DW_FORM_block1"; |
| 675 | case DW_FORM_data1: return "DW_FORM_data1"; |
| 676 | case DW_FORM_flag: return "DW_FORM_flag"; |
| 677 | case DW_FORM_sdata: return "DW_FORM_sdata"; |
| 678 | case DW_FORM_strp: return "DW_FORM_strp"; |
| 679 | case DW_FORM_udata: return "DW_FORM_udata"; |
| 680 | case DW_FORM_ref_addr: return "DW_FORM_ref_addr"; |
| 681 | case DW_FORM_ref1: return "DW_FORM_ref1"; |
| 682 | case DW_FORM_ref2: return "DW_FORM_ref2"; |
| 683 | case DW_FORM_ref4: return "DW_FORM_ref4"; |
| 684 | case DW_FORM_ref8: return "DW_FORM_ref8"; |
| 685 | case DW_FORM_ref_udata: return "DW_FORM_ref_udata"; |
| 686 | case DW_FORM_indirect: return "DW_FORM_indirect"; |
| 687 | /* DWARF 4 values. */ |
| 688 | case DW_FORM_sec_offset: return "DW_FORM_sec_offset"; |
| 689 | case DW_FORM_exprloc: return "DW_FORM_exprloc"; |
| 690 | case DW_FORM_flag_present: return "DW_FORM_flag_present"; |
| 691 | case DW_FORM_ref_sig8: return "DW_FORM_ref_sig8"; |
| 692 | default: |
| 693 | { |
| 694 | static char buffer[100]; |
| 695 | |
| 696 | snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); |
| 697 | return buffer; |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | static unsigned char * |
| 703 | display_block (unsigned char *data, dwarf_vma length) |
| 704 | { |
| 705 | printf (_(" %s byte block: "), dwarf_vmatoa ("u", length)); |
| 706 | |
| 707 | while (length --) |
| 708 | printf ("%lx ", (unsigned long) byte_get (data++, 1)); |
| 709 | |
| 710 | return data; |
| 711 | } |
| 712 | |
| 713 | static int |
| 714 | decode_location_expression (unsigned char * data, |
| 715 | unsigned int pointer_size, |
| 716 | unsigned int offset_size, |
| 717 | int dwarf_version, |
| 718 | dwarf_vma length, |
| 719 | dwarf_vma cu_offset, |
| 720 | struct dwarf_section * section) |
| 721 | { |
| 722 | unsigned op; |
| 723 | unsigned int bytes_read; |
| 724 | dwarf_vma uvalue; |
| 725 | unsigned char *end = data + length; |
| 726 | int need_frame_base = 0; |
| 727 | |
| 728 | while (data < end) |
| 729 | { |
| 730 | op = *data++; |
| 731 | |
| 732 | switch (op) |
| 733 | { |
| 734 | case DW_OP_addr: |
| 735 | printf ("DW_OP_addr: %s", |
| 736 | dwarf_vmatoa ("x", byte_get (data, pointer_size))); |
| 737 | data += pointer_size; |
| 738 | break; |
| 739 | case DW_OP_deref: |
| 740 | printf ("DW_OP_deref"); |
| 741 | break; |
| 742 | case DW_OP_const1u: |
| 743 | printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1)); |
| 744 | break; |
| 745 | case DW_OP_const1s: |
| 746 | printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data++, 1)); |
| 747 | break; |
| 748 | case DW_OP_const2u: |
| 749 | printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2)); |
| 750 | data += 2; |
| 751 | break; |
| 752 | case DW_OP_const2s: |
| 753 | printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data, 2)); |
| 754 | data += 2; |
| 755 | break; |
| 756 | case DW_OP_const4u: |
| 757 | printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4)); |
| 758 | data += 4; |
| 759 | break; |
| 760 | case DW_OP_const4s: |
| 761 | printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data, 4)); |
| 762 | data += 4; |
| 763 | break; |
| 764 | case DW_OP_const8u: |
| 765 | printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4), |
| 766 | (unsigned long) byte_get (data + 4, 4)); |
| 767 | data += 8; |
| 768 | break; |
| 769 | case DW_OP_const8s: |
| 770 | printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4), |
| 771 | (long) byte_get (data + 4, 4)); |
| 772 | data += 8; |
| 773 | break; |
| 774 | case DW_OP_constu: |
| 775 | printf ("DW_OP_constu: %s", |
| 776 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); |
| 777 | data += bytes_read; |
| 778 | break; |
| 779 | case DW_OP_consts: |
| 780 | printf ("DW_OP_consts: %s", |
| 781 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); |
| 782 | data += bytes_read; |
| 783 | break; |
| 784 | case DW_OP_dup: |
| 785 | printf ("DW_OP_dup"); |
| 786 | break; |
| 787 | case DW_OP_drop: |
| 788 | printf ("DW_OP_drop"); |
| 789 | break; |
| 790 | case DW_OP_over: |
| 791 | printf ("DW_OP_over"); |
| 792 | break; |
| 793 | case DW_OP_pick: |
| 794 | printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1)); |
| 795 | break; |
| 796 | case DW_OP_swap: |
| 797 | printf ("DW_OP_swap"); |
| 798 | break; |
| 799 | case DW_OP_rot: |
| 800 | printf ("DW_OP_rot"); |
| 801 | break; |
| 802 | case DW_OP_xderef: |
| 803 | printf ("DW_OP_xderef"); |
| 804 | break; |
| 805 | case DW_OP_abs: |
| 806 | printf ("DW_OP_abs"); |
| 807 | break; |
| 808 | case DW_OP_and: |
| 809 | printf ("DW_OP_and"); |
| 810 | break; |
| 811 | case DW_OP_div: |
| 812 | printf ("DW_OP_div"); |
| 813 | break; |
| 814 | case DW_OP_minus: |
| 815 | printf ("DW_OP_minus"); |
| 816 | break; |
| 817 | case DW_OP_mod: |
| 818 | printf ("DW_OP_mod"); |
| 819 | break; |
| 820 | case DW_OP_mul: |
| 821 | printf ("DW_OP_mul"); |
| 822 | break; |
| 823 | case DW_OP_neg: |
| 824 | printf ("DW_OP_neg"); |
| 825 | break; |
| 826 | case DW_OP_not: |
| 827 | printf ("DW_OP_not"); |
| 828 | break; |
| 829 | case DW_OP_or: |
| 830 | printf ("DW_OP_or"); |
| 831 | break; |
| 832 | case DW_OP_plus: |
| 833 | printf ("DW_OP_plus"); |
| 834 | break; |
| 835 | case DW_OP_plus_uconst: |
| 836 | printf ("DW_OP_plus_uconst: %s", |
| 837 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); |
| 838 | data += bytes_read; |
| 839 | break; |
| 840 | case DW_OP_shl: |
| 841 | printf ("DW_OP_shl"); |
| 842 | break; |
| 843 | case DW_OP_shr: |
| 844 | printf ("DW_OP_shr"); |
| 845 | break; |
| 846 | case DW_OP_shra: |
| 847 | printf ("DW_OP_shra"); |
| 848 | break; |
| 849 | case DW_OP_xor: |
| 850 | printf ("DW_OP_xor"); |
| 851 | break; |
| 852 | case DW_OP_bra: |
| 853 | printf ("DW_OP_bra: %ld", (long) byte_get_signed (data, 2)); |
| 854 | data += 2; |
| 855 | break; |
| 856 | case DW_OP_eq: |
| 857 | printf ("DW_OP_eq"); |
| 858 | break; |
| 859 | case DW_OP_ge: |
| 860 | printf ("DW_OP_ge"); |
| 861 | break; |
| 862 | case DW_OP_gt: |
| 863 | printf ("DW_OP_gt"); |
| 864 | break; |
| 865 | case DW_OP_le: |
| 866 | printf ("DW_OP_le"); |
| 867 | break; |
| 868 | case DW_OP_lt: |
| 869 | printf ("DW_OP_lt"); |
| 870 | break; |
| 871 | case DW_OP_ne: |
| 872 | printf ("DW_OP_ne"); |
| 873 | break; |
| 874 | case DW_OP_skip: |
| 875 | printf ("DW_OP_skip: %ld", (long) byte_get_signed (data, 2)); |
| 876 | data += 2; |
| 877 | break; |
| 878 | |
| 879 | case DW_OP_lit0: |
| 880 | case DW_OP_lit1: |
| 881 | case DW_OP_lit2: |
| 882 | case DW_OP_lit3: |
| 883 | case DW_OP_lit4: |
| 884 | case DW_OP_lit5: |
| 885 | case DW_OP_lit6: |
| 886 | case DW_OP_lit7: |
| 887 | case DW_OP_lit8: |
| 888 | case DW_OP_lit9: |
| 889 | case DW_OP_lit10: |
| 890 | case DW_OP_lit11: |
| 891 | case DW_OP_lit12: |
| 892 | case DW_OP_lit13: |
| 893 | case DW_OP_lit14: |
| 894 | case DW_OP_lit15: |
| 895 | case DW_OP_lit16: |
| 896 | case DW_OP_lit17: |
| 897 | case DW_OP_lit18: |
| 898 | case DW_OP_lit19: |
| 899 | case DW_OP_lit20: |
| 900 | case DW_OP_lit21: |
| 901 | case DW_OP_lit22: |
| 902 | case DW_OP_lit23: |
| 903 | case DW_OP_lit24: |
| 904 | case DW_OP_lit25: |
| 905 | case DW_OP_lit26: |
| 906 | case DW_OP_lit27: |
| 907 | case DW_OP_lit28: |
| 908 | case DW_OP_lit29: |
| 909 | case DW_OP_lit30: |
| 910 | case DW_OP_lit31: |
| 911 | printf ("DW_OP_lit%d", op - DW_OP_lit0); |
| 912 | break; |
| 913 | |
| 914 | case DW_OP_reg0: |
| 915 | case DW_OP_reg1: |
| 916 | case DW_OP_reg2: |
| 917 | case DW_OP_reg3: |
| 918 | case DW_OP_reg4: |
| 919 | case DW_OP_reg5: |
| 920 | case DW_OP_reg6: |
| 921 | case DW_OP_reg7: |
| 922 | case DW_OP_reg8: |
| 923 | case DW_OP_reg9: |
| 924 | case DW_OP_reg10: |
| 925 | case DW_OP_reg11: |
| 926 | case DW_OP_reg12: |
| 927 | case DW_OP_reg13: |
| 928 | case DW_OP_reg14: |
| 929 | case DW_OP_reg15: |
| 930 | case DW_OP_reg16: |
| 931 | case DW_OP_reg17: |
| 932 | case DW_OP_reg18: |
| 933 | case DW_OP_reg19: |
| 934 | case DW_OP_reg20: |
| 935 | case DW_OP_reg21: |
| 936 | case DW_OP_reg22: |
| 937 | case DW_OP_reg23: |
| 938 | case DW_OP_reg24: |
| 939 | case DW_OP_reg25: |
| 940 | case DW_OP_reg26: |
| 941 | case DW_OP_reg27: |
| 942 | case DW_OP_reg28: |
| 943 | case DW_OP_reg29: |
| 944 | case DW_OP_reg30: |
| 945 | case DW_OP_reg31: |
| 946 | printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, |
| 947 | regname (op - DW_OP_reg0, 1)); |
| 948 | break; |
| 949 | |
| 950 | case DW_OP_breg0: |
| 951 | case DW_OP_breg1: |
| 952 | case DW_OP_breg2: |
| 953 | case DW_OP_breg3: |
| 954 | case DW_OP_breg4: |
| 955 | case DW_OP_breg5: |
| 956 | case DW_OP_breg6: |
| 957 | case DW_OP_breg7: |
| 958 | case DW_OP_breg8: |
| 959 | case DW_OP_breg9: |
| 960 | case DW_OP_breg10: |
| 961 | case DW_OP_breg11: |
| 962 | case DW_OP_breg12: |
| 963 | case DW_OP_breg13: |
| 964 | case DW_OP_breg14: |
| 965 | case DW_OP_breg15: |
| 966 | case DW_OP_breg16: |
| 967 | case DW_OP_breg17: |
| 968 | case DW_OP_breg18: |
| 969 | case DW_OP_breg19: |
| 970 | case DW_OP_breg20: |
| 971 | case DW_OP_breg21: |
| 972 | case DW_OP_breg22: |
| 973 | case DW_OP_breg23: |
| 974 | case DW_OP_breg24: |
| 975 | case DW_OP_breg25: |
| 976 | case DW_OP_breg26: |
| 977 | case DW_OP_breg27: |
| 978 | case DW_OP_breg28: |
| 979 | case DW_OP_breg29: |
| 980 | case DW_OP_breg30: |
| 981 | case DW_OP_breg31: |
| 982 | printf ("DW_OP_breg%d (%s): %s", |
| 983 | op - DW_OP_breg0, |
| 984 | regname (op - DW_OP_breg0, 1), |
| 985 | dwarf_vmatoa ("d", (dwarf_signed_vma) |
| 986 | read_leb128 (data, &bytes_read, 1))); |
| 987 | data += bytes_read; |
| 988 | break; |
| 989 | |
| 990 | case DW_OP_regx: |
| 991 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 992 | data += bytes_read; |
| 993 | printf ("DW_OP_regx: %s (%s)", |
| 994 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| 995 | break; |
| 996 | case DW_OP_fbreg: |
| 997 | need_frame_base = 1; |
| 998 | printf ("DW_OP_fbreg: %s", |
| 999 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); |
| 1000 | data += bytes_read; |
| 1001 | break; |
| 1002 | case DW_OP_bregx: |
| 1003 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1004 | data += bytes_read; |
| 1005 | printf ("DW_OP_bregx: %s (%s) %s", |
| 1006 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), |
| 1007 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); |
| 1008 | data += bytes_read; |
| 1009 | break; |
| 1010 | case DW_OP_piece: |
| 1011 | printf ("DW_OP_piece: %s", |
| 1012 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); |
| 1013 | data += bytes_read; |
| 1014 | break; |
| 1015 | case DW_OP_deref_size: |
| 1016 | printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1)); |
| 1017 | break; |
| 1018 | case DW_OP_xderef_size: |
| 1019 | printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1)); |
| 1020 | break; |
| 1021 | case DW_OP_nop: |
| 1022 | printf ("DW_OP_nop"); |
| 1023 | break; |
| 1024 | |
| 1025 | /* DWARF 3 extensions. */ |
| 1026 | case DW_OP_push_object_address: |
| 1027 | printf ("DW_OP_push_object_address"); |
| 1028 | break; |
| 1029 | case DW_OP_call2: |
| 1030 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1031 | this ought to be an 8-byte wide computation. */ |
| 1032 | printf ("DW_OP_call2: <0x%s>", |
| 1033 | dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 2) |
| 1034 | + cu_offset)); |
| 1035 | data += 2; |
| 1036 | break; |
| 1037 | case DW_OP_call4: |
| 1038 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1039 | this ought to be an 8-byte wide computation. */ |
| 1040 | printf ("DW_OP_call4: <0x%s>", |
| 1041 | dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 4) |
| 1042 | + cu_offset)); |
| 1043 | data += 4; |
| 1044 | break; |
| 1045 | case DW_OP_call_ref: |
| 1046 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1047 | this ought to be an 8-byte wide computation. */ |
| 1048 | if (dwarf_version == -1) |
| 1049 | { |
| 1050 | printf (_("(DW_OP_call_ref in frame info)")); |
| 1051 | /* No way to tell where the next op is, so just bail. */ |
| 1052 | return need_frame_base; |
| 1053 | } |
| 1054 | if (dwarf_version == 2) |
| 1055 | { |
| 1056 | printf ("DW_OP_call_ref: <0x%s>", |
| 1057 | dwarf_vmatoa ("x", byte_get (data, pointer_size))); |
| 1058 | data += pointer_size; |
| 1059 | } |
| 1060 | else |
| 1061 | { |
| 1062 | printf ("DW_OP_call_ref: <0x%s>", |
| 1063 | dwarf_vmatoa ("x", byte_get (data, offset_size))); |
| 1064 | data += offset_size; |
| 1065 | } |
| 1066 | break; |
| 1067 | case DW_OP_form_tls_address: |
| 1068 | printf ("DW_OP_form_tls_address"); |
| 1069 | break; |
| 1070 | case DW_OP_call_frame_cfa: |
| 1071 | printf ("DW_OP_call_frame_cfa"); |
| 1072 | break; |
| 1073 | case DW_OP_bit_piece: |
| 1074 | printf ("DW_OP_bit_piece: "); |
| 1075 | printf (_("size: %s "), |
| 1076 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); |
| 1077 | data += bytes_read; |
| 1078 | printf (_("offset: %s "), |
| 1079 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); |
| 1080 | data += bytes_read; |
| 1081 | break; |
| 1082 | |
| 1083 | /* DWARF 4 extensions. */ |
| 1084 | case DW_OP_stack_value: |
| 1085 | printf ("DW_OP_stack_value"); |
| 1086 | break; |
| 1087 | |
| 1088 | case DW_OP_implicit_value: |
| 1089 | printf ("DW_OP_implicit_value"); |
| 1090 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1091 | data += bytes_read; |
| 1092 | display_block (data, uvalue); |
| 1093 | data += uvalue; |
| 1094 | break; |
| 1095 | |
| 1096 | /* GNU extensions. */ |
| 1097 | case DW_OP_GNU_push_tls_address: |
| 1098 | printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown")); |
| 1099 | break; |
| 1100 | case DW_OP_GNU_uninit: |
| 1101 | printf ("DW_OP_GNU_uninit"); |
| 1102 | /* FIXME: Is there data associated with this OP ? */ |
| 1103 | break; |
| 1104 | case DW_OP_GNU_encoded_addr: |
| 1105 | { |
| 1106 | int encoding; |
| 1107 | dwarf_vma addr; |
| 1108 | |
| 1109 | encoding = *data++; |
| 1110 | addr = get_encoded_value (data, encoding, section); |
| 1111 | data += size_of_encoded_value (encoding); |
| 1112 | |
| 1113 | printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); |
| 1114 | print_dwarf_vma (addr, pointer_size); |
| 1115 | } |
| 1116 | break; |
| 1117 | case DW_OP_GNU_implicit_pointer: |
| 1118 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1119 | this ought to be an 8-byte wide computation. */ |
| 1120 | if (dwarf_version == -1) |
| 1121 | { |
| 1122 | printf (_("(DW_OP_GNU_implicit_pointer in frame info)")); |
| 1123 | /* No way to tell where the next op is, so just bail. */ |
| 1124 | return need_frame_base; |
| 1125 | } |
| 1126 | if (dwarf_version == 2) |
| 1127 | { |
| 1128 | printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", |
| 1129 | dwarf_vmatoa ("x", byte_get (data, pointer_size)), |
| 1130 | dwarf_vmatoa ("d", read_sleb128 (data + pointer_size, |
| 1131 | &bytes_read))); |
| 1132 | data += pointer_size + bytes_read; |
| 1133 | } |
| 1134 | else |
| 1135 | { |
| 1136 | printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", |
| 1137 | dwarf_vmatoa ("x", byte_get (data, offset_size)), |
| 1138 | dwarf_vmatoa ("d", read_sleb128 (data + offset_size, |
| 1139 | &bytes_read))); |
| 1140 | data += offset_size + bytes_read; |
| 1141 | } |
| 1142 | break; |
| 1143 | case DW_OP_GNU_entry_value: |
| 1144 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1145 | data += bytes_read; |
| 1146 | printf ("DW_OP_GNU_entry_value: ("); |
| 1147 | if (decode_location_expression (data, pointer_size, offset_size, |
| 1148 | dwarf_version, uvalue, |
| 1149 | cu_offset, section)) |
| 1150 | need_frame_base = 1; |
| 1151 | putchar (')'); |
| 1152 | data += uvalue; |
| 1153 | break; |
| 1154 | case DW_OP_GNU_const_type: |
| 1155 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1156 | data += bytes_read; |
| 1157 | printf ("DW_OP_GNU_const_type: <0x%s> ", |
| 1158 | dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1159 | uvalue = byte_get (data++, 1); |
| 1160 | display_block (data, uvalue); |
| 1161 | data += uvalue; |
| 1162 | break; |
| 1163 | case DW_OP_GNU_regval_type: |
| 1164 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1165 | data += bytes_read; |
| 1166 | printf ("DW_OP_GNU_regval_type: %s (%s)", |
| 1167 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| 1168 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1169 | data += bytes_read; |
| 1170 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1171 | break; |
| 1172 | case DW_OP_GNU_deref_type: |
| 1173 | printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data++, 1)); |
| 1174 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1175 | data += bytes_read; |
| 1176 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1177 | break; |
| 1178 | case DW_OP_GNU_convert: |
| 1179 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1180 | data += bytes_read; |
| 1181 | printf ("DW_OP_GNU_convert <0x%s>", |
| 1182 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| 1183 | break; |
| 1184 | case DW_OP_GNU_reinterpret: |
| 1185 | uvalue = read_leb128 (data, &bytes_read, 0); |
| 1186 | data += bytes_read; |
| 1187 | printf ("DW_OP_GNU_reinterpret <0x%s>", |
| 1188 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| 1189 | break; |
| 1190 | case DW_OP_GNU_parameter_ref: |
| 1191 | printf ("DW_OP_GNU_parameter_ref: <0x%s>", |
| 1192 | dwarf_vmatoa ("x", cu_offset + byte_get (data, 4))); |
| 1193 | data += 4; |
| 1194 | break; |
| 1195 | |
| 1196 | /* HP extensions. */ |
| 1197 | case DW_OP_HP_is_value: |
| 1198 | printf ("DW_OP_HP_is_value"); |
| 1199 | /* FIXME: Is there data associated with this OP ? */ |
| 1200 | break; |
| 1201 | case DW_OP_HP_fltconst4: |
| 1202 | printf ("DW_OP_HP_fltconst4"); |
| 1203 | /* FIXME: Is there data associated with this OP ? */ |
| 1204 | break; |
| 1205 | case DW_OP_HP_fltconst8: |
| 1206 | printf ("DW_OP_HP_fltconst8"); |
| 1207 | /* FIXME: Is there data associated with this OP ? */ |
| 1208 | break; |
| 1209 | case DW_OP_HP_mod_range: |
| 1210 | printf ("DW_OP_HP_mod_range"); |
| 1211 | /* FIXME: Is there data associated with this OP ? */ |
| 1212 | break; |
| 1213 | case DW_OP_HP_unmod_range: |
| 1214 | printf ("DW_OP_HP_unmod_range"); |
| 1215 | /* FIXME: Is there data associated with this OP ? */ |
| 1216 | break; |
| 1217 | case DW_OP_HP_tls: |
| 1218 | printf ("DW_OP_HP_tls"); |
| 1219 | /* FIXME: Is there data associated with this OP ? */ |
| 1220 | break; |
| 1221 | |
| 1222 | /* PGI (STMicroelectronics) extensions. */ |
| 1223 | case DW_OP_PGI_omp_thread_num: |
| 1224 | /* Pushes the thread number for the current thread as it would be |
| 1225 | returned by the standard OpenMP library function: |
| 1226 | omp_get_thread_num(). The "current thread" is the thread for |
| 1227 | which the expression is being evaluated. */ |
| 1228 | printf ("DW_OP_PGI_omp_thread_num"); |
| 1229 | break; |
| 1230 | |
| 1231 | default: |
| 1232 | if (op >= DW_OP_lo_user |
| 1233 | && op <= DW_OP_hi_user) |
| 1234 | printf (_("(User defined location op)")); |
| 1235 | else |
| 1236 | printf (_("(Unknown location op)")); |
| 1237 | /* No way to tell where the next op is, so just bail. */ |
| 1238 | return need_frame_base; |
| 1239 | } |
| 1240 | |
| 1241 | /* Separate the ops. */ |
| 1242 | if (data < end) |
| 1243 | printf ("; "); |
| 1244 | } |
| 1245 | |
| 1246 | return need_frame_base; |
| 1247 | } |
| 1248 | |
| 1249 | static unsigned char * |
| 1250 | read_and_display_attr_value (unsigned long attribute, |
| 1251 | unsigned long form, |
| 1252 | unsigned char * data, |
| 1253 | dwarf_vma cu_offset, |
| 1254 | dwarf_vma pointer_size, |
| 1255 | dwarf_vma offset_size, |
| 1256 | int dwarf_version, |
| 1257 | debug_info * debug_info_p, |
| 1258 | int do_loc, |
| 1259 | struct dwarf_section * section) |
| 1260 | { |
| 1261 | dwarf_vma uvalue = 0; |
| 1262 | unsigned char *block_start = NULL; |
| 1263 | unsigned char * orig_data = data; |
| 1264 | unsigned int bytes_read; |
| 1265 | |
| 1266 | switch (form) |
| 1267 | { |
| 1268 | default: |
| 1269 | break; |
| 1270 | |
| 1271 | case DW_FORM_ref_addr: |
| 1272 | if (dwarf_version == 2) |
| 1273 | { |
| 1274 | uvalue = byte_get (data, pointer_size); |
| 1275 | data += pointer_size; |
| 1276 | } |
| 1277 | else if (dwarf_version == 3 || dwarf_version == 4) |
| 1278 | { |
| 1279 | uvalue = byte_get (data, offset_size); |
| 1280 | data += offset_size; |
| 1281 | } |
| 1282 | else |
| 1283 | error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); |
| 1284 | |
| 1285 | break; |
| 1286 | |
| 1287 | case DW_FORM_addr: |
| 1288 | uvalue = byte_get (data, pointer_size); |
| 1289 | data += pointer_size; |
| 1290 | break; |
| 1291 | |
| 1292 | case DW_FORM_strp: |
| 1293 | case DW_FORM_sec_offset: |
| 1294 | uvalue = byte_get (data, offset_size); |
| 1295 | data += offset_size; |
| 1296 | break; |
| 1297 | |
| 1298 | case DW_FORM_flag_present: |
| 1299 | uvalue = 1; |
| 1300 | break; |
| 1301 | |
| 1302 | case DW_FORM_ref1: |
| 1303 | case DW_FORM_flag: |
| 1304 | case DW_FORM_data1: |
| 1305 | uvalue = byte_get (data++, 1); |
| 1306 | break; |
| 1307 | |
| 1308 | case DW_FORM_ref2: |
| 1309 | case DW_FORM_data2: |
| 1310 | uvalue = byte_get (data, 2); |
| 1311 | data += 2; |
| 1312 | break; |
| 1313 | |
| 1314 | case DW_FORM_ref4: |
| 1315 | case DW_FORM_data4: |
| 1316 | uvalue = byte_get (data, 4); |
| 1317 | data += 4; |
| 1318 | break; |
| 1319 | |
| 1320 | case DW_FORM_sdata: |
| 1321 | uvalue = read_leb128 (data, & bytes_read, 1); |
| 1322 | data += bytes_read; |
| 1323 | break; |
| 1324 | |
| 1325 | case DW_FORM_ref_udata: |
| 1326 | case DW_FORM_udata: |
| 1327 | uvalue = read_leb128 (data, & bytes_read, 0); |
| 1328 | data += bytes_read; |
| 1329 | break; |
| 1330 | |
| 1331 | case DW_FORM_indirect: |
| 1332 | form = read_leb128 (data, & bytes_read, 0); |
| 1333 | data += bytes_read; |
| 1334 | if (!do_loc) |
| 1335 | printf (" %s", get_FORM_name (form)); |
| 1336 | return read_and_display_attr_value (attribute, form, data, |
| 1337 | cu_offset, pointer_size, |
| 1338 | offset_size, dwarf_version, |
| 1339 | debug_info_p, do_loc, |
| 1340 | section); |
| 1341 | } |
| 1342 | |
| 1343 | switch (form) |
| 1344 | { |
| 1345 | case DW_FORM_ref_addr: |
| 1346 | if (!do_loc) |
| 1347 | printf (" <0x%s>", dwarf_vmatoa ("x",uvalue)); |
| 1348 | break; |
| 1349 | |
| 1350 | case DW_FORM_ref1: |
| 1351 | case DW_FORM_ref2: |
| 1352 | case DW_FORM_ref4: |
| 1353 | case DW_FORM_ref_udata: |
| 1354 | if (!do_loc) |
| 1355 | printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset)); |
| 1356 | break; |
| 1357 | |
| 1358 | case DW_FORM_data4: |
| 1359 | case DW_FORM_addr: |
| 1360 | case DW_FORM_sec_offset: |
| 1361 | if (!do_loc) |
| 1362 | printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); |
| 1363 | break; |
| 1364 | |
| 1365 | case DW_FORM_flag_present: |
| 1366 | case DW_FORM_flag: |
| 1367 | case DW_FORM_data1: |
| 1368 | case DW_FORM_data2: |
| 1369 | case DW_FORM_sdata: |
| 1370 | case DW_FORM_udata: |
| 1371 | if (!do_loc) |
| 1372 | printf (" %s", dwarf_vmatoa ("d", uvalue)); |
| 1373 | break; |
| 1374 | |
| 1375 | case DW_FORM_ref8: |
| 1376 | case DW_FORM_data8: |
| 1377 | if (!do_loc) |
| 1378 | { |
| 1379 | uvalue = byte_get (data, 4); |
| 1380 | printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); |
| 1381 | printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4)); |
| 1382 | } |
| 1383 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 1384 | && num_debug_info_entries == 0) |
| 1385 | { |
| 1386 | if (sizeof (uvalue) == 8) |
| 1387 | uvalue = byte_get (data, 8); |
| 1388 | else |
| 1389 | error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); |
| 1390 | } |
| 1391 | data += 8; |
| 1392 | break; |
| 1393 | |
| 1394 | case DW_FORM_string: |
| 1395 | if (!do_loc) |
| 1396 | printf (" %s", data); |
| 1397 | data += strlen ((char *) data) + 1; |
| 1398 | break; |
| 1399 | |
| 1400 | case DW_FORM_block: |
| 1401 | case DW_FORM_exprloc: |
| 1402 | uvalue = read_leb128 (data, & bytes_read, 0); |
| 1403 | block_start = data + bytes_read; |
| 1404 | if (do_loc) |
| 1405 | data = block_start + uvalue; |
| 1406 | else |
| 1407 | data = display_block (block_start, uvalue); |
| 1408 | break; |
| 1409 | |
| 1410 | case DW_FORM_block1: |
| 1411 | uvalue = byte_get (data, 1); |
| 1412 | block_start = data + 1; |
| 1413 | if (do_loc) |
| 1414 | data = block_start + uvalue; |
| 1415 | else |
| 1416 | data = display_block (block_start, uvalue); |
| 1417 | break; |
| 1418 | |
| 1419 | case DW_FORM_block2: |
| 1420 | uvalue = byte_get (data, 2); |
| 1421 | block_start = data + 2; |
| 1422 | if (do_loc) |
| 1423 | data = block_start + uvalue; |
| 1424 | else |
| 1425 | data = display_block (block_start, uvalue); |
| 1426 | break; |
| 1427 | |
| 1428 | case DW_FORM_block4: |
| 1429 | uvalue = byte_get (data, 4); |
| 1430 | block_start = data + 4; |
| 1431 | if (do_loc) |
| 1432 | data = block_start + uvalue; |
| 1433 | else |
| 1434 | data = display_block (block_start, uvalue); |
| 1435 | break; |
| 1436 | |
| 1437 | case DW_FORM_strp: |
| 1438 | if (!do_loc) |
| 1439 | printf (_(" (indirect string, offset: 0x%s): %s"), |
| 1440 | dwarf_vmatoa ("x", uvalue), |
| 1441 | fetch_indirect_string (uvalue)); |
| 1442 | break; |
| 1443 | |
| 1444 | case DW_FORM_indirect: |
| 1445 | /* Handled above. */ |
| 1446 | break; |
| 1447 | |
| 1448 | case DW_FORM_ref_sig8: |
| 1449 | if (!do_loc) |
| 1450 | { |
| 1451 | int i; |
| 1452 | printf (" signature: "); |
| 1453 | for (i = 0; i < 8; i++) |
| 1454 | { |
| 1455 | printf ("%02x", (unsigned) byte_get (data, 1)); |
| 1456 | data += 1; |
| 1457 | } |
| 1458 | } |
| 1459 | else |
| 1460 | data += 8; |
| 1461 | break; |
| 1462 | |
| 1463 | default: |
| 1464 | warn (_("Unrecognized form: %lu\n"), form); |
| 1465 | break; |
| 1466 | } |
| 1467 | |
| 1468 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 1469 | && num_debug_info_entries == 0 |
| 1470 | && debug_info_p != NULL) |
| 1471 | { |
| 1472 | switch (attribute) |
| 1473 | { |
| 1474 | case DW_AT_frame_base: |
| 1475 | have_frame_base = 1; |
| 1476 | case DW_AT_location: |
| 1477 | case DW_AT_string_length: |
| 1478 | case DW_AT_return_addr: |
| 1479 | case DW_AT_data_member_location: |
| 1480 | case DW_AT_vtable_elem_location: |
| 1481 | case DW_AT_segment: |
| 1482 | case DW_AT_static_link: |
| 1483 | case DW_AT_use_location: |
| 1484 | case DW_AT_GNU_call_site_value: |
| 1485 | case DW_AT_GNU_call_site_data_value: |
| 1486 | case DW_AT_GNU_call_site_target: |
| 1487 | case DW_AT_GNU_call_site_target_clobbered: |
| 1488 | if ((dwarf_version < 4 |
| 1489 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 1490 | || form == DW_FORM_sec_offset) |
| 1491 | { |
| 1492 | /* Process location list. */ |
| 1493 | unsigned int lmax = debug_info_p->max_loc_offsets; |
| 1494 | unsigned int num = debug_info_p->num_loc_offsets; |
| 1495 | |
| 1496 | if (lmax == 0 || num >= lmax) |
| 1497 | { |
| 1498 | lmax += 1024; |
| 1499 | debug_info_p->loc_offsets = (dwarf_vma *) |
| 1500 | xcrealloc (debug_info_p->loc_offsets, |
| 1501 | lmax, sizeof (*debug_info_p->loc_offsets)); |
| 1502 | debug_info_p->have_frame_base = (int *) |
| 1503 | xcrealloc (debug_info_p->have_frame_base, |
| 1504 | lmax, sizeof (*debug_info_p->have_frame_base)); |
| 1505 | debug_info_p->max_loc_offsets = lmax; |
| 1506 | } |
| 1507 | debug_info_p->loc_offsets [num] = uvalue; |
| 1508 | debug_info_p->have_frame_base [num] = have_frame_base; |
| 1509 | debug_info_p->num_loc_offsets++; |
| 1510 | } |
| 1511 | break; |
| 1512 | |
| 1513 | case DW_AT_low_pc: |
| 1514 | if (need_base_address) |
| 1515 | debug_info_p->base_address = uvalue; |
| 1516 | break; |
| 1517 | |
| 1518 | case DW_AT_ranges: |
| 1519 | if ((dwarf_version < 4 |
| 1520 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 1521 | || form == DW_FORM_sec_offset) |
| 1522 | { |
| 1523 | /* Process range list. */ |
| 1524 | unsigned int lmax = debug_info_p->max_range_lists; |
| 1525 | unsigned int num = debug_info_p->num_range_lists; |
| 1526 | |
| 1527 | if (lmax == 0 || num >= lmax) |
| 1528 | { |
| 1529 | lmax += 1024; |
| 1530 | debug_info_p->range_lists = (dwarf_vma *) |
| 1531 | xcrealloc (debug_info_p->range_lists, |
| 1532 | lmax, sizeof (*debug_info_p->range_lists)); |
| 1533 | debug_info_p->max_range_lists = lmax; |
| 1534 | } |
| 1535 | debug_info_p->range_lists [num] = uvalue; |
| 1536 | debug_info_p->num_range_lists++; |
| 1537 | } |
| 1538 | break; |
| 1539 | |
| 1540 | default: |
| 1541 | break; |
| 1542 | } |
| 1543 | } |
| 1544 | |
| 1545 | if (do_loc || attribute == 0) |
| 1546 | return data; |
| 1547 | |
| 1548 | /* For some attributes we can display further information. */ |
| 1549 | printf ("\t"); |
| 1550 | |
| 1551 | switch (attribute) |
| 1552 | { |
| 1553 | case DW_AT_inline: |
| 1554 | switch (uvalue) |
| 1555 | { |
| 1556 | case DW_INL_not_inlined: |
| 1557 | printf (_("(not inlined)")); |
| 1558 | break; |
| 1559 | case DW_INL_inlined: |
| 1560 | printf (_("(inlined)")); |
| 1561 | break; |
| 1562 | case DW_INL_declared_not_inlined: |
| 1563 | printf (_("(declared as inline but ignored)")); |
| 1564 | break; |
| 1565 | case DW_INL_declared_inlined: |
| 1566 | printf (_("(declared as inline and inlined)")); |
| 1567 | break; |
| 1568 | default: |
| 1569 | printf (_(" (Unknown inline attribute value: %s)"), |
| 1570 | dwarf_vmatoa ("x", uvalue)); |
| 1571 | break; |
| 1572 | } |
| 1573 | break; |
| 1574 | |
| 1575 | case DW_AT_language: |
| 1576 | switch (uvalue) |
| 1577 | { |
| 1578 | /* Ordered by the numeric value of these constants. */ |
| 1579 | case DW_LANG_C89: printf ("(ANSI C)"); break; |
| 1580 | case DW_LANG_C: printf ("(non-ANSI C)"); break; |
| 1581 | case DW_LANG_Ada83: printf ("(Ada)"); break; |
| 1582 | case DW_LANG_C_plus_plus: printf ("(C++)"); break; |
| 1583 | case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; |
| 1584 | case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; |
| 1585 | case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; |
| 1586 | case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; |
| 1587 | case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; |
| 1588 | case DW_LANG_Modula2: printf ("(Modula 2)"); break; |
| 1589 | /* DWARF 2.1 values. */ |
| 1590 | case DW_LANG_Java: printf ("(Java)"); break; |
| 1591 | case DW_LANG_C99: printf ("(ANSI C99)"); break; |
| 1592 | case DW_LANG_Ada95: printf ("(ADA 95)"); break; |
| 1593 | case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; |
| 1594 | /* DWARF 3 values. */ |
| 1595 | case DW_LANG_PLI: printf ("(PLI)"); break; |
| 1596 | case DW_LANG_ObjC: printf ("(Objective C)"); break; |
| 1597 | case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; |
| 1598 | case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; |
| 1599 | case DW_LANG_D: printf ("(D)"); break; |
| 1600 | /* DWARF 4 values. */ |
| 1601 | case DW_LANG_Python: printf ("(Python)"); break; |
| 1602 | /* DWARF 5 values. */ |
| 1603 | case DW_LANG_Go: printf ("(Go)"); break; |
| 1604 | /* MIPS extension. */ |
| 1605 | case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; |
| 1606 | /* UPC extension. */ |
| 1607 | case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; |
| 1608 | default: |
| 1609 | if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) |
| 1610 | printf (_("(implementation defined: %s)"), |
| 1611 | dwarf_vmatoa ("x", uvalue)); |
| 1612 | else |
| 1613 | printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue)); |
| 1614 | break; |
| 1615 | } |
| 1616 | break; |
| 1617 | |
| 1618 | case DW_AT_encoding: |
| 1619 | switch (uvalue) |
| 1620 | { |
| 1621 | case DW_ATE_void: printf ("(void)"); break; |
| 1622 | case DW_ATE_address: printf ("(machine address)"); break; |
| 1623 | case DW_ATE_boolean: printf ("(boolean)"); break; |
| 1624 | case DW_ATE_complex_float: printf ("(complex float)"); break; |
| 1625 | case DW_ATE_float: printf ("(float)"); break; |
| 1626 | case DW_ATE_signed: printf ("(signed)"); break; |
| 1627 | case DW_ATE_signed_char: printf ("(signed char)"); break; |
| 1628 | case DW_ATE_unsigned: printf ("(unsigned)"); break; |
| 1629 | case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; |
| 1630 | /* DWARF 2.1 values: */ |
| 1631 | case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; |
| 1632 | case DW_ATE_decimal_float: printf ("(decimal float)"); break; |
| 1633 | /* DWARF 3 values: */ |
| 1634 | case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; |
| 1635 | case DW_ATE_numeric_string: printf ("(numeric_string)"); break; |
| 1636 | case DW_ATE_edited: printf ("(edited)"); break; |
| 1637 | case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; |
| 1638 | case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; |
| 1639 | /* HP extensions: */ |
| 1640 | case DW_ATE_HP_float80: printf ("(HP_float80)"); break; |
| 1641 | case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; |
| 1642 | case DW_ATE_HP_float128: printf ("(HP_float128)"); break; |
| 1643 | case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; |
| 1644 | case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; |
| 1645 | case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; |
| 1646 | case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; |
| 1647 | |
| 1648 | default: |
| 1649 | if (uvalue >= DW_ATE_lo_user |
| 1650 | && uvalue <= DW_ATE_hi_user) |
| 1651 | printf (_("(user defined type)")); |
| 1652 | else |
| 1653 | printf (_("(unknown type)")); |
| 1654 | break; |
| 1655 | } |
| 1656 | break; |
| 1657 | |
| 1658 | case DW_AT_accessibility: |
| 1659 | switch (uvalue) |
| 1660 | { |
| 1661 | case DW_ACCESS_public: printf ("(public)"); break; |
| 1662 | case DW_ACCESS_protected: printf ("(protected)"); break; |
| 1663 | case DW_ACCESS_private: printf ("(private)"); break; |
| 1664 | default: |
| 1665 | printf (_("(unknown accessibility)")); |
| 1666 | break; |
| 1667 | } |
| 1668 | break; |
| 1669 | |
| 1670 | case DW_AT_visibility: |
| 1671 | switch (uvalue) |
| 1672 | { |
| 1673 | case DW_VIS_local: printf ("(local)"); break; |
| 1674 | case DW_VIS_exported: printf ("(exported)"); break; |
| 1675 | case DW_VIS_qualified: printf ("(qualified)"); break; |
| 1676 | default: printf (_("(unknown visibility)")); break; |
| 1677 | } |
| 1678 | break; |
| 1679 | |
| 1680 | case DW_AT_virtuality: |
| 1681 | switch (uvalue) |
| 1682 | { |
| 1683 | case DW_VIRTUALITY_none: printf ("(none)"); break; |
| 1684 | case DW_VIRTUALITY_virtual: printf ("(virtual)"); break; |
| 1685 | case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break; |
| 1686 | default: printf (_("(unknown virtuality)")); break; |
| 1687 | } |
| 1688 | break; |
| 1689 | |
| 1690 | case DW_AT_identifier_case: |
| 1691 | switch (uvalue) |
| 1692 | { |
| 1693 | case DW_ID_case_sensitive: printf ("(case_sensitive)"); break; |
| 1694 | case DW_ID_up_case: printf ("(up_case)"); break; |
| 1695 | case DW_ID_down_case: printf ("(down_case)"); break; |
| 1696 | case DW_ID_case_insensitive: printf ("(case_insensitive)"); break; |
| 1697 | default: printf (_("(unknown case)")); break; |
| 1698 | } |
| 1699 | break; |
| 1700 | |
| 1701 | case DW_AT_calling_convention: |
| 1702 | switch (uvalue) |
| 1703 | { |
| 1704 | case DW_CC_normal: printf ("(normal)"); break; |
| 1705 | case DW_CC_program: printf ("(program)"); break; |
| 1706 | case DW_CC_nocall: printf ("(nocall)"); break; |
| 1707 | default: |
| 1708 | if (uvalue >= DW_CC_lo_user |
| 1709 | && uvalue <= DW_CC_hi_user) |
| 1710 | printf (_("(user defined)")); |
| 1711 | else |
| 1712 | printf (_("(unknown convention)")); |
| 1713 | } |
| 1714 | break; |
| 1715 | |
| 1716 | case DW_AT_ordering: |
| 1717 | switch (uvalue) |
| 1718 | { |
| 1719 | case -1: printf (_("(undefined)")); break; |
| 1720 | case 0: printf ("(row major)"); break; |
| 1721 | case 1: printf ("(column major)"); break; |
| 1722 | } |
| 1723 | break; |
| 1724 | |
| 1725 | case DW_AT_frame_base: |
| 1726 | have_frame_base = 1; |
| 1727 | case DW_AT_location: |
| 1728 | case DW_AT_string_length: |
| 1729 | case DW_AT_return_addr: |
| 1730 | case DW_AT_data_member_location: |
| 1731 | case DW_AT_vtable_elem_location: |
| 1732 | case DW_AT_segment: |
| 1733 | case DW_AT_static_link: |
| 1734 | case DW_AT_use_location: |
| 1735 | case DW_AT_GNU_call_site_value: |
| 1736 | case DW_AT_GNU_call_site_data_value: |
| 1737 | case DW_AT_GNU_call_site_target: |
| 1738 | case DW_AT_GNU_call_site_target_clobbered: |
| 1739 | if ((dwarf_version < 4 |
| 1740 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 1741 | || form == DW_FORM_sec_offset) |
| 1742 | printf (_("(location list)")); |
| 1743 | /* Fall through. */ |
| 1744 | case DW_AT_allocated: |
| 1745 | case DW_AT_associated: |
| 1746 | case DW_AT_data_location: |
| 1747 | case DW_AT_stride: |
| 1748 | case DW_AT_upper_bound: |
| 1749 | case DW_AT_lower_bound: |
| 1750 | if (block_start) |
| 1751 | { |
| 1752 | int need_frame_base; |
| 1753 | |
| 1754 | printf ("("); |
| 1755 | need_frame_base = decode_location_expression (block_start, |
| 1756 | pointer_size, |
| 1757 | offset_size, |
| 1758 | dwarf_version, |
| 1759 | uvalue, |
| 1760 | cu_offset, section); |
| 1761 | printf (")"); |
| 1762 | if (need_frame_base && !have_frame_base) |
| 1763 | printf (_(" [without DW_AT_frame_base]")); |
| 1764 | } |
| 1765 | break; |
| 1766 | |
| 1767 | case DW_AT_import: |
| 1768 | { |
| 1769 | if (form == DW_FORM_ref_sig8) |
| 1770 | break; |
| 1771 | |
| 1772 | if (form == DW_FORM_ref1 |
| 1773 | || form == DW_FORM_ref2 |
| 1774 | || form == DW_FORM_ref4 |
| 1775 | || form == DW_FORM_ref_udata) |
| 1776 | uvalue += cu_offset; |
| 1777 | |
| 1778 | if (uvalue >= section->size) |
| 1779 | warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"), |
| 1780 | dwarf_vmatoa ("x", uvalue), |
| 1781 | (unsigned long) (orig_data - section->start)); |
| 1782 | else |
| 1783 | { |
| 1784 | unsigned long abbrev_number; |
| 1785 | abbrev_entry * entry; |
| 1786 | |
| 1787 | abbrev_number = read_leb128 (section->start + uvalue, NULL, 0); |
| 1788 | |
| 1789 | printf (_("[Abbrev Number: %ld"), abbrev_number); |
| 1790 | for (entry = first_abbrev; entry != NULL; entry = entry->next) |
| 1791 | if (entry->entry == abbrev_number) |
| 1792 | break; |
| 1793 | if (entry != NULL) |
| 1794 | printf (" (%s)", get_TAG_name (entry->tag)); |
| 1795 | printf ("]"); |
| 1796 | } |
| 1797 | } |
| 1798 | break; |
| 1799 | |
| 1800 | default: |
| 1801 | break; |
| 1802 | } |
| 1803 | |
| 1804 | return data; |
| 1805 | } |
| 1806 | |
| 1807 | static char * |
| 1808 | get_AT_name (unsigned long attribute) |
| 1809 | { |
| 1810 | switch (attribute) |
| 1811 | { |
| 1812 | case DW_AT_sibling: return "DW_AT_sibling"; |
| 1813 | case DW_AT_location: return "DW_AT_location"; |
| 1814 | case DW_AT_name: return "DW_AT_name"; |
| 1815 | case DW_AT_ordering: return "DW_AT_ordering"; |
| 1816 | case DW_AT_subscr_data: return "DW_AT_subscr_data"; |
| 1817 | case DW_AT_byte_size: return "DW_AT_byte_size"; |
| 1818 | case DW_AT_bit_offset: return "DW_AT_bit_offset"; |
| 1819 | case DW_AT_bit_size: return "DW_AT_bit_size"; |
| 1820 | case DW_AT_element_list: return "DW_AT_element_list"; |
| 1821 | case DW_AT_stmt_list: return "DW_AT_stmt_list"; |
| 1822 | case DW_AT_low_pc: return "DW_AT_low_pc"; |
| 1823 | case DW_AT_high_pc: return "DW_AT_high_pc"; |
| 1824 | case DW_AT_language: return "DW_AT_language"; |
| 1825 | case DW_AT_member: return "DW_AT_member"; |
| 1826 | case DW_AT_discr: return "DW_AT_discr"; |
| 1827 | case DW_AT_discr_value: return "DW_AT_discr_value"; |
| 1828 | case DW_AT_visibility: return "DW_AT_visibility"; |
| 1829 | case DW_AT_import: return "DW_AT_import"; |
| 1830 | case DW_AT_string_length: return "DW_AT_string_length"; |
| 1831 | case DW_AT_common_reference: return "DW_AT_common_reference"; |
| 1832 | case DW_AT_comp_dir: return "DW_AT_comp_dir"; |
| 1833 | case DW_AT_const_value: return "DW_AT_const_value"; |
| 1834 | case DW_AT_containing_type: return "DW_AT_containing_type"; |
| 1835 | case DW_AT_default_value: return "DW_AT_default_value"; |
| 1836 | case DW_AT_inline: return "DW_AT_inline"; |
| 1837 | case DW_AT_is_optional: return "DW_AT_is_optional"; |
| 1838 | case DW_AT_lower_bound: return "DW_AT_lower_bound"; |
| 1839 | case DW_AT_producer: return "DW_AT_producer"; |
| 1840 | case DW_AT_prototyped: return "DW_AT_prototyped"; |
| 1841 | case DW_AT_return_addr: return "DW_AT_return_addr"; |
| 1842 | case DW_AT_start_scope: return "DW_AT_start_scope"; |
| 1843 | case DW_AT_stride_size: return "DW_AT_stride_size"; |
| 1844 | case DW_AT_upper_bound: return "DW_AT_upper_bound"; |
| 1845 | case DW_AT_abstract_origin: return "DW_AT_abstract_origin"; |
| 1846 | case DW_AT_accessibility: return "DW_AT_accessibility"; |
| 1847 | case DW_AT_address_class: return "DW_AT_address_class"; |
| 1848 | case DW_AT_artificial: return "DW_AT_artificial"; |
| 1849 | case DW_AT_base_types: return "DW_AT_base_types"; |
| 1850 | case DW_AT_calling_convention: return "DW_AT_calling_convention"; |
| 1851 | case DW_AT_count: return "DW_AT_count"; |
| 1852 | case DW_AT_data_member_location: return "DW_AT_data_member_location"; |
| 1853 | case DW_AT_decl_column: return "DW_AT_decl_column"; |
| 1854 | case DW_AT_decl_file: return "DW_AT_decl_file"; |
| 1855 | case DW_AT_decl_line: return "DW_AT_decl_line"; |
| 1856 | case DW_AT_declaration: return "DW_AT_declaration"; |
| 1857 | case DW_AT_discr_list: return "DW_AT_discr_list"; |
| 1858 | case DW_AT_encoding: return "DW_AT_encoding"; |
| 1859 | case DW_AT_external: return "DW_AT_external"; |
| 1860 | case DW_AT_frame_base: return "DW_AT_frame_base"; |
| 1861 | case DW_AT_friend: return "DW_AT_friend"; |
| 1862 | case DW_AT_identifier_case: return "DW_AT_identifier_case"; |
| 1863 | case DW_AT_macro_info: return "DW_AT_macro_info"; |
| 1864 | case DW_AT_namelist_items: return "DW_AT_namelist_items"; |
| 1865 | case DW_AT_priority: return "DW_AT_priority"; |
| 1866 | case DW_AT_segment: return "DW_AT_segment"; |
| 1867 | case DW_AT_specification: return "DW_AT_specification"; |
| 1868 | case DW_AT_static_link: return "DW_AT_static_link"; |
| 1869 | case DW_AT_type: return "DW_AT_type"; |
| 1870 | case DW_AT_use_location: return "DW_AT_use_location"; |
| 1871 | case DW_AT_variable_parameter: return "DW_AT_variable_parameter"; |
| 1872 | case DW_AT_virtuality: return "DW_AT_virtuality"; |
| 1873 | case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location"; |
| 1874 | /* DWARF 2.1 values. */ |
| 1875 | case DW_AT_allocated: return "DW_AT_allocated"; |
| 1876 | case DW_AT_associated: return "DW_AT_associated"; |
| 1877 | case DW_AT_data_location: return "DW_AT_data_location"; |
| 1878 | case DW_AT_stride: return "DW_AT_stride"; |
| 1879 | case DW_AT_entry_pc: return "DW_AT_entry_pc"; |
| 1880 | case DW_AT_use_UTF8: return "DW_AT_use_UTF8"; |
| 1881 | case DW_AT_extension: return "DW_AT_extension"; |
| 1882 | case DW_AT_ranges: return "DW_AT_ranges"; |
| 1883 | case DW_AT_trampoline: return "DW_AT_trampoline"; |
| 1884 | case DW_AT_call_column: return "DW_AT_call_column"; |
| 1885 | case DW_AT_call_file: return "DW_AT_call_file"; |
| 1886 | case DW_AT_call_line: return "DW_AT_call_line"; |
| 1887 | case DW_AT_description: return "DW_AT_description"; |
| 1888 | case DW_AT_binary_scale: return "DW_AT_binary_scale"; |
| 1889 | case DW_AT_decimal_scale: return "DW_AT_decimal_scale"; |
| 1890 | case DW_AT_small: return "DW_AT_small"; |
| 1891 | case DW_AT_decimal_sign: return "DW_AT_decimal_sign"; |
| 1892 | case DW_AT_digit_count: return "DW_AT_digit_count"; |
| 1893 | case DW_AT_picture_string: return "DW_AT_picture_string"; |
| 1894 | case DW_AT_mutable: return "DW_AT_mutable"; |
| 1895 | case DW_AT_threads_scaled: return "DW_AT_threads_scaled"; |
| 1896 | case DW_AT_explicit: return "DW_AT_explicit"; |
| 1897 | case DW_AT_object_pointer: return "DW_AT_object_pointer"; |
| 1898 | case DW_AT_endianity: return "DW_AT_endianity"; |
| 1899 | case DW_AT_elemental: return "DW_AT_elemental"; |
| 1900 | case DW_AT_pure: return "DW_AT_pure"; |
| 1901 | case DW_AT_recursive: return "DW_AT_recursive"; |
| 1902 | /* DWARF 4 values. */ |
| 1903 | case DW_AT_signature: return "DW_AT_signature"; |
| 1904 | case DW_AT_main_subprogram: return "DW_AT_main_subprogram"; |
| 1905 | case DW_AT_data_bit_offset: return "DW_AT_data_bit_offset"; |
| 1906 | case DW_AT_const_expr: return "DW_AT_const_expr"; |
| 1907 | case DW_AT_enum_class: return "DW_AT_enum_class"; |
| 1908 | case DW_AT_linkage_name: return "DW_AT_linkage_name"; |
| 1909 | |
| 1910 | /* HP and SGI/MIPS extensions. */ |
| 1911 | case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin"; |
| 1912 | case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin"; |
| 1913 | case DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin"; |
| 1914 | case DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor"; |
| 1915 | case DW_AT_MIPS_software_pipeline_depth: return "DW_AT_MIPS_software_pipeline_depth"; |
| 1916 | case DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name"; |
| 1917 | case DW_AT_MIPS_stride: return "DW_AT_MIPS_stride"; |
| 1918 | case DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name"; |
| 1919 | case DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin"; |
| 1920 | case DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines"; |
| 1921 | |
| 1922 | /* HP Extensions. */ |
| 1923 | case DW_AT_HP_block_index: return "DW_AT_HP_block_index"; |
| 1924 | case DW_AT_HP_actuals_stmt_list: return "DW_AT_HP_actuals_stmt_list"; |
| 1925 | case DW_AT_HP_proc_per_section: return "DW_AT_HP_proc_per_section"; |
| 1926 | case DW_AT_HP_raw_data_ptr: return "DW_AT_HP_raw_data_ptr"; |
| 1927 | case DW_AT_HP_pass_by_reference: return "DW_AT_HP_pass_by_reference"; |
| 1928 | case DW_AT_HP_opt_level: return "DW_AT_HP_opt_level"; |
| 1929 | case DW_AT_HP_prof_version_id: return "DW_AT_HP_prof_version_id"; |
| 1930 | case DW_AT_HP_opt_flags: return "DW_AT_HP_opt_flags"; |
| 1931 | case DW_AT_HP_cold_region_low_pc: return "DW_AT_HP_cold_region_low_pc"; |
| 1932 | case DW_AT_HP_cold_region_high_pc: return "DW_AT_HP_cold_region_high_pc"; |
| 1933 | case DW_AT_HP_all_variables_modifiable: return "DW_AT_HP_all_variables_modifiable"; |
| 1934 | case DW_AT_HP_linkage_name: return "DW_AT_HP_linkage_name"; |
| 1935 | case DW_AT_HP_prof_flags: return "DW_AT_HP_prof_flags"; |
| 1936 | |
| 1937 | /* One value is shared by the MIPS and HP extensions: */ |
| 1938 | case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; |
| 1939 | |
| 1940 | /* GNU extensions. */ |
| 1941 | case DW_AT_sf_names: return "DW_AT_sf_names"; |
| 1942 | case DW_AT_src_info: return "DW_AT_src_info"; |
| 1943 | case DW_AT_mac_info: return "DW_AT_mac_info"; |
| 1944 | case DW_AT_src_coords: return "DW_AT_src_coords"; |
| 1945 | case DW_AT_body_begin: return "DW_AT_body_begin"; |
| 1946 | case DW_AT_body_end: return "DW_AT_body_end"; |
| 1947 | case DW_AT_GNU_vector: return "DW_AT_GNU_vector"; |
| 1948 | case DW_AT_GNU_guarded_by: return "DW_AT_GNU_guarded_by"; |
| 1949 | case DW_AT_GNU_pt_guarded_by: return "DW_AT_GNU_pt_guarded_by"; |
| 1950 | case DW_AT_GNU_guarded: return "DW_AT_GNU_guarded"; |
| 1951 | case DW_AT_GNU_pt_guarded: return "DW_AT_GNU_pt_guarded"; |
| 1952 | case DW_AT_GNU_locks_excluded: return "DW_AT_GNU_locks_excluded"; |
| 1953 | case DW_AT_GNU_exclusive_locks_required: return "DW_AT_GNU_exclusive_locks_required"; |
| 1954 | case DW_AT_GNU_shared_locks_required: return "DW_AT_GNU_shared_locks_required"; |
| 1955 | case DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature"; |
| 1956 | case DW_AT_use_GNAT_descriptive_type: return "DW_AT_use_GNAT_descriptive_type"; |
| 1957 | case DW_AT_GNAT_descriptive_type: return "DW_AT_GNAT_descriptive_type"; |
| 1958 | case DW_AT_GNU_call_site_value: return "DW_AT_GNU_call_site_value"; |
| 1959 | case DW_AT_GNU_call_site_data_value: return "DW_AT_GNU_call_site_data_value"; |
| 1960 | case DW_AT_GNU_call_site_target: return "DW_AT_GNU_call_site_target"; |
| 1961 | case DW_AT_GNU_call_site_target_clobbered: return "DW_AT_GNU_call_site_target_clobbered"; |
| 1962 | case DW_AT_GNU_tail_call: return "DW_AT_GNU_tail_call"; |
| 1963 | case DW_AT_GNU_all_tail_call_sites: return "DW_AT_GNU_all_tail_call_sites"; |
| 1964 | case DW_AT_GNU_all_call_sites: return "DW_AT_GNU_all_call_sites"; |
| 1965 | case DW_AT_GNU_all_source_call_sites: return "DW_AT_GNU_all_source_call_sites"; |
| 1966 | case DW_AT_GNU_macros: return "DW_AT_GNU_macros"; |
| 1967 | |
| 1968 | /* UPC extension. */ |
| 1969 | case DW_AT_upc_threads_scaled: return "DW_AT_upc_threads_scaled"; |
| 1970 | |
| 1971 | /* PGI (STMicroelectronics) extensions. */ |
| 1972 | case DW_AT_PGI_lbase: return "DW_AT_PGI_lbase"; |
| 1973 | case DW_AT_PGI_soffset: return "DW_AT_PGI_soffset"; |
| 1974 | case DW_AT_PGI_lstride: return "DW_AT_PGI_lstride"; |
| 1975 | |
| 1976 | default: |
| 1977 | { |
| 1978 | static char buffer[100]; |
| 1979 | |
| 1980 | snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), |
| 1981 | attribute); |
| 1982 | return buffer; |
| 1983 | } |
| 1984 | } |
| 1985 | } |
| 1986 | |
| 1987 | static unsigned char * |
| 1988 | read_and_display_attr (unsigned long attribute, |
| 1989 | unsigned long form, |
| 1990 | unsigned char * data, |
| 1991 | dwarf_vma cu_offset, |
| 1992 | dwarf_vma pointer_size, |
| 1993 | dwarf_vma offset_size, |
| 1994 | int dwarf_version, |
| 1995 | debug_info * debug_info_p, |
| 1996 | int do_loc, |
| 1997 | struct dwarf_section * section) |
| 1998 | { |
| 1999 | if (!do_loc) |
| 2000 | printf (" %-18s:", get_AT_name (attribute)); |
| 2001 | data = read_and_display_attr_value (attribute, form, data, cu_offset, |
| 2002 | pointer_size, offset_size, |
| 2003 | dwarf_version, debug_info_p, |
| 2004 | do_loc, section); |
| 2005 | if (!do_loc) |
| 2006 | printf ("\n"); |
| 2007 | return data; |
| 2008 | } |
| 2009 | |
| 2010 | |
| 2011 | /* Process the contents of a .debug_info section. If do_loc is non-zero |
| 2012 | then we are scanning for location lists and we do not want to display |
| 2013 | anything to the user. If do_types is non-zero, we are processing |
| 2014 | a .debug_types section instead of a .debug_info section. */ |
| 2015 | |
| 2016 | static int |
| 2017 | process_debug_info (struct dwarf_section *section, |
| 2018 | void *file, |
| 2019 | enum dwarf_section_display_enum abbrev_sec, |
| 2020 | int do_loc, |
| 2021 | int do_types) |
| 2022 | { |
| 2023 | unsigned char *start = section->start; |
| 2024 | unsigned char *end = start + section->size; |
| 2025 | unsigned char *section_begin; |
| 2026 | unsigned int unit; |
| 2027 | unsigned int num_units = 0; |
| 2028 | |
| 2029 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2030 | && num_debug_info_entries == 0 |
| 2031 | && ! do_types) |
| 2032 | { |
| 2033 | dwarf_vma length; |
| 2034 | |
| 2035 | /* First scan the section to get the number of comp units. */ |
| 2036 | for (section_begin = start, num_units = 0; section_begin < end; |
| 2037 | num_units ++) |
| 2038 | { |
| 2039 | /* Read the first 4 bytes. For a 32-bit DWARF section, this |
| 2040 | will be the length. For a 64-bit DWARF section, it'll be |
| 2041 | the escape code 0xffffffff followed by an 8 byte length. */ |
| 2042 | length = byte_get (section_begin, 4); |
| 2043 | |
| 2044 | if (length == 0xffffffff) |
| 2045 | { |
| 2046 | length = byte_get (section_begin + 4, 8); |
| 2047 | section_begin += length + 12; |
| 2048 | } |
| 2049 | else if (length >= 0xfffffff0 && length < 0xffffffff) |
| 2050 | { |
| 2051 | warn (_("Reserved length value (0x%s) found in section %s\n"), |
| 2052 | dwarf_vmatoa ("x", length), section->name); |
| 2053 | return 0; |
| 2054 | } |
| 2055 | else |
| 2056 | section_begin += length + 4; |
| 2057 | |
| 2058 | /* Negative values are illegal, they may even cause infinite |
| 2059 | looping. This can happen if we can't accurately apply |
| 2060 | relocations to an object file. */ |
| 2061 | if ((signed long) length <= 0) |
| 2062 | { |
| 2063 | warn (_("Corrupt unit length (0x%s) found in section %s\n"), |
| 2064 | dwarf_vmatoa ("x", length), section->name); |
| 2065 | return 0; |
| 2066 | } |
| 2067 | } |
| 2068 | |
| 2069 | if (num_units == 0) |
| 2070 | { |
| 2071 | error (_("No comp units in %s section ?"), section->name); |
| 2072 | return 0; |
| 2073 | } |
| 2074 | |
| 2075 | /* Then allocate an array to hold the information. */ |
| 2076 | debug_information = (debug_info *) cmalloc (num_units, |
| 2077 | sizeof (* debug_information)); |
| 2078 | if (debug_information == NULL) |
| 2079 | { |
| 2080 | error (_("Not enough memory for a debug info array of %u entries"), |
| 2081 | num_units); |
| 2082 | return 0; |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | if (!do_loc) |
| 2087 | { |
| 2088 | if (dwarf_start_die == 0) |
| 2089 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 2090 | |
| 2091 | load_debug_section (str, file); |
| 2092 | } |
| 2093 | |
| 2094 | load_debug_section (abbrev_sec, file); |
| 2095 | if (debug_displays [abbrev_sec].section.start == NULL) |
| 2096 | { |
| 2097 | warn (_("Unable to locate %s section!\n"), |
| 2098 | debug_displays [abbrev_sec].section.name); |
| 2099 | return 0; |
| 2100 | } |
| 2101 | |
| 2102 | for (section_begin = start, unit = 0; start < end; unit++) |
| 2103 | { |
| 2104 | DWARF2_Internal_CompUnit compunit; |
| 2105 | unsigned char *hdrptr; |
| 2106 | unsigned char *tags; |
| 2107 | int level, last_level, saved_level; |
| 2108 | dwarf_vma cu_offset; |
| 2109 | int offset_size; |
| 2110 | int initial_length_size; |
| 2111 | unsigned char signature[8] = { 0 }; |
| 2112 | dwarf_vma type_offset = 0; |
| 2113 | |
| 2114 | hdrptr = start; |
| 2115 | |
| 2116 | compunit.cu_length = byte_get (hdrptr, 4); |
| 2117 | hdrptr += 4; |
| 2118 | |
| 2119 | if (compunit.cu_length == 0xffffffff) |
| 2120 | { |
| 2121 | compunit.cu_length = byte_get (hdrptr, 8); |
| 2122 | hdrptr += 8; |
| 2123 | offset_size = 8; |
| 2124 | initial_length_size = 12; |
| 2125 | } |
| 2126 | else |
| 2127 | { |
| 2128 | offset_size = 4; |
| 2129 | initial_length_size = 4; |
| 2130 | } |
| 2131 | |
| 2132 | compunit.cu_version = byte_get (hdrptr, 2); |
| 2133 | hdrptr += 2; |
| 2134 | |
| 2135 | cu_offset = start - section_begin; |
| 2136 | |
| 2137 | compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size); |
| 2138 | hdrptr += offset_size; |
| 2139 | |
| 2140 | compunit.cu_pointer_size = byte_get (hdrptr, 1); |
| 2141 | hdrptr += 1; |
| 2142 | |
| 2143 | if (do_types) |
| 2144 | { |
| 2145 | int i; |
| 2146 | |
| 2147 | for (i = 0; i < 8; i++) |
| 2148 | { |
| 2149 | signature[i] = byte_get (hdrptr, 1); |
| 2150 | hdrptr += 1; |
| 2151 | } |
| 2152 | |
| 2153 | type_offset = byte_get (hdrptr, offset_size); |
| 2154 | hdrptr += offset_size; |
| 2155 | } |
| 2156 | |
| 2157 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2158 | && num_debug_info_entries == 0 |
| 2159 | && ! do_types) |
| 2160 | { |
| 2161 | debug_information [unit].cu_offset = cu_offset; |
| 2162 | debug_information [unit].pointer_size |
| 2163 | = compunit.cu_pointer_size; |
| 2164 | debug_information [unit].offset_size = offset_size; |
| 2165 | debug_information [unit].dwarf_version = compunit.cu_version; |
| 2166 | debug_information [unit].base_address = 0; |
| 2167 | debug_information [unit].loc_offsets = NULL; |
| 2168 | debug_information [unit].have_frame_base = NULL; |
| 2169 | debug_information [unit].max_loc_offsets = 0; |
| 2170 | debug_information [unit].num_loc_offsets = 0; |
| 2171 | debug_information [unit].range_lists = NULL; |
| 2172 | debug_information [unit].max_range_lists= 0; |
| 2173 | debug_information [unit].num_range_lists = 0; |
| 2174 | } |
| 2175 | |
| 2176 | if (!do_loc && dwarf_start_die == 0) |
| 2177 | { |
| 2178 | printf (_(" Compilation Unit @ offset 0x%s:\n"), |
| 2179 | dwarf_vmatoa ("x", cu_offset)); |
| 2180 | printf (_(" Length: 0x%s (%s)\n"), |
| 2181 | dwarf_vmatoa ("x", compunit.cu_length), |
| 2182 | offset_size == 8 ? "64-bit" : "32-bit"); |
| 2183 | printf (_(" Version: %d\n"), compunit.cu_version); |
| 2184 | printf (_(" Abbrev Offset: %s\n"), |
| 2185 | dwarf_vmatoa ("d", compunit.cu_abbrev_offset)); |
| 2186 | printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size); |
| 2187 | if (do_types) |
| 2188 | { |
| 2189 | int i; |
| 2190 | printf (_(" Signature: ")); |
| 2191 | for (i = 0; i < 8; i++) |
| 2192 | printf ("%02x", signature[i]); |
| 2193 | printf ("\n"); |
| 2194 | printf (_(" Type Offset: 0x%s\n"), |
| 2195 | dwarf_vmatoa ("x", type_offset)); |
| 2196 | } |
| 2197 | } |
| 2198 | |
| 2199 | if (cu_offset + compunit.cu_length + initial_length_size |
| 2200 | > section->size) |
| 2201 | { |
| 2202 | warn (_("Debug info is corrupted, length of CU at %s" |
| 2203 | " extends beyond end of section (length = %s)\n"), |
| 2204 | dwarf_vmatoa ("x", cu_offset), |
| 2205 | dwarf_vmatoa ("x", compunit.cu_length)); |
| 2206 | break; |
| 2207 | } |
| 2208 | tags = hdrptr; |
| 2209 | start += compunit.cu_length + initial_length_size; |
| 2210 | |
| 2211 | if (compunit.cu_version != 2 |
| 2212 | && compunit.cu_version != 3 |
| 2213 | && compunit.cu_version != 4) |
| 2214 | { |
| 2215 | warn (_("CU at offset %s contains corrupt or " |
| 2216 | "unsupported version number: %d.\n"), |
| 2217 | dwarf_vmatoa ("x", cu_offset), compunit.cu_version); |
| 2218 | continue; |
| 2219 | } |
| 2220 | |
| 2221 | free_abbrevs (); |
| 2222 | |
| 2223 | /* Process the abbrevs used by this compilation unit. DWARF |
| 2224 | sections under Mach-O have non-zero addresses. */ |
| 2225 | if (compunit.cu_abbrev_offset >= debug_displays [abbrev_sec].section.size) |
| 2226 | warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"), |
| 2227 | (unsigned long) compunit.cu_abbrev_offset, |
| 2228 | (unsigned long) debug_displays [abbrev_sec].section.size); |
| 2229 | else |
| 2230 | process_abbrev_section |
| 2231 | ((unsigned char *) debug_displays [abbrev_sec].section.start |
| 2232 | + compunit.cu_abbrev_offset, |
| 2233 | (unsigned char *) debug_displays [abbrev_sec].section.start |
| 2234 | + debug_displays [abbrev_sec].section.size); |
| 2235 | |
| 2236 | level = 0; |
| 2237 | last_level = level; |
| 2238 | saved_level = -1; |
| 2239 | while (tags < start) |
| 2240 | { |
| 2241 | unsigned int bytes_read; |
| 2242 | unsigned long abbrev_number; |
| 2243 | unsigned long die_offset; |
| 2244 | abbrev_entry *entry; |
| 2245 | abbrev_attr *attr; |
| 2246 | int do_printing = 1; |
| 2247 | |
| 2248 | die_offset = tags - section_begin; |
| 2249 | |
| 2250 | abbrev_number = read_leb128 (tags, & bytes_read, 0); |
| 2251 | tags += bytes_read; |
| 2252 | |
| 2253 | /* A null DIE marks the end of a list of siblings or it may also be |
| 2254 | a section padding. */ |
| 2255 | if (abbrev_number == 0) |
| 2256 | { |
| 2257 | /* Check if it can be a section padding for the last CU. */ |
| 2258 | if (level == 0 && start == end) |
| 2259 | { |
| 2260 | unsigned char *chk; |
| 2261 | |
| 2262 | for (chk = tags; chk < start; chk++) |
| 2263 | if (*chk != 0) |
| 2264 | break; |
| 2265 | if (chk == start) |
| 2266 | break; |
| 2267 | } |
| 2268 | |
| 2269 | --level; |
| 2270 | if (level < 0) |
| 2271 | { |
| 2272 | static unsigned num_bogus_warns = 0; |
| 2273 | |
| 2274 | if (num_bogus_warns < 3) |
| 2275 | { |
| 2276 | warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"), |
| 2277 | die_offset); |
| 2278 | num_bogus_warns ++; |
| 2279 | if (num_bogus_warns == 3) |
| 2280 | warn (_("Further warnings about bogus end-of-sibling markers suppressed\n")); |
| 2281 | } |
| 2282 | } |
| 2283 | if (dwarf_start_die != 0 && level < saved_level) |
| 2284 | return 1; |
| 2285 | continue; |
| 2286 | } |
| 2287 | |
| 2288 | if (!do_loc) |
| 2289 | { |
| 2290 | if (dwarf_start_die != 0 && die_offset < dwarf_start_die) |
| 2291 | do_printing = 0; |
| 2292 | else |
| 2293 | { |
| 2294 | if (dwarf_start_die != 0 && die_offset == dwarf_start_die) |
| 2295 | saved_level = level; |
| 2296 | do_printing = (dwarf_cutoff_level == -1 |
| 2297 | || level < dwarf_cutoff_level); |
| 2298 | if (do_printing) |
| 2299 | printf (_(" <%d><%lx>: Abbrev Number: %lu"), |
| 2300 | level, die_offset, abbrev_number); |
| 2301 | else if (dwarf_cutoff_level == -1 |
| 2302 | || last_level < dwarf_cutoff_level) |
| 2303 | printf (_(" <%d><%lx>: ...\n"), level, die_offset); |
| 2304 | last_level = level; |
| 2305 | } |
| 2306 | } |
| 2307 | |
| 2308 | /* Scan through the abbreviation list until we reach the |
| 2309 | correct entry. */ |
| 2310 | for (entry = first_abbrev; |
| 2311 | entry && entry->entry != abbrev_number; |
| 2312 | entry = entry->next) |
| 2313 | continue; |
| 2314 | |
| 2315 | if (entry == NULL) |
| 2316 | { |
| 2317 | if (!do_loc && do_printing) |
| 2318 | { |
| 2319 | printf ("\n"); |
| 2320 | fflush (stdout); |
| 2321 | } |
| 2322 | warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"), |
| 2323 | die_offset, abbrev_number); |
| 2324 | return 0; |
| 2325 | } |
| 2326 | |
| 2327 | if (!do_loc && do_printing) |
| 2328 | printf (" (%s)\n", get_TAG_name (entry->tag)); |
| 2329 | |
| 2330 | switch (entry->tag) |
| 2331 | { |
| 2332 | default: |
| 2333 | need_base_address = 0; |
| 2334 | break; |
| 2335 | case DW_TAG_compile_unit: |
| 2336 | need_base_address = 1; |
| 2337 | break; |
| 2338 | case DW_TAG_entry_point: |
| 2339 | case DW_TAG_subprogram: |
| 2340 | need_base_address = 0; |
| 2341 | /* Assuming that there is no DW_AT_frame_base. */ |
| 2342 | have_frame_base = 0; |
| 2343 | break; |
| 2344 | } |
| 2345 | |
| 2346 | for (attr = entry->first_attr; attr; attr = attr->next) |
| 2347 | { |
| 2348 | debug_info *arg; |
| 2349 | |
| 2350 | if (! do_loc && do_printing) |
| 2351 | /* Show the offset from where the tag was extracted. */ |
| 2352 | printf (" <%lx>", (unsigned long)(tags - section_begin)); |
| 2353 | |
| 2354 | arg = debug_information; |
| 2355 | if (debug_information) |
| 2356 | arg += unit; |
| 2357 | |
| 2358 | tags = read_and_display_attr (attr->attribute, |
| 2359 | attr->form, |
| 2360 | tags, cu_offset, |
| 2361 | compunit.cu_pointer_size, |
| 2362 | offset_size, |
| 2363 | compunit.cu_version, |
| 2364 | arg, |
| 2365 | do_loc || ! do_printing, section); |
| 2366 | } |
| 2367 | |
| 2368 | if (entry->children) |
| 2369 | ++level; |
| 2370 | } |
| 2371 | } |
| 2372 | |
| 2373 | /* Set num_debug_info_entries here so that it can be used to check if |
| 2374 | we need to process .debug_loc and .debug_ranges sections. */ |
| 2375 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2376 | && num_debug_info_entries == 0 |
| 2377 | && ! do_types) |
| 2378 | num_debug_info_entries = num_units; |
| 2379 | |
| 2380 | if (!do_loc) |
| 2381 | printf ("\n"); |
| 2382 | |
| 2383 | return 1; |
| 2384 | } |
| 2385 | |
| 2386 | /* Locate and scan the .debug_info section in the file and record the pointer |
| 2387 | sizes and offsets for the compilation units in it. Usually an executable |
| 2388 | will have just one pointer size, but this is not guaranteed, and so we try |
| 2389 | not to make any assumptions. Returns zero upon failure, or the number of |
| 2390 | compilation units upon success. */ |
| 2391 | |
| 2392 | static unsigned int |
| 2393 | load_debug_info (void * file) |
| 2394 | { |
| 2395 | /* Reset the last pointer size so that we can issue correct error |
| 2396 | messages if we are displaying the contents of more than one section. */ |
| 2397 | last_pointer_size = 0; |
| 2398 | warned_about_missing_comp_units = FALSE; |
| 2399 | |
| 2400 | /* If we have already tried and failed to load the .debug_info |
| 2401 | section then do not bother to repear the task. */ |
| 2402 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
| 2403 | return 0; |
| 2404 | |
| 2405 | /* If we already have the information there is nothing else to do. */ |
| 2406 | if (num_debug_info_entries > 0) |
| 2407 | return num_debug_info_entries; |
| 2408 | |
| 2409 | if (load_debug_section (info, file) |
| 2410 | && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0)) |
| 2411 | return num_debug_info_entries; |
| 2412 | |
| 2413 | num_debug_info_entries = DEBUG_INFO_UNAVAILABLE; |
| 2414 | return 0; |
| 2415 | } |
| 2416 | |
| 2417 | static int |
| 2418 | display_debug_lines_raw (struct dwarf_section *section, |
| 2419 | unsigned char *data, |
| 2420 | unsigned char *end) |
| 2421 | { |
| 2422 | unsigned char *start = section->start; |
| 2423 | |
| 2424 | printf (_("Raw dump of debug contents of section %s:\n\n"), |
| 2425 | section->name); |
| 2426 | |
| 2427 | while (data < end) |
| 2428 | { |
| 2429 | DWARF2_Internal_LineInfo linfo; |
| 2430 | unsigned char *standard_opcodes; |
| 2431 | unsigned char *end_of_sequence; |
| 2432 | unsigned char *hdrptr; |
| 2433 | unsigned long hdroff; |
| 2434 | int initial_length_size; |
| 2435 | int offset_size; |
| 2436 | int i; |
| 2437 | |
| 2438 | hdrptr = data; |
| 2439 | hdroff = hdrptr - start; |
| 2440 | |
| 2441 | /* Check the length of the block. */ |
| 2442 | linfo.li_length = byte_get (hdrptr, 4); |
| 2443 | hdrptr += 4; |
| 2444 | |
| 2445 | if (linfo.li_length == 0xffffffff) |
| 2446 | { |
| 2447 | /* This section is 64-bit DWARF 3. */ |
| 2448 | linfo.li_length = byte_get (hdrptr, 8); |
| 2449 | hdrptr += 8; |
| 2450 | offset_size = 8; |
| 2451 | initial_length_size = 12; |
| 2452 | } |
| 2453 | else |
| 2454 | { |
| 2455 | offset_size = 4; |
| 2456 | initial_length_size = 4; |
| 2457 | } |
| 2458 | |
| 2459 | if (linfo.li_length + initial_length_size > section->size) |
| 2460 | { |
| 2461 | warn |
| 2462 | (_("The information in section %s appears to be corrupt - the section is too small\n"), |
| 2463 | section->name); |
| 2464 | return 0; |
| 2465 | } |
| 2466 | |
| 2467 | /* Check its version number. */ |
| 2468 | linfo.li_version = byte_get (hdrptr, 2); |
| 2469 | hdrptr += 2; |
| 2470 | if (linfo.li_version != 2 |
| 2471 | && linfo.li_version != 3 |
| 2472 | && linfo.li_version != 4) |
| 2473 | { |
| 2474 | warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n")); |
| 2475 | return 0; |
| 2476 | } |
| 2477 | |
| 2478 | linfo.li_prologue_length = byte_get (hdrptr, offset_size); |
| 2479 | hdrptr += offset_size; |
| 2480 | linfo.li_min_insn_length = byte_get (hdrptr, 1); |
| 2481 | hdrptr++; |
| 2482 | if (linfo.li_version >= 4) |
| 2483 | { |
| 2484 | linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); |
| 2485 | hdrptr++; |
| 2486 | if (linfo.li_max_ops_per_insn == 0) |
| 2487 | { |
| 2488 | warn (_("Invalid maximum operations per insn.\n")); |
| 2489 | return 0; |
| 2490 | } |
| 2491 | } |
| 2492 | else |
| 2493 | linfo.li_max_ops_per_insn = 1; |
| 2494 | linfo.li_default_is_stmt = byte_get (hdrptr, 1); |
| 2495 | hdrptr++; |
| 2496 | linfo.li_line_base = byte_get (hdrptr, 1); |
| 2497 | hdrptr++; |
| 2498 | linfo.li_line_range = byte_get (hdrptr, 1); |
| 2499 | hdrptr++; |
| 2500 | linfo.li_opcode_base = byte_get (hdrptr, 1); |
| 2501 | hdrptr++; |
| 2502 | |
| 2503 | /* Sign extend the line base field. */ |
| 2504 | linfo.li_line_base <<= 24; |
| 2505 | linfo.li_line_base >>= 24; |
| 2506 | |
| 2507 | printf (_(" Offset: 0x%lx\n"), hdroff); |
| 2508 | printf (_(" Length: %ld\n"), (long) linfo.li_length); |
| 2509 | printf (_(" DWARF Version: %d\n"), linfo.li_version); |
| 2510 | printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length); |
| 2511 | printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); |
| 2512 | if (linfo.li_version >= 4) |
| 2513 | printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); |
| 2514 | printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt); |
| 2515 | printf (_(" Line Base: %d\n"), linfo.li_line_base); |
| 2516 | printf (_(" Line Range: %d\n"), linfo.li_line_range); |
| 2517 | printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); |
| 2518 | |
| 2519 | end_of_sequence = data + linfo.li_length + initial_length_size; |
| 2520 | |
| 2521 | reset_state_machine (linfo.li_default_is_stmt); |
| 2522 | |
| 2523 | /* Display the contents of the Opcodes table. */ |
| 2524 | standard_opcodes = hdrptr; |
| 2525 | |
| 2526 | printf (_("\n Opcodes:\n")); |
| 2527 | |
| 2528 | for (i = 1; i < linfo.li_opcode_base; i++) |
| 2529 | printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]); |
| 2530 | |
| 2531 | /* Display the contents of the Directory table. */ |
| 2532 | data = standard_opcodes + linfo.li_opcode_base - 1; |
| 2533 | |
| 2534 | if (*data == 0) |
| 2535 | printf (_("\n The Directory Table is empty.\n")); |
| 2536 | else |
| 2537 | { |
| 2538 | printf (_("\n The Directory Table:\n")); |
| 2539 | |
| 2540 | while (*data != 0) |
| 2541 | { |
| 2542 | printf (" %s\n", data); |
| 2543 | |
| 2544 | data += strlen ((char *) data) + 1; |
| 2545 | } |
| 2546 | } |
| 2547 | |
| 2548 | /* Skip the NUL at the end of the table. */ |
| 2549 | data++; |
| 2550 | |
| 2551 | /* Display the contents of the File Name table. */ |
| 2552 | if (*data == 0) |
| 2553 | printf (_("\n The File Name Table is empty.\n")); |
| 2554 | else |
| 2555 | { |
| 2556 | printf (_("\n The File Name Table:\n")); |
| 2557 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
| 2558 | |
| 2559 | while (*data != 0) |
| 2560 | { |
| 2561 | unsigned char *name; |
| 2562 | unsigned int bytes_read; |
| 2563 | |
| 2564 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
| 2565 | name = data; |
| 2566 | |
| 2567 | data += strlen ((char *) data) + 1; |
| 2568 | |
| 2569 | printf ("%s\t", |
| 2570 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 2571 | data += bytes_read; |
| 2572 | printf ("%s\t", |
| 2573 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 2574 | data += bytes_read; |
| 2575 | printf ("%s\t", |
| 2576 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
| 2577 | data += bytes_read; |
| 2578 | printf ("%s\n", name); |
| 2579 | } |
| 2580 | } |
| 2581 | |
| 2582 | /* Skip the NUL at the end of the table. */ |
| 2583 | data++; |
| 2584 | |
| 2585 | /* Now display the statements. */ |
| 2586 | printf (_("\n Line Number Statements:\n")); |
| 2587 | |
| 2588 | while (data < end_of_sequence) |
| 2589 | { |
| 2590 | unsigned char op_code; |
| 2591 | dwarf_signed_vma adv; |
| 2592 | dwarf_vma uladv; |
| 2593 | unsigned int bytes_read; |
| 2594 | |
| 2595 | op_code = *data++; |
| 2596 | |
| 2597 | if (op_code >= linfo.li_opcode_base) |
| 2598 | { |
| 2599 | op_code -= linfo.li_opcode_base; |
| 2600 | uladv = (op_code / linfo.li_line_range); |
| 2601 | if (linfo.li_max_ops_per_insn == 1) |
| 2602 | { |
| 2603 | uladv *= linfo.li_min_insn_length; |
| 2604 | state_machine_regs.address += uladv; |
| 2605 | printf (_(" Special opcode %d: " |
| 2606 | "advance Address by %s to 0x%s"), |
| 2607 | op_code, dwarf_vmatoa ("u", uladv), |
| 2608 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 2609 | } |
| 2610 | else |
| 2611 | { |
| 2612 | state_machine_regs.address |
| 2613 | += ((state_machine_regs.op_index + uladv) |
| 2614 | / linfo.li_max_ops_per_insn) |
| 2615 | * linfo.li_min_insn_length; |
| 2616 | state_machine_regs.op_index |
| 2617 | = (state_machine_regs.op_index + uladv) |
| 2618 | % linfo.li_max_ops_per_insn; |
| 2619 | printf (_(" Special opcode %d: " |
| 2620 | "advance Address by %s to 0x%s[%d]"), |
| 2621 | op_code, dwarf_vmatoa ("u", uladv), |
| 2622 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 2623 | state_machine_regs.op_index); |
| 2624 | } |
| 2625 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
| 2626 | state_machine_regs.line += adv; |
| 2627 | printf (_(" and Line by %s to %d\n"), |
| 2628 | dwarf_vmatoa ("d", adv), state_machine_regs.line); |
| 2629 | } |
| 2630 | else switch (op_code) |
| 2631 | { |
| 2632 | case DW_LNS_extended_op: |
| 2633 | data += process_extended_line_op (data, linfo.li_default_is_stmt); |
| 2634 | break; |
| 2635 | |
| 2636 | case DW_LNS_copy: |
| 2637 | printf (_(" Copy\n")); |
| 2638 | break; |
| 2639 | |
| 2640 | case DW_LNS_advance_pc: |
| 2641 | uladv = read_leb128 (data, & bytes_read, 0); |
| 2642 | data += bytes_read; |
| 2643 | if (linfo.li_max_ops_per_insn == 1) |
| 2644 | { |
| 2645 | uladv *= linfo.li_min_insn_length; |
| 2646 | state_machine_regs.address += uladv; |
| 2647 | printf (_(" Advance PC by %s to 0x%s\n"), |
| 2648 | dwarf_vmatoa ("u", uladv), |
| 2649 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 2650 | } |
| 2651 | else |
| 2652 | { |
| 2653 | state_machine_regs.address |
| 2654 | += ((state_machine_regs.op_index + uladv) |
| 2655 | / linfo.li_max_ops_per_insn) |
| 2656 | * linfo.li_min_insn_length; |
| 2657 | state_machine_regs.op_index |
| 2658 | = (state_machine_regs.op_index + uladv) |
| 2659 | % linfo.li_max_ops_per_insn; |
| 2660 | printf (_(" Advance PC by %s to 0x%s[%d]\n"), |
| 2661 | dwarf_vmatoa ("u", uladv), |
| 2662 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 2663 | state_machine_regs.op_index); |
| 2664 | } |
| 2665 | break; |
| 2666 | |
| 2667 | case DW_LNS_advance_line: |
| 2668 | adv = read_sleb128 (data, & bytes_read); |
| 2669 | data += bytes_read; |
| 2670 | state_machine_regs.line += adv; |
| 2671 | printf (_(" Advance Line by %s to %d\n"), |
| 2672 | dwarf_vmatoa ("d", adv), |
| 2673 | state_machine_regs.line); |
| 2674 | break; |
| 2675 | |
| 2676 | case DW_LNS_set_file: |
| 2677 | adv = read_leb128 (data, & bytes_read, 0); |
| 2678 | data += bytes_read; |
| 2679 | printf (_(" Set File Name to entry %s in the File Name Table\n"), |
| 2680 | dwarf_vmatoa ("d", adv)); |
| 2681 | state_machine_regs.file = adv; |
| 2682 | break; |
| 2683 | |
| 2684 | case DW_LNS_set_column: |
| 2685 | uladv = read_leb128 (data, & bytes_read, 0); |
| 2686 | data += bytes_read; |
| 2687 | printf (_(" Set column to %s\n"), |
| 2688 | dwarf_vmatoa ("u", uladv)); |
| 2689 | state_machine_regs.column = uladv; |
| 2690 | break; |
| 2691 | |
| 2692 | case DW_LNS_negate_stmt: |
| 2693 | adv = state_machine_regs.is_stmt; |
| 2694 | adv = ! adv; |
| 2695 | printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv)); |
| 2696 | state_machine_regs.is_stmt = adv; |
| 2697 | break; |
| 2698 | |
| 2699 | case DW_LNS_set_basic_block: |
| 2700 | printf (_(" Set basic block\n")); |
| 2701 | state_machine_regs.basic_block = 1; |
| 2702 | break; |
| 2703 | |
| 2704 | case DW_LNS_const_add_pc: |
| 2705 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
| 2706 | if (linfo.li_max_ops_per_insn) |
| 2707 | { |
| 2708 | uladv *= linfo.li_min_insn_length; |
| 2709 | state_machine_regs.address += uladv; |
| 2710 | printf (_(" Advance PC by constant %s to 0x%s\n"), |
| 2711 | dwarf_vmatoa ("u", uladv), |
| 2712 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 2713 | } |
| 2714 | else |
| 2715 | { |
| 2716 | state_machine_regs.address |
| 2717 | += ((state_machine_regs.op_index + uladv) |
| 2718 | / linfo.li_max_ops_per_insn) |
| 2719 | * linfo.li_min_insn_length; |
| 2720 | state_machine_regs.op_index |
| 2721 | = (state_machine_regs.op_index + uladv) |
| 2722 | % linfo.li_max_ops_per_insn; |
| 2723 | printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), |
| 2724 | dwarf_vmatoa ("u", uladv), |
| 2725 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 2726 | state_machine_regs.op_index); |
| 2727 | } |
| 2728 | break; |
| 2729 | |
| 2730 | case DW_LNS_fixed_advance_pc: |
| 2731 | uladv = byte_get (data, 2); |
| 2732 | data += 2; |
| 2733 | state_machine_regs.address += uladv; |
| 2734 | state_machine_regs.op_index = 0; |
| 2735 | printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), |
| 2736 | dwarf_vmatoa ("u", uladv), |
| 2737 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 2738 | break; |
| 2739 | |
| 2740 | case DW_LNS_set_prologue_end: |
| 2741 | printf (_(" Set prologue_end to true\n")); |
| 2742 | break; |
| 2743 | |
| 2744 | case DW_LNS_set_epilogue_begin: |
| 2745 | printf (_(" Set epilogue_begin to true\n")); |
| 2746 | break; |
| 2747 | |
| 2748 | case DW_LNS_set_isa: |
| 2749 | uladv = read_leb128 (data, & bytes_read, 0); |
| 2750 | data += bytes_read; |
| 2751 | printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); |
| 2752 | break; |
| 2753 | |
| 2754 | default: |
| 2755 | printf (_(" Unknown opcode %d with operands: "), op_code); |
| 2756 | |
| 2757 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) |
| 2758 | { |
| 2759 | printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, |
| 2760 | &bytes_read, 0)), |
| 2761 | i == 1 ? "" : ", "); |
| 2762 | data += bytes_read; |
| 2763 | } |
| 2764 | putchar ('\n'); |
| 2765 | break; |
| 2766 | } |
| 2767 | } |
| 2768 | putchar ('\n'); |
| 2769 | } |
| 2770 | |
| 2771 | return 1; |
| 2772 | } |
| 2773 | |
| 2774 | typedef struct |
| 2775 | { |
| 2776 | unsigned char *name; |
| 2777 | unsigned int directory_index; |
| 2778 | unsigned int modification_date; |
| 2779 | unsigned int length; |
| 2780 | } File_Entry; |
| 2781 | |
| 2782 | /* Output a decoded representation of the .debug_line section. */ |
| 2783 | |
| 2784 | static int |
| 2785 | display_debug_lines_decoded (struct dwarf_section *section, |
| 2786 | unsigned char *data, |
| 2787 | unsigned char *end) |
| 2788 | { |
| 2789 | printf (_("Decoded dump of debug contents of section %s:\n\n"), |
| 2790 | section->name); |
| 2791 | |
| 2792 | while (data < end) |
| 2793 | { |
| 2794 | /* This loop amounts to one iteration per compilation unit. */ |
| 2795 | DWARF2_Internal_LineInfo linfo; |
| 2796 | unsigned char *standard_opcodes; |
| 2797 | unsigned char *end_of_sequence; |
| 2798 | unsigned char *hdrptr; |
| 2799 | int initial_length_size; |
| 2800 | int offset_size; |
| 2801 | int i; |
| 2802 | File_Entry *file_table = NULL; |
| 2803 | unsigned char **directory_table = NULL; |
| 2804 | |
| 2805 | hdrptr = data; |
| 2806 | |
| 2807 | /* Extract information from the Line Number Program Header. |
| 2808 | (section 6.2.4 in the Dwarf3 doc). */ |
| 2809 | |
| 2810 | /* Get the length of this CU's line number information block. */ |
| 2811 | linfo.li_length = byte_get (hdrptr, 4); |
| 2812 | hdrptr += 4; |
| 2813 | |
| 2814 | if (linfo.li_length == 0xffffffff) |
| 2815 | { |
| 2816 | /* This section is 64-bit DWARF 3. */ |
| 2817 | linfo.li_length = byte_get (hdrptr, 8); |
| 2818 | hdrptr += 8; |
| 2819 | offset_size = 8; |
| 2820 | initial_length_size = 12; |
| 2821 | } |
| 2822 | else |
| 2823 | { |
| 2824 | offset_size = 4; |
| 2825 | initial_length_size = 4; |
| 2826 | } |
| 2827 | |
| 2828 | if (linfo.li_length + initial_length_size > section->size) |
| 2829 | { |
| 2830 | warn (_("The line info appears to be corrupt - " |
| 2831 | "the section is too small\n")); |
| 2832 | return 0; |
| 2833 | } |
| 2834 | |
| 2835 | /* Get this CU's Line Number Block version number. */ |
| 2836 | linfo.li_version = byte_get (hdrptr, 2); |
| 2837 | hdrptr += 2; |
| 2838 | if (linfo.li_version != 2 |
| 2839 | && linfo.li_version != 3 |
| 2840 | && linfo.li_version != 4) |
| 2841 | { |
| 2842 | warn (_("Only DWARF version 2, 3 and 4 line info is currently " |
| 2843 | "supported.\n")); |
| 2844 | return 0; |
| 2845 | } |
| 2846 | |
| 2847 | linfo.li_prologue_length = byte_get (hdrptr, offset_size); |
| 2848 | hdrptr += offset_size; |
| 2849 | linfo.li_min_insn_length = byte_get (hdrptr, 1); |
| 2850 | hdrptr++; |
| 2851 | if (linfo.li_version >= 4) |
| 2852 | { |
| 2853 | linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); |
| 2854 | hdrptr++; |
| 2855 | if (linfo.li_max_ops_per_insn == 0) |
| 2856 | { |
| 2857 | warn (_("Invalid maximum operations per insn.\n")); |
| 2858 | return 0; |
| 2859 | } |
| 2860 | } |
| 2861 | else |
| 2862 | linfo.li_max_ops_per_insn = 1; |
| 2863 | linfo.li_default_is_stmt = byte_get (hdrptr, 1); |
| 2864 | hdrptr++; |
| 2865 | linfo.li_line_base = byte_get (hdrptr, 1); |
| 2866 | hdrptr++; |
| 2867 | linfo.li_line_range = byte_get (hdrptr, 1); |
| 2868 | hdrptr++; |
| 2869 | linfo.li_opcode_base = byte_get (hdrptr, 1); |
| 2870 | hdrptr++; |
| 2871 | |
| 2872 | /* Sign extend the line base field. */ |
| 2873 | linfo.li_line_base <<= 24; |
| 2874 | linfo.li_line_base >>= 24; |
| 2875 | |
| 2876 | /* Find the end of this CU's Line Number Information Block. */ |
| 2877 | end_of_sequence = data + linfo.li_length + initial_length_size; |
| 2878 | |
| 2879 | reset_state_machine (linfo.li_default_is_stmt); |
| 2880 | |
| 2881 | /* Save a pointer to the contents of the Opcodes table. */ |
| 2882 | standard_opcodes = hdrptr; |
| 2883 | |
| 2884 | /* Traverse the Directory table just to count entries. */ |
| 2885 | data = standard_opcodes + linfo.li_opcode_base - 1; |
| 2886 | if (*data != 0) |
| 2887 | { |
| 2888 | unsigned int n_directories = 0; |
| 2889 | unsigned char *ptr_directory_table = data; |
| 2890 | |
| 2891 | while (*data != 0) |
| 2892 | { |
| 2893 | data += strlen ((char *) data) + 1; |
| 2894 | n_directories++; |
| 2895 | } |
| 2896 | |
| 2897 | /* Go through the directory table again to save the directories. */ |
| 2898 | directory_table = (unsigned char **) |
| 2899 | xmalloc (n_directories * sizeof (unsigned char *)); |
| 2900 | |
| 2901 | i = 0; |
| 2902 | while (*ptr_directory_table != 0) |
| 2903 | { |
| 2904 | directory_table[i] = ptr_directory_table; |
| 2905 | ptr_directory_table += strlen ((char *) ptr_directory_table) + 1; |
| 2906 | i++; |
| 2907 | } |
| 2908 | } |
| 2909 | /* Skip the NUL at the end of the table. */ |
| 2910 | data++; |
| 2911 | |
| 2912 | /* Traverse the File Name table just to count the entries. */ |
| 2913 | if (*data != 0) |
| 2914 | { |
| 2915 | unsigned int n_files = 0; |
| 2916 | unsigned char *ptr_file_name_table = data; |
| 2917 | |
| 2918 | while (*data != 0) |
| 2919 | { |
| 2920 | unsigned int bytes_read; |
| 2921 | |
| 2922 | /* Skip Name, directory index, last modification time and length |
| 2923 | of file. */ |
| 2924 | data += strlen ((char *) data) + 1; |
| 2925 | read_leb128 (data, & bytes_read, 0); |
| 2926 | data += bytes_read; |
| 2927 | read_leb128 (data, & bytes_read, 0); |
| 2928 | data += bytes_read; |
| 2929 | read_leb128 (data, & bytes_read, 0); |
| 2930 | data += bytes_read; |
| 2931 | |
| 2932 | n_files++; |
| 2933 | } |
| 2934 | |
| 2935 | /* Go through the file table again to save the strings. */ |
| 2936 | file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry)); |
| 2937 | |
| 2938 | i = 0; |
| 2939 | while (*ptr_file_name_table != 0) |
| 2940 | { |
| 2941 | unsigned int bytes_read; |
| 2942 | |
| 2943 | file_table[i].name = ptr_file_name_table; |
| 2944 | ptr_file_name_table += strlen ((char *) ptr_file_name_table) + 1; |
| 2945 | |
| 2946 | /* We are not interested in directory, time or size. */ |
| 2947 | file_table[i].directory_index = read_leb128 (ptr_file_name_table, |
| 2948 | & bytes_read, 0); |
| 2949 | ptr_file_name_table += bytes_read; |
| 2950 | file_table[i].modification_date = read_leb128 (ptr_file_name_table, |
| 2951 | & bytes_read, 0); |
| 2952 | ptr_file_name_table += bytes_read; |
| 2953 | file_table[i].length = read_leb128 (ptr_file_name_table, & bytes_read, 0); |
| 2954 | ptr_file_name_table += bytes_read; |
| 2955 | i++; |
| 2956 | } |
| 2957 | i = 0; |
| 2958 | |
| 2959 | /* Print the Compilation Unit's name and a header. */ |
| 2960 | if (directory_table == NULL) |
| 2961 | { |
| 2962 | printf (_("CU: %s:\n"), file_table[0].name); |
| 2963 | printf (_("File name Line number Starting address\n")); |
| 2964 | } |
| 2965 | else |
| 2966 | { |
| 2967 | unsigned int ix = file_table[0].directory_index; |
| 2968 | const char *directory = ix ? (char *)directory_table[ix - 1] : "."; |
| 2969 | if (do_wide || strlen (directory) < 76) |
| 2970 | printf (_("CU: %s/%s:\n"), directory, file_table[0].name); |
| 2971 | else |
| 2972 | printf ("%s:\n", file_table[0].name); |
| 2973 | |
| 2974 | printf (_("File name Line number Starting address\n")); |
| 2975 | } |
| 2976 | } |
| 2977 | |
| 2978 | /* Skip the NUL at the end of the table. */ |
| 2979 | data++; |
| 2980 | |
| 2981 | /* This loop iterates through the Dwarf Line Number Program. */ |
| 2982 | while (data < end_of_sequence) |
| 2983 | { |
| 2984 | unsigned char op_code; |
| 2985 | int adv; |
| 2986 | unsigned long int uladv; |
| 2987 | unsigned int bytes_read; |
| 2988 | int is_special_opcode = 0; |
| 2989 | |
| 2990 | op_code = *data++; |
| 2991 | |
| 2992 | if (op_code >= linfo.li_opcode_base) |
| 2993 | { |
| 2994 | op_code -= linfo.li_opcode_base; |
| 2995 | uladv = (op_code / linfo.li_line_range); |
| 2996 | if (linfo.li_max_ops_per_insn == 1) |
| 2997 | { |
| 2998 | uladv *= linfo.li_min_insn_length; |
| 2999 | state_machine_regs.address += uladv; |
| 3000 | } |
| 3001 | else |
| 3002 | { |
| 3003 | state_machine_regs.address |
| 3004 | += ((state_machine_regs.op_index + uladv) |
| 3005 | / linfo.li_max_ops_per_insn) |
| 3006 | * linfo.li_min_insn_length; |
| 3007 | state_machine_regs.op_index |
| 3008 | = (state_machine_regs.op_index + uladv) |
| 3009 | % linfo.li_max_ops_per_insn; |
| 3010 | } |
| 3011 | |
| 3012 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
| 3013 | state_machine_regs.line += adv; |
| 3014 | is_special_opcode = 1; |
| 3015 | } |
| 3016 | else switch (op_code) |
| 3017 | { |
| 3018 | case DW_LNS_extended_op: |
| 3019 | { |
| 3020 | unsigned int ext_op_code_len; |
| 3021 | unsigned char ext_op_code; |
| 3022 | unsigned char *op_code_data = data; |
| 3023 | |
| 3024 | ext_op_code_len = read_leb128 (op_code_data, &bytes_read, 0); |
| 3025 | op_code_data += bytes_read; |
| 3026 | |
| 3027 | if (ext_op_code_len == 0) |
| 3028 | { |
| 3029 | warn (_("badly formed extended line op encountered!\n")); |
| 3030 | break; |
| 3031 | } |
| 3032 | ext_op_code_len += bytes_read; |
| 3033 | ext_op_code = *op_code_data++; |
| 3034 | |
| 3035 | switch (ext_op_code) |
| 3036 | { |
| 3037 | case DW_LNE_end_sequence: |
| 3038 | reset_state_machine (linfo.li_default_is_stmt); |
| 3039 | break; |
| 3040 | case DW_LNE_set_address: |
| 3041 | state_machine_regs.address = |
| 3042 | byte_get (op_code_data, ext_op_code_len - bytes_read - 1); |
| 3043 | state_machine_regs.op_index = 0; |
| 3044 | break; |
| 3045 | case DW_LNE_define_file: |
| 3046 | { |
| 3047 | unsigned int dir_index = 0; |
| 3048 | |
| 3049 | ++state_machine_regs.last_file_entry; |
| 3050 | op_code_data += strlen ((char *) op_code_data) + 1; |
| 3051 | dir_index = read_leb128 (op_code_data, & bytes_read, 0); |
| 3052 | op_code_data += bytes_read; |
| 3053 | read_leb128 (op_code_data, & bytes_read, 0); |
| 3054 | op_code_data += bytes_read; |
| 3055 | read_leb128 (op_code_data, & bytes_read, 0); |
| 3056 | |
| 3057 | printf ("%s:\n", directory_table[dir_index]); |
| 3058 | break; |
| 3059 | } |
| 3060 | default: |
| 3061 | printf (_("UNKNOWN: length %d\n"), ext_op_code_len - bytes_read); |
| 3062 | break; |
| 3063 | } |
| 3064 | data += ext_op_code_len; |
| 3065 | break; |
| 3066 | } |
| 3067 | case DW_LNS_copy: |
| 3068 | break; |
| 3069 | |
| 3070 | case DW_LNS_advance_pc: |
| 3071 | uladv = read_leb128 (data, & bytes_read, 0); |
| 3072 | data += bytes_read; |
| 3073 | if (linfo.li_max_ops_per_insn == 1) |
| 3074 | { |
| 3075 | uladv *= linfo.li_min_insn_length; |
| 3076 | state_machine_regs.address += uladv; |
| 3077 | } |
| 3078 | else |
| 3079 | { |
| 3080 | state_machine_regs.address |
| 3081 | += ((state_machine_regs.op_index + uladv) |
| 3082 | / linfo.li_max_ops_per_insn) |
| 3083 | * linfo.li_min_insn_length; |
| 3084 | state_machine_regs.op_index |
| 3085 | = (state_machine_regs.op_index + uladv) |
| 3086 | % linfo.li_max_ops_per_insn; |
| 3087 | } |
| 3088 | break; |
| 3089 | |
| 3090 | case DW_LNS_advance_line: |
| 3091 | adv = read_sleb128 (data, & bytes_read); |
| 3092 | data += bytes_read; |
| 3093 | state_machine_regs.line += adv; |
| 3094 | break; |
| 3095 | |
| 3096 | case DW_LNS_set_file: |
| 3097 | adv = read_leb128 (data, & bytes_read, 0); |
| 3098 | data += bytes_read; |
| 3099 | state_machine_regs.file = adv; |
| 3100 | if (file_table[state_machine_regs.file - 1].directory_index == 0) |
| 3101 | { |
| 3102 | /* If directory index is 0, that means current directory. */ |
| 3103 | printf ("\n./%s:[++]\n", |
| 3104 | file_table[state_machine_regs.file - 1].name); |
| 3105 | } |
| 3106 | else |
| 3107 | { |
| 3108 | /* The directory index starts counting at 1. */ |
| 3109 | printf ("\n%s/%s:\n", |
| 3110 | directory_table[file_table[state_machine_regs.file - 1].directory_index - 1], |
| 3111 | file_table[state_machine_regs.file - 1].name); |
| 3112 | } |
| 3113 | break; |
| 3114 | |
| 3115 | case DW_LNS_set_column: |
| 3116 | uladv = read_leb128 (data, & bytes_read, 0); |
| 3117 | data += bytes_read; |
| 3118 | state_machine_regs.column = uladv; |
| 3119 | break; |
| 3120 | |
| 3121 | case DW_LNS_negate_stmt: |
| 3122 | adv = state_machine_regs.is_stmt; |
| 3123 | adv = ! adv; |
| 3124 | state_machine_regs.is_stmt = adv; |
| 3125 | break; |
| 3126 | |
| 3127 | case DW_LNS_set_basic_block: |
| 3128 | state_machine_regs.basic_block = 1; |
| 3129 | break; |
| 3130 | |
| 3131 | case DW_LNS_const_add_pc: |
| 3132 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
| 3133 | if (linfo.li_max_ops_per_insn == 1) |
| 3134 | { |
| 3135 | uladv *= linfo.li_min_insn_length; |
| 3136 | state_machine_regs.address += uladv; |
| 3137 | } |
| 3138 | else |
| 3139 | { |
| 3140 | state_machine_regs.address |
| 3141 | += ((state_machine_regs.op_index + uladv) |
| 3142 | / linfo.li_max_ops_per_insn) |
| 3143 | * linfo.li_min_insn_length; |
| 3144 | state_machine_regs.op_index |
| 3145 | = (state_machine_regs.op_index + uladv) |
| 3146 | % linfo.li_max_ops_per_insn; |
| 3147 | } |
| 3148 | break; |
| 3149 | |
| 3150 | case DW_LNS_fixed_advance_pc: |
| 3151 | uladv = byte_get (data, 2); |
| 3152 | data += 2; |
| 3153 | state_machine_regs.address += uladv; |
| 3154 | state_machine_regs.op_index = 0; |
| 3155 | break; |
| 3156 | |
| 3157 | case DW_LNS_set_prologue_end: |
| 3158 | break; |
| 3159 | |
| 3160 | case DW_LNS_set_epilogue_begin: |
| 3161 | break; |
| 3162 | |
| 3163 | case DW_LNS_set_isa: |
| 3164 | uladv = read_leb128 (data, & bytes_read, 0); |
| 3165 | data += bytes_read; |
| 3166 | printf (_(" Set ISA to %lu\n"), uladv); |
| 3167 | break; |
| 3168 | |
| 3169 | default: |
| 3170 | printf (_(" Unknown opcode %d with operands: "), op_code); |
| 3171 | |
| 3172 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) |
| 3173 | { |
| 3174 | printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, |
| 3175 | &bytes_read, 0)), |
| 3176 | i == 1 ? "" : ", "); |
| 3177 | data += bytes_read; |
| 3178 | } |
| 3179 | putchar ('\n'); |
| 3180 | break; |
| 3181 | } |
| 3182 | |
| 3183 | /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row |
| 3184 | to the DWARF address/line matrix. */ |
| 3185 | if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) |
| 3186 | || (op_code == DW_LNS_copy)) |
| 3187 | { |
| 3188 | const unsigned int MAX_FILENAME_LENGTH = 35; |
| 3189 | char *fileName = (char *)file_table[state_machine_regs.file - 1].name; |
| 3190 | char *newFileName = NULL; |
| 3191 | size_t fileNameLength = strlen (fileName); |
| 3192 | |
| 3193 | if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide)) |
| 3194 | { |
| 3195 | newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1); |
| 3196 | /* Truncate file name */ |
| 3197 | strncpy (newFileName, |
| 3198 | fileName + fileNameLength - MAX_FILENAME_LENGTH, |
| 3199 | MAX_FILENAME_LENGTH + 1); |
| 3200 | } |
| 3201 | else |
| 3202 | { |
| 3203 | newFileName = (char *) xmalloc (fileNameLength + 1); |
| 3204 | strncpy (newFileName, fileName, fileNameLength + 1); |
| 3205 | } |
| 3206 | |
| 3207 | if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) |
| 3208 | { |
| 3209 | if (linfo.li_max_ops_per_insn == 1) |
| 3210 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", |
| 3211 | newFileName, state_machine_regs.line, |
| 3212 | state_machine_regs.address); |
| 3213 | else |
| 3214 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
| 3215 | newFileName, state_machine_regs.line, |
| 3216 | state_machine_regs.address, |
| 3217 | state_machine_regs.op_index); |
| 3218 | } |
| 3219 | else |
| 3220 | { |
| 3221 | if (linfo.li_max_ops_per_insn == 1) |
| 3222 | printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", |
| 3223 | newFileName, state_machine_regs.line, |
| 3224 | state_machine_regs.address); |
| 3225 | else |
| 3226 | printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
| 3227 | newFileName, state_machine_regs.line, |
| 3228 | state_machine_regs.address, |
| 3229 | state_machine_regs.op_index); |
| 3230 | } |
| 3231 | |
| 3232 | if (op_code == DW_LNE_end_sequence) |
| 3233 | printf ("\n"); |
| 3234 | |
| 3235 | free (newFileName); |
| 3236 | } |
| 3237 | } |
| 3238 | free (file_table); |
| 3239 | file_table = NULL; |
| 3240 | free (directory_table); |
| 3241 | directory_table = NULL; |
| 3242 | putchar ('\n'); |
| 3243 | } |
| 3244 | |
| 3245 | return 1; |
| 3246 | } |
| 3247 | |
| 3248 | static int |
| 3249 | display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) |
| 3250 | { |
| 3251 | unsigned char *data = section->start; |
| 3252 | unsigned char *end = data + section->size; |
| 3253 | int retValRaw = 1; |
| 3254 | int retValDecoded = 1; |
| 3255 | |
| 3256 | if (do_debug_lines == 0) |
| 3257 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; |
| 3258 | |
| 3259 | if (do_debug_lines & FLAG_DEBUG_LINES_RAW) |
| 3260 | retValRaw = display_debug_lines_raw (section, data, end); |
| 3261 | |
| 3262 | if (do_debug_lines & FLAG_DEBUG_LINES_DECODED) |
| 3263 | retValDecoded = display_debug_lines_decoded (section, data, end); |
| 3264 | |
| 3265 | if (!retValRaw || !retValDecoded) |
| 3266 | return 0; |
| 3267 | |
| 3268 | return 1; |
| 3269 | } |
| 3270 | |
| 3271 | static debug_info * |
| 3272 | find_debug_info_for_offset (unsigned long offset) |
| 3273 | { |
| 3274 | unsigned int i; |
| 3275 | |
| 3276 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
| 3277 | return NULL; |
| 3278 | |
| 3279 | for (i = 0; i < num_debug_info_entries; i++) |
| 3280 | if (debug_information[i].cu_offset == offset) |
| 3281 | return debug_information + i; |
| 3282 | |
| 3283 | return NULL; |
| 3284 | } |
| 3285 | |
| 3286 | static int |
| 3287 | display_debug_pubnames (struct dwarf_section *section, |
| 3288 | void *file ATTRIBUTE_UNUSED) |
| 3289 | { |
| 3290 | DWARF2_Internal_PubNames names; |
| 3291 | unsigned char *start = section->start; |
| 3292 | unsigned char *end = start + section->size; |
| 3293 | |
| 3294 | /* It does not matter if this load fails, |
| 3295 | we test for that later on. */ |
| 3296 | load_debug_info (file); |
| 3297 | |
| 3298 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 3299 | |
| 3300 | while (start < end) |
| 3301 | { |
| 3302 | unsigned char *data; |
| 3303 | unsigned long offset; |
| 3304 | int offset_size, initial_length_size; |
| 3305 | |
| 3306 | data = start; |
| 3307 | |
| 3308 | names.pn_length = byte_get (data, 4); |
| 3309 | data += 4; |
| 3310 | if (names.pn_length == 0xffffffff) |
| 3311 | { |
| 3312 | names.pn_length = byte_get (data, 8); |
| 3313 | data += 8; |
| 3314 | offset_size = 8; |
| 3315 | initial_length_size = 12; |
| 3316 | } |
| 3317 | else |
| 3318 | { |
| 3319 | offset_size = 4; |
| 3320 | initial_length_size = 4; |
| 3321 | } |
| 3322 | |
| 3323 | names.pn_version = byte_get (data, 2); |
| 3324 | data += 2; |
| 3325 | |
| 3326 | names.pn_offset = byte_get (data, offset_size); |
| 3327 | data += offset_size; |
| 3328 | |
| 3329 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
| 3330 | && num_debug_info_entries > 0 |
| 3331 | && find_debug_info_for_offset (names.pn_offset) == NULL) |
| 3332 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
| 3333 | (unsigned long) names.pn_offset, section->name); |
| 3334 | |
| 3335 | names.pn_size = byte_get (data, offset_size); |
| 3336 | data += offset_size; |
| 3337 | |
| 3338 | start += names.pn_length + initial_length_size; |
| 3339 | |
| 3340 | if (names.pn_version != 2 && names.pn_version != 3) |
| 3341 | { |
| 3342 | static int warned = 0; |
| 3343 | |
| 3344 | if (! warned) |
| 3345 | { |
| 3346 | warn (_("Only DWARF 2 and 3 pubnames are currently supported\n")); |
| 3347 | warned = 1; |
| 3348 | } |
| 3349 | |
| 3350 | continue; |
| 3351 | } |
| 3352 | |
| 3353 | printf (_(" Length: %ld\n"), |
| 3354 | (long) names.pn_length); |
| 3355 | printf (_(" Version: %d\n"), |
| 3356 | names.pn_version); |
| 3357 | printf (_(" Offset into .debug_info section: 0x%lx\n"), |
| 3358 | (unsigned long) names.pn_offset); |
| 3359 | printf (_(" Size of area in .debug_info section: %ld\n"), |
| 3360 | (long) names.pn_size); |
| 3361 | |
| 3362 | printf (_("\n Offset\tName\n")); |
| 3363 | |
| 3364 | do |
| 3365 | { |
| 3366 | offset = byte_get (data, offset_size); |
| 3367 | |
| 3368 | if (offset != 0) |
| 3369 | { |
| 3370 | data += offset_size; |
| 3371 | printf (" %-6lx\t%s\n", offset, data); |
| 3372 | data += strlen ((char *) data) + 1; |
| 3373 | } |
| 3374 | } |
| 3375 | while (offset != 0); |
| 3376 | } |
| 3377 | |
| 3378 | printf ("\n"); |
| 3379 | return 1; |
| 3380 | } |
| 3381 | |
| 3382 | static int |
| 3383 | display_debug_macinfo (struct dwarf_section *section, |
| 3384 | void *file ATTRIBUTE_UNUSED) |
| 3385 | { |
| 3386 | unsigned char *start = section->start; |
| 3387 | unsigned char *end = start + section->size; |
| 3388 | unsigned char *curr = start; |
| 3389 | unsigned int bytes_read; |
| 3390 | enum dwarf_macinfo_record_type op; |
| 3391 | |
| 3392 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 3393 | |
| 3394 | while (curr < end) |
| 3395 | { |
| 3396 | unsigned int lineno; |
| 3397 | const char *string; |
| 3398 | |
| 3399 | op = (enum dwarf_macinfo_record_type) *curr; |
| 3400 | curr++; |
| 3401 | |
| 3402 | switch (op) |
| 3403 | { |
| 3404 | case DW_MACINFO_start_file: |
| 3405 | { |
| 3406 | unsigned int filenum; |
| 3407 | |
| 3408 | lineno = read_leb128 (curr, & bytes_read, 0); |
| 3409 | curr += bytes_read; |
| 3410 | filenum = read_leb128 (curr, & bytes_read, 0); |
| 3411 | curr += bytes_read; |
| 3412 | |
| 3413 | printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), |
| 3414 | lineno, filenum); |
| 3415 | } |
| 3416 | break; |
| 3417 | |
| 3418 | case DW_MACINFO_end_file: |
| 3419 | printf (_(" DW_MACINFO_end_file\n")); |
| 3420 | break; |
| 3421 | |
| 3422 | case DW_MACINFO_define: |
| 3423 | lineno = read_leb128 (curr, & bytes_read, 0); |
| 3424 | curr += bytes_read; |
| 3425 | string = (char *) curr; |
| 3426 | curr += strlen (string) + 1; |
| 3427 | printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), |
| 3428 | lineno, string); |
| 3429 | break; |
| 3430 | |
| 3431 | case DW_MACINFO_undef: |
| 3432 | lineno = read_leb128 (curr, & bytes_read, 0); |
| 3433 | curr += bytes_read; |
| 3434 | string = (char *) curr; |
| 3435 | curr += strlen (string) + 1; |
| 3436 | printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), |
| 3437 | lineno, string); |
| 3438 | break; |
| 3439 | |
| 3440 | case DW_MACINFO_vendor_ext: |
| 3441 | { |
| 3442 | unsigned int constant; |
| 3443 | |
| 3444 | constant = read_leb128 (curr, & bytes_read, 0); |
| 3445 | curr += bytes_read; |
| 3446 | string = (char *) curr; |
| 3447 | curr += strlen (string) + 1; |
| 3448 | printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), |
| 3449 | constant, string); |
| 3450 | } |
| 3451 | break; |
| 3452 | } |
| 3453 | } |
| 3454 | |
| 3455 | return 1; |
| 3456 | } |
| 3457 | |
| 3458 | /* Given LINE_OFFSET into the .debug_line section, attempt to return |
| 3459 | filename and dirname corresponding to file name table entry with index |
| 3460 | FILEIDX. Return NULL on failure. */ |
| 3461 | |
| 3462 | static unsigned char * |
| 3463 | get_line_filename_and_dirname (dwarf_vma line_offset, dwarf_vma fileidx, |
| 3464 | unsigned char **dir_name) |
| 3465 | { |
| 3466 | struct dwarf_section *section = &debug_displays [line].section; |
| 3467 | unsigned char *hdrptr, *dirtable, *file_name; |
| 3468 | unsigned int offset_size, initial_length_size; |
| 3469 | unsigned int version, opcode_base, bytes_read; |
| 3470 | dwarf_vma length, diridx; |
| 3471 | |
| 3472 | *dir_name = NULL; |
| 3473 | if (section->start == NULL |
| 3474 | || line_offset >= section->size |
| 3475 | || fileidx == 0) |
| 3476 | return NULL; |
| 3477 | |
| 3478 | hdrptr = section->start + line_offset; |
| 3479 | length = byte_get (hdrptr, 4); |
| 3480 | hdrptr += 4; |
| 3481 | if (length == 0xffffffff) |
| 3482 | { |
| 3483 | /* This section is 64-bit DWARF 3. */ |
| 3484 | length = byte_get (hdrptr, 8); |
| 3485 | hdrptr += 8; |
| 3486 | offset_size = 8; |
| 3487 | initial_length_size = 12; |
| 3488 | } |
| 3489 | else |
| 3490 | { |
| 3491 | offset_size = 4; |
| 3492 | initial_length_size = 4; |
| 3493 | } |
| 3494 | if (length + initial_length_size > section->size) |
| 3495 | return NULL; |
| 3496 | version = byte_get (hdrptr, 2); |
| 3497 | hdrptr += 2; |
| 3498 | if (version != 2 && version != 3 && version != 4) |
| 3499 | return NULL; |
| 3500 | hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */ |
| 3501 | if (version >= 4) |
| 3502 | hdrptr++; /* Skip max_ops_per_insn. */ |
| 3503 | hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */ |
| 3504 | opcode_base = byte_get (hdrptr, 1); |
| 3505 | if (opcode_base == 0) |
| 3506 | return NULL; |
| 3507 | hdrptr++; |
| 3508 | hdrptr += opcode_base - 1; |
| 3509 | dirtable = hdrptr; |
| 3510 | /* Skip over dirname table. */ |
| 3511 | while (*hdrptr != '\0') |
| 3512 | hdrptr += strlen ((char *) hdrptr) + 1; |
| 3513 | hdrptr++; /* Skip the NUL at the end of the table. */ |
| 3514 | /* Now skip over preceding filename table entries. */ |
| 3515 | for (; *hdrptr != '\0' && fileidx > 1; fileidx--) |
| 3516 | { |
| 3517 | hdrptr += strlen ((char *) hdrptr) + 1; |
| 3518 | read_leb128 (hdrptr, &bytes_read, 0); |
| 3519 | hdrptr += bytes_read; |
| 3520 | read_leb128 (hdrptr, &bytes_read, 0); |
| 3521 | hdrptr += bytes_read; |
| 3522 | read_leb128 (hdrptr, &bytes_read, 0); |
| 3523 | hdrptr += bytes_read; |
| 3524 | } |
| 3525 | if (*hdrptr == '\0') |
| 3526 | return NULL; |
| 3527 | file_name = hdrptr; |
| 3528 | hdrptr += strlen ((char *) hdrptr) + 1; |
| 3529 | diridx = read_leb128 (hdrptr, &bytes_read, 0); |
| 3530 | if (diridx == 0) |
| 3531 | return file_name; |
| 3532 | for (; *dirtable != '\0' && diridx > 1; diridx--) |
| 3533 | dirtable += strlen ((char *) dirtable) + 1; |
| 3534 | if (*dirtable == '\0') |
| 3535 | return NULL; |
| 3536 | *dir_name = dirtable; |
| 3537 | return file_name; |
| 3538 | } |
| 3539 | |
| 3540 | static int |
| 3541 | display_debug_macro (struct dwarf_section *section, |
| 3542 | void *file) |
| 3543 | { |
| 3544 | unsigned char *start = section->start; |
| 3545 | unsigned char *end = start + section->size; |
| 3546 | unsigned char *curr = start; |
| 3547 | unsigned char *extended_op_buf[256]; |
| 3548 | unsigned int bytes_read; |
| 3549 | |
| 3550 | load_debug_section (str, file); |
| 3551 | load_debug_section (line, file); |
| 3552 | |
| 3553 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 3554 | |
| 3555 | while (curr < end) |
| 3556 | { |
| 3557 | unsigned int lineno, version, flags; |
| 3558 | unsigned int offset_size = 4; |
| 3559 | const char *string; |
| 3560 | dwarf_vma line_offset = 0, sec_offset = curr - start, offset; |
| 3561 | unsigned char **extended_ops = NULL; |
| 3562 | |
| 3563 | version = byte_get (curr, 2); |
| 3564 | curr += 2; |
| 3565 | |
| 3566 | if (version != 4) |
| 3567 | { |
| 3568 | error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"), |
| 3569 | section->name); |
| 3570 | return 0; |
| 3571 | } |
| 3572 | |
| 3573 | flags = byte_get (curr++, 1); |
| 3574 | if (flags & 1) |
| 3575 | offset_size = 8; |
| 3576 | printf (_(" Offset: 0x%lx\n"), |
| 3577 | (unsigned long) sec_offset); |
| 3578 | printf (_(" Version: %d\n"), version); |
| 3579 | printf (_(" Offset size: %d\n"), offset_size); |
| 3580 | if (flags & 2) |
| 3581 | { |
| 3582 | line_offset = byte_get (curr, offset_size); |
| 3583 | curr += offset_size; |
| 3584 | printf (_(" Offset into .debug_line: 0x%lx\n"), |
| 3585 | (unsigned long) line_offset); |
| 3586 | } |
| 3587 | if (flags & 4) |
| 3588 | { |
| 3589 | unsigned int i, count = byte_get (curr++, 1), op; |
| 3590 | dwarf_vma nargs, n; |
| 3591 | memset (extended_op_buf, 0, sizeof (extended_op_buf)); |
| 3592 | extended_ops = extended_op_buf; |
| 3593 | if (count) |
| 3594 | { |
| 3595 | printf (_(" Extension opcode arguments:\n")); |
| 3596 | for (i = 0; i < count; i++) |
| 3597 | { |
| 3598 | op = byte_get (curr++, 1); |
| 3599 | extended_ops[op] = curr; |
| 3600 | nargs = read_leb128 (curr, &bytes_read, 0); |
| 3601 | curr += bytes_read; |
| 3602 | if (nargs == 0) |
| 3603 | printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op); |
| 3604 | else |
| 3605 | { |
| 3606 | printf (_(" DW_MACRO_GNU_%02x arguments: "), op); |
| 3607 | for (n = 0; n < nargs; n++) |
| 3608 | { |
| 3609 | unsigned int form = byte_get (curr++, 1); |
| 3610 | printf ("%s%s", get_FORM_name (form), |
| 3611 | n == nargs - 1 ? "\n" : ", "); |
| 3612 | switch (form) |
| 3613 | { |
| 3614 | case DW_FORM_data1: |
| 3615 | case DW_FORM_data2: |
| 3616 | case DW_FORM_data4: |
| 3617 | case DW_FORM_data8: |
| 3618 | case DW_FORM_sdata: |
| 3619 | case DW_FORM_udata: |
| 3620 | case DW_FORM_block: |
| 3621 | case DW_FORM_block1: |
| 3622 | case DW_FORM_block2: |
| 3623 | case DW_FORM_block4: |
| 3624 | case DW_FORM_flag: |
| 3625 | case DW_FORM_string: |
| 3626 | case DW_FORM_strp: |
| 3627 | case DW_FORM_sec_offset: |
| 3628 | break; |
| 3629 | default: |
| 3630 | error (_("Invalid extension opcode form %s\n"), |
| 3631 | get_FORM_name (form)); |
| 3632 | return 0; |
| 3633 | } |
| 3634 | } |
| 3635 | } |
| 3636 | } |
| 3637 | } |
| 3638 | } |
| 3639 | printf ("\n"); |
| 3640 | |
| 3641 | while (1) |
| 3642 | { |
| 3643 | unsigned int op; |
| 3644 | |
| 3645 | if (curr >= end) |
| 3646 | { |
| 3647 | error (_(".debug_macro section not zero terminated\n")); |
| 3648 | return 0; |
| 3649 | } |
| 3650 | |
| 3651 | op = byte_get (curr++, 1); |
| 3652 | if (op == 0) |
| 3653 | break; |
| 3654 | |
| 3655 | switch (op) |
| 3656 | { |
| 3657 | case DW_MACRO_GNU_start_file: |
| 3658 | { |
| 3659 | unsigned int filenum; |
| 3660 | unsigned char *file_name = NULL, *dir_name = NULL; |
| 3661 | |
| 3662 | lineno = read_leb128 (curr, &bytes_read, 0); |
| 3663 | curr += bytes_read; |
| 3664 | filenum = read_leb128 (curr, &bytes_read, 0); |
| 3665 | curr += bytes_read; |
| 3666 | |
| 3667 | if ((flags & 2) == 0) |
| 3668 | error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n")); |
| 3669 | else |
| 3670 | file_name |
| 3671 | = get_line_filename_and_dirname (line_offset, filenum, |
| 3672 | &dir_name); |
| 3673 | if (file_name == NULL) |
| 3674 | printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"), |
| 3675 | lineno, filenum); |
| 3676 | else |
| 3677 | printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"), |
| 3678 | lineno, filenum, |
| 3679 | dir_name != NULL ? (const char *) dir_name : "", |
| 3680 | dir_name != NULL ? "/" : "", file_name); |
| 3681 | } |
| 3682 | break; |
| 3683 | |
| 3684 | case DW_MACRO_GNU_end_file: |
| 3685 | printf (_(" DW_MACRO_GNU_end_file\n")); |
| 3686 | break; |
| 3687 | |
| 3688 | case DW_MACRO_GNU_define: |
| 3689 | lineno = read_leb128 (curr, &bytes_read, 0); |
| 3690 | curr += bytes_read; |
| 3691 | string = (char *) curr; |
| 3692 | curr += strlen (string) + 1; |
| 3693 | printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"), |
| 3694 | lineno, string); |
| 3695 | break; |
| 3696 | |
| 3697 | case DW_MACRO_GNU_undef: |
| 3698 | lineno = read_leb128 (curr, &bytes_read, 0); |
| 3699 | curr += bytes_read; |
| 3700 | string = (char *) curr; |
| 3701 | curr += strlen (string) + 1; |
| 3702 | printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"), |
| 3703 | lineno, string); |
| 3704 | break; |
| 3705 | |
| 3706 | case DW_MACRO_GNU_define_indirect: |
| 3707 | lineno = read_leb128 (curr, &bytes_read, 0); |
| 3708 | curr += bytes_read; |
| 3709 | offset = byte_get (curr, offset_size); |
| 3710 | curr += offset_size; |
| 3711 | string = fetch_indirect_string (offset); |
| 3712 | printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"), |
| 3713 | lineno, string); |
| 3714 | break; |
| 3715 | |
| 3716 | case DW_MACRO_GNU_undef_indirect: |
| 3717 | lineno = read_leb128 (curr, &bytes_read, 0); |
| 3718 | curr += bytes_read; |
| 3719 | offset = byte_get (curr, offset_size); |
| 3720 | curr += offset_size; |
| 3721 | string = fetch_indirect_string (offset); |
| 3722 | printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"), |
| 3723 | lineno, string); |
| 3724 | break; |
| 3725 | |
| 3726 | case DW_MACRO_GNU_transparent_include: |
| 3727 | offset = byte_get (curr, offset_size); |
| 3728 | curr += offset_size; |
| 3729 | printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"), |
| 3730 | (unsigned long) offset); |
| 3731 | break; |
| 3732 | |
| 3733 | default: |
| 3734 | if (extended_ops == NULL || extended_ops[op] == NULL) |
| 3735 | { |
| 3736 | error (_(" Unknown macro opcode %02x seen\n"), op); |
| 3737 | return 0; |
| 3738 | } |
| 3739 | else |
| 3740 | { |
| 3741 | /* Skip over unhandled opcodes. */ |
| 3742 | dwarf_vma nargs, n; |
| 3743 | unsigned char *desc = extended_ops[op]; |
| 3744 | nargs = read_leb128 (desc, &bytes_read, 0); |
| 3745 | desc += bytes_read; |
| 3746 | if (nargs == 0) |
| 3747 | { |
| 3748 | printf (_(" DW_MACRO_GNU_%02x\n"), op); |
| 3749 | break; |
| 3750 | } |
| 3751 | printf (_(" DW_MACRO_GNU_%02x -"), op); |
| 3752 | for (n = 0; n < nargs; n++) |
| 3753 | { |
| 3754 | curr |
| 3755 | = read_and_display_attr_value (0, byte_get (desc++, 1), |
| 3756 | curr, 0, 0, offset_size, |
| 3757 | version, NULL, 0, NULL); |
| 3758 | if (n != nargs - 1) |
| 3759 | printf (","); |
| 3760 | } |
| 3761 | printf ("\n"); |
| 3762 | } |
| 3763 | break; |
| 3764 | } |
| 3765 | } |
| 3766 | |
| 3767 | printf ("\n"); |
| 3768 | } |
| 3769 | |
| 3770 | return 1; |
| 3771 | } |
| 3772 | |
| 3773 | static int |
| 3774 | display_debug_abbrev (struct dwarf_section *section, |
| 3775 | void *file ATTRIBUTE_UNUSED) |
| 3776 | { |
| 3777 | abbrev_entry *entry; |
| 3778 | unsigned char *start = section->start; |
| 3779 | unsigned char *end = start + section->size; |
| 3780 | |
| 3781 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 3782 | |
| 3783 | do |
| 3784 | { |
| 3785 | free_abbrevs (); |
| 3786 | |
| 3787 | start = process_abbrev_section (start, end); |
| 3788 | |
| 3789 | if (first_abbrev == NULL) |
| 3790 | continue; |
| 3791 | |
| 3792 | printf (_(" Number TAG\n")); |
| 3793 | |
| 3794 | for (entry = first_abbrev; entry; entry = entry->next) |
| 3795 | { |
| 3796 | abbrev_attr *attr; |
| 3797 | |
| 3798 | printf (" %ld %s [%s]\n", |
| 3799 | entry->entry, |
| 3800 | get_TAG_name (entry->tag), |
| 3801 | entry->children ? _("has children") : _("no children")); |
| 3802 | |
| 3803 | for (attr = entry->first_attr; attr; attr = attr->next) |
| 3804 | printf (" %-18s %s\n", |
| 3805 | get_AT_name (attr->attribute), |
| 3806 | get_FORM_name (attr->form)); |
| 3807 | } |
| 3808 | } |
| 3809 | while (start); |
| 3810 | |
| 3811 | printf ("\n"); |
| 3812 | |
| 3813 | return 1; |
| 3814 | } |
| 3815 | |
| 3816 | /* Sort array of indexes in ascending order of loc_offsets[idx]. */ |
| 3817 | |
| 3818 | static dwarf_vma *loc_offsets; |
| 3819 | |
| 3820 | static int |
| 3821 | loc_offsets_compar (const void *ap, const void *bp) |
| 3822 | { |
| 3823 | dwarf_vma a = loc_offsets[*(const unsigned int *) ap]; |
| 3824 | dwarf_vma b = loc_offsets[*(const unsigned int *) bp]; |
| 3825 | |
| 3826 | return (a > b) - (b > a); |
| 3827 | } |
| 3828 | |
| 3829 | static int |
| 3830 | display_debug_loc (struct dwarf_section *section, void *file) |
| 3831 | { |
| 3832 | unsigned char *start = section->start; |
| 3833 | unsigned char *section_end; |
| 3834 | unsigned long bytes; |
| 3835 | unsigned char *section_begin = start; |
| 3836 | unsigned int num_loc_list = 0; |
| 3837 | unsigned long last_offset = 0; |
| 3838 | unsigned int first = 0; |
| 3839 | unsigned int i; |
| 3840 | unsigned int j; |
| 3841 | unsigned int k; |
| 3842 | int seen_first_offset = 0; |
| 3843 | int locs_sorted = 1; |
| 3844 | unsigned char *next; |
| 3845 | unsigned int *array = NULL; |
| 3846 | |
| 3847 | bytes = section->size; |
| 3848 | section_end = start + bytes; |
| 3849 | |
| 3850 | if (bytes == 0) |
| 3851 | { |
| 3852 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 3853 | return 0; |
| 3854 | } |
| 3855 | |
| 3856 | if (load_debug_info (file) == 0) |
| 3857 | { |
| 3858 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), |
| 3859 | section->name); |
| 3860 | return 0; |
| 3861 | } |
| 3862 | |
| 3863 | /* Check the order of location list in .debug_info section. If |
| 3864 | offsets of location lists are in the ascending order, we can |
| 3865 | use `debug_information' directly. */ |
| 3866 | for (i = 0; i < num_debug_info_entries; i++) |
| 3867 | { |
| 3868 | unsigned int num; |
| 3869 | |
| 3870 | num = debug_information [i].num_loc_offsets; |
| 3871 | if (num > num_loc_list) |
| 3872 | num_loc_list = num; |
| 3873 | |
| 3874 | /* Check if we can use `debug_information' directly. */ |
| 3875 | if (locs_sorted && num != 0) |
| 3876 | { |
| 3877 | if (!seen_first_offset) |
| 3878 | { |
| 3879 | /* This is the first location list. */ |
| 3880 | last_offset = debug_information [i].loc_offsets [0]; |
| 3881 | first = i; |
| 3882 | seen_first_offset = 1; |
| 3883 | j = 1; |
| 3884 | } |
| 3885 | else |
| 3886 | j = 0; |
| 3887 | |
| 3888 | for (; j < num; j++) |
| 3889 | { |
| 3890 | if (last_offset > |
| 3891 | debug_information [i].loc_offsets [j]) |
| 3892 | { |
| 3893 | locs_sorted = 0; |
| 3894 | break; |
| 3895 | } |
| 3896 | last_offset = debug_information [i].loc_offsets [j]; |
| 3897 | } |
| 3898 | } |
| 3899 | } |
| 3900 | |
| 3901 | if (!seen_first_offset) |
| 3902 | error (_("No location lists in .debug_info section!\n")); |
| 3903 | |
| 3904 | /* DWARF sections under Mach-O have non-zero addresses. */ |
| 3905 | if (debug_information [first].num_loc_offsets > 0 |
| 3906 | && debug_information [first].loc_offsets [0] != section->address) |
| 3907 | warn (_("Location lists in %s section start at 0x%s\n"), |
| 3908 | section->name, |
| 3909 | dwarf_vmatoa ("x", debug_information [first].loc_offsets [0])); |
| 3910 | |
| 3911 | if (!locs_sorted) |
| 3912 | array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int)); |
| 3913 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 3914 | printf (_(" Offset Begin End Expression\n")); |
| 3915 | |
| 3916 | seen_first_offset = 0; |
| 3917 | for (i = first; i < num_debug_info_entries; i++) |
| 3918 | { |
| 3919 | dwarf_vma begin; |
| 3920 | dwarf_vma end; |
| 3921 | unsigned short length; |
| 3922 | unsigned long offset; |
| 3923 | unsigned int pointer_size; |
| 3924 | unsigned int offset_size; |
| 3925 | int dwarf_version; |
| 3926 | unsigned long cu_offset; |
| 3927 | unsigned long base_address; |
| 3928 | int need_frame_base; |
| 3929 | int has_frame_base; |
| 3930 | |
| 3931 | pointer_size = debug_information [i].pointer_size; |
| 3932 | cu_offset = debug_information [i].cu_offset; |
| 3933 | offset_size = debug_information [i].offset_size; |
| 3934 | dwarf_version = debug_information [i].dwarf_version; |
| 3935 | if (!locs_sorted) |
| 3936 | { |
| 3937 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
| 3938 | array[k] = k; |
| 3939 | loc_offsets = debug_information [i].loc_offsets; |
| 3940 | qsort (array, debug_information [i].num_loc_offsets, |
| 3941 | sizeof (*array), loc_offsets_compar); |
| 3942 | } |
| 3943 | |
| 3944 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
| 3945 | { |
| 3946 | j = locs_sorted ? k : array[k]; |
| 3947 | if (k |
| 3948 | && debug_information [i].loc_offsets [locs_sorted |
| 3949 | ? k - 1 : array [k - 1]] |
| 3950 | == debug_information [i].loc_offsets [j]) |
| 3951 | continue; |
| 3952 | has_frame_base = debug_information [i].have_frame_base [j]; |
| 3953 | /* DWARF sections under Mach-O have non-zero addresses. */ |
| 3954 | offset = debug_information [i].loc_offsets [j] - section->address; |
| 3955 | next = section_begin + offset; |
| 3956 | base_address = debug_information [i].base_address; |
| 3957 | |
| 3958 | if (!seen_first_offset) |
| 3959 | seen_first_offset = 1; |
| 3960 | else |
| 3961 | { |
| 3962 | if (start < next) |
| 3963 | warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"), |
| 3964 | (unsigned long) (start - section_begin), |
| 3965 | (unsigned long) (next - section_begin)); |
| 3966 | else if (start > next) |
| 3967 | warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"), |
| 3968 | (unsigned long) (start - section_begin), |
| 3969 | (unsigned long) (next - section_begin)); |
| 3970 | } |
| 3971 | start = next; |
| 3972 | |
| 3973 | if (offset >= bytes) |
| 3974 | { |
| 3975 | warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"), |
| 3976 | offset); |
| 3977 | continue; |
| 3978 | } |
| 3979 | |
| 3980 | while (1) |
| 3981 | { |
| 3982 | if (start + 2 * pointer_size > section_end) |
| 3983 | { |
| 3984 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 3985 | offset); |
| 3986 | break; |
| 3987 | } |
| 3988 | |
| 3989 | /* Note: we use sign extension here in order to be sure that |
| 3990 | we can detect the -1 escape value. Sign extension into the |
| 3991 | top 32 bits of a 32-bit address will not affect the values |
| 3992 | that we display since we always show hex values, and always |
| 3993 | the bottom 32-bits. */ |
| 3994 | begin = byte_get_signed (start, pointer_size); |
| 3995 | start += pointer_size; |
| 3996 | end = byte_get_signed (start, pointer_size); |
| 3997 | start += pointer_size; |
| 3998 | |
| 3999 | printf (" %8.8lx ", offset); |
| 4000 | |
| 4001 | if (begin == 0 && end == 0) |
| 4002 | { |
| 4003 | printf (_("<End of list>\n")); |
| 4004 | break; |
| 4005 | } |
| 4006 | |
| 4007 | /* Check base address specifiers. */ |
| 4008 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) |
| 4009 | { |
| 4010 | base_address = end; |
| 4011 | print_dwarf_vma (begin, pointer_size); |
| 4012 | print_dwarf_vma (end, pointer_size); |
| 4013 | printf (_("(base address)\n")); |
| 4014 | continue; |
| 4015 | } |
| 4016 | |
| 4017 | if (start + 2 > section_end) |
| 4018 | { |
| 4019 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 4020 | offset); |
| 4021 | break; |
| 4022 | } |
| 4023 | |
| 4024 | length = byte_get (start, 2); |
| 4025 | start += 2; |
| 4026 | |
| 4027 | if (start + length > section_end) |
| 4028 | { |
| 4029 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 4030 | offset); |
| 4031 | break; |
| 4032 | } |
| 4033 | |
| 4034 | print_dwarf_vma (begin + base_address, pointer_size); |
| 4035 | print_dwarf_vma (end + base_address, pointer_size); |
| 4036 | |
| 4037 | putchar ('('); |
| 4038 | need_frame_base = decode_location_expression (start, |
| 4039 | pointer_size, |
| 4040 | offset_size, |
| 4041 | dwarf_version, |
| 4042 | length, |
| 4043 | cu_offset, section); |
| 4044 | putchar (')'); |
| 4045 | |
| 4046 | if (need_frame_base && !has_frame_base) |
| 4047 | printf (_(" [without DW_AT_frame_base]")); |
| 4048 | |
| 4049 | if (begin == end) |
| 4050 | fputs (_(" (start == end)"), stdout); |
| 4051 | else if (begin > end) |
| 4052 | fputs (_(" (start > end)"), stdout); |
| 4053 | |
| 4054 | putchar ('\n'); |
| 4055 | |
| 4056 | start += length; |
| 4057 | } |
| 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | if (start < section_end) |
| 4062 | warn (_("There are %ld unused bytes at the end of section %s\n"), |
| 4063 | (long) (section_end - start), section->name); |
| 4064 | putchar ('\n'); |
| 4065 | free (array); |
| 4066 | return 1; |
| 4067 | } |
| 4068 | |
| 4069 | static int |
| 4070 | display_debug_str (struct dwarf_section *section, |
| 4071 | void *file ATTRIBUTE_UNUSED) |
| 4072 | { |
| 4073 | unsigned char *start = section->start; |
| 4074 | unsigned long bytes = section->size; |
| 4075 | dwarf_vma addr = section->address; |
| 4076 | |
| 4077 | if (bytes == 0) |
| 4078 | { |
| 4079 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 4080 | return 0; |
| 4081 | } |
| 4082 | |
| 4083 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4084 | |
| 4085 | while (bytes) |
| 4086 | { |
| 4087 | int j; |
| 4088 | int k; |
| 4089 | int lbytes; |
| 4090 | |
| 4091 | lbytes = (bytes > 16 ? 16 : bytes); |
| 4092 | |
| 4093 | printf (" 0x%8.8lx ", (unsigned long) addr); |
| 4094 | |
| 4095 | for (j = 0; j < 16; j++) |
| 4096 | { |
| 4097 | if (j < lbytes) |
| 4098 | printf ("%2.2x", start[j]); |
| 4099 | else |
| 4100 | printf (" "); |
| 4101 | |
| 4102 | if ((j & 3) == 3) |
| 4103 | printf (" "); |
| 4104 | } |
| 4105 | |
| 4106 | for (j = 0; j < lbytes; j++) |
| 4107 | { |
| 4108 | k = start[j]; |
| 4109 | if (k >= ' ' && k < 0x80) |
| 4110 | printf ("%c", k); |
| 4111 | else |
| 4112 | printf ("."); |
| 4113 | } |
| 4114 | |
| 4115 | putchar ('\n'); |
| 4116 | |
| 4117 | start += lbytes; |
| 4118 | addr += lbytes; |
| 4119 | bytes -= lbytes; |
| 4120 | } |
| 4121 | |
| 4122 | putchar ('\n'); |
| 4123 | |
| 4124 | return 1; |
| 4125 | } |
| 4126 | |
| 4127 | static int |
| 4128 | display_debug_info (struct dwarf_section *section, void *file) |
| 4129 | { |
| 4130 | return process_debug_info (section, file, abbrev, 0, 0); |
| 4131 | } |
| 4132 | |
| 4133 | static int |
| 4134 | display_debug_types (struct dwarf_section *section, void *file) |
| 4135 | { |
| 4136 | return process_debug_info (section, file, abbrev, 0, 1); |
| 4137 | } |
| 4138 | |
| 4139 | static int |
| 4140 | display_trace_info (struct dwarf_section *section, void *file) |
| 4141 | { |
| 4142 | return process_debug_info (section, file, trace_abbrev, 0, 0); |
| 4143 | } |
| 4144 | |
| 4145 | static int |
| 4146 | display_debug_aranges (struct dwarf_section *section, |
| 4147 | void *file ATTRIBUTE_UNUSED) |
| 4148 | { |
| 4149 | unsigned char *start = section->start; |
| 4150 | unsigned char *end = start + section->size; |
| 4151 | |
| 4152 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4153 | |
| 4154 | /* It does not matter if this load fails, |
| 4155 | we test for that later on. */ |
| 4156 | load_debug_info (file); |
| 4157 | |
| 4158 | while (start < end) |
| 4159 | { |
| 4160 | unsigned char *hdrptr; |
| 4161 | DWARF2_Internal_ARange arange; |
| 4162 | unsigned char *addr_ranges; |
| 4163 | dwarf_vma length; |
| 4164 | dwarf_vma address; |
| 4165 | unsigned char address_size; |
| 4166 | int excess; |
| 4167 | int offset_size; |
| 4168 | int initial_length_size; |
| 4169 | |
| 4170 | hdrptr = start; |
| 4171 | |
| 4172 | arange.ar_length = byte_get (hdrptr, 4); |
| 4173 | hdrptr += 4; |
| 4174 | |
| 4175 | if (arange.ar_length == 0xffffffff) |
| 4176 | { |
| 4177 | arange.ar_length = byte_get (hdrptr, 8); |
| 4178 | hdrptr += 8; |
| 4179 | offset_size = 8; |
| 4180 | initial_length_size = 12; |
| 4181 | } |
| 4182 | else |
| 4183 | { |
| 4184 | offset_size = 4; |
| 4185 | initial_length_size = 4; |
| 4186 | } |
| 4187 | |
| 4188 | arange.ar_version = byte_get (hdrptr, 2); |
| 4189 | hdrptr += 2; |
| 4190 | |
| 4191 | arange.ar_info_offset = byte_get (hdrptr, offset_size); |
| 4192 | hdrptr += offset_size; |
| 4193 | |
| 4194 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
| 4195 | && num_debug_info_entries > 0 |
| 4196 | && find_debug_info_for_offset (arange.ar_info_offset) == NULL) |
| 4197 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
| 4198 | (unsigned long) arange.ar_info_offset, section->name); |
| 4199 | |
| 4200 | arange.ar_pointer_size = byte_get (hdrptr, 1); |
| 4201 | hdrptr += 1; |
| 4202 | |
| 4203 | arange.ar_segment_size = byte_get (hdrptr, 1); |
| 4204 | hdrptr += 1; |
| 4205 | |
| 4206 | if (arange.ar_version != 2 && arange.ar_version != 3) |
| 4207 | { |
| 4208 | warn (_("Only DWARF 2 and 3 aranges are currently supported.\n")); |
| 4209 | break; |
| 4210 | } |
| 4211 | |
| 4212 | printf (_(" Length: %ld\n"), |
| 4213 | (long) arange.ar_length); |
| 4214 | printf (_(" Version: %d\n"), arange.ar_version); |
| 4215 | printf (_(" Offset into .debug_info: 0x%lx\n"), |
| 4216 | (unsigned long) arange.ar_info_offset); |
| 4217 | printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); |
| 4218 | printf (_(" Segment Size: %d\n"), arange.ar_segment_size); |
| 4219 | |
| 4220 | address_size = arange.ar_pointer_size + arange.ar_segment_size; |
| 4221 | |
| 4222 | if (address_size == 0) |
| 4223 | { |
| 4224 | error (_("Invalid address size in %s section!\n"), |
| 4225 | section->name); |
| 4226 | break; |
| 4227 | } |
| 4228 | |
| 4229 | /* The DWARF spec does not require that the address size be a power |
| 4230 | of two, but we do. This will have to change if we ever encounter |
| 4231 | an uneven architecture. */ |
| 4232 | if ((address_size & (address_size - 1)) != 0) |
| 4233 | { |
| 4234 | warn (_("Pointer size + Segment size is not a power of two.\n")); |
| 4235 | break; |
| 4236 | } |
| 4237 | |
| 4238 | if (address_size > 4) |
| 4239 | printf (_("\n Address Length\n")); |
| 4240 | else |
| 4241 | printf (_("\n Address Length\n")); |
| 4242 | |
| 4243 | addr_ranges = hdrptr; |
| 4244 | |
| 4245 | /* Must pad to an alignment boundary that is twice the address size. */ |
| 4246 | excess = (hdrptr - start) % (2 * address_size); |
| 4247 | if (excess) |
| 4248 | addr_ranges += (2 * address_size) - excess; |
| 4249 | |
| 4250 | start += arange.ar_length + initial_length_size; |
| 4251 | |
| 4252 | while (addr_ranges + 2 * address_size <= start) |
| 4253 | { |
| 4254 | address = byte_get (addr_ranges, address_size); |
| 4255 | |
| 4256 | addr_ranges += address_size; |
| 4257 | |
| 4258 | length = byte_get (addr_ranges, address_size); |
| 4259 | |
| 4260 | addr_ranges += address_size; |
| 4261 | |
| 4262 | printf (" "); |
| 4263 | print_dwarf_vma (address, address_size); |
| 4264 | print_dwarf_vma (length, address_size); |
| 4265 | putchar ('\n'); |
| 4266 | } |
| 4267 | } |
| 4268 | |
| 4269 | printf ("\n"); |
| 4270 | |
| 4271 | return 1; |
| 4272 | } |
| 4273 | |
| 4274 | /* Each debug_information[x].range_lists[y] gets this representation for |
| 4275 | sorting purposes. */ |
| 4276 | |
| 4277 | struct range_entry |
| 4278 | { |
| 4279 | /* The debug_information[x].range_lists[y] value. */ |
| 4280 | unsigned long ranges_offset; |
| 4281 | |
| 4282 | /* Original debug_information to find parameters of the data. */ |
| 4283 | debug_info *debug_info_p; |
| 4284 | }; |
| 4285 | |
| 4286 | /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */ |
| 4287 | |
| 4288 | static int |
| 4289 | range_entry_compar (const void *ap, const void *bp) |
| 4290 | { |
| 4291 | const struct range_entry *a_re = (const struct range_entry *) ap; |
| 4292 | const struct range_entry *b_re = (const struct range_entry *) bp; |
| 4293 | const unsigned long a = a_re->ranges_offset; |
| 4294 | const unsigned long b = b_re->ranges_offset; |
| 4295 | |
| 4296 | return (a > b) - (b > a); |
| 4297 | } |
| 4298 | |
| 4299 | static int |
| 4300 | display_debug_ranges (struct dwarf_section *section, |
| 4301 | void *file ATTRIBUTE_UNUSED) |
| 4302 | { |
| 4303 | unsigned char *start = section->start; |
| 4304 | unsigned long bytes; |
| 4305 | unsigned char *section_begin = start; |
| 4306 | unsigned int num_range_list, i; |
| 4307 | struct range_entry *range_entries, *range_entry_fill; |
| 4308 | |
| 4309 | bytes = section->size; |
| 4310 | |
| 4311 | if (bytes == 0) |
| 4312 | { |
| 4313 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 4314 | return 0; |
| 4315 | } |
| 4316 | |
| 4317 | if (load_debug_info (file) == 0) |
| 4318 | { |
| 4319 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), |
| 4320 | section->name); |
| 4321 | return 0; |
| 4322 | } |
| 4323 | |
| 4324 | num_range_list = 0; |
| 4325 | for (i = 0; i < num_debug_info_entries; i++) |
| 4326 | num_range_list += debug_information [i].num_range_lists; |
| 4327 | |
| 4328 | if (num_range_list == 0) |
| 4329 | error (_("No range lists in .debug_info section!\n")); |
| 4330 | |
| 4331 | range_entries = (struct range_entry *) |
| 4332 | xmalloc (sizeof (*range_entries) * num_range_list); |
| 4333 | range_entry_fill = range_entries; |
| 4334 | |
| 4335 | for (i = 0; i < num_debug_info_entries; i++) |
| 4336 | { |
| 4337 | debug_info *debug_info_p = &debug_information[i]; |
| 4338 | unsigned int j; |
| 4339 | |
| 4340 | for (j = 0; j < debug_info_p->num_range_lists; j++) |
| 4341 | { |
| 4342 | range_entry_fill->ranges_offset = debug_info_p->range_lists[j]; |
| 4343 | range_entry_fill->debug_info_p = debug_info_p; |
| 4344 | range_entry_fill++; |
| 4345 | } |
| 4346 | } |
| 4347 | |
| 4348 | qsort (range_entries, num_range_list, sizeof (*range_entries), |
| 4349 | range_entry_compar); |
| 4350 | |
| 4351 | /* DWARF sections under Mach-O have non-zero addresses. */ |
| 4352 | if (range_entries[0].ranges_offset != section->address) |
| 4353 | warn (_("Range lists in %s section start at 0x%lx\n"), |
| 4354 | section->name, range_entries[0].ranges_offset); |
| 4355 | |
| 4356 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4357 | printf (_(" Offset Begin End\n")); |
| 4358 | |
| 4359 | for (i = 0; i < num_range_list; i++) |
| 4360 | { |
| 4361 | struct range_entry *range_entry = &range_entries[i]; |
| 4362 | debug_info *debug_info_p = range_entry->debug_info_p; |
| 4363 | unsigned int pointer_size; |
| 4364 | unsigned long offset; |
| 4365 | unsigned char *next; |
| 4366 | unsigned long base_address; |
| 4367 | |
| 4368 | pointer_size = debug_info_p->pointer_size; |
| 4369 | |
| 4370 | /* DWARF sections under Mach-O have non-zero addresses. */ |
| 4371 | offset = range_entry->ranges_offset - section->address; |
| 4372 | next = section_begin + offset; |
| 4373 | base_address = debug_info_p->base_address; |
| 4374 | |
| 4375 | if (i > 0) |
| 4376 | { |
| 4377 | if (start < next) |
| 4378 | warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"), |
| 4379 | (unsigned long) (start - section_begin), |
| 4380 | (unsigned long) (next - section_begin), section->name); |
| 4381 | else if (start > next) |
| 4382 | warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"), |
| 4383 | (unsigned long) (start - section_begin), |
| 4384 | (unsigned long) (next - section_begin), section->name); |
| 4385 | } |
| 4386 | start = next; |
| 4387 | |
| 4388 | while (1) |
| 4389 | { |
| 4390 | dwarf_vma begin; |
| 4391 | dwarf_vma end; |
| 4392 | |
| 4393 | /* Note: we use sign extension here in order to be sure that |
| 4394 | we can detect the -1 escape value. Sign extension into the |
| 4395 | top 32 bits of a 32-bit address will not affect the values |
| 4396 | that we display since we always show hex values, and always |
| 4397 | the bottom 32-bits. */ |
| 4398 | begin = byte_get_signed (start, pointer_size); |
| 4399 | start += pointer_size; |
| 4400 | end = byte_get_signed (start, pointer_size); |
| 4401 | start += pointer_size; |
| 4402 | |
| 4403 | printf (" %8.8lx ", offset); |
| 4404 | |
| 4405 | if (begin == 0 && end == 0) |
| 4406 | { |
| 4407 | printf (_("<End of list>\n")); |
| 4408 | break; |
| 4409 | } |
| 4410 | |
| 4411 | /* Check base address specifiers. */ |
| 4412 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) |
| 4413 | { |
| 4414 | base_address = end; |
| 4415 | print_dwarf_vma (begin, pointer_size); |
| 4416 | print_dwarf_vma (end, pointer_size); |
| 4417 | printf ("(base address)\n"); |
| 4418 | continue; |
| 4419 | } |
| 4420 | |
| 4421 | print_dwarf_vma (begin + base_address, pointer_size); |
| 4422 | print_dwarf_vma (end + base_address, pointer_size); |
| 4423 | |
| 4424 | if (begin == end) |
| 4425 | fputs (_("(start == end)"), stdout); |
| 4426 | else if (begin > end) |
| 4427 | fputs (_("(start > end)"), stdout); |
| 4428 | |
| 4429 | putchar ('\n'); |
| 4430 | } |
| 4431 | } |
| 4432 | putchar ('\n'); |
| 4433 | |
| 4434 | free (range_entries); |
| 4435 | |
| 4436 | return 1; |
| 4437 | } |
| 4438 | |
| 4439 | typedef struct Frame_Chunk |
| 4440 | { |
| 4441 | struct Frame_Chunk *next; |
| 4442 | unsigned char *chunk_start; |
| 4443 | int ncols; |
| 4444 | /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */ |
| 4445 | short int *col_type; |
| 4446 | int *col_offset; |
| 4447 | char *augmentation; |
| 4448 | unsigned int code_factor; |
| 4449 | int data_factor; |
| 4450 | unsigned long pc_begin; |
| 4451 | unsigned long pc_range; |
| 4452 | int cfa_reg; |
| 4453 | int cfa_offset; |
| 4454 | int ra; |
| 4455 | unsigned char fde_encoding; |
| 4456 | unsigned char cfa_exp; |
| 4457 | unsigned char ptr_size; |
| 4458 | unsigned char segment_size; |
| 4459 | } |
| 4460 | Frame_Chunk; |
| 4461 | |
| 4462 | static const char *const *dwarf_regnames; |
| 4463 | static unsigned int dwarf_regnames_count; |
| 4464 | |
| 4465 | /* A marker for a col_type that means this column was never referenced |
| 4466 | in the frame info. */ |
| 4467 | #define DW_CFA_unreferenced (-1) |
| 4468 | |
| 4469 | /* Return 0 if not more space is needed, 1 if more space is needed, |
| 4470 | -1 for invalid reg. */ |
| 4471 | |
| 4472 | static int |
| 4473 | frame_need_space (Frame_Chunk *fc, unsigned int reg) |
| 4474 | { |
| 4475 | int prev = fc->ncols; |
| 4476 | |
| 4477 | if (reg < (unsigned int) fc->ncols) |
| 4478 | return 0; |
| 4479 | |
| 4480 | if (dwarf_regnames_count |
| 4481 | && reg > dwarf_regnames_count) |
| 4482 | return -1; |
| 4483 | |
| 4484 | fc->ncols = reg + 1; |
| 4485 | fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, |
| 4486 | sizeof (short int)); |
| 4487 | fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); |
| 4488 | |
| 4489 | while (prev < fc->ncols) |
| 4490 | { |
| 4491 | fc->col_type[prev] = DW_CFA_unreferenced; |
| 4492 | fc->col_offset[prev] = 0; |
| 4493 | prev++; |
| 4494 | } |
| 4495 | return 1; |
| 4496 | } |
| 4497 | |
| 4498 | static const char *const dwarf_regnames_i386[] = |
| 4499 | { |
| 4500 | "eax", "ecx", "edx", "ebx", |
| 4501 | "esp", "ebp", "esi", "edi", |
| 4502 | "eip", "eflags", NULL, |
| 4503 | "st0", "st1", "st2", "st3", |
| 4504 | "st4", "st5", "st6", "st7", |
| 4505 | NULL, NULL, |
| 4506 | "xmm0", "xmm1", "xmm2", "xmm3", |
| 4507 | "xmm4", "xmm5", "xmm6", "xmm7", |
| 4508 | "mm0", "mm1", "mm2", "mm3", |
| 4509 | "mm4", "mm5", "mm6", "mm7", |
| 4510 | "fcw", "fsw", "mxcsr", |
| 4511 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, |
| 4512 | "tr", "ldtr" |
| 4513 | }; |
| 4514 | |
| 4515 | void |
| 4516 | init_dwarf_regnames_i386 (void) |
| 4517 | { |
| 4518 | dwarf_regnames = dwarf_regnames_i386; |
| 4519 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386); |
| 4520 | } |
| 4521 | |
| 4522 | static const char *const dwarf_regnames_x86_64[] = |
| 4523 | { |
| 4524 | "rax", "rdx", "rcx", "rbx", |
| 4525 | "rsi", "rdi", "rbp", "rsp", |
| 4526 | "r8", "r9", "r10", "r11", |
| 4527 | "r12", "r13", "r14", "r15", |
| 4528 | "rip", |
| 4529 | "xmm0", "xmm1", "xmm2", "xmm3", |
| 4530 | "xmm4", "xmm5", "xmm6", "xmm7", |
| 4531 | "xmm8", "xmm9", "xmm10", "xmm11", |
| 4532 | "xmm12", "xmm13", "xmm14", "xmm15", |
| 4533 | "st0", "st1", "st2", "st3", |
| 4534 | "st4", "st5", "st6", "st7", |
| 4535 | "mm0", "mm1", "mm2", "mm3", |
| 4536 | "mm4", "mm5", "mm6", "mm7", |
| 4537 | "rflags", |
| 4538 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, |
| 4539 | "fs.base", "gs.base", NULL, NULL, |
| 4540 | "tr", "ldtr", |
| 4541 | "mxcsr", "fcw", "fsw" |
| 4542 | }; |
| 4543 | |
| 4544 | void |
| 4545 | init_dwarf_regnames_x86_64 (void) |
| 4546 | { |
| 4547 | dwarf_regnames = dwarf_regnames_x86_64; |
| 4548 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64); |
| 4549 | } |
| 4550 | |
| 4551 | void |
| 4552 | init_dwarf_regnames (unsigned int e_machine) |
| 4553 | { |
| 4554 | switch (e_machine) |
| 4555 | { |
| 4556 | case EM_386: |
| 4557 | case EM_486: |
| 4558 | init_dwarf_regnames_i386 (); |
| 4559 | break; |
| 4560 | |
| 4561 | case EM_X86_64: |
| 4562 | case EM_L1OM: |
| 4563 | case EM_K1OM: |
| 4564 | init_dwarf_regnames_x86_64 (); |
| 4565 | break; |
| 4566 | |
| 4567 | default: |
| 4568 | break; |
| 4569 | } |
| 4570 | } |
| 4571 | |
| 4572 | static const char * |
| 4573 | regname (unsigned int regno, int row) |
| 4574 | { |
| 4575 | static char reg[64]; |
| 4576 | if (dwarf_regnames |
| 4577 | && regno < dwarf_regnames_count |
| 4578 | && dwarf_regnames [regno] != NULL) |
| 4579 | { |
| 4580 | if (row) |
| 4581 | return dwarf_regnames [regno]; |
| 4582 | snprintf (reg, sizeof (reg), "r%d (%s)", regno, |
| 4583 | dwarf_regnames [regno]); |
| 4584 | } |
| 4585 | else |
| 4586 | snprintf (reg, sizeof (reg), "r%d", regno); |
| 4587 | return reg; |
| 4588 | } |
| 4589 | |
| 4590 | static void |
| 4591 | frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs) |
| 4592 | { |
| 4593 | int r; |
| 4594 | char tmp[100]; |
| 4595 | |
| 4596 | if (*max_regs < fc->ncols) |
| 4597 | *max_regs = fc->ncols; |
| 4598 | |
| 4599 | if (*need_col_headers) |
| 4600 | { |
| 4601 | static const char *sloc = " LOC"; |
| 4602 | |
| 4603 | *need_col_headers = 0; |
| 4604 | |
| 4605 | printf ("%-*s CFA ", eh_addr_size * 2, sloc); |
| 4606 | |
| 4607 | for (r = 0; r < *max_regs; r++) |
| 4608 | if (fc->col_type[r] != DW_CFA_unreferenced) |
| 4609 | { |
| 4610 | if (r == fc->ra) |
| 4611 | printf ("ra "); |
| 4612 | else |
| 4613 | printf ("%-5s ", regname (r, 1)); |
| 4614 | } |
| 4615 | |
| 4616 | printf ("\n"); |
| 4617 | } |
| 4618 | |
| 4619 | printf ("%0*lx ", eh_addr_size * 2, fc->pc_begin); |
| 4620 | if (fc->cfa_exp) |
| 4621 | strcpy (tmp, "exp"); |
| 4622 | else |
| 4623 | sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset); |
| 4624 | printf ("%-8s ", tmp); |
| 4625 | |
| 4626 | for (r = 0; r < fc->ncols; r++) |
| 4627 | { |
| 4628 | if (fc->col_type[r] != DW_CFA_unreferenced) |
| 4629 | { |
| 4630 | switch (fc->col_type[r]) |
| 4631 | { |
| 4632 | case DW_CFA_undefined: |
| 4633 | strcpy (tmp, "u"); |
| 4634 | break; |
| 4635 | case DW_CFA_same_value: |
| 4636 | strcpy (tmp, "s"); |
| 4637 | break; |
| 4638 | case DW_CFA_offset: |
| 4639 | sprintf (tmp, "c%+d", fc->col_offset[r]); |
| 4640 | break; |
| 4641 | case DW_CFA_val_offset: |
| 4642 | sprintf (tmp, "v%+d", fc->col_offset[r]); |
| 4643 | break; |
| 4644 | case DW_CFA_register: |
| 4645 | sprintf (tmp, "%s", regname (fc->col_offset[r], 0)); |
| 4646 | break; |
| 4647 | case DW_CFA_expression: |
| 4648 | strcpy (tmp, "exp"); |
| 4649 | break; |
| 4650 | case DW_CFA_val_expression: |
| 4651 | strcpy (tmp, "vexp"); |
| 4652 | break; |
| 4653 | default: |
| 4654 | strcpy (tmp, "n/a"); |
| 4655 | break; |
| 4656 | } |
| 4657 | printf ("%-5s ", tmp); |
| 4658 | } |
| 4659 | } |
| 4660 | printf ("\n"); |
| 4661 | } |
| 4662 | |
| 4663 | #define GET(N) byte_get (start, N); start += N |
| 4664 | #define LEB() read_leb128 (start, & length_return, 0); start += length_return |
| 4665 | #define SLEB() read_sleb128 (start, & length_return); start += length_return |
| 4666 | |
| 4667 | static int |
| 4668 | display_debug_frames (struct dwarf_section *section, |
| 4669 | void *file ATTRIBUTE_UNUSED) |
| 4670 | { |
| 4671 | unsigned char *start = section->start; |
| 4672 | unsigned char *end = start + section->size; |
| 4673 | unsigned char *section_start = start; |
| 4674 | Frame_Chunk *chunks = 0; |
| 4675 | Frame_Chunk *remembered_state = 0; |
| 4676 | Frame_Chunk *rs; |
| 4677 | int is_eh = strcmp (section->name, ".eh_frame") == 0; |
| 4678 | unsigned int length_return; |
| 4679 | int max_regs = 0; |
| 4680 | const char *bad_reg = _("bad register: "); |
| 4681 | int saved_eh_addr_size = eh_addr_size; |
| 4682 | |
| 4683 | printf (_("Contents of the %s section:\n"), section->name); |
| 4684 | |
| 4685 | while (start < end) |
| 4686 | { |
| 4687 | unsigned char *saved_start; |
| 4688 | unsigned char *block_end; |
| 4689 | unsigned long length; |
| 4690 | unsigned long cie_id; |
| 4691 | Frame_Chunk *fc; |
| 4692 | Frame_Chunk *cie; |
| 4693 | int need_col_headers = 1; |
| 4694 | unsigned char *augmentation_data = NULL; |
| 4695 | unsigned long augmentation_data_len = 0; |
| 4696 | int encoded_ptr_size = saved_eh_addr_size; |
| 4697 | int offset_size; |
| 4698 | int initial_length_size; |
| 4699 | |
| 4700 | saved_start = start; |
| 4701 | length = byte_get (start, 4); start += 4; |
| 4702 | |
| 4703 | if (length == 0) |
| 4704 | { |
| 4705 | printf ("\n%08lx ZERO terminator\n\n", |
| 4706 | (unsigned long)(saved_start - section_start)); |
| 4707 | continue; |
| 4708 | } |
| 4709 | |
| 4710 | if (length == 0xffffffff) |
| 4711 | { |
| 4712 | length = byte_get (start, 8); |
| 4713 | start += 8; |
| 4714 | offset_size = 8; |
| 4715 | initial_length_size = 12; |
| 4716 | } |
| 4717 | else |
| 4718 | { |
| 4719 | offset_size = 4; |
| 4720 | initial_length_size = 4; |
| 4721 | } |
| 4722 | |
| 4723 | block_end = saved_start + length + initial_length_size; |
| 4724 | if (block_end > end) |
| 4725 | { |
| 4726 | warn ("Invalid length %#08lx in FDE at %#08lx\n", |
| 4727 | length, (unsigned long)(saved_start - section_start)); |
| 4728 | block_end = end; |
| 4729 | } |
| 4730 | cie_id = byte_get (start, offset_size); start += offset_size; |
| 4731 | |
| 4732 | if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID)) |
| 4733 | { |
| 4734 | int version; |
| 4735 | |
| 4736 | fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
| 4737 | memset (fc, 0, sizeof (Frame_Chunk)); |
| 4738 | |
| 4739 | fc->next = chunks; |
| 4740 | chunks = fc; |
| 4741 | fc->chunk_start = saved_start; |
| 4742 | fc->ncols = 0; |
| 4743 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
| 4744 | fc->col_offset = (int *) xmalloc (sizeof (int)); |
| 4745 | frame_need_space (fc, max_regs - 1); |
| 4746 | |
| 4747 | version = *start++; |
| 4748 | |
| 4749 | fc->augmentation = (char *) start; |
| 4750 | start = (unsigned char *) strchr ((char *) start, '\0') + 1; |
| 4751 | |
| 4752 | if (strcmp (fc->augmentation, "eh") == 0) |
| 4753 | start += eh_addr_size; |
| 4754 | |
| 4755 | if (version >= 4) |
| 4756 | { |
| 4757 | fc->ptr_size = GET (1); |
| 4758 | fc->segment_size = GET (1); |
| 4759 | eh_addr_size = fc->ptr_size; |
| 4760 | } |
| 4761 | else |
| 4762 | { |
| 4763 | fc->ptr_size = eh_addr_size; |
| 4764 | fc->segment_size = 0; |
| 4765 | } |
| 4766 | fc->code_factor = LEB (); |
| 4767 | fc->data_factor = SLEB (); |
| 4768 | if (version == 1) |
| 4769 | { |
| 4770 | fc->ra = GET (1); |
| 4771 | } |
| 4772 | else |
| 4773 | { |
| 4774 | fc->ra = LEB (); |
| 4775 | } |
| 4776 | |
| 4777 | if (fc->augmentation[0] == 'z') |
| 4778 | { |
| 4779 | augmentation_data_len = LEB (); |
| 4780 | augmentation_data = start; |
| 4781 | start += augmentation_data_len; |
| 4782 | } |
| 4783 | cie = fc; |
| 4784 | |
| 4785 | if (do_debug_frames_interp) |
| 4786 | printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n", |
| 4787 | (unsigned long)(saved_start - section_start), length, cie_id, |
| 4788 | fc->augmentation, fc->code_factor, fc->data_factor, |
| 4789 | fc->ra); |
| 4790 | else |
| 4791 | { |
| 4792 | printf ("\n%08lx %08lx %08lx CIE\n", |
| 4793 | (unsigned long)(saved_start - section_start), length, cie_id); |
| 4794 | printf (" Version: %d\n", version); |
| 4795 | printf (" Augmentation: \"%s\"\n", fc->augmentation); |
| 4796 | if (version >= 4) |
| 4797 | { |
| 4798 | printf (" Pointer Size: %u\n", fc->ptr_size); |
| 4799 | printf (" Segment Size: %u\n", fc->segment_size); |
| 4800 | } |
| 4801 | printf (" Code alignment factor: %u\n", fc->code_factor); |
| 4802 | printf (" Data alignment factor: %d\n", fc->data_factor); |
| 4803 | printf (" Return address column: %d\n", fc->ra); |
| 4804 | |
| 4805 | if (augmentation_data_len) |
| 4806 | { |
| 4807 | unsigned long i; |
| 4808 | printf (" Augmentation data: "); |
| 4809 | for (i = 0; i < augmentation_data_len; ++i) |
| 4810 | printf (" %02x", augmentation_data[i]); |
| 4811 | putchar ('\n'); |
| 4812 | } |
| 4813 | putchar ('\n'); |
| 4814 | } |
| 4815 | |
| 4816 | if (augmentation_data_len) |
| 4817 | { |
| 4818 | unsigned char *p, *q; |
| 4819 | p = (unsigned char *) fc->augmentation + 1; |
| 4820 | q = augmentation_data; |
| 4821 | |
| 4822 | while (1) |
| 4823 | { |
| 4824 | if (*p == 'L') |
| 4825 | q++; |
| 4826 | else if (*p == 'P') |
| 4827 | q += 1 + size_of_encoded_value (*q); |
| 4828 | else if (*p == 'R') |
| 4829 | fc->fde_encoding = *q++; |
| 4830 | else if (*p == 'S') |
| 4831 | ; |
| 4832 | else |
| 4833 | break; |
| 4834 | p++; |
| 4835 | } |
| 4836 | |
| 4837 | if (fc->fde_encoding) |
| 4838 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); |
| 4839 | } |
| 4840 | |
| 4841 | frame_need_space (fc, fc->ra); |
| 4842 | } |
| 4843 | else |
| 4844 | { |
| 4845 | unsigned char *look_for; |
| 4846 | static Frame_Chunk fde_fc; |
| 4847 | unsigned long segment_selector; |
| 4848 | |
| 4849 | fc = & fde_fc; |
| 4850 | memset (fc, 0, sizeof (Frame_Chunk)); |
| 4851 | |
| 4852 | look_for = is_eh ? start - 4 - cie_id : section_start + cie_id; |
| 4853 | |
| 4854 | for (cie = chunks; cie ; cie = cie->next) |
| 4855 | if (cie->chunk_start == look_for) |
| 4856 | break; |
| 4857 | |
| 4858 | if (!cie) |
| 4859 | { |
| 4860 | warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n", |
| 4861 | cie_id, (unsigned long)(saved_start - section_start)); |
| 4862 | fc->ncols = 0; |
| 4863 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
| 4864 | fc->col_offset = (int *) xmalloc (sizeof (int)); |
| 4865 | frame_need_space (fc, max_regs - 1); |
| 4866 | cie = fc; |
| 4867 | fc->augmentation = ""; |
| 4868 | fc->fde_encoding = 0; |
| 4869 | fc->ptr_size = eh_addr_size; |
| 4870 | fc->segment_size = 0; |
| 4871 | } |
| 4872 | else |
| 4873 | { |
| 4874 | fc->ncols = cie->ncols; |
| 4875 | fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int)); |
| 4876 | fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int)); |
| 4877 | memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int)); |
| 4878 | memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int)); |
| 4879 | fc->augmentation = cie->augmentation; |
| 4880 | fc->ptr_size = cie->ptr_size; |
| 4881 | eh_addr_size = cie->ptr_size; |
| 4882 | fc->segment_size = cie->segment_size; |
| 4883 | fc->code_factor = cie->code_factor; |
| 4884 | fc->data_factor = cie->data_factor; |
| 4885 | fc->cfa_reg = cie->cfa_reg; |
| 4886 | fc->cfa_offset = cie->cfa_offset; |
| 4887 | fc->ra = cie->ra; |
| 4888 | frame_need_space (fc, max_regs - 1); |
| 4889 | fc->fde_encoding = cie->fde_encoding; |
| 4890 | } |
| 4891 | |
| 4892 | if (fc->fde_encoding) |
| 4893 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); |
| 4894 | |
| 4895 | segment_selector = 0; |
| 4896 | if (fc->segment_size) |
| 4897 | { |
| 4898 | segment_selector = byte_get (start, fc->segment_size); |
| 4899 | start += fc->segment_size; |
| 4900 | } |
| 4901 | fc->pc_begin = get_encoded_value (start, fc->fde_encoding, section); |
| 4902 | start += encoded_ptr_size; |
| 4903 | fc->pc_range = byte_get (start, encoded_ptr_size); |
| 4904 | start += encoded_ptr_size; |
| 4905 | |
| 4906 | if (cie->augmentation[0] == 'z') |
| 4907 | { |
| 4908 | augmentation_data_len = LEB (); |
| 4909 | augmentation_data = start; |
| 4910 | start += augmentation_data_len; |
| 4911 | } |
| 4912 | |
| 4913 | printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=", |
| 4914 | (unsigned long)(saved_start - section_start), length, cie_id, |
| 4915 | (unsigned long)(cie->chunk_start - section_start)); |
| 4916 | if (fc->segment_size) |
| 4917 | printf ("%04lx:", segment_selector); |
| 4918 | printf ("%08lx..%08lx\n", fc->pc_begin, fc->pc_begin + fc->pc_range); |
| 4919 | if (! do_debug_frames_interp && augmentation_data_len) |
| 4920 | { |
| 4921 | unsigned long i; |
| 4922 | |
| 4923 | printf (" Augmentation data: "); |
| 4924 | for (i = 0; i < augmentation_data_len; ++i) |
| 4925 | printf (" %02x", augmentation_data[i]); |
| 4926 | putchar ('\n'); |
| 4927 | putchar ('\n'); |
| 4928 | } |
| 4929 | } |
| 4930 | |
| 4931 | /* At this point, fc is the current chunk, cie (if any) is set, and |
| 4932 | we're about to interpret instructions for the chunk. */ |
| 4933 | /* ??? At present we need to do this always, since this sizes the |
| 4934 | fc->col_type and fc->col_offset arrays, which we write into always. |
| 4935 | We should probably split the interpreted and non-interpreted bits |
| 4936 | into two different routines, since there's so much that doesn't |
| 4937 | really overlap between them. */ |
| 4938 | if (1 || do_debug_frames_interp) |
| 4939 | { |
| 4940 | /* Start by making a pass over the chunk, allocating storage |
| 4941 | and taking note of what registers are used. */ |
| 4942 | unsigned char *tmp = start; |
| 4943 | |
| 4944 | while (start < block_end) |
| 4945 | { |
| 4946 | unsigned op, opa; |
| 4947 | unsigned long reg, temp; |
| 4948 | |
| 4949 | op = *start++; |
| 4950 | opa = op & 0x3f; |
| 4951 | if (op & 0xc0) |
| 4952 | op &= 0xc0; |
| 4953 | |
| 4954 | /* Warning: if you add any more cases to this switch, be |
| 4955 | sure to add them to the corresponding switch below. */ |
| 4956 | switch (op) |
| 4957 | { |
| 4958 | case DW_CFA_advance_loc: |
| 4959 | break; |
| 4960 | case DW_CFA_offset: |
| 4961 | LEB (); |
| 4962 | if (frame_need_space (fc, opa) >= 0) |
| 4963 | fc->col_type[opa] = DW_CFA_undefined; |
| 4964 | break; |
| 4965 | case DW_CFA_restore: |
| 4966 | if (frame_need_space (fc, opa) >= 0) |
| 4967 | fc->col_type[opa] = DW_CFA_undefined; |
| 4968 | break; |
| 4969 | case DW_CFA_set_loc: |
| 4970 | start += encoded_ptr_size; |
| 4971 | break; |
| 4972 | case DW_CFA_advance_loc1: |
| 4973 | start += 1; |
| 4974 | break; |
| 4975 | case DW_CFA_advance_loc2: |
| 4976 | start += 2; |
| 4977 | break; |
| 4978 | case DW_CFA_advance_loc4: |
| 4979 | start += 4; |
| 4980 | break; |
| 4981 | case DW_CFA_offset_extended: |
| 4982 | case DW_CFA_val_offset: |
| 4983 | reg = LEB (); LEB (); |
| 4984 | if (frame_need_space (fc, reg) >= 0) |
| 4985 | fc->col_type[reg] = DW_CFA_undefined; |
| 4986 | break; |
| 4987 | case DW_CFA_restore_extended: |
| 4988 | reg = LEB (); |
| 4989 | frame_need_space (fc, reg); |
| 4990 | if (frame_need_space (fc, reg) >= 0) |
| 4991 | fc->col_type[reg] = DW_CFA_undefined; |
| 4992 | break; |
| 4993 | case DW_CFA_undefined: |
| 4994 | reg = LEB (); |
| 4995 | if (frame_need_space (fc, reg) >= 0) |
| 4996 | fc->col_type[reg] = DW_CFA_undefined; |
| 4997 | break; |
| 4998 | case DW_CFA_same_value: |
| 4999 | reg = LEB (); |
| 5000 | if (frame_need_space (fc, reg) >= 0) |
| 5001 | fc->col_type[reg] = DW_CFA_undefined; |
| 5002 | break; |
| 5003 | case DW_CFA_register: |
| 5004 | reg = LEB (); LEB (); |
| 5005 | if (frame_need_space (fc, reg) >= 0) |
| 5006 | fc->col_type[reg] = DW_CFA_undefined; |
| 5007 | break; |
| 5008 | case DW_CFA_def_cfa: |
| 5009 | LEB (); LEB (); |
| 5010 | break; |
| 5011 | case DW_CFA_def_cfa_register: |
| 5012 | LEB (); |
| 5013 | break; |
| 5014 | case DW_CFA_def_cfa_offset: |
| 5015 | LEB (); |
| 5016 | break; |
| 5017 | case DW_CFA_def_cfa_expression: |
| 5018 | temp = LEB (); |
| 5019 | start += temp; |
| 5020 | break; |
| 5021 | case DW_CFA_expression: |
| 5022 | case DW_CFA_val_expression: |
| 5023 | reg = LEB (); |
| 5024 | temp = LEB (); |
| 5025 | start += temp; |
| 5026 | if (frame_need_space (fc, reg) >= 0) |
| 5027 | fc->col_type[reg] = DW_CFA_undefined; |
| 5028 | break; |
| 5029 | case DW_CFA_offset_extended_sf: |
| 5030 | case DW_CFA_val_offset_sf: |
| 5031 | reg = LEB (); SLEB (); |
| 5032 | if (frame_need_space (fc, reg) >= 0) |
| 5033 | fc->col_type[reg] = DW_CFA_undefined; |
| 5034 | break; |
| 5035 | case DW_CFA_def_cfa_sf: |
| 5036 | LEB (); SLEB (); |
| 5037 | break; |
| 5038 | case DW_CFA_def_cfa_offset_sf: |
| 5039 | SLEB (); |
| 5040 | break; |
| 5041 | case DW_CFA_MIPS_advance_loc8: |
| 5042 | start += 8; |
| 5043 | break; |
| 5044 | case DW_CFA_GNU_args_size: |
| 5045 | LEB (); |
| 5046 | break; |
| 5047 | case DW_CFA_GNU_negative_offset_extended: |
| 5048 | reg = LEB (); LEB (); |
| 5049 | if (frame_need_space (fc, reg) >= 0) |
| 5050 | fc->col_type[reg] = DW_CFA_undefined; |
| 5051 | break; |
| 5052 | default: |
| 5053 | break; |
| 5054 | } |
| 5055 | } |
| 5056 | start = tmp; |
| 5057 | } |
| 5058 | |
| 5059 | /* Now we know what registers are used, make a second pass over |
| 5060 | the chunk, this time actually printing out the info. */ |
| 5061 | |
| 5062 | while (start < block_end) |
| 5063 | { |
| 5064 | unsigned op, opa; |
| 5065 | unsigned long ul, reg, roffs; |
| 5066 | long l, ofs; |
| 5067 | dwarf_vma vma; |
| 5068 | const char *reg_prefix = ""; |
| 5069 | |
| 5070 | op = *start++; |
| 5071 | opa = op & 0x3f; |
| 5072 | if (op & 0xc0) |
| 5073 | op &= 0xc0; |
| 5074 | |
| 5075 | /* Warning: if you add any more cases to this switch, be |
| 5076 | sure to add them to the corresponding switch above. */ |
| 5077 | switch (op) |
| 5078 | { |
| 5079 | case DW_CFA_advance_loc: |
| 5080 | if (do_debug_frames_interp) |
| 5081 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5082 | else |
| 5083 | printf (" DW_CFA_advance_loc: %d to %08lx\n", |
| 5084 | opa * fc->code_factor, |
| 5085 | fc->pc_begin + opa * fc->code_factor); |
| 5086 | fc->pc_begin += opa * fc->code_factor; |
| 5087 | break; |
| 5088 | |
| 5089 | case DW_CFA_offset: |
| 5090 | roffs = LEB (); |
| 5091 | if (opa >= (unsigned int) fc->ncols) |
| 5092 | reg_prefix = bad_reg; |
| 5093 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5094 | printf (" DW_CFA_offset: %s%s at cfa%+ld\n", |
| 5095 | reg_prefix, regname (opa, 0), |
| 5096 | roffs * fc->data_factor); |
| 5097 | if (*reg_prefix == '\0') |
| 5098 | { |
| 5099 | fc->col_type[opa] = DW_CFA_offset; |
| 5100 | fc->col_offset[opa] = roffs * fc->data_factor; |
| 5101 | } |
| 5102 | break; |
| 5103 | |
| 5104 | case DW_CFA_restore: |
| 5105 | if (opa >= (unsigned int) cie->ncols |
| 5106 | || opa >= (unsigned int) fc->ncols) |
| 5107 | reg_prefix = bad_reg; |
| 5108 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5109 | printf (" DW_CFA_restore: %s%s\n", |
| 5110 | reg_prefix, regname (opa, 0)); |
| 5111 | if (*reg_prefix == '\0') |
| 5112 | { |
| 5113 | fc->col_type[opa] = cie->col_type[opa]; |
| 5114 | fc->col_offset[opa] = cie->col_offset[opa]; |
| 5115 | if (do_debug_frames_interp |
| 5116 | && fc->col_type[opa] == DW_CFA_unreferenced) |
| 5117 | fc->col_type[opa] = DW_CFA_undefined; |
| 5118 | } |
| 5119 | break; |
| 5120 | |
| 5121 | case DW_CFA_set_loc: |
| 5122 | vma = get_encoded_value (start, fc->fde_encoding, section); |
| 5123 | start += encoded_ptr_size; |
| 5124 | if (do_debug_frames_interp) |
| 5125 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5126 | else |
| 5127 | printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma); |
| 5128 | fc->pc_begin = vma; |
| 5129 | break; |
| 5130 | |
| 5131 | case DW_CFA_advance_loc1: |
| 5132 | ofs = byte_get (start, 1); start += 1; |
| 5133 | if (do_debug_frames_interp) |
| 5134 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5135 | else |
| 5136 | printf (" DW_CFA_advance_loc1: %ld to %08lx\n", |
| 5137 | ofs * fc->code_factor, |
| 5138 | fc->pc_begin + ofs * fc->code_factor); |
| 5139 | fc->pc_begin += ofs * fc->code_factor; |
| 5140 | break; |
| 5141 | |
| 5142 | case DW_CFA_advance_loc2: |
| 5143 | ofs = byte_get (start, 2); start += 2; |
| 5144 | if (do_debug_frames_interp) |
| 5145 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5146 | else |
| 5147 | printf (" DW_CFA_advance_loc2: %ld to %08lx\n", |
| 5148 | ofs * fc->code_factor, |
| 5149 | fc->pc_begin + ofs * fc->code_factor); |
| 5150 | fc->pc_begin += ofs * fc->code_factor; |
| 5151 | break; |
| 5152 | |
| 5153 | case DW_CFA_advance_loc4: |
| 5154 | ofs = byte_get (start, 4); start += 4; |
| 5155 | if (do_debug_frames_interp) |
| 5156 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5157 | else |
| 5158 | printf (" DW_CFA_advance_loc4: %ld to %08lx\n", |
| 5159 | ofs * fc->code_factor, |
| 5160 | fc->pc_begin + ofs * fc->code_factor); |
| 5161 | fc->pc_begin += ofs * fc->code_factor; |
| 5162 | break; |
| 5163 | |
| 5164 | case DW_CFA_offset_extended: |
| 5165 | reg = LEB (); |
| 5166 | roffs = LEB (); |
| 5167 | if (reg >= (unsigned int) fc->ncols) |
| 5168 | reg_prefix = bad_reg; |
| 5169 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5170 | printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n", |
| 5171 | reg_prefix, regname (reg, 0), |
| 5172 | roffs * fc->data_factor); |
| 5173 | if (*reg_prefix == '\0') |
| 5174 | { |
| 5175 | fc->col_type[reg] = DW_CFA_offset; |
| 5176 | fc->col_offset[reg] = roffs * fc->data_factor; |
| 5177 | } |
| 5178 | break; |
| 5179 | |
| 5180 | case DW_CFA_val_offset: |
| 5181 | reg = LEB (); |
| 5182 | roffs = LEB (); |
| 5183 | if (reg >= (unsigned int) fc->ncols) |
| 5184 | reg_prefix = bad_reg; |
| 5185 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5186 | printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n", |
| 5187 | reg_prefix, regname (reg, 0), |
| 5188 | roffs * fc->data_factor); |
| 5189 | if (*reg_prefix == '\0') |
| 5190 | { |
| 5191 | fc->col_type[reg] = DW_CFA_val_offset; |
| 5192 | fc->col_offset[reg] = roffs * fc->data_factor; |
| 5193 | } |
| 5194 | break; |
| 5195 | |
| 5196 | case DW_CFA_restore_extended: |
| 5197 | reg = LEB (); |
| 5198 | if (reg >= (unsigned int) cie->ncols |
| 5199 | || reg >= (unsigned int) fc->ncols) |
| 5200 | reg_prefix = bad_reg; |
| 5201 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5202 | printf (" DW_CFA_restore_extended: %s%s\n", |
| 5203 | reg_prefix, regname (reg, 0)); |
| 5204 | if (*reg_prefix == '\0') |
| 5205 | { |
| 5206 | fc->col_type[reg] = cie->col_type[reg]; |
| 5207 | fc->col_offset[reg] = cie->col_offset[reg]; |
| 5208 | } |
| 5209 | break; |
| 5210 | |
| 5211 | case DW_CFA_undefined: |
| 5212 | reg = LEB (); |
| 5213 | if (reg >= (unsigned int) fc->ncols) |
| 5214 | reg_prefix = bad_reg; |
| 5215 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5216 | printf (" DW_CFA_undefined: %s%s\n", |
| 5217 | reg_prefix, regname (reg, 0)); |
| 5218 | if (*reg_prefix == '\0') |
| 5219 | { |
| 5220 | fc->col_type[reg] = DW_CFA_undefined; |
| 5221 | fc->col_offset[reg] = 0; |
| 5222 | } |
| 5223 | break; |
| 5224 | |
| 5225 | case DW_CFA_same_value: |
| 5226 | reg = LEB (); |
| 5227 | if (reg >= (unsigned int) fc->ncols) |
| 5228 | reg_prefix = bad_reg; |
| 5229 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5230 | printf (" DW_CFA_same_value: %s%s\n", |
| 5231 | reg_prefix, regname (reg, 0)); |
| 5232 | if (*reg_prefix == '\0') |
| 5233 | { |
| 5234 | fc->col_type[reg] = DW_CFA_same_value; |
| 5235 | fc->col_offset[reg] = 0; |
| 5236 | } |
| 5237 | break; |
| 5238 | |
| 5239 | case DW_CFA_register: |
| 5240 | reg = LEB (); |
| 5241 | roffs = LEB (); |
| 5242 | if (reg >= (unsigned int) fc->ncols) |
| 5243 | reg_prefix = bad_reg; |
| 5244 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5245 | { |
| 5246 | printf (" DW_CFA_register: %s%s in ", |
| 5247 | reg_prefix, regname (reg, 0)); |
| 5248 | puts (regname (roffs, 0)); |
| 5249 | } |
| 5250 | if (*reg_prefix == '\0') |
| 5251 | { |
| 5252 | fc->col_type[reg] = DW_CFA_register; |
| 5253 | fc->col_offset[reg] = roffs; |
| 5254 | } |
| 5255 | break; |
| 5256 | |
| 5257 | case DW_CFA_remember_state: |
| 5258 | if (! do_debug_frames_interp) |
| 5259 | printf (" DW_CFA_remember_state\n"); |
| 5260 | rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
| 5261 | rs->ncols = fc->ncols; |
| 5262 | rs->col_type = (short int *) xcmalloc (rs->ncols, |
| 5263 | sizeof (short int)); |
| 5264 | rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (int)); |
| 5265 | memcpy (rs->col_type, fc->col_type, rs->ncols); |
| 5266 | memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (int)); |
| 5267 | rs->next = remembered_state; |
| 5268 | remembered_state = rs; |
| 5269 | break; |
| 5270 | |
| 5271 | case DW_CFA_restore_state: |
| 5272 | if (! do_debug_frames_interp) |
| 5273 | printf (" DW_CFA_restore_state\n"); |
| 5274 | rs = remembered_state; |
| 5275 | if (rs) |
| 5276 | { |
| 5277 | remembered_state = rs->next; |
| 5278 | frame_need_space (fc, rs->ncols - 1); |
| 5279 | memcpy (fc->col_type, rs->col_type, rs->ncols); |
| 5280 | memcpy (fc->col_offset, rs->col_offset, |
| 5281 | rs->ncols * sizeof (int)); |
| 5282 | free (rs->col_type); |
| 5283 | free (rs->col_offset); |
| 5284 | free (rs); |
| 5285 | } |
| 5286 | else if (do_debug_frames_interp) |
| 5287 | printf ("Mismatched DW_CFA_restore_state\n"); |
| 5288 | break; |
| 5289 | |
| 5290 | case DW_CFA_def_cfa: |
| 5291 | fc->cfa_reg = LEB (); |
| 5292 | fc->cfa_offset = LEB (); |
| 5293 | fc->cfa_exp = 0; |
| 5294 | if (! do_debug_frames_interp) |
| 5295 | printf (" DW_CFA_def_cfa: %s ofs %d\n", |
| 5296 | regname (fc->cfa_reg, 0), fc->cfa_offset); |
| 5297 | break; |
| 5298 | |
| 5299 | case DW_CFA_def_cfa_register: |
| 5300 | fc->cfa_reg = LEB (); |
| 5301 | fc->cfa_exp = 0; |
| 5302 | if (! do_debug_frames_interp) |
| 5303 | printf (" DW_CFA_def_cfa_register: %s\n", |
| 5304 | regname (fc->cfa_reg, 0)); |
| 5305 | break; |
| 5306 | |
| 5307 | case DW_CFA_def_cfa_offset: |
| 5308 | fc->cfa_offset = LEB (); |
| 5309 | if (! do_debug_frames_interp) |
| 5310 | printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset); |
| 5311 | break; |
| 5312 | |
| 5313 | case DW_CFA_nop: |
| 5314 | if (! do_debug_frames_interp) |
| 5315 | printf (" DW_CFA_nop\n"); |
| 5316 | break; |
| 5317 | |
| 5318 | case DW_CFA_def_cfa_expression: |
| 5319 | ul = LEB (); |
| 5320 | if (! do_debug_frames_interp) |
| 5321 | { |
| 5322 | printf (" DW_CFA_def_cfa_expression ("); |
| 5323 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 5324 | ul, 0, section); |
| 5325 | printf (")\n"); |
| 5326 | } |
| 5327 | fc->cfa_exp = 1; |
| 5328 | start += ul; |
| 5329 | break; |
| 5330 | |
| 5331 | case DW_CFA_expression: |
| 5332 | reg = LEB (); |
| 5333 | ul = LEB (); |
| 5334 | if (reg >= (unsigned int) fc->ncols) |
| 5335 | reg_prefix = bad_reg; |
| 5336 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5337 | { |
| 5338 | printf (" DW_CFA_expression: %s%s (", |
| 5339 | reg_prefix, regname (reg, 0)); |
| 5340 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 5341 | ul, 0, section); |
| 5342 | printf (")\n"); |
| 5343 | } |
| 5344 | if (*reg_prefix == '\0') |
| 5345 | fc->col_type[reg] = DW_CFA_expression; |
| 5346 | start += ul; |
| 5347 | break; |
| 5348 | |
| 5349 | case DW_CFA_val_expression: |
| 5350 | reg = LEB (); |
| 5351 | ul = LEB (); |
| 5352 | if (reg >= (unsigned int) fc->ncols) |
| 5353 | reg_prefix = bad_reg; |
| 5354 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5355 | { |
| 5356 | printf (" DW_CFA_val_expression: %s%s (", |
| 5357 | reg_prefix, regname (reg, 0)); |
| 5358 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 5359 | ul, 0, section); |
| 5360 | printf (")\n"); |
| 5361 | } |
| 5362 | if (*reg_prefix == '\0') |
| 5363 | fc->col_type[reg] = DW_CFA_val_expression; |
| 5364 | start += ul; |
| 5365 | break; |
| 5366 | |
| 5367 | case DW_CFA_offset_extended_sf: |
| 5368 | reg = LEB (); |
| 5369 | l = SLEB (); |
| 5370 | if (frame_need_space (fc, reg) < 0) |
| 5371 | reg_prefix = bad_reg; |
| 5372 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5373 | printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n", |
| 5374 | reg_prefix, regname (reg, 0), |
| 5375 | l * fc->data_factor); |
| 5376 | if (*reg_prefix == '\0') |
| 5377 | { |
| 5378 | fc->col_type[reg] = DW_CFA_offset; |
| 5379 | fc->col_offset[reg] = l * fc->data_factor; |
| 5380 | } |
| 5381 | break; |
| 5382 | |
| 5383 | case DW_CFA_val_offset_sf: |
| 5384 | reg = LEB (); |
| 5385 | l = SLEB (); |
| 5386 | if (frame_need_space (fc, reg) < 0) |
| 5387 | reg_prefix = bad_reg; |
| 5388 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5389 | printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n", |
| 5390 | reg_prefix, regname (reg, 0), |
| 5391 | l * fc->data_factor); |
| 5392 | if (*reg_prefix == '\0') |
| 5393 | { |
| 5394 | fc->col_type[reg] = DW_CFA_val_offset; |
| 5395 | fc->col_offset[reg] = l * fc->data_factor; |
| 5396 | } |
| 5397 | break; |
| 5398 | |
| 5399 | case DW_CFA_def_cfa_sf: |
| 5400 | fc->cfa_reg = LEB (); |
| 5401 | fc->cfa_offset = SLEB (); |
| 5402 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; |
| 5403 | fc->cfa_exp = 0; |
| 5404 | if (! do_debug_frames_interp) |
| 5405 | printf (" DW_CFA_def_cfa_sf: %s ofs %d\n", |
| 5406 | regname (fc->cfa_reg, 0), fc->cfa_offset); |
| 5407 | break; |
| 5408 | |
| 5409 | case DW_CFA_def_cfa_offset_sf: |
| 5410 | fc->cfa_offset = SLEB (); |
| 5411 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; |
| 5412 | if (! do_debug_frames_interp) |
| 5413 | printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset); |
| 5414 | break; |
| 5415 | |
| 5416 | case DW_CFA_MIPS_advance_loc8: |
| 5417 | ofs = byte_get (start, 8); start += 8; |
| 5418 | if (do_debug_frames_interp) |
| 5419 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5420 | else |
| 5421 | printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n", |
| 5422 | ofs * fc->code_factor, |
| 5423 | fc->pc_begin + ofs * fc->code_factor); |
| 5424 | fc->pc_begin += ofs * fc->code_factor; |
| 5425 | break; |
| 5426 | |
| 5427 | case DW_CFA_GNU_window_save: |
| 5428 | if (! do_debug_frames_interp) |
| 5429 | printf (" DW_CFA_GNU_window_save\n"); |
| 5430 | break; |
| 5431 | |
| 5432 | case DW_CFA_GNU_args_size: |
| 5433 | ul = LEB (); |
| 5434 | if (! do_debug_frames_interp) |
| 5435 | printf (" DW_CFA_GNU_args_size: %ld\n", ul); |
| 5436 | break; |
| 5437 | |
| 5438 | case DW_CFA_GNU_negative_offset_extended: |
| 5439 | reg = LEB (); |
| 5440 | l = - LEB (); |
| 5441 | if (frame_need_space (fc, reg) < 0) |
| 5442 | reg_prefix = bad_reg; |
| 5443 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 5444 | printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n", |
| 5445 | reg_prefix, regname (reg, 0), |
| 5446 | l * fc->data_factor); |
| 5447 | if (*reg_prefix == '\0') |
| 5448 | { |
| 5449 | fc->col_type[reg] = DW_CFA_offset; |
| 5450 | fc->col_offset[reg] = l * fc->data_factor; |
| 5451 | } |
| 5452 | break; |
| 5453 | |
| 5454 | default: |
| 5455 | if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) |
| 5456 | printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); |
| 5457 | else |
| 5458 | warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); |
| 5459 | start = block_end; |
| 5460 | } |
| 5461 | } |
| 5462 | |
| 5463 | if (do_debug_frames_interp) |
| 5464 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 5465 | |
| 5466 | start = block_end; |
| 5467 | eh_addr_size = saved_eh_addr_size; |
| 5468 | } |
| 5469 | |
| 5470 | printf ("\n"); |
| 5471 | |
| 5472 | return 1; |
| 5473 | } |
| 5474 | |
| 5475 | #undef GET |
| 5476 | #undef LEB |
| 5477 | #undef SLEB |
| 5478 | |
| 5479 | static int |
| 5480 | display_gdb_index (struct dwarf_section *section, |
| 5481 | void *file ATTRIBUTE_UNUSED) |
| 5482 | { |
| 5483 | unsigned char *start = section->start; |
| 5484 | uint32_t version; |
| 5485 | uint32_t cu_list_offset, tu_list_offset; |
| 5486 | uint32_t address_table_offset, symbol_table_offset, constant_pool_offset; |
| 5487 | unsigned int cu_list_elements, tu_list_elements; |
| 5488 | unsigned int address_table_size, symbol_table_slots; |
| 5489 | unsigned char *cu_list, *tu_list; |
| 5490 | unsigned char *address_table, *symbol_table, *constant_pool; |
| 5491 | unsigned int i; |
| 5492 | |
| 5493 | /* The documentation for the format of this file is in gdb/dwarf2read.c. */ |
| 5494 | |
| 5495 | printf (_("Contents of the %s section:\n"), section->name); |
| 5496 | |
| 5497 | if (section->size < 6 * sizeof (uint32_t)) |
| 5498 | { |
| 5499 | warn (_("Truncated header in the %s section.\n"), section->name); |
| 5500 | return 0; |
| 5501 | } |
| 5502 | |
| 5503 | version = byte_get_little_endian (start, 4); |
| 5504 | printf (_("Version %ld\n"), (long) version); |
| 5505 | |
| 5506 | /* Prior versions are obsolete, and future versions may not be |
| 5507 | backwards compatible. */ |
| 5508 | switch (version) |
| 5509 | { |
| 5510 | case 3: |
| 5511 | warn (_("The address table data in version 3 may be wrong.\n")); |
| 5512 | break; |
| 5513 | case 4: |
| 5514 | warn (_("Version 4 does not support case insensitive lookups.\n")); |
| 5515 | break; |
| 5516 | case 5: |
| 5517 | break; |
| 5518 | default: |
| 5519 | warn (_("Unsupported version %lu.\n"), (unsigned long) version); |
| 5520 | return 0; |
| 5521 | } |
| 5522 | |
| 5523 | cu_list_offset = byte_get_little_endian (start + 4, 4); |
| 5524 | tu_list_offset = byte_get_little_endian (start + 8, 4); |
| 5525 | address_table_offset = byte_get_little_endian (start + 12, 4); |
| 5526 | symbol_table_offset = byte_get_little_endian (start + 16, 4); |
| 5527 | constant_pool_offset = byte_get_little_endian (start + 20, 4); |
| 5528 | |
| 5529 | if (cu_list_offset > section->size |
| 5530 | || tu_list_offset > section->size |
| 5531 | || address_table_offset > section->size |
| 5532 | || symbol_table_offset > section->size |
| 5533 | || constant_pool_offset > section->size) |
| 5534 | { |
| 5535 | warn (_("Corrupt header in the %s section.\n"), section->name); |
| 5536 | return 0; |
| 5537 | } |
| 5538 | |
| 5539 | cu_list_elements = (tu_list_offset - cu_list_offset) / 8; |
| 5540 | tu_list_elements = (address_table_offset - tu_list_offset) / 8; |
| 5541 | address_table_size = symbol_table_offset - address_table_offset; |
| 5542 | symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8; |
| 5543 | |
| 5544 | cu_list = start + cu_list_offset; |
| 5545 | tu_list = start + tu_list_offset; |
| 5546 | address_table = start + address_table_offset; |
| 5547 | symbol_table = start + symbol_table_offset; |
| 5548 | constant_pool = start + constant_pool_offset; |
| 5549 | |
| 5550 | printf (_("\nCU table:\n")); |
| 5551 | for (i = 0; i < cu_list_elements; i += 2) |
| 5552 | { |
| 5553 | uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8); |
| 5554 | uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8); |
| 5555 | |
| 5556 | printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2, |
| 5557 | (unsigned long) cu_offset, |
| 5558 | (unsigned long) (cu_offset + cu_length - 1)); |
| 5559 | } |
| 5560 | |
| 5561 | printf (_("\nTU table:\n")); |
| 5562 | for (i = 0; i < tu_list_elements; i += 3) |
| 5563 | { |
| 5564 | uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8); |
| 5565 | uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8); |
| 5566 | uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8); |
| 5567 | |
| 5568 | printf (_("[%3u] 0x%lx 0x%lx "), i / 3, |
| 5569 | (unsigned long) tu_offset, |
| 5570 | (unsigned long) type_offset); |
| 5571 | print_dwarf_vma (signature, 8); |
| 5572 | printf ("\n"); |
| 5573 | } |
| 5574 | |
| 5575 | printf (_("\nAddress table:\n")); |
| 5576 | for (i = 0; i < address_table_size; i += 2 * 8 + 4) |
| 5577 | { |
| 5578 | uint64_t low = byte_get_little_endian (address_table + i, 8); |
| 5579 | uint64_t high = byte_get_little_endian (address_table + i + 8, 8); |
| 5580 | uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4); |
| 5581 | |
| 5582 | print_dwarf_vma (low, 8); |
| 5583 | print_dwarf_vma (high, 8); |
| 5584 | printf (_("%lu\n"), (unsigned long) cu_index); |
| 5585 | } |
| 5586 | |
| 5587 | printf (_("\nSymbol table:\n")); |
| 5588 | for (i = 0; i < symbol_table_slots; ++i) |
| 5589 | { |
| 5590 | uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4); |
| 5591 | uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4); |
| 5592 | uint32_t num_cus, cu; |
| 5593 | |
| 5594 | if (name_offset != 0 |
| 5595 | || cu_vector_offset != 0) |
| 5596 | { |
| 5597 | unsigned int j; |
| 5598 | |
| 5599 | printf ("[%3u] %s:", i, constant_pool + name_offset); |
| 5600 | num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4); |
| 5601 | for (j = 0; j < num_cus; ++j) |
| 5602 | { |
| 5603 | cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4); |
| 5604 | /* Convert to TU number if it's for a type unit. */ |
| 5605 | if (cu >= cu_list_elements / 2) |
| 5606 | printf (" T%lu", (unsigned long) (cu - cu_list_elements / 2)); |
| 5607 | else |
| 5608 | printf (" %lu", (unsigned long) cu); |
| 5609 | } |
| 5610 | printf ("\n"); |
| 5611 | } |
| 5612 | } |
| 5613 | |
| 5614 | return 1; |
| 5615 | } |
| 5616 | |
| 5617 | static int |
| 5618 | display_debug_not_supported (struct dwarf_section *section, |
| 5619 | void *file ATTRIBUTE_UNUSED) |
| 5620 | { |
| 5621 | printf (_("Displaying the debug contents of section %s is not yet supported.\n"), |
| 5622 | section->name); |
| 5623 | |
| 5624 | return 1; |
| 5625 | } |
| 5626 | |
| 5627 | void * |
| 5628 | cmalloc (size_t nmemb, size_t size) |
| 5629 | { |
| 5630 | /* Check for overflow. */ |
| 5631 | if (nmemb >= ~(size_t) 0 / size) |
| 5632 | return NULL; |
| 5633 | else |
| 5634 | return malloc (nmemb * size); |
| 5635 | } |
| 5636 | |
| 5637 | void * |
| 5638 | xcmalloc (size_t nmemb, size_t size) |
| 5639 | { |
| 5640 | /* Check for overflow. */ |
| 5641 | if (nmemb >= ~(size_t) 0 / size) |
| 5642 | return NULL; |
| 5643 | else |
| 5644 | return xmalloc (nmemb * size); |
| 5645 | } |
| 5646 | |
| 5647 | void * |
| 5648 | xcrealloc (void *ptr, size_t nmemb, size_t size) |
| 5649 | { |
| 5650 | /* Check for overflow. */ |
| 5651 | if (nmemb >= ~(size_t) 0 / size) |
| 5652 | return NULL; |
| 5653 | else |
| 5654 | return xrealloc (ptr, nmemb * size); |
| 5655 | } |
| 5656 | |
| 5657 | void |
| 5658 | free_debug_memory (void) |
| 5659 | { |
| 5660 | unsigned int i; |
| 5661 | |
| 5662 | free_abbrevs (); |
| 5663 | |
| 5664 | for (i = 0; i < max; i++) |
| 5665 | free_debug_section ((enum dwarf_section_display_enum) i); |
| 5666 | |
| 5667 | if (debug_information != NULL) |
| 5668 | { |
| 5669 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE) |
| 5670 | { |
| 5671 | for (i = 0; i < num_debug_info_entries; i++) |
| 5672 | { |
| 5673 | if (!debug_information [i].max_loc_offsets) |
| 5674 | { |
| 5675 | free (debug_information [i].loc_offsets); |
| 5676 | free (debug_information [i].have_frame_base); |
| 5677 | } |
| 5678 | if (!debug_information [i].max_range_lists) |
| 5679 | free (debug_information [i].range_lists); |
| 5680 | } |
| 5681 | } |
| 5682 | |
| 5683 | free (debug_information); |
| 5684 | debug_information = NULL; |
| 5685 | num_debug_info_entries = 0; |
| 5686 | } |
| 5687 | } |
| 5688 | |
| 5689 | void |
| 5690 | dwarf_select_sections_by_names (const char *names) |
| 5691 | { |
| 5692 | typedef struct |
| 5693 | { |
| 5694 | const char * option; |
| 5695 | int * variable; |
| 5696 | int val; |
| 5697 | } |
| 5698 | debug_dump_long_opts; |
| 5699 | |
| 5700 | static const debug_dump_long_opts opts_table [] = |
| 5701 | { |
| 5702 | /* Please keep this table alpha- sorted. */ |
| 5703 | { "Ranges", & do_debug_ranges, 1 }, |
| 5704 | { "abbrev", & do_debug_abbrevs, 1 }, |
| 5705 | { "aranges", & do_debug_aranges, 1 }, |
| 5706 | { "frames", & do_debug_frames, 1 }, |
| 5707 | { "frames-interp", & do_debug_frames_interp, 1 }, |
| 5708 | { "info", & do_debug_info, 1 }, |
| 5709 | { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */ |
| 5710 | { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, |
| 5711 | { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, |
| 5712 | { "loc", & do_debug_loc, 1 }, |
| 5713 | { "macro", & do_debug_macinfo, 1 }, |
| 5714 | { "pubnames", & do_debug_pubnames, 1 }, |
| 5715 | { "pubtypes", & do_debug_pubtypes, 1 }, |
| 5716 | /* This entry is for compatability |
| 5717 | with earlier versions of readelf. */ |
| 5718 | { "ranges", & do_debug_aranges, 1 }, |
| 5719 | { "str", & do_debug_str, 1 }, |
| 5720 | /* The special .gdb_index section. */ |
| 5721 | { "gdb_index", & do_gdb_index, 1 }, |
| 5722 | /* These trace_* sections are used by Itanium VMS. */ |
| 5723 | { "trace_abbrev", & do_trace_abbrevs, 1 }, |
| 5724 | { "trace_aranges", & do_trace_aranges, 1 }, |
| 5725 | { "trace_info", & do_trace_info, 1 }, |
| 5726 | { NULL, NULL, 0 } |
| 5727 | }; |
| 5728 | |
| 5729 | const char *p; |
| 5730 | |
| 5731 | p = names; |
| 5732 | while (*p) |
| 5733 | { |
| 5734 | const debug_dump_long_opts * entry; |
| 5735 | |
| 5736 | for (entry = opts_table; entry->option; entry++) |
| 5737 | { |
| 5738 | size_t len = strlen (entry->option); |
| 5739 | |
| 5740 | if (strncmp (p, entry->option, len) == 0 |
| 5741 | && (p[len] == ',' || p[len] == '\0')) |
| 5742 | { |
| 5743 | * entry->variable |= entry->val; |
| 5744 | |
| 5745 | /* The --debug-dump=frames-interp option also |
| 5746 | enables the --debug-dump=frames option. */ |
| 5747 | if (do_debug_frames_interp) |
| 5748 | do_debug_frames = 1; |
| 5749 | |
| 5750 | p += len; |
| 5751 | break; |
| 5752 | } |
| 5753 | } |
| 5754 | |
| 5755 | if (entry->option == NULL) |
| 5756 | { |
| 5757 | warn (_("Unrecognized debug option '%s'\n"), p); |
| 5758 | p = strchr (p, ','); |
| 5759 | if (p == NULL) |
| 5760 | break; |
| 5761 | } |
| 5762 | |
| 5763 | if (*p == ',') |
| 5764 | p++; |
| 5765 | } |
| 5766 | } |
| 5767 | |
| 5768 | void |
| 5769 | dwarf_select_sections_by_letters (const char *letters) |
| 5770 | { |
| 5771 | unsigned int lindex = 0; |
| 5772 | |
| 5773 | while (letters[lindex]) |
| 5774 | switch (letters[lindex++]) |
| 5775 | { |
| 5776 | case 'i': |
| 5777 | do_debug_info = 1; |
| 5778 | break; |
| 5779 | |
| 5780 | case 'a': |
| 5781 | do_debug_abbrevs = 1; |
| 5782 | break; |
| 5783 | |
| 5784 | case 'l': |
| 5785 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; |
| 5786 | break; |
| 5787 | |
| 5788 | case 'L': |
| 5789 | do_debug_lines |= FLAG_DEBUG_LINES_DECODED; |
| 5790 | break; |
| 5791 | |
| 5792 | case 'p': |
| 5793 | do_debug_pubnames = 1; |
| 5794 | break; |
| 5795 | |
| 5796 | case 't': |
| 5797 | do_debug_pubtypes = 1; |
| 5798 | break; |
| 5799 | |
| 5800 | case 'r': |
| 5801 | do_debug_aranges = 1; |
| 5802 | break; |
| 5803 | |
| 5804 | case 'R': |
| 5805 | do_debug_ranges = 1; |
| 5806 | break; |
| 5807 | |
| 5808 | case 'F': |
| 5809 | do_debug_frames_interp = 1; |
| 5810 | case 'f': |
| 5811 | do_debug_frames = 1; |
| 5812 | break; |
| 5813 | |
| 5814 | case 'm': |
| 5815 | do_debug_macinfo = 1; |
| 5816 | break; |
| 5817 | |
| 5818 | case 's': |
| 5819 | do_debug_str = 1; |
| 5820 | break; |
| 5821 | |
| 5822 | case 'o': |
| 5823 | do_debug_loc = 1; |
| 5824 | break; |
| 5825 | |
| 5826 | default: |
| 5827 | warn (_("Unrecognized debug option '%s'\n"), optarg); |
| 5828 | break; |
| 5829 | } |
| 5830 | } |
| 5831 | |
| 5832 | void |
| 5833 | dwarf_select_sections_all (void) |
| 5834 | { |
| 5835 | do_debug_info = 1; |
| 5836 | do_debug_abbrevs = 1; |
| 5837 | do_debug_lines = FLAG_DEBUG_LINES_RAW; |
| 5838 | do_debug_pubnames = 1; |
| 5839 | do_debug_pubtypes = 1; |
| 5840 | do_debug_aranges = 1; |
| 5841 | do_debug_ranges = 1; |
| 5842 | do_debug_frames = 1; |
| 5843 | do_debug_macinfo = 1; |
| 5844 | do_debug_str = 1; |
| 5845 | do_debug_loc = 1; |
| 5846 | do_gdb_index = 1; |
| 5847 | do_trace_info = 1; |
| 5848 | do_trace_abbrevs = 1; |
| 5849 | do_trace_aranges = 1; |
| 5850 | } |
| 5851 | |
| 5852 | struct dwarf_section_display debug_displays[] = |
| 5853 | { |
| 5854 | { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 }, |
| 5855 | display_debug_abbrev, &do_debug_abbrevs, 0 }, |
| 5856 | { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 }, |
| 5857 | display_debug_aranges, &do_debug_aranges, 1 }, |
| 5858 | { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 }, |
| 5859 | display_debug_frames, &do_debug_frames, 1 }, |
| 5860 | { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 }, |
| 5861 | display_debug_info, &do_debug_info, 1 }, |
| 5862 | { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 }, |
| 5863 | display_debug_lines, &do_debug_lines, 1 }, |
| 5864 | { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 }, |
| 5865 | display_debug_pubnames, &do_debug_pubnames, 0 }, |
| 5866 | { { ".eh_frame", "", NULL, NULL, 0, 0 }, |
| 5867 | display_debug_frames, &do_debug_frames, 1 }, |
| 5868 | { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 }, |
| 5869 | display_debug_macinfo, &do_debug_macinfo, 0 }, |
| 5870 | { { ".debug_macro", ".zdebug_macro", NULL, NULL, 0, 0 }, |
| 5871 | display_debug_macro, &do_debug_macinfo, 1 }, |
| 5872 | { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 }, |
| 5873 | display_debug_str, &do_debug_str, 0 }, |
| 5874 | { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 }, |
| 5875 | display_debug_loc, &do_debug_loc, 1 }, |
| 5876 | { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 }, |
| 5877 | display_debug_pubnames, &do_debug_pubtypes, 0 }, |
| 5878 | { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 }, |
| 5879 | display_debug_ranges, &do_debug_ranges, 1 }, |
| 5880 | { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 }, |
| 5881 | display_debug_not_supported, NULL, 0 }, |
| 5882 | { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 }, |
| 5883 | display_debug_not_supported, NULL, 0 }, |
| 5884 | { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 }, |
| 5885 | display_debug_types, &do_debug_info, 1 }, |
| 5886 | { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 }, |
| 5887 | display_debug_not_supported, NULL, 0 }, |
| 5888 | { { ".gdb_index", "", NULL, NULL, 0, 0 }, |
| 5889 | display_gdb_index, &do_gdb_index, 0 }, |
| 5890 | { { ".trace_info", "", NULL, NULL, 0, 0 }, |
| 5891 | display_trace_info, &do_trace_info, 1 }, |
| 5892 | { { ".trace_abbrev", "", NULL, NULL, 0, 0 }, |
| 5893 | display_debug_abbrev, &do_trace_abbrevs, 0 }, |
| 5894 | { { ".trace_aranges", "", NULL, NULL, 0, 0 }, |
| 5895 | display_debug_aranges, &do_trace_aranges, 0 } |
| 5896 | }; |