| /* dwarf.c -- display DWARF contents of a BFD binary file |
| Copyright (C) 2005-2021 Free Software Foundation, Inc. |
| |
| This file is part of GNU Binutils. |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation; either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
| Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
| 02110-1301, USA. */ |
| |
| #include "sysdep.h" |
| #include "libiberty.h" |
| #include "bfd.h" |
| #include <stdint.h> |
| #include "bucomm.h" |
| #include "elfcomm.h" |
| #include "elf/common.h" |
| #include "dwarf2.h" |
| #include "dwarf.h" |
| #include "gdb/gdb-index.h" |
| #include "filenames.h" |
| #include "safe-ctype.h" |
| #include <assert.h> |
| |
| #ifdef HAVE_LIBDEBUGINFOD |
| #include <elfutils/debuginfod.h> |
| #endif |
| |
| #include <limits.h> |
| #ifndef CHAR_BIT |
| #define CHAR_BIT 8 |
| #endif |
| |
| #ifndef ENABLE_CHECKING |
| #define ENABLE_CHECKING 0 |
| #endif |
| |
| #undef MAX |
| #undef MIN |
| #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
| #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| |
| static const char *regname (unsigned int regno, int row); |
| static const char *regname_internal_by_table_only (unsigned int regno); |
| |
| static int have_frame_base; |
| static int need_base_address; |
| |
| static unsigned int num_debug_info_entries = 0; |
| static unsigned int alloc_num_debug_info_entries = 0; |
| static debug_info *debug_information = NULL; |
| /* Special value for num_debug_info_entries to indicate |
| that the .debug_info section could not be loaded/parsed. */ |
| #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 |
| |
| /* A .debug_info section can contain multiple links to separate |
| DWO object files. We use these structures to record these links. */ |
| typedef enum dwo_type |
| { |
| DWO_NAME, |
| DWO_DIR, |
| DWO_ID |
| } dwo_type; |
| |
| typedef struct dwo_info |
| { |
| dwo_type type; |
| const char * value; |
| dwarf_vma cu_offset; |
| struct dwo_info * next; |
| } dwo_info; |
| |
| static dwo_info *first_dwo_info = NULL; |
| static bool need_dwo_info; |
| |
| separate_info * first_separate_info = NULL; |
| |
| unsigned int eh_addr_size; |
| |
| int do_debug_info; |
| int do_debug_abbrevs; |
| int do_debug_lines; |
| int do_debug_pubnames; |
| int do_debug_pubtypes; |
| int do_debug_aranges; |
| int do_debug_ranges; |
| int do_debug_frames; |
| int do_debug_frames_interp; |
| int do_debug_macinfo; |
| int do_debug_str; |
| int do_debug_str_offsets; |
| int do_debug_loc; |
| int do_gdb_index; |
| int do_trace_info; |
| int do_trace_abbrevs; |
| int do_trace_aranges; |
| int do_debug_addr; |
| int do_debug_cu_index; |
| int do_wide; |
| int do_debug_links; |
| int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS; |
| bool do_checks; |
| |
| int dwarf_cutoff_level = -1; |
| unsigned long dwarf_start_die; |
| |
| int dwarf_check = 0; |
| |
| /* Convenient constant, to avoid having to cast -1 to dwarf_vma when |
| testing whether e.g. a locview list is present. */ |
| static const dwarf_vma vm1 = -1; |
| |
| /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index |
| sections. For version 1 package files, each set is stored in SHNDX_POOL |
| as a zero-terminated list of section indexes comprising one set of debug |
| sections from a .dwo file. */ |
| |
| static unsigned int *shndx_pool = NULL; |
| static unsigned int shndx_pool_size = 0; |
| static unsigned int shndx_pool_used = 0; |
| |
| /* For version 2 package files, each set contains an array of section offsets |
| and an array of section sizes, giving the offset and size of the |
| contribution from a CU or TU within one of the debug sections. |
| When displaying debug info from a package file, we need to use these |
| tables to locate the corresponding contributions to each section. */ |
| |
| struct cu_tu_set |
| { |
| uint64_t signature; |
| dwarf_vma section_offsets[DW_SECT_MAX]; |
| size_t section_sizes[DW_SECT_MAX]; |
| }; |
| |
| static int cu_count = 0; |
| static int tu_count = 0; |
| static struct cu_tu_set *cu_sets = NULL; |
| static struct cu_tu_set *tu_sets = NULL; |
| |
| static bool load_cu_tu_indexes (void *); |
| |
| /* An array that indicates for a given level of CU nesting whether |
| the latest DW_AT_type seen for that level was a signed type or |
| an unsigned type. */ |
| #define MAX_CU_NESTING (1 << 8) |
| static bool level_type_signed[MAX_CU_NESTING]; |
| |
| /* Values for do_debug_lines. */ |
| #define FLAG_DEBUG_LINES_RAW 1 |
| #define FLAG_DEBUG_LINES_DECODED 2 |
| |
| static unsigned int |
| size_of_encoded_value (int encoding) |
| { |
| switch (encoding & 0x7) |
| { |
| default: /* ??? */ |
| case 0: return eh_addr_size; |
| case 2: return 2; |
| case 3: return 4; |
| case 4: return 8; |
| } |
| } |
| |
| static dwarf_vma |
| get_encoded_value (unsigned char **pdata, |
| int encoding, |
| struct dwarf_section *section, |
| unsigned char * end) |
| { |
| unsigned char * data = * pdata; |
| unsigned int size = size_of_encoded_value (encoding); |
| dwarf_vma val; |
| |
| if (data >= end || size > (size_t) (end - data)) |
| { |
| warn (_("Encoded value extends past end of section\n")); |
| * pdata = end; |
| return 0; |
| } |
| |
| /* PR 17512: file: 002-829853-0.004. */ |
| if (size > 8) |
| { |
| warn (_("Encoded size of %d is too large to read\n"), size); |
| * pdata = end; |
| return 0; |
| } |
| |
| /* PR 17512: file: 1085-5603-0.004. */ |
| if (size == 0) |
| { |
| warn (_("Encoded size of 0 is too small to read\n")); |
| * pdata = end; |
| return 0; |
| } |
| |
| if (encoding & DW_EH_PE_signed) |
| val = byte_get_signed (data, size); |
| else |
| val = byte_get (data, size); |
| |
| if ((encoding & 0x70) == DW_EH_PE_pcrel) |
| val += section->address + (data - section->start); |
| |
| * pdata = data + size; |
| return val; |
| } |
| |
| #if SIZEOF_LONG_LONG > SIZEOF_LONG |
| # ifndef __MINGW32__ |
| # define DWARF_VMA_FMT "ll" |
| # define DWARF_VMA_FMT_LONG "%16.16llx" |
| # else |
| # define DWARF_VMA_FMT "I64" |
| # define DWARF_VMA_FMT_LONG "%016I64x" |
| # endif |
| #else |
| # define DWARF_VMA_FMT "l" |
| # define DWARF_VMA_FMT_LONG "%16.16lx" |
| #endif |
| |
| /* Convert a dwarf vma value into a string. Returns a pointer to a static |
| buffer containing the converted VALUE. The value is converted according |
| to the printf formating character FMTCH. If NUM_BYTES is non-zero then |
| it specifies the maximum number of bytes to be displayed in the converted |
| value and FMTCH is ignored - hex is always used. */ |
| |
| static const char * |
| dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes) |
| { |
| /* As dwarf_vmatoa is used more then once in a printf call |
| for output, we are cycling through an fixed array of pointers |
| for return address. */ |
| static int buf_pos = 0; |
| static struct dwarf_vmatoa_buf |
| { |
| char place[64]; |
| } buf[16]; |
| char *ret; |
| |
| ret = buf[buf_pos++].place; |
| buf_pos %= ARRAY_SIZE (buf); |
| |
| if (num_bytes) |
| { |
| /* Printf does not have a way of specifying a maximum field width for an |
| integer value, so we print the full value into a buffer and then select |
| the precision we need. */ |
| snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value); |
| if (num_bytes > 8) |
| num_bytes = 8; |
| return ret + (16 - 2 * num_bytes); |
| } |
| else |
| { |
| char fmt[32]; |
| |
| if (fmtch) |
| sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); |
| else |
| sprintf (fmt, "%%%s", DWARF_VMA_FMT); |
| snprintf (ret, sizeof (buf[0].place), fmt, value); |
| return ret; |
| } |
| } |
| |
| static inline const char * |
| dwarf_vmatoa (const char * fmtch, dwarf_vma value) |
| { |
| return dwarf_vmatoa_1 (fmtch, value, 0); |
| } |
| |
| /* Print a dwarf_vma value (typically an address, offset or length) in |
| hexadecimal format, followed by a space. The length of the VALUE (and |
| hence the precision displayed) is determined by the NUM_BYTES parameter. */ |
| |
| static void |
| print_dwarf_vma (dwarf_vma value, unsigned num_bytes) |
| { |
| printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes)); |
| } |
| |
| /* Print a view number in hexadecimal value, with the same width |
| print_dwarf_vma would have printed it with the same num_bytes. |
| Print blanks for zero view, unless force is nonzero. */ |
| |
| static void |
| print_dwarf_view (dwarf_vma value, unsigned num_bytes, int force) |
| { |
| int len; |
| if (!num_bytes) |
| len = 4; |
| else |
| len = num_bytes * 2; |
| |
| assert (value == (unsigned long) value); |
| if (value || force) |
| printf ("v%0*lx ", len - 1, (unsigned long) value); |
| else |
| printf ("%*s", len + 1, ""); |
| } |
| |
| /* Read in a LEB128 encoded value starting at address DATA. |
| If SIGN is true, return a signed LEB128 value. |
| If LENGTH_RETURN is not NULL, return in it the number of bytes read. |
| If STATUS_RETURN is not NULL, return with bit 0 (LSB) set if the |
| terminating byte was not found and with bit 1 set if the value |
| overflows a dwarf_vma. |
| No bytes will be read at address END or beyond. */ |
| |
| dwarf_vma |
| read_leb128 (unsigned char *data, |
| const unsigned char *const end, |
| bool sign, |
| unsigned int *length_return, |
| int *status_return) |
| { |
| dwarf_vma result = 0; |
| unsigned int num_read = 0; |
| unsigned int shift = 0; |
| int status = 1; |
| |
| while (data < end) |
| { |
| unsigned char byte = *data++; |
| unsigned char lost, mask; |
| |
| num_read++; |
| |
| if (shift < CHAR_BIT * sizeof (result)) |
| { |
| result |= ((dwarf_vma) (byte & 0x7f)) << shift; |
| /* These bits overflowed. */ |
| lost = byte ^ (result >> shift); |
| /* And this is the mask of possible overflow bits. */ |
| mask = 0x7f ^ ((dwarf_vma) 0x7f << shift >> shift); |
| shift += 7; |
| } |
| else |
| { |
| lost = byte; |
| mask = 0x7f; |
| } |
| if ((lost & mask) != (sign && (dwarf_signed_vma) result < 0 ? mask : 0)) |
| status |= 2; |
| |
| if ((byte & 0x80) == 0) |
| { |
| status &= ~1; |
| if (sign && shift < CHAR_BIT * sizeof (result) && (byte & 0x40)) |
| result |= -((dwarf_vma) 1 << shift); |
| break; |
| } |
| } |
| |
| if (length_return != NULL) |
| *length_return = num_read; |
| if (status_return != NULL) |
| *status_return = status; |
| |
| return result; |
| } |
| |
| /* Read AMOUNT bytes from PTR and store them in VAL. |
| Checks to make sure that the read will not reach or pass END. |
| FUNC chooses whether the value read is unsigned or signed, and may |
| be either byte_get or byte_get_signed. If INC is true, PTR is |
| incremented after reading the value. |
| This macro cannot protect against PTR values derived from user input. |
| The C standard sections 6.5.6 and 6.5.8 say attempts to do so using |
| pointers is undefined behaviour. */ |
| #define SAFE_BYTE_GET_INTERNAL(VAL, PTR, AMOUNT, END, FUNC, INC) \ |
| do \ |
| { \ |
| size_t amount = (AMOUNT); \ |
| if (sizeof (VAL) < amount) \ |
| { \ |
| error (ngettext ("internal error: attempt to read %d byte " \ |
| "of data in to %d sized variable", \ |
| "internal error: attempt to read %d bytes " \ |
| "of data in to %d sized variable", \ |
| amount), \ |
| (int) amount, (int) sizeof (VAL)); \ |
| amount = sizeof (VAL); \ |
| } \ |
| if (ENABLE_CHECKING) \ |
| assert ((PTR) <= (END)); \ |
| size_t avail = (END) - (PTR); \ |
| if ((PTR) > (END)) \ |
| avail = 0; \ |
| if (amount > avail) \ |
| amount = avail; \ |
| if (amount == 0) \ |
| (VAL) = 0; \ |
| else \ |
| (VAL) = (FUNC) ((PTR), amount); \ |
| if (INC) \ |
| (PTR) += amount; \ |
| } \ |
| while (0) |
| |
| #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \ |
| SAFE_BYTE_GET_INTERNAL (VAL, PTR, AMOUNT, END, byte_get, false) |
| |
| #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ |
| SAFE_BYTE_GET_INTERNAL (VAL, PTR, AMOUNT, END, byte_get, true) |
| |
| #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \ |
| SAFE_BYTE_GET_INTERNAL (VAL, PTR, AMOUNT, END, byte_get_signed, false) |
| |
| #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ |
| SAFE_BYTE_GET_INTERNAL (VAL, PTR, AMOUNT, END, byte_get_signed, true) |
| |
| typedef struct State_Machine_Registers |
| { |
| dwarf_vma address; |
| unsigned int view; |
| unsigned int file; |
| unsigned int line; |
| unsigned int column; |
| int is_stmt; |
| int basic_block; |
| unsigned char op_index; |
| unsigned char end_sequence; |
| /* This variable hold the number of the last entry seen |
| in the File Table. */ |
| unsigned int last_file_entry; |
| } SMR; |
| |
| static SMR state_machine_regs; |
| |
| static void |
| reset_state_machine (int is_stmt) |
| { |
| state_machine_regs.address = 0; |
| state_machine_regs.view = 0; |
| state_machine_regs.op_index = 0; |
| state_machine_regs.file = 1; |
| state_machine_regs.line = 1; |
| state_machine_regs.column = 0; |
| state_machine_regs.is_stmt = is_stmt; |
| state_machine_regs.basic_block = 0; |
| state_machine_regs.end_sequence = 0; |
| state_machine_regs.last_file_entry = 0; |
| } |
| |
| /* Handled an extend line op. |
| Returns the number of bytes read. */ |
| |
| static size_t |
| process_extended_line_op (unsigned char * data, |
| int is_stmt, |
| unsigned char * end) |
| { |
| unsigned char op_code; |
| size_t len, header_len; |
| unsigned char *name; |
| unsigned char *orig_data = data; |
| dwarf_vma adr, val; |
| |
| READ_ULEB (len, data, end); |
| header_len = data - orig_data; |
| |
| if (len == 0 || data >= end || len > (size_t) (end - data)) |
| { |
| warn (_("Badly formed extended line op encountered!\n")); |
| return header_len; |
| } |
| |
| op_code = *data++; |
| |
| printf (_(" Extended opcode %d: "), op_code); |
| |
| switch (op_code) |
| { |
| case DW_LNE_end_sequence: |
| printf (_("End of Sequence\n\n")); |
| reset_state_machine (is_stmt); |
| break; |
| |
| case DW_LNE_set_address: |
| /* PR 17512: file: 002-100480-0.004. */ |
| if (len - 1 > 8) |
| { |
| warn (_("Length (%lu) of DW_LNE_set_address op is too long\n"), |
| (unsigned long) len - 1); |
| adr = 0; |
| } |
| else |
| SAFE_BYTE_GET (adr, data, len - 1, end); |
| printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); |
| state_machine_regs.address = adr; |
| state_machine_regs.view = 0; |
| state_machine_regs.op_index = 0; |
| break; |
| |
| case DW_LNE_define_file: |
| printf (_("define new File Table entry\n")); |
| printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
| printf (" %d\t", ++state_machine_regs.last_file_entry); |
| |
| { |
| size_t l; |
| |
| name = data; |
| l = strnlen ((char *) data, end - data); |
| data += l; |
| if (data < end) |
| data++; |
| READ_ULEB (val, data, end); |
| printf ("%s\t", dwarf_vmatoa ("u", val)); |
| READ_ULEB (val, data, end); |
| printf ("%s\t", dwarf_vmatoa ("u", val)); |
| READ_ULEB (val, data, end); |
| printf ("%s\t", dwarf_vmatoa ("u", val)); |
| printf ("%.*s\n\n", (int) l, name); |
| } |
| |
| if (((size_t) (data - orig_data) != len + header_len) || data >= end) |
| warn (_("DW_LNE_define_file: Bad opcode length\n")); |
| break; |
| |
| case DW_LNE_set_discriminator: |
| READ_ULEB (val, data, end); |
| printf (_("set Discriminator to %s\n"), dwarf_vmatoa ("u", val)); |
| break; |
| |
| /* HP extensions. */ |
| case DW_LNE_HP_negate_is_UV_update: |
| printf ("DW_LNE_HP_negate_is_UV_update\n"); |
| break; |
| case DW_LNE_HP_push_context: |
| printf ("DW_LNE_HP_push_context\n"); |
| break; |
| case DW_LNE_HP_pop_context: |
| printf ("DW_LNE_HP_pop_context\n"); |
| break; |
| case DW_LNE_HP_set_file_line_column: |
| printf ("DW_LNE_HP_set_file_line_column\n"); |
| break; |
| case DW_LNE_HP_set_routine_name: |
| printf ("DW_LNE_HP_set_routine_name\n"); |
| break; |
| case DW_LNE_HP_set_sequence: |
| printf ("DW_LNE_HP_set_sequence\n"); |
| break; |
| case DW_LNE_HP_negate_post_semantics: |
| printf ("DW_LNE_HP_negate_post_semantics\n"); |
| break; |
| case DW_LNE_HP_negate_function_exit: |
| printf ("DW_LNE_HP_negate_function_exit\n"); |
| break; |
| case DW_LNE_HP_negate_front_end_logical: |
| printf ("DW_LNE_HP_negate_front_end_logical\n"); |
| break; |
| case DW_LNE_HP_define_proc: |
| printf ("DW_LNE_HP_define_proc\n"); |
| break; |
| case DW_LNE_HP_source_file_correlation: |
| { |
| unsigned char *edata = data + len - 1; |
| |
| printf ("DW_LNE_HP_source_file_correlation\n"); |
| |
| while (data < edata) |
| { |
| unsigned int opc; |
| |
| READ_ULEB (opc, data, edata); |
| |
| switch (opc) |
| { |
| case DW_LNE_HP_SFC_formfeed: |
| printf (" DW_LNE_HP_SFC_formfeed\n"); |
| break; |
| case DW_LNE_HP_SFC_set_listing_line: |
| READ_ULEB (val, data, edata); |
| printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", |
| dwarf_vmatoa ("u", val)); |
| break; |
| case DW_LNE_HP_SFC_associate: |
| printf (" DW_LNE_HP_SFC_associate "); |
| READ_ULEB (val, data, edata); |
| printf ("(%s", dwarf_vmatoa ("u", val)); |
| READ_ULEB (val, data, edata); |
| printf (",%s", dwarf_vmatoa ("u", val)); |
| READ_ULEB (val, data, edata); |
| printf (",%s)\n", dwarf_vmatoa ("u", val)); |
| break; |
| default: |
| printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc); |
| data = edata; |
| break; |
| } |
| } |
| } |
| break; |
| |
| default: |
| { |
| unsigned int rlen = len - 1; |
| |
| if (op_code >= DW_LNE_lo_user |
| /* The test against DW_LNW_hi_user is redundant due to |
| the limited range of the unsigned char data type used |
| for op_code. */ |
| /*&& op_code <= DW_LNE_hi_user*/) |
| printf (_("user defined: ")); |
| else |
| printf (_("UNKNOWN: ")); |
| printf (_("length %d ["), rlen); |
| for (; rlen; rlen--) |
| printf (" %02x", *data++); |
| printf ("]\n"); |
| } |
| break; |
| } |
| |
| return len + header_len; |
| } |
| |
| static const unsigned char * |
| fetch_indirect_string (dwarf_vma offset) |
| { |
| struct dwarf_section *section = &debug_displays [str].section; |
| const unsigned char * ret; |
| |
| if (section->start == NULL) |
| return (const unsigned char *) _("<no .debug_str section>"); |
| |
| if (offset >= section->size) |
| { |
| warn (_("DW_FORM_strp offset too big: 0x%s\n"), |
| dwarf_vmatoa ("x", offset)); |
| return (const unsigned char *) _("<offset is too big>"); |
| } |
| |
| ret = section->start + offset; |
| /* Unfortunately we cannot rely upon the .debug_str section ending with a |
| NUL byte. Since our caller is expecting to receive a well formed C |
| string we test for the lack of a terminating byte here. */ |
| if (strnlen ((const char *) ret, section->size - offset) |
| == section->size - offset) |
| ret = (const unsigned char *) |
| _("<no NUL byte at end of .debug_str section>"); |
| |
| return ret; |
| } |
| |
| static const unsigned char * |
| fetch_indirect_line_string (dwarf_vma offset) |
| { |
| struct dwarf_section *section = &debug_displays [line_str].section; |
| const unsigned char * ret; |
| |
| if (section->start == NULL) |
| return (const unsigned char *) _("<no .debug_line_str section>"); |
| |
| if (offset >= section->size) |
| { |
| warn (_("DW_FORM_line_strp offset too big: 0x%s\n"), |
| dwarf_vmatoa ("x", offset)); |
| return (const unsigned char *) _("<offset is too big>"); |
| } |
| |
| ret = section->start + offset; |
| /* Unfortunately we cannot rely upon the .debug_line_str section ending |
| with a NUL byte. Since our caller is expecting to receive a well formed |
| C string we test for the lack of a terminating byte here. */ |
| if (strnlen ((const char *) ret, section->size - offset) |
| == section->size - offset) |
| ret = (const unsigned char *) |
| _("<no NUL byte at end of .debug_line_str section>"); |
| |
| return ret; |
| } |
| |
| static const char * |
| fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, |
| dwarf_vma offset_size, bool dwo) |
| { |
| enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str; |
| enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index; |
| struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section; |
| struct dwarf_section *str_section = &debug_displays [str_sec_idx].section; |
| dwarf_vma index_offset; |
| dwarf_vma str_offset; |
| const char * ret; |
| unsigned char *curr = index_section->start; |
| unsigned char *end = curr + index_section->size; |
| dwarf_vma length; |
| |
| if (index_section->start == NULL) |
| return (dwo ? _("<no .debug_str_offsets.dwo section>") |
| : _("<no .debug_str_offsets section>")); |
| |
| if (str_section->start == NULL) |
| return (dwo ? _("<no .debug_str.dwo section>") |
| : _("<no .debug_str section>")); |
| |
| /* FIXME: We should cache the length... */ |
| SAFE_BYTE_GET_AND_INC (length, curr, 4, end); |
| if (length == 0xffffffff) |
| { |
| if (offset_size != 8) |
| warn (_("Expected offset size of 8 but given %s"), dwarf_vmatoa ("x", offset_size)); |
| SAFE_BYTE_GET_AND_INC (length, curr, 8, end); |
| } |
| else if (offset_size != 4) |
| { |
| warn (_("Expected offset size of 4 but given %s"), dwarf_vmatoa ("x", offset_size)); |
| } |
| |
| if (length == 0) |
| { |
| /* This is probably an old style .debug_str_offset section which |
| just contains offsets and no header (and the first offset is 0). */ |
| curr = index_section->start; |
| length = index_section->size; |
| } |
| else |
| { |
| /* Skip the version and padding bytes. |
| We assume that they are correct. */ |
| if (end - curr >= 4) |
| curr += 4; |
| else |
| curr = end; |
| if (length >= 4) |
| length -= 4; |
| else |
| length = 0; |
| |
| if (this_set != NULL |
| && this_set->section_sizes[DW_SECT_STR_OFFSETS] < length) |
| length = this_set->section_sizes[DW_SECT_STR_OFFSETS]; |
| |
| if (length > (dwarf_vma) (end - curr)) |
| { |
| warn (_("index table size too large for section %s vs %s\n"), |
| dwarf_vmatoa ("x", length), |
| dwarf_vmatoa ("x", index_section->size)); |
| length = end - curr; |
| } |
| |
| if (length < offset_size) |
| { |
| warn (_("index table size %s is too small\n"), |
| dwarf_vmatoa ("x", length)); |
| return _("<table too small>"); |
| } |
| } |
| |
| index_offset = idx * offset_size; |
| |
| if (this_set != NULL) |
| index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; |
| |
| if (index_offset >= length |
| || length - index_offset < offset_size) |
| { |
| warn (_("DW_FORM_GNU_str_index offset too big: 0x%s vs 0x%s\n"), |
| dwarf_vmatoa ("x", index_offset), |
| dwarf_vmatoa ("x", length)); |
| return _("<index offset is too big>"); |
| } |
| |
| str_offset = byte_get (curr + index_offset, offset_size); |
| str_offset -= str_section->address; |
| if (str_offset >= str_section->size) |
| { |
| warn (_("DW_FORM_GNU_str_index indirect offset too big: 0x%s\n"), |
| dwarf_vmatoa ("x", str_offset)); |
| return _("<indirect index offset is too big>"); |
| } |
| |
| ret = (const char *) str_section->start + str_offset; |
| /* Unfortunately we cannot rely upon str_section ending with a NUL byte. |
| Since our caller is expecting to receive a well formed C string we test |
| for the lack of a terminating byte here. */ |
| if (strnlen (ret, str_section->size - str_offset) |
| == str_section->size - str_offset) |
| ret = (const char *) _("<no NUL byte at end of section>"); |
| |
| return ret; |
| } |
| |
| static const char * |
| fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes) |
| { |
| struct dwarf_section *section = &debug_displays [debug_addr].section; |
| |
| if (section->start == NULL) |
| return (_("<no .debug_addr section>")); |
| |
| if (offset + bytes > section->size) |
| { |
| warn (_("Offset into section %s too big: 0x%s\n"), |
| section->name, dwarf_vmatoa ("x", offset)); |
| return "<offset too big>"; |
| } |
| |
| return dwarf_vmatoa ("x", byte_get (section->start + offset, bytes)); |
| } |
| |
| |
| /* FIXME: There are better and more efficient ways to handle |
| these structures. For now though, I just want something that |
| is simple to implement. */ |
| /* Records a single attribute in an abbrev. */ |
| typedef struct abbrev_attr |
| { |
| unsigned long attribute; |
| unsigned long form; |
| dwarf_signed_vma implicit_const; |
| struct abbrev_attr * next; |
| } |
| abbrev_attr; |
| |
| /* Records a single abbrev. */ |
| typedef struct abbrev_entry |
| { |
| unsigned long number; |
| unsigned long tag; |
| int children; |
| struct abbrev_attr * first_attr; |
| struct abbrev_attr * last_attr; |
| struct abbrev_entry * next; |
| } |
| abbrev_entry; |
| |
| /* Records a set of abbreviations. */ |
| typedef struct abbrev_list |
| { |
| abbrev_entry * first_abbrev; |
| abbrev_entry * last_abbrev; |
| dwarf_vma abbrev_base; |
| dwarf_vma abbrev_offset; |
| struct abbrev_list * next; |
| unsigned char * start_of_next_abbrevs; |
| } |
| abbrev_list; |
| |
| /* Records all the abbrevs found so far. */ |
| static struct abbrev_list * abbrev_lists = NULL; |
| |
| typedef struct abbrev_map |
| { |
| dwarf_vma start; |
| dwarf_vma end; |
| abbrev_list * list; |
| } abbrev_map; |
| |
| /* Maps between CU offsets and abbrev sets. */ |
| static abbrev_map * cu_abbrev_map = NULL; |
| static unsigned long num_abbrev_map_entries = 0; |
| static unsigned long next_free_abbrev_map_entry = 0; |
| |
| #define INITIAL_NUM_ABBREV_MAP_ENTRIES 8 |
| #define ABBREV_MAP_ENTRIES_INCREMENT 8 |
| |
| static void |
| record_abbrev_list_for_cu (dwarf_vma start, dwarf_vma end, abbrev_list * list) |
| { |
| if (cu_abbrev_map == NULL) |
| { |
| num_abbrev_map_entries = INITIAL_NUM_ABBREV_MAP_ENTRIES; |
| cu_abbrev_map = xmalloc (num_abbrev_map_entries * sizeof (* cu_abbrev_map)); |
| } |
| else if (next_free_abbrev_map_entry == num_abbrev_map_entries) |
| { |
| num_abbrev_map_entries += ABBREV_MAP_ENTRIES_INCREMENT; |
| cu_abbrev_map = xrealloc (cu_abbrev_map, num_abbrev_map_entries * sizeof (* cu_abbrev_map)); |
| } |
| |
| cu_abbrev_map[next_free_abbrev_map_entry].start = start; |
| cu_abbrev_map[next_free_abbrev_map_entry].end = end; |
| cu_abbrev_map[next_free_abbrev_map_entry].list = list; |
| next_free_abbrev_map_entry ++; |
| } |
| |
| static void |
| free_all_abbrevs (void) |
| { |
| abbrev_list * list; |
| |
| for (list = abbrev_lists; list != NULL;) |
| { |
| abbrev_list * next = list->next; |
| abbrev_entry * abbrv; |
| |
| for (abbrv = list->first_abbrev; abbrv != NULL;) |
| { |
| abbrev_entry * next_abbrev = abbrv->next; |
| abbrev_attr * attr; |
| |
| for (attr = abbrv->first_attr; attr;) |
| { |
| abbrev_attr *next_attr = attr->next; |
| |
| free (attr); |
| attr = next_attr; |
| } |
| |
| free (abbrv); |
| abbrv = next_abbrev; |
| } |
| |
| free (list); |
| list = next; |
| } |
| |
| abbrev_lists = NULL; |
| } |
| |
| static abbrev_list * |
| new_abbrev_list (dwarf_vma abbrev_base, dwarf_vma abbrev_offset) |
| { |
| abbrev_list * list = (abbrev_list *) xcalloc (sizeof * list, 1); |
| |
| list->abbrev_base = abbrev_base; |
| list->abbrev_offset = abbrev_offset; |
| |
| list->next = abbrev_lists; |
| abbrev_lists = list; |
| |
| return list; |
| } |
| |
| static abbrev_list * |
| find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base, |
| dwarf_vma abbrev_offset) |
| { |
| abbrev_list * list; |
| |
| for (list = abbrev_lists; list != NULL; list = list->next) |
| if (list->abbrev_base == abbrev_base |
| && list->abbrev_offset == abbrev_offset) |
| return list; |
| |
| return NULL; |
| } |
| |
| /* Find the abbreviation map for the CU that includes OFFSET. |
| OFFSET is an absolute offset from the start of the .debug_info section. */ |
| /* FIXME: This function is going to slow down readelf & objdump. |
| Consider using a better algorithm to mitigate this effect. */ |
| |
| static abbrev_map * |
| find_abbrev_map_by_offset (dwarf_vma offset) |
| { |
| unsigned long i; |
| |
| for (i = 0; i < next_free_abbrev_map_entry; i++) |
| if (cu_abbrev_map[i].start <= offset |
| && cu_abbrev_map[i].end > offset) |
| return cu_abbrev_map + i; |
| |
| return NULL; |
| } |
| |
| static void |
| add_abbrev (unsigned long number, |
| unsigned long tag, |
| int children, |
| abbrev_list * list) |
| { |
| abbrev_entry * entry; |
| |
| entry = (abbrev_entry *) xmalloc (sizeof (*entry)); |
| |
| entry->number = number; |
| entry->tag = tag; |
| entry->children = children; |
| entry->first_attr = NULL; |
| entry->last_attr = NULL; |
| entry->next = NULL; |
| |
| assert (list != NULL); |
| |
| if (list->first_abbrev == NULL) |
| list->first_abbrev = entry; |
| else |
| list->last_abbrev->next = entry; |
| |
| list->last_abbrev = entry; |
| } |
| |
| static void |
| add_abbrev_attr (unsigned long attribute, |
| unsigned long form, |
| dwarf_signed_vma implicit_const, |
| abbrev_list * list) |
| { |
| abbrev_attr *attr; |
| |
| attr = (abbrev_attr *) xmalloc (sizeof (*attr)); |
| |
| attr->attribute = attribute; |
| attr->form = form; |
| attr->implicit_const = implicit_const; |
| attr->next = NULL; |
| |
| assert (list != NULL && list->last_abbrev != NULL); |
| |
| if (list->last_abbrev->first_attr == NULL) |
| list->last_abbrev->first_attr = attr; |
| else |
| list->last_abbrev->last_attr->next = attr; |
| |
| list->last_abbrev->last_attr = attr; |
| } |
| |
| /* Processes the (partial) contents of a .debug_abbrev section. |
| Returns NULL if the end of the section was encountered. |
| Returns the address after the last byte read if the end of |
| an abbreviation set was found. */ |
| |
| static unsigned char * |
| process_abbrev_set (struct dwarf_section *section, |
| dwarf_vma abbrev_base, |
| dwarf_vma abbrev_size, |
| dwarf_vma abbrev_offset, |
| abbrev_list *list) |
| { |
| if (abbrev_base >= section->size |
| || abbrev_size > section->size - abbrev_base) |
| { |
| /* PR 17531: file:4bcd9ce9. */ |
| warn (_("Debug info is corrupted, abbrev size (%lx) is larger than " |
| "abbrev section size (%lx)\n"), |
| (unsigned long) (abbrev_base + abbrev_size), |
| (unsigned long) section->size); |
| return NULL; |
| } |
| if (abbrev_offset >= abbrev_size) |
| { |
| warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than " |
| "abbrev section size (%lx)\n"), |
| (unsigned long) abbrev_offset, |
| (unsigned long) abbrev_size); |
| return NULL; |
| } |
| |
| unsigned char *start = section->start + abbrev_base; |
| unsigned char *end = start + abbrev_size; |
| start += abbrev_offset; |
| while (start < end) |
| { |
| unsigned long entry; |
| unsigned long tag; |
| unsigned long attribute; |
| int children; |
| |
| READ_ULEB (entry, start, end); |
| |
| /* A single zero is supposed to end the set according |
| to the standard. If there's more, then signal that to |
| the caller. */ |
| if (start == end) |
| return NULL; |
| if (entry == 0) |
| return start; |
| |
| READ_ULEB (tag, start, end); |
| if (start == end) |
| return NULL; |
| |
| children = *start++; |
| |
| add_abbrev (entry, tag, children, list); |
| |
| do |
| { |
| unsigned long form; |
| /* Initialize it due to a false compiler warning. */ |
| dwarf_signed_vma implicit_const = -1; |
| |
| READ_ULEB (attribute, start, end); |
| if (start == end) |
| break; |
| |
| READ_ULEB (form, start, end); |
| if (start == end) |
| break; |
| |
| if (form == DW_FORM_implicit_const) |
| { |
| READ_SLEB (implicit_const, start, end); |
| if (start == end) |
| break; |
| } |
| |
| add_abbrev_attr (attribute, form, implicit_const, list); |
| } |
| while (attribute != 0); |
| } |
| |
| /* Report the missing single zero which ends the section. */ |
| error (_(".debug_abbrev section not zero terminated\n")); |
| |
| return NULL; |
| } |
| |
| static const char * |
| get_TAG_name (unsigned long tag) |
| { |
| const char *name = get_DW_TAG_name ((unsigned int) tag); |
| |
| if (name == NULL) |
| { |
| static char buffer[100]; |
| |
| if (tag >= DW_TAG_lo_user && tag <= DW_TAG_hi_user) |
| snprintf (buffer, sizeof (buffer), _("User TAG value: %#lx"), tag); |
| else |
| snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %#lx"), tag); |
| return buffer; |
| } |
| |
| return name; |
| } |
| |
| static const char * |
| get_FORM_name (unsigned long form) |
| { |
| const char *name; |
| |
| if (form == 0) |
| return "DW_FORM value: 0"; |
| |
| name = get_DW_FORM_name (form); |
| if (name == NULL) |
| { |
| static char buffer[100]; |
| |
| snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); |
| return buffer; |
| } |
| |
| return name; |
| } |
| |
| static const char * |
| get_IDX_name (unsigned long idx) |
| { |
| const char *name = get_DW_IDX_name ((unsigned int) idx); |
| |
| if (name == NULL) |
| { |
| static char buffer[100]; |
| |
| snprintf (buffer, sizeof (buffer), _("Unknown IDX value: %lx"), idx); |
| return buffer; |
| } |
| |
| return name; |
| } |
| |
| static unsigned char * |
| display_block (unsigned char *data, |
| dwarf_vma length, |
| const unsigned char * const end, char delimiter) |
| { |
| dwarf_vma maxlen; |
| |
| printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length)); |
| if (data > end) |
| return (unsigned char *) end; |
| |
| maxlen = (dwarf_vma) (end - data); |
| length = length > maxlen ? maxlen : length; |
| |
| while (length --) |
| printf ("%lx ", (unsigned long) byte_get (data++, 1)); |
| |
| return data; |
| } |
| |
| static int |
| decode_location_expression (unsigned char * data, |
| unsigned int pointer_size, |
| unsigned int offset_size, |
| int dwarf_version, |
| dwarf_vma length, |
| dwarf_vma cu_offset, |
| struct dwarf_section * section) |
| { |
| unsigned op; |
| dwarf_vma uvalue; |
| dwarf_signed_vma svalue; |
| unsigned char *end = data + length; |
| int need_frame_base = 0; |
| |
| while (data < end) |
| { |
| op = *data++; |
| |
| switch (op) |
| { |
| case DW_OP_addr: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue)); |
| break; |
| case DW_OP_deref: |
| printf ("DW_OP_deref"); |
| break; |
| case DW_OP_const1u: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| printf ("DW_OP_const1u: %lu", (unsigned long) uvalue); |
| break; |
| case DW_OP_const1s: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end); |
| printf ("DW_OP_const1s: %ld", (long) svalue); |
| break; |
| case DW_OP_const2u: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| printf ("DW_OP_const2u: %lu", (unsigned long) uvalue); |
| break; |
| case DW_OP_const2s: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| printf ("DW_OP_const2s: %ld", (long) svalue); |
| break; |
| case DW_OP_const4u: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| printf ("DW_OP_const4u: %lu", (unsigned long) uvalue); |
| break; |
| case DW_OP_const4s: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| printf ("DW_OP_const4s: %ld", (long) svalue); |
| break; |
| case DW_OP_const8u: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue); |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| printf ("%lu", (unsigned long) uvalue); |
| break; |
| case DW_OP_const8s: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| printf ("DW_OP_const8s: %ld ", (long) svalue); |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| printf ("%ld", (long) svalue); |
| break; |
| case DW_OP_constu: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_constu: %s", dwarf_vmatoa ("u", uvalue)); |
| break; |
| case DW_OP_consts: |
| READ_SLEB (svalue, data, end); |
| printf ("DW_OP_consts: %s", dwarf_vmatoa ("d", svalue)); |
| break; |
| case DW_OP_dup: |
| printf ("DW_OP_dup"); |
| break; |
| case DW_OP_drop: |
| printf ("DW_OP_drop"); |
| break; |
| case DW_OP_over: |
| printf ("DW_OP_over"); |
| break; |
| case DW_OP_pick: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| printf ("DW_OP_pick: %ld", (unsigned long) uvalue); |
| break; |
| case DW_OP_swap: |
| printf ("DW_OP_swap"); |
| break; |
| case DW_OP_rot: |
| printf ("DW_OP_rot"); |
| break; |
| case DW_OP_xderef: |
| printf ("DW_OP_xderef"); |
| break; |
| case DW_OP_abs: |
| printf ("DW_OP_abs"); |
| break; |
| case DW_OP_and: |
| printf ("DW_OP_and"); |
| break; |
| case DW_OP_div: |
| printf ("DW_OP_div"); |
| break; |
| case DW_OP_minus: |
| printf ("DW_OP_minus"); |
| break; |
| case DW_OP_mod: |
| printf ("DW_OP_mod"); |
| break; |
| case DW_OP_mul: |
| printf ("DW_OP_mul"); |
| break; |
| case DW_OP_neg: |
| printf ("DW_OP_neg"); |
| break; |
| case DW_OP_not: |
| printf ("DW_OP_not"); |
| break; |
| case DW_OP_or: |
| printf ("DW_OP_or"); |
| break; |
| case DW_OP_plus: |
| printf ("DW_OP_plus"); |
| break; |
| case DW_OP_plus_uconst: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_plus_uconst: %s", dwarf_vmatoa ("u", uvalue)); |
| break; |
| case DW_OP_shl: |
| printf ("DW_OP_shl"); |
| break; |
| case DW_OP_shr: |
| printf ("DW_OP_shr"); |
| break; |
| case DW_OP_shra: |
| printf ("DW_OP_shra"); |
| break; |
| case DW_OP_xor: |
| printf ("DW_OP_xor"); |
| break; |
| case DW_OP_bra: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| printf ("DW_OP_bra: %ld", (long) svalue); |
| break; |
| case DW_OP_eq: |
| printf ("DW_OP_eq"); |
| break; |
| case DW_OP_ge: |
| printf ("DW_OP_ge"); |
| break; |
| case DW_OP_gt: |
| printf ("DW_OP_gt"); |
| break; |
| case DW_OP_le: |
| printf ("DW_OP_le"); |
| break; |
| case DW_OP_lt: |
| printf ("DW_OP_lt"); |
| break; |
| case DW_OP_ne: |
| printf ("DW_OP_ne"); |
| break; |
| case DW_OP_skip: |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| printf ("DW_OP_skip: %ld", (long) svalue); |
| break; |
| |
| case DW_OP_lit0: |
| case DW_OP_lit1: |
| case DW_OP_lit2: |
| case DW_OP_lit3: |
| case DW_OP_lit4: |
| case DW_OP_lit5: |
| case DW_OP_lit6: |
| case DW_OP_lit7: |
| case DW_OP_lit8: |
| case DW_OP_lit9: |
| case DW_OP_lit10: |
| case DW_OP_lit11: |
| case DW_OP_lit12: |
| case DW_OP_lit13: |
| case DW_OP_lit14: |
| case DW_OP_lit15: |
| case DW_OP_lit16: |
| case DW_OP_lit17: |
| case DW_OP_lit18: |
| case DW_OP_lit19: |
| case DW_OP_lit20: |
| case DW_OP_lit21: |
| case DW_OP_lit22: |
| case DW_OP_lit23: |
| case DW_OP_lit24: |
| case DW_OP_lit25: |
| case DW_OP_lit26: |
| case DW_OP_lit27: |
| case DW_OP_lit28: |
| case DW_OP_lit29: |
| case DW_OP_lit30: |
| case DW_OP_lit31: |
| printf ("DW_OP_lit%d", op - DW_OP_lit0); |
| break; |
| |
| case DW_OP_reg0: |
| case DW_OP_reg1: |
| case DW_OP_reg2: |
| case DW_OP_reg3: |
| case DW_OP_reg4: |
| case DW_OP_reg5: |
| case DW_OP_reg6: |
| case DW_OP_reg7: |
| case DW_OP_reg8: |
| case DW_OP_reg9: |
| case DW_OP_reg10: |
| case DW_OP_reg11: |
| case DW_OP_reg12: |
| case DW_OP_reg13: |
| case DW_OP_reg14: |
| case DW_OP_reg15: |
| case DW_OP_reg16: |
| case DW_OP_reg17: |
| case DW_OP_reg18: |
| case DW_OP_reg19: |
| case DW_OP_reg20: |
| case DW_OP_reg21: |
| case DW_OP_reg22: |
| case DW_OP_reg23: |
| case DW_OP_reg24: |
| case DW_OP_reg25: |
| case DW_OP_reg26: |
| case DW_OP_reg27: |
| case DW_OP_reg28: |
| case DW_OP_reg29: |
| case DW_OP_reg30: |
| case DW_OP_reg31: |
| printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, |
| regname (op - DW_OP_reg0, 1)); |
| break; |
| |
| case DW_OP_breg0: |
| case DW_OP_breg1: |
| case DW_OP_breg2: |
| case DW_OP_breg3: |
| case DW_OP_breg4: |
| case DW_OP_breg5: |
| case DW_OP_breg6: |
| case DW_OP_breg7: |
| case DW_OP_breg8: |
| case DW_OP_breg9: |
| case DW_OP_breg10: |
| case DW_OP_breg11: |
| case DW_OP_breg12: |
| case DW_OP_breg13: |
| case DW_OP_breg14: |
| case DW_OP_breg15: |
| case DW_OP_breg16: |
| case DW_OP_breg17: |
| case DW_OP_breg18: |
| case DW_OP_breg19: |
| case DW_OP_breg20: |
| case DW_OP_breg21: |
| case DW_OP_breg22: |
| case DW_OP_breg23: |
| case DW_OP_breg24: |
| case DW_OP_breg25: |
| case DW_OP_breg26: |
| case DW_OP_breg27: |
| case DW_OP_breg28: |
| case DW_OP_breg29: |
| case DW_OP_breg30: |
| case DW_OP_breg31: |
| READ_SLEB (svalue, data, end); |
| printf ("DW_OP_breg%d (%s): %s", op - DW_OP_breg0, |
| regname (op - DW_OP_breg0, 1), dwarf_vmatoa ("d", svalue)); |
| break; |
| |
| case DW_OP_regx: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_regx: %s (%s)", |
| dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| break; |
| case DW_OP_fbreg: |
| need_frame_base = 1; |
| READ_SLEB (svalue, data, end); |
| printf ("DW_OP_fbreg: %s", dwarf_vmatoa ("d", svalue)); |
| break; |
| case DW_OP_bregx: |
| READ_ULEB (uvalue, data, end); |
| READ_SLEB (svalue, data, end); |
| printf ("DW_OP_bregx: %s (%s) %s", |
| dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), |
| dwarf_vmatoa ("d", svalue)); |
| break; |
| case DW_OP_piece: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_piece: %s", dwarf_vmatoa ("u", uvalue)); |
| break; |
| case DW_OP_deref_size: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| printf ("DW_OP_deref_size: %ld", (long) uvalue); |
| break; |
| case DW_OP_xderef_size: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| printf ("DW_OP_xderef_size: %ld", (long) uvalue); |
| break; |
| case DW_OP_nop: |
| printf ("DW_OP_nop"); |
| break; |
| |
| /* DWARF 3 extensions. */ |
| case DW_OP_push_object_address: |
| printf ("DW_OP_push_object_address"); |
| break; |
| case DW_OP_call2: |
| /* FIXME: Strictly speaking for 64-bit DWARF3 files |
| this ought to be an 8-byte wide computation. */ |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| printf ("DW_OP_call2: <0x%s>", |
| dwarf_vmatoa ("x", svalue + cu_offset)); |
| break; |
| case DW_OP_call4: |
| /* FIXME: Strictly speaking for 64-bit DWARF3 files |
| this ought to be an 8-byte wide computation. */ |
| SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| printf ("DW_OP_call4: <0x%s>", |
| dwarf_vmatoa ("x", svalue + cu_offset)); |
| break; |
| case DW_OP_call_ref: |
| /* FIXME: Strictly speaking for 64-bit DWARF3 files |
| this ought to be an 8-byte wide computation. */ |
| if (dwarf_version == -1) |
| { |
| printf (_("(DW_OP_call_ref in frame info)")); |
| /* No way to tell where the next op is, so just bail. */ |
| return need_frame_base; |
| } |
| if (dwarf_version == 2) |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| } |
| else |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| } |
| printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| break; |
| case DW_OP_form_tls_address: |
| printf ("DW_OP_form_tls_address"); |
| break; |
| case DW_OP_call_frame_cfa: |
| printf ("DW_OP_call_frame_cfa"); |
| break; |
| case DW_OP_bit_piece: |
| printf ("DW_OP_bit_piece: "); |
| READ_ULEB (uvalue, data, end); |
| printf (_("size: %s "), dwarf_vmatoa ("u", uvalue)); |
| READ_ULEB (uvalue, data, end); |
| printf (_("offset: %s "), dwarf_vmatoa ("u", uvalue)); |
| break; |
| |
| /* DWARF 4 extensions. */ |
| case DW_OP_stack_value: |
| printf ("DW_OP_stack_value"); |
| break; |
| |
| case DW_OP_implicit_value: |
| printf ("DW_OP_implicit_value"); |
| READ_ULEB (uvalue, data, end); |
| data = display_block (data, uvalue, end, ' '); |
| break; |
| |
| /* GNU extensions. */ |
| case DW_OP_GNU_push_tls_address: |
| printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown")); |
| break; |
| case DW_OP_GNU_uninit: |
| printf ("DW_OP_GNU_uninit"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_GNU_encoded_addr: |
| { |
| int encoding = 0; |
| dwarf_vma addr; |
| |
| if (data < end) |
| encoding = *data++; |
| addr = get_encoded_value (&data, encoding, section, end); |
| |
| printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); |
| print_dwarf_vma (addr, pointer_size); |
| } |
| break; |
| case DW_OP_implicit_pointer: |
| case DW_OP_GNU_implicit_pointer: |
| /* FIXME: Strictly speaking for 64-bit DWARF3 files |
| this ought to be an 8-byte wide computation. */ |
| if (dwarf_version == -1) |
| { |
| printf (_("(%s in frame info)"), |
| (op == DW_OP_implicit_pointer |
| ? "DW_OP_implicit_pointer" |
| : "DW_OP_GNU_implicit_pointer")); |
| /* No way to tell where the next op is, so just bail. */ |
| return need_frame_base; |
| } |
| if (dwarf_version == 2) |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| } |
| else |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| } |
| READ_SLEB (svalue, data, end); |
| printf ("%s: <0x%s> %s", |
| (op == DW_OP_implicit_pointer |
| ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"), |
| dwarf_vmatoa ("x", uvalue), |
| dwarf_vmatoa ("d", svalue)); |
| break; |
| case DW_OP_entry_value: |
| case DW_OP_GNU_entry_value: |
| READ_ULEB (uvalue, data, end); |
| /* PR 17531: file: 0cc9cd00. */ |
| if (uvalue > (dwarf_vma) (end - data)) |
| uvalue = end - data; |
| printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value" |
| : "DW_OP_GNU_entry_value")); |
| if (decode_location_expression (data, pointer_size, offset_size, |
| dwarf_version, uvalue, |
| cu_offset, section)) |
| need_frame_base = 1; |
| putchar (')'); |
| data += uvalue; |
| break; |
| case DW_OP_const_type: |
| case DW_OP_GNU_const_type: |
| READ_ULEB (uvalue, data, end); |
| printf ("%s: <0x%s> ", |
| (op == DW_OP_const_type ? "DW_OP_const_type" |
| : "DW_OP_GNU_const_type"), |
| dwarf_vmatoa ("x", cu_offset + uvalue)); |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| data = display_block (data, uvalue, end, ' '); |
| break; |
| case DW_OP_regval_type: |
| case DW_OP_GNU_regval_type: |
| READ_ULEB (uvalue, data, end); |
| printf ("%s: %s (%s)", |
| (op == DW_OP_regval_type ? "DW_OP_regval_type" |
| : "DW_OP_GNU_regval_type"), |
| dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| READ_ULEB (uvalue, data, end); |
| printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| break; |
| case DW_OP_deref_type: |
| case DW_OP_GNU_deref_type: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| printf ("%s: %ld", |
| (op == DW_OP_deref_type ? "DW_OP_deref_type" |
| : "DW_OP_GNU_deref_type"), |
| (long) uvalue); |
| READ_ULEB (uvalue, data, end); |
| printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| break; |
| case DW_OP_convert: |
| case DW_OP_GNU_convert: |
| READ_ULEB (uvalue, data, end); |
| printf ("%s <0x%s>", |
| (op == DW_OP_convert ? "DW_OP_convert" : "DW_OP_GNU_convert"), |
| dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| break; |
| case DW_OP_reinterpret: |
| case DW_OP_GNU_reinterpret: |
| READ_ULEB (uvalue, data, end); |
| printf ("%s <0x%s>", |
| (op == DW_OP_reinterpret ? "DW_OP_reinterpret" |
| : "DW_OP_GNU_reinterpret"), |
| dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| break; |
| case DW_OP_GNU_parameter_ref: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| printf ("DW_OP_GNU_parameter_ref: <0x%s>", |
| dwarf_vmatoa ("x", cu_offset + uvalue)); |
| break; |
| case DW_OP_GNU_addr_index: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| break; |
| case DW_OP_GNU_const_index: |
| READ_ULEB (uvalue, data, end); |
| printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| break; |
| case DW_OP_GNU_variable_value: |
| /* FIXME: Strictly speaking for 64-bit DWARF3 files |
| this ought to be an 8-byte wide computation. */ |
| if (dwarf_version == -1) |
| { |
| printf (_("(DW_OP_GNU_variable_value in frame info)")); |
| /* No way to tell where the next op is, so just bail. */ |
| return need_frame_base; |
| } |
| if (dwarf_version == 2) |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| } |
| else |
| { |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| } |
| printf ("DW_OP_GNU_variable_value: <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| break; |
| |
| /* HP extensions. */ |
| case DW_OP_HP_is_value: |
| printf ("DW_OP_HP_is_value"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_HP_fltconst4: |
| printf ("DW_OP_HP_fltconst4"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_HP_fltconst8: |
| printf ("DW_OP_HP_fltconst8"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_HP_mod_range: |
| printf ("DW_OP_HP_mod_range"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_HP_unmod_range: |
| printf ("DW_OP_HP_unmod_range"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| case DW_OP_HP_tls: |
| printf ("DW_OP_HP_tls"); |
| /* FIXME: Is there data associated with this OP ? */ |
| break; |
| |
| /* PGI (STMicroelectronics) extensions. */ |
| case DW_OP_PGI_omp_thread_num: |
| /* Pushes the thread number for the current thread as it would be |
| returned by the standard OpenMP library function: |
| omp_get_thread_num(). The "current thread" is the thread for |
| which the expression is being evaluated. */ |
| printf ("DW_OP_PGI_omp_thread_num"); |
| break; |
| |
| default: |
| if (op >= DW_OP_lo_user |
| && op <= DW_OP_hi_user) |
| printf (_("(User defined location op 0x%x)"), op); |
| else |
| printf (_("(Unknown location op 0x%x)"), op); |
| /* No way to tell where the next op is, so just bail. */ |
| return need_frame_base; |
| } |
| |
| /* Separate the ops. */ |
| if (data < end) |
| printf ("; "); |
| } |
| |
| return need_frame_base; |
| } |
| |
| /* Find the CU or TU set corresponding to the given CU_OFFSET. |
| This is used for DWARF package files. */ |
| |
| static struct cu_tu_set * |
| find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types) |
| { |
| struct cu_tu_set *p; |
| unsigned int nsets; |
| unsigned int dw_sect; |
| |
| if (do_types) |
| { |
| p = tu_sets; |
| nsets = tu_count; |
| dw_sect = DW_SECT_TYPES; |
| } |
| else |
| { |
| p = cu_sets; |
| nsets = cu_count; |
| dw_sect = DW_SECT_INFO; |
| } |
| while (nsets > 0) |
| { |
| if (p->section_offsets [dw_sect] == cu_offset) |
| return p; |
| p++; |
| nsets--; |
| } |
| return NULL; |
| } |
| |
| static const char * |
| fetch_alt_indirect_string (dwarf_vma offset) |
| { |
| separate_info * i; |
| |
| if (! do_follow_links) |
| return ""; |
| |
| if (first_separate_info == NULL) |
| return _("<no links available>"); |
| |
| for (i = first_separate_info; i != NULL; i = i->next) |
| { |
| struct dwarf_section * section; |
| const char * ret; |
| |
| if (! load_debug_section (separate_debug_str, i->handle)) |
| continue; |
| |
| section = &debug_displays [separate_debug_str].section; |
| |
| if (section->start == NULL) |
| continue; |
| |
| if (offset >= section->size) |
| continue; |
| |
| ret = (const char *) (section->start + offset); |
| /* Unfortunately we cannot rely upon the .debug_str section ending with a |
| NUL byte. Since our caller is expecting to receive a well formed C |
| string we test for the lack of a terminating byte here. */ |
| if (strnlen ((const char *) ret, section->size - offset) |
| == section->size - offset) |
| return _("<no NUL byte at end of alt .debug_str section>"); |
| |
| return ret; |
| } |
| |
| warn (_("DW_FORM_GNU_strp_alt offset (%s) too big or no string sections available\n"), |
| dwarf_vmatoa ("x", offset)); |
| return _("<offset is too big>"); |
| } |
| |
| static const char * |
| get_AT_name (unsigned long attribute) |
| { |
| const char *name; |
| |
| if (attribute == 0) |
| return "DW_AT value: 0"; |
| |
| /* One value is shared by the MIPS and HP extensions: */ |
| if (attribute == DW_AT_MIPS_fde) |
| return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; |
| |
| name = get_DW_AT_name (attribute); |
| |
| if (name == NULL) |
| { |
| static char buffer[100]; |
| |
| snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), |
| attribute); |
| return buffer; |
| } |
| |
| return name; |
| } |
| |
| static void |
| add_dwo_info (const char * value, dwarf_vma cu_offset, dwo_type type) |
| { |
| dwo_info * dwinfo = xmalloc (sizeof * dwinfo); |
| |
| dwinfo->type = type; |
| dwinfo->value = value; |
| dwinfo->cu_offset = cu_offset; |
| dwinfo->next = first_dwo_info; |
| first_dwo_info = dwinfo; |
| } |
| |
| static void |
| add_dwo_name (const char * name, dwarf_vma cu_offset) |
| { |
| add_dwo_info (name, cu_offset, DWO_NAME); |
| } |
| |
| static void |
| add_dwo_dir (const char * dir, dwarf_vma cu_offset) |
| { |
| add_dwo_info (dir, cu_offset, DWO_DIR); |
| } |
| |
| static void |
| add_dwo_id (const char * id, dwarf_vma cu_offset) |
| { |
| add_dwo_info (id, cu_offset, DWO_ID); |
| } |
| |
| static void |
| free_dwo_info (void) |
| { |
| dwo_info * dwinfo; |
| dwo_info * next; |
| |
| for (dwinfo = first_dwo_info; dwinfo != NULL; dwinfo = next) |
| { |
| next = dwinfo->next; |
| free (dwinfo); |
| } |
| first_dwo_info = NULL; |
| } |
| |
| /* Ensure that START + UVALUE is less than END. |
| Return an adjusted UVALUE if necessary to ensure this relationship. */ |
| |
| static inline dwarf_vma |
| check_uvalue (const unsigned char * start, |
| dwarf_vma uvalue, |
| const unsigned char * end) |
| { |
| dwarf_vma max_uvalue = end - start; |
| |
| /* See PR 17512: file: 008-103549-0.001:0.1. |
| and PR 24829 for examples of where these tests are triggered. */ |
| if (uvalue > max_uvalue) |
| { |
| warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); |
| uvalue = max_uvalue; |
| } |
| |
| return uvalue; |
| } |
| |
| static unsigned char * |
| skip_attr_bytes (unsigned long form, |
| unsigned char *data, |
| unsigned char *end, |
| dwarf_vma pointer_size, |
| dwarf_vma offset_size, |
| int dwarf_version, |
| dwarf_vma *value_return) |
| { |
| dwarf_signed_vma svalue; |
| dwarf_vma uvalue = 0; |
| dwarf_vma inc = 0; |
| |
| * value_return = 0; |
| |
| switch (form) |
| { |
| case DW_FORM_ref_addr: |
| if (dwarf_version == 2) |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| else if (dwarf_version > 2) |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| else |
| return NULL; |
| break; |
| |
| case DW_FORM_addr: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| break; |
| |
| case DW_FORM_strp: |
| case DW_FORM_line_strp: |
| case DW_FORM_sec_offset: |
| case DW_FORM_GNU_ref_alt: |
| case DW_FORM_GNU_strp_alt: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| break; |
| |
| case DW_FORM_flag_present: |
| uvalue = 1; |
| break; |
| |
| case DW_FORM_ref1: |
| case DW_FORM_flag: |
| case DW_FORM_data1: |
| case DW_FORM_strx1: |
| case DW_FORM_addrx1: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| break; |
| |
| case DW_FORM_strx3: |
| case DW_FORM_addrx3: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 3, end); |
| break; |
| |
| case DW_FORM_ref2: |
| case DW_FORM_data2: |
| case DW_FORM_strx2: |
| case DW_FORM_addrx2: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| break; |
| |
| case DW_FORM_ref4: |
| case DW_FORM_data4: |
| case DW_FORM_strx4: |
| case DW_FORM_addrx4: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| break; |
| |
| case DW_FORM_sdata: |
| READ_SLEB (svalue, data, end); |
| uvalue = svalue; |
| break; |
| |
| case DW_FORM_ref_udata: |
| case DW_FORM_udata: |
| case DW_FORM_GNU_str_index: |
| case DW_FORM_strx: |
| case DW_FORM_GNU_addr_index: |
| case DW_FORM_addrx: |
| READ_ULEB (uvalue, data, end); |
| break; |
| |
| case DW_FORM_ref8: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end); |
| break; |
| |
| case DW_FORM_data8: |
| case DW_FORM_ref_sig8: |
| inc = 8; |
| break; |
| |
| case DW_FORM_data16: |
| inc = 16; |
| break; |
| |
| case DW_FORM_string: |
| inc = strnlen ((char *) data, end - data) + 1; |
| break; |
| |
| case DW_FORM_block: |
| case DW_FORM_exprloc: |
| READ_ULEB (uvalue, data, end); |
| inc = uvalue; |
| break; |
| |
| case DW_FORM_block1: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| inc = uvalue; |
| break; |
| |
| case DW_FORM_block2: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| inc = uvalue; |
| break; |
| |
| case DW_FORM_block4: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| inc = uvalue; |
| break; |
| |
| case DW_FORM_indirect: |
| READ_ULEB (form, data, end); |
| if (form == DW_FORM_implicit_const) |
| SKIP_ULEB (data, end); |
| return skip_attr_bytes (form, data, end, pointer_size, offset_size, |
| dwarf_version, value_return); |
| |
| default: |
| return NULL; |
| } |
| |
| * value_return = uvalue; |
| if (inc <= (dwarf_vma) (end - data)) |
| data += inc; |
| else |
| data = end; |
| return data; |
| } |
| |
| /* Given form FORM with value UVALUE, locate and return the abbreviation |
| associated with it. */ |
| |
| static abbrev_entry * |
| get_type_abbrev_from_form (unsigned long form, |
| unsigned long uvalue, |
| dwarf_vma cu_offset, |
| unsigned char *cu_end, |
| const struct dwarf_section *section, |
| unsigned long *abbrev_num_return, |
| unsigned char **data_return, |
| abbrev_map **map_return) |
| { |
| unsigned long abbrev_number; |
| abbrev_map * map; |
| abbrev_entry * entry; |
| unsigned char * data; |
| |
| if (abbrev_num_return != NULL) |
| * abbrev_num_return = 0; |
| if (data_return != NULL) |
| * data_return = NULL; |
| |
| switch (form) |
| { |
| case DW_FORM_GNU_ref_alt: |
| case DW_FORM_ref_sig8: |
| /* FIXME: We are unable to handle this form at the moment. */ |
| return NULL; |
| |
| case DW_FORM_ref_addr: |
| if (uvalue >= section->size) |
| { |
| warn (_("Unable to resolve ref_addr form: uvalue %lx > section size %lx (%s)\n"), |
| uvalue, (long) section->size, section->name); |
| return NULL; |
| } |
| break; |
| |
| case DW_FORM_ref_sup4: |
| case DW_FORM_ref_sup8: |
| break; |
| |
| case DW_FORM_ref1: |
| case DW_FORM_ref2: |
| case DW_FORM_ref4: |
| case DW_FORM_ref8: |
| case DW_FORM_ref_udata: |
| if (uvalue + cu_offset > (size_t) (cu_end - section->start)) |
| { |
| warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\n"), |
| uvalue, (long) cu_offset, (long) (cu_end - section->start)); |
| return NULL; |
| } |
| uvalue += cu_offset; |
| break; |
| |
| /* FIXME: Are there other DW_FORMs that can be used by types ? */ |
| |
| default: |
| warn (_("Unexpected form %lx encountered whilst finding abbreviation for type\n"), form); |
| return NULL; |
| } |
| |
| data = (unsigned char *) section->start + uvalue; |
| map = find_abbrev_map_by_offset (uvalue); |
| |
| if (map == NULL) |
| { |
| warn (_("Unable to find abbreviations for CU offset %#lx\n"), uvalue); |
| return NULL; |
| } |
| if (map->list == NULL) |
| { |
| warn (_("Empty abbreviation list encountered for CU offset %lx\n"), uvalue); |
| return NULL; |
| } |
| |
| if (map_return != NULL) |
| { |
| if (form == DW_FORM_ref_addr) |
| *map_return = map; |
| else |
| *map_return = NULL; |
| } |
| |
| READ_ULEB (abbrev_number, data, section->start + section->size); |
| |
| for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next) |
| if (entry->number == abbrev_number) |
| break; |
| |
| if (abbrev_num_return != NULL) |
| * abbrev_num_return = abbrev_number; |
| |
| if (data_return != NULL) |
| * data_return = data; |
| |
| if (entry == NULL) |
| warn (_("Unable to find entry for abbreviation %lu\n"), abbrev_number); |
| |
| return entry; |
| } |
| |
| /* Return IS_SIGNED set to TRUE if the type using abbreviation ENTRY |
| can be determined to be a signed type. The data for ENTRY can be |
| found starting at DATA. */ |
| |
| static void |
| get_type_signedness (abbrev_entry *entry, |
| const struct dwarf_section *section, |
| unsigned char *data, |
| unsigned char *end, |
| dwarf_vma cu_offset, |
| dwarf_vma pointer_size, |
| dwarf_vma offset_size, |
| int dwarf_version, |
| bool *is_signed, |
| unsigned int nesting) |
| { |
| abbrev_attr * attr; |
| |
| * is_signed = false; |
| |
| #define MAX_NESTING 20 |
| if (nesting > MAX_NESTING) |
| { |
| /* FIXME: Warn - or is this expected ? |
| NB/ We need to avoid infinite recursion. */ |
| return; |
| } |
| |
| for (attr = entry->first_attr; |
| attr != NULL && attr->attribute; |
| attr = attr->next) |
| { |
| unsigned char * orig_data = data; |
| dwarf_vma uvalue = 0; |
| |
| data = skip_attr_bytes (attr->form, data, end, pointer_size, |
| offset_size, dwarf_version, & uvalue); |
| if (data == NULL) |
| return; |
| |
| switch (attr->attribute) |
| { |
| case DW_AT_linkage_name: |
| case DW_AT_name: |
| if (do_wide) |
| { |
| if (attr->form == DW_FORM_strp) |
| printf (", %s", fetch_indirect_string (uvalue)); |
| else if (attr->form == DW_FORM_string) |
| printf (", %.*s", (int) (end - orig_data), orig_data); |
| } |
| break; |
| |
| case DW_AT_type: |
| /* Recurse. */ |
| { |
| abbrev_entry *type_abbrev; |
| unsigned char *type_data; |
| abbrev_map *map; |
| |
| type_abbrev = get_type_abbrev_from_form (attr->form, |
| uvalue, |
| cu_offset, |
| end, |
| section, |
| NULL /* abbrev num return */, |
| &type_data, |
| &map); |
| if (type_abbrev == NULL) |
| break; |
| |
| get_type_signedness (type_abbrev, section, type_data, |
| map ? section->start + map->end : end, |
| map ? map->start : cu_offset, |
| pointer_size, offset_size, dwarf_version, |
| is_signed, nesting + 1); |
| } |
| break; |
| |
| case DW_AT_encoding: |
| /* Determine signness. */ |
| switch (uvalue) |
| { |
| case DW_ATE_address: |
| /* FIXME - some architectures have signed addresses. */ |
| case DW_ATE_boolean: |
| case DW_ATE_unsigned: |
| case DW_ATE_unsigned_char: |
| case DW_ATE_unsigned_fixed: |
| * is_signed = false; |
| break; |
| |
| default: |
| case DW_ATE_complex_float: |
| case DW_ATE_float: |
| case DW_ATE_signed: |
| case DW_ATE_signed_char: |
| case DW_ATE_imaginary_float: |
| case DW_ATE_decimal_float: |
| case DW_ATE_signed_fixed: |
| * is_signed = true; |
| break; |
| } |
| break; |
| } |
| } |
| } |
| |
| static void |
| read_and_print_leb128 (unsigned char *data, |
| unsigned int *bytes_read, |
| unsigned const char *end, |
| bool is_signed) |
| { |
| int status; |
| dwarf_vma val = read_leb128 (data, end, is_signed, bytes_read, &status); |
| if (status != 0) |
| report_leb_status (status); |
| else |
| printf ("%s", dwarf_vmatoa (is_signed ? "d" : "u", val)); |
| } |
| |
| static void |
| display_discr_list (unsigned long form, |
| dwarf_vma uvalue, |
| unsigned char * data, |
| int level) |
| { |
| unsigned char *end = data; |
| |
| if (uvalue == 0) |
| { |
| printf ("[default]"); |
| return; |
| } |
| |
| switch (form) |
| { |
| case DW_FORM_block: |
| case DW_FORM_block1: |
| case DW_FORM_block2: |
| case DW_FORM_block4: |
| /* Move data pointer back to the start of the byte array. */ |
| data -= uvalue; |
| break; |
| default: |
| printf ("<corrupt>\n"); |
| warn (_("corrupt discr_list - not using a block form\n")); |
| return; |
| } |
| |
| if (uvalue < 2) |
| { |
| printf ("<corrupt>\n"); |
| warn (_("corrupt discr_list - block not long enough\n")); |
| return; |
| } |
| |
| bool is_signed = (level > 0 && level <= MAX_CU_NESTING |
| ? level_type_signed [level - 1] : false); |
| |
| printf ("("); |
| while (data < end) |
| { |
| unsigned char discriminant; |
| unsigned int bytes_read; |
| |
| SAFE_BYTE_GET_AND_INC (discriminant, data, 1, end); |
| |
| switch (discriminant) |
| { |
| case DW_DSC_label: |
| printf ("label "); |
| read_and_print_leb128 (data, & bytes_read, end, is_signed); |
| data += bytes_read; |
| break; |
| |
| case DW_DSC_range: |
| printf ("range "); |
| read_and_print_leb128 (data, & bytes_read, end, is_signed); |
| data += bytes_read; |
| |
| printf (".."); |
| read_and_print_leb128 (data, & bytes_read, end, is_signed); |
| data += bytes_read; |
| break; |
| |
| default: |
| printf ("<corrupt>\n"); |
| warn (_("corrupt discr_list - unrecognized discriminant byte %#x\n"), |
| discriminant); |
| return; |
| } |
| |
| if (data < end) |
| printf (", "); |
| } |
| |
| if (is_signed) |
| printf (")(signed)"); |
| else |
| printf (")(unsigned)"); |
| } |
| |
| static unsigned char * |
| read_and_display_attr_value (unsigned long attribute, |
| unsigned long form, |
| dwarf_signed_vma implicit_const, |
| unsigned char * start, |
| unsigned char * data, |
| unsigned char * end, |
| dwarf_vma cu_offset, |
| dwarf_vma pointer_size, |
| dwarf_vma offset_size, |
| int dwarf_version, |
| debug_info * debug_info_p, |
| int do_loc, |
| struct dwarf_section * section, |
| struct cu_tu_set * this_set, |
| char delimiter, |
| int level) |
| { |
| dwarf_signed_vma svalue; |
| dwarf_vma uvalue = 0; |
| dwarf_vma uvalue_hi = 0; |
| unsigned char *block_start = NULL; |
| unsigned char *orig_data = data; |
| |
| if (data > end || (data == end && form != DW_FORM_flag_present)) |
| { |
| warn (_("Corrupt attribute\n")); |
| return data; |
| } |
| |
| if (do_wide && ! do_loc) |
| { |
| /* PR 26847: Display the name of the form. */ |
| const char * name = get_FORM_name (form); |
| |
| /* For convenience we skip the DW_FORM_ prefix to the name. */ |
| if (name[0] == 'D') |
| name += 8; /* strlen ("DW_FORM_") */ |
| printf ("%c(%s)", delimiter, name); |
| } |
| |
| switch (form) |
| { |
| default: |
| break; |
| |
| case DW_FORM_ref_addr: |
| if (dwarf_version == 2) |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| else if (dwarf_version > 2) |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| else |
| error (_("Internal error: DW_FORM_ref_addr is not supported in DWARF version 1.\n")); |
| break; |
| |
| case DW_FORM_addr: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| break; |
| |
| case DW_FORM_strp_sup: |
| case DW_FORM_strp: |
| case DW_FORM_line_strp: |
| case DW_FORM_sec_offset: |
| case DW_FORM_GNU_ref_alt: |
| case DW_FORM_GNU_strp_alt: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| break; |
| |
| case DW_FORM_flag_present: |
| uvalue = 1; |
| break; |
| |
| case DW_FORM_ref1: |
| case DW_FORM_flag: |
| case DW_FORM_data1: |
| case DW_FORM_strx1: |
| case DW_FORM_addrx1: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| break; |
| |
| case DW_FORM_ref2: |
| case DW_FORM_data2: |
| case DW_FORM_strx2: |
| case DW_FORM_addrx2: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| break; |
| |
| case DW_FORM_strx3: |
| case DW_FORM_addrx3: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 3, end); |
| break; |
| |
| case DW_FORM_ref_sup4: |
| case DW_FORM_ref4: |
| case DW_FORM_data4: |
| case DW_FORM_strx4: |
| case DW_FORM_addrx4: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| break; |
| |
| case DW_FORM_ref_sup8: |
| case DW_FORM_ref8: |
| case DW_FORM_data8: |
| case DW_FORM_ref_sig8: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end); |
| break; |
| |
| case DW_FORM_data16: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end); |
| SAFE_BYTE_GET_AND_INC (uvalue_hi, data, 8, end); |
| if (byte_get != byte_get_little_endian) |
| { |
| dwarf_vma utmp = uvalue; |
| uvalue = uvalue_hi; |
| uvalue_hi = utmp; |
| } |
| break; |
| |
| case DW_FORM_sdata: |
| READ_SLEB (svalue, data, end); |
| uvalue = svalue; |
| break; |
| |
| case DW_FORM_GNU_str_index: |
| case DW_FORM_strx: |
| case DW_FORM_ref_udata: |
| case DW_FORM_udata: |
| case DW_FORM_GNU_addr_index: |
| case DW_FORM_addrx: |
| READ_ULEB (uvalue, data, end); |
| break; |
| |
| case DW_FORM_indirect: |
| READ_ULEB (form, data, end); |
| if (!do_loc) |
| printf ("%c%s", delimiter, get_FORM_name (form)); |
| if (form == DW_FORM_implicit_const) |
| READ_SLEB (implicit_const, data, end); |
| return read_and_display_attr_value (attribute, form, implicit_const, |
| start, data, end, |
| cu_offset, pointer_size, |
| offset_size, dwarf_version, |
| debug_info_p, do_loc, |
| section, this_set, delimiter, level); |
| |
| case DW_FORM_implicit_const: |
| uvalue = implicit_const; |
| break; |
| } |
| |
| switch (form) |
| { |
| case DW_FORM_ref_addr: |
| if (!do_loc) |
| printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue)); |
| break; |
| |
| case DW_FORM_GNU_ref_alt: |
| if (!do_loc) |
| { |
| if (do_wide) |
| /* We have already printed the form name. */ |
| printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue)); |
| else |
| printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x", uvalue)); |
| } |
| /* FIXME: Follow the reference... */ |
| break; |
| |
| case DW_FORM_ref1: |
| case DW_FORM_ref2: |
| case DW_FORM_ref4: |
| case DW_FORM_ref_sup4: |
| case DW_FORM_ref_udata: |
| if (!do_loc) |
| printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset)); |
| break; |
| |
| case DW_FORM_data4: |
| case DW_FORM_addr: |
| case DW_FORM_sec_offset: |
| if (!do_loc) |
| printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue)); |
| break; |
| |
| case DW_FORM_flag_present: |
| case DW_FORM_flag: |
| case DW_FORM_data1: |
| case DW_FORM_data2: |
| case DW_FORM_sdata: |
| case DW_FORM_udata: |
| if (!do_loc) |
| printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue)); |
| break; |
| |
| case DW_FORM_implicit_const: |
| if (!do_loc) |
| printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const)); |
| break; |
| |
| case DW_FORM_ref_sup8: |
| case DW_FORM_ref8: |
| case DW_FORM_data8: |
| if (!do_loc) |
| { |
| dwarf_vma utmp = uvalue; |
| if (form == DW_FORM_ref8) |
| utmp += cu_offset; |
| printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", utmp)); |
| } |
| break; |
| |
| case DW_FORM_data16: |
| if (!do_loc) |
| printf (" 0x%s%s", |
| uvalue_hi == 0 ? "" : dwarf_vmatoa ("x", uvalue_hi), |
| dwarf_vmatoa_1 ("x", uvalue, uvalue_hi == 0 ? 0 : 8)); |
| break; |
| |
| case DW_FORM_string: |
| if (!do_loc) |
| printf ("%c%.*s", delimiter, (int) (end - data), data); |
| data += strnlen ((char *) data, end - data); |
| if (data < end) |
| data++; |
| break; |
| |
| case DW_FORM_block: |
| case DW_FORM_exprloc: |
| READ_ULEB (uvalue, data, end); |
| do_block: |
| block_start = data; |
| if (block_start >= end) |
| { |
| warn (_("Block ends prematurely\n")); |
| uvalue = 0; |
| block_start = end; |
| } |
| |
| uvalue = check_uvalue (block_start, uvalue, end); |
| |
| if (do_loc) |
| data = block_start + uvalue; |
| else |
| data = display_block (block_start, uvalue, end, delimiter); |
| break; |
| |
| case DW_FORM_block1: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| goto do_block; |
| |
| case DW_FORM_block2: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| goto do_block; |
| |
| case DW_FORM_block4: |
| SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| goto do_block; |
| |
| case DW_FORM_strp: |
| if (!do_loc) |
| { |
| if (do_wide) |
| /* We have already displayed the form name. */ |
| printf (_("%c(offset: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indirect_string (uvalue)); |
| else |
| printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indirect_string (uvalue)); |
| } |
| break; |
| |
| case DW_FORM_line_strp: |
| if (!do_loc) |
| { |
| if (do_wide) |
| /* We have already displayed the form name. */ |
| printf (_("%c(offset: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indirect_line_string (uvalue)); |
| else |
| printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indirect_line_string (uvalue)); |
| } |
| break; |
| |
| case DW_FORM_GNU_str_index: |
| case DW_FORM_strx: |
| case DW_FORM_strx1: |
| case DW_FORM_strx2: |
| case DW_FORM_strx3: |
| case DW_FORM_strx4: |
| if (!do_loc) |
| { |
| const char *suffix = strrchr (section->name, '.'); |
| bool dwo = suffix && strcmp (suffix, ".dwo") == 0; |
| |
| if (do_wide) |
| /* We have already displayed the form name. */ |
| printf (_("%c(offset: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indexed_string (uvalue, this_set, offset_size, dwo)); |
| else |
| printf (_("%c(indexed string: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indexed_string (uvalue, this_set, offset_size, dwo)); |
| } |
| break; |
| |
| case DW_FORM_GNU_strp_alt: |
| if (!do_loc) |
| { |
| if (do_wide) |
| /* We have already displayed the form name. */ |
| printf (_("%c(offset: 0x%s) %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_alt_indirect_string (uvalue)); |
| else |
| printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_alt_indirect_string (uvalue)); |
| } |
| break; |
| |
| case DW_FORM_indirect: |
| /* Handled above. */ |
| break; |
| |
| case DW_FORM_ref_sig8: |
| if (!do_loc) |
| printf ("%c%s: 0x%s", delimiter, do_wide ? "" : "signature", |
| dwarf_vmatoa ("x", uvalue)); |
| break; |
| |
| case DW_FORM_GNU_addr_index: |
| case DW_FORM_addrx: |
| case DW_FORM_addrx1: |
| case DW_FORM_addrx2: |
| case DW_FORM_addrx3: |
| case DW_FORM_addrx4: |
| if (!do_loc) |
| { |
| dwarf_vma base; |
| dwarf_vma offset; |
| |
| if (debug_info_p == NULL) |
| base = 0; |
| else if (debug_info_p->addr_base == DEBUG_INFO_UNAVAILABLE) |
| base = 0; |
| else |
| base = debug_info_p->addr_base; |
| |
| offset = base + uvalue * pointer_size; |
| |
| if (do_wide) |
| /* We have already displayed the form name. */ |
| printf (_("%c(index: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indexed_value (offset, pointer_size)); |
| else |
| printf (_("%c(addr_index: 0x%s): %s"), delimiter, |
| dwarf_vmatoa ("x", uvalue), |
| fetch_indexed_value (offset, pointer_size)); |
| } |
| break; |
| |
| case DW_FORM_strp_sup: |
| if (!do_loc) |
| printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset)); |
| break; |
| |
| default: |
| warn (_("Unrecognized form: 0x%lx\n"), form); |
| break; |
| } |
| |
| if ((do_loc || do_debug_loc || do_debug_ranges) |
| && num_debug_info_entries == 0 |
| && debug_info_p != NULL) |
| { |
| switch (attribute) |
| { |
| case DW_AT_frame_base: |
| have_frame_base = 1; |
| /* Fall through. */ |
| case DW_AT_location: |
| case DW_AT_GNU_locviews: |
| case DW_AT_string_length: |
| case DW_AT_return_addr: |
| case DW_AT_data_member_location: |
| case DW_AT_vtable_elem_location: |
| case DW_AT_segment: |
| case DW_AT_static_link: |
| case DW_AT_use_location: |
| case DW_AT_call_value: |
| case DW_AT_GNU_call_site_value: |
| case DW_AT_call_data_value: |
| case DW_AT_GNU_call_site_data_value: |
| case DW_AT_call_target: |
| case DW_AT_GNU_call_site_target: |
| case DW_AT_call_target_clobbered: |
| case DW_AT_GNU_call_site_target_clobbered: |
| if ((dwarf_version < 4 |
| && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| || form == DW_FORM_sec_offset) |
| { |
| /* Process location list. */ |
| unsigned int lmax = debug_info_p->max_loc_offsets; |
| unsigned int num = debug_info_p->num_loc_offsets; |
| |
| if (lmax == 0 || num >= lmax) |
| { |
| lmax += 1024; |
| debug_info_p->loc_offsets = (dwarf_vma *) |
| xcrealloc (debug_info_p->loc_offsets, |
| lmax, sizeof (*debug_info_p->loc_offsets)); |
| debug_info_p->loc_views = (dwarf_vma *) |
| xcrealloc (debug_info_p->loc_views, |
| lmax, sizeof (*debug_info_p->loc_views)); |
| debug_info_p->have_frame_base = (int *) |
| xcrealloc (debug_info_p->have_frame_base, |
| lmax, sizeof (*debug_info_p->have_frame_base)); |
| debug_info_p->max_loc_offsets = lmax; |
| } |
| if (this_set != NULL) |
| uvalue += this_set->section_offsets [DW_SECT_LOC]; |
| debug_info_p->have_frame_base [num] = have_frame_base; |
| if (attribute != DW_AT_GNU_locviews) |
| { |
| /* Corrupt DWARF info can produce more offsets than views. |
| See PR 23062 for an example. */ |
| if (debug_info_p->num_loc_offsets |
| > debug_info_p->num_loc_views) |
| warn (_("More location offset attributes than DW_AT_GNU_locview attributes\n")); |
| else |
| { |
| debug_info_p->loc_offsets [num] = uvalue; |
| debug_info_p->num_loc_offsets++; |
| } |
| } |
| else |
| { |
| assert (debug_info_p->num_loc_views <= num); |
| num = debug_info_p->num_loc_views; |
| if (num > debug_info_p->num_loc_offsets) |
| warn (_("More DW_AT_GNU_locview attributes than location offset attributes\n")); |
| else |
| { |
| debug_info_p->loc_views [num] = uvalue; |
| debug_info_p->num_loc_views++; |
| } |
| } |
| } |
| break; |
| |
| case DW_AT_low_pc: |
| if (need_base_address) |
| debug_info_p->base_address = uvalue; |
| break; |
| |
| case DW_AT_GNU_addr_base: |
| case DW_AT_addr_base: |
| debug_info_p->addr_base = uvalue; |
| break; |
| |
| case DW_AT_GNU_ranges_base: |
| debug_info_p->ranges_base = uvalue; |
| break; |
| |
| case DW_AT_ranges: |
| if ((dwarf_version < 4 |
| && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| || form == DW_FORM_sec_offset) |
| { |
| /* Process range list. */ |
| unsigned int lmax = debug_info_p->max_range_lists; |
| unsigned int num = debug_info_p->num_range_lists; |
| |
| if (lmax == 0 || num >= lmax) |
| { |
| lmax += 1024; |
| debug_info_p->range_lists = (dwarf_vma *) |
| xcrealloc (debug_info_p->range_lists, |
| lmax, sizeof (*debug_info_p->range_lists)); |
| debug_info_p->max_range_lists = lmax; |
| } |
| debug_info_p->range_lists [num] = uvalue; |
| debug_info_p->num_range_lists++; |
| } |
| break; |
| |
| case DW_AT_GNU_dwo_name: |
| case DW_AT_dwo_name: |
| if (need_dwo_info) |
| switch (form) |
| { |
| case DW_FORM_strp: |
| add_dwo_name ((const char *) fetch_indirect_string (uvalue), cu_offset); |
| break; |
| case DW_FORM_GNU_strp_alt: |
| add_dwo_name ((const char *) fetch_alt_indirect_string (uvalue), cu_offset); |
| break; |
| case DW_FORM_GNU_str_index: |
| case DW_FORM_strx: |
| case DW_FORM_strx1: |
| case DW_FORM_strx2: |
| case DW_FORM_strx3: |
| case DW_FORM_strx4: |
| add_dwo_name (fetch_indexed_string (uvalue, this_set, offset_size, false), cu_offset); |
| break; |
| case DW_FORM_string: |
| add_dwo_name ((const char *) orig_data, cu_offset); |
| break; |
| default: |
| warn (_("Unsupported form (%s) for attribute %s\n"), |
| get_FORM_name (form), get_AT_name (attribute)); |
| break; |
| } |
| break; |
| |
| case DW_AT_comp_dir: |
| /* FIXME: Also extract a build-id in a CU/TU. */ |
| if (need_dwo_info) |
| switch (form) |
| { |
| case DW_FORM_strp: |
| add_dwo_dir ((const char *) fetch_indirect_string (uvalue), cu_offset); |
| break; |
| case DW_FORM_GNU_strp_alt: |
| add_dwo_dir (fetch_alt_indirect_string (uvalue), cu_offset); |
| break; |
| case DW_FORM_line_strp: |
| add_dwo_dir ((const char *) fetch_indirect_line_string (uvalue), cu_offset); |
| break; |
| case DW_FORM_GNU_str_index: |
| case DW_FORM_strx: |
| case DW_FORM_strx1: |
| case DW_FORM_strx2: |
| case DW_FORM_strx3: |
| case DW_FORM_strx4: |
| add_dwo_dir (fetch_indexed_string (uvalue, this_set, offset_size, false), cu_offset); |
| break; |
| case DW_FORM_string: |
| add_dwo_dir ((const char *) orig_data, cu_offset); |
| break; |
| default: |
| warn (_("Unsupported form (%s) for attribute %s\n"), |
| get_FORM_name (form), get_AT_name (attribute)); |
| break; |
| } |
| break; |
| |
| case DW_AT_GNU_dwo_id: |
| if (need_dwo_info) |
| switch (form) |
| { |
| case DW_FORM_data8: |
| /* FIXME: Record the length of the ID as well ? */ |
| add_dwo_id ((const char *) (data - 8), cu_offset); |
| break; |
| default: |
| warn (_("Unsupported form (%s) for attribute %s\n"), |
| get_FORM_name (form), get_AT_name (attribute)); |
| break; |
| } |
| break; |
| |
| default: |
| break; |
| } |
| } |
| |
| if (do_loc || attribute == 0) |
| return data; |
| |
| /* For some attributes we can display further information. */ |
| switch (attribute) |
| { |
| case DW_AT_type: |
| if (level >= 0 && level < MAX_CU_NESTING |
| && uvalue < (size_t) (end - start)) |
| { |
| bool is_signed = false; |
| abbrev_entry *type_abbrev; |
| unsigned char *type_data; |
| abbrev_map *map; |
| |
| type_abbrev = get_type_abbrev_from_form (form, uvalue, |
| cu_offset, end, |
| section, NULL, |
| &type_data, &map); |
| if (type_abbrev != NULL) |
| { |
| get_type_signedness (type_abbrev, section, type_data, |
| map ? section->start + map->end : end, |
| map ? map->start : cu_offset, |
| pointer_size, offset_size, dwarf_version, |
| & is_signed, 0); |
| } |
| level_type_signed[level] = is_signed; |
| } |
| break; |
| |
| case DW_AT_inline: |
| printf ("\t"); |
| switch (uvalue) |
| { |
| case DW_INL_not_inlined: |
| printf (_("(not inlined)")); |
| break; |
| case DW_INL_inlined: |
| printf (_("(inlined)")); |
| break; |
| case DW_INL_declared_not_inlined: |
| printf (_("(declared as inline but ignored)")); |
| break; |
| case DW_INL_declared_inlined: |
| printf (_("(declared as inline and inlined)")); |
| break; |
| default: |
| printf (_(" (Unknown inline attribute value: %s)"), |
| dwarf_vmatoa ("x", uvalue)); |
| break; |
| } |
| break; |
| |
| case DW_AT_language: |
| printf ("\t"); |
| switch (uvalue) |
| { |
| /* Ordered by the numeric value of these constants. */ |
| case DW_LANG_C89: printf ("(ANSI C)"); break; |
| case DW_LANG_C: printf ("(non-ANSI C)"); break; |
| case DW_LANG_Ada83: printf ("(Ada)"); break; |
| case DW_LANG_C_plus_plus: printf ("(C++)"); break; |
| case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; |
| case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; |
| case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; |
| case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; |
| case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; |
| case DW_LANG_Modula2: printf ("(Modula 2)"); break; |
| /* DWARF 2.1 values. */ |
| case DW_LANG_Java: printf ("(Java)"); break; |
| case DW_LANG_C99: printf ("(ANSI C99)"); break; |
| case DW_LANG_Ada95: printf ("(ADA 95)"); break; |
| case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; |
| /* DWARF 3 values. */ |
| case DW_LANG_PLI: printf ("(PLI)"); break; |
| case DW_LANG_ObjC: printf ("(Objective C)"); break; |
| case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; |
| case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; |
| case DW_LANG_D: printf ("(D)"); break; |
| /* DWARF 4 values. */ |
| case DW_LANG_Python: printf ("(Python)"); break; |
| /* DWARF 5 values. */ |
| case DW_LANG_OpenCL: printf ("(OpenCL)"); break; |
| case DW_LANG_Go: printf ("(Go)"); break; |
| case DW_LANG_Modula3: printf ("(Modula 3)"); break; |
| case DW_LANG_Haskell: printf ("(Haskell)"); break; |
| case DW_LANG_C_plus_plus_03: printf ("(C++03)"); break; |
| case DW_LANG_C_plus_plus_11: printf ("(C++11)"); break; |
| case DW_LANG_OCaml: printf ("(OCaml)"); break; |
| case DW_LANG_Rust: printf ("(Rust)"); break; |
| case DW_LANG_C11: printf ("(C11)"); break; |
| case DW_LANG_Swift: printf ("(Swift)"); break; |
| case DW_LANG_Julia: printf ("(Julia)"); break; |
| case DW_LANG_Dylan: printf ("(Dylan)"); break; |
| case DW_LANG_C_plus_plus_14: printf ("(C++14)"); break; |
| case DW_LANG_Fortran03: printf ("(Fortran 03)"); break; |
| case DW_LANG_Fortran08: printf ("(Fortran 08)"); break; |
| case DW_LANG_RenderScript: printf ("(RenderScript)"); break; |
| /* MIPS extension. */ |
| case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; |
| /* UPC extension. */ |
| case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; |
| default: |
| if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) |
| printf (_("(implementation defined: %s)"), |
| dwarf_vmatoa ("x", uvalue)); |
| else |
| printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue)); |
| break; |
| } |
| break; |
| |
| case DW_AT_encoding: |
| printf ("\t"); |
| switch (uvalue) |
| { |
| case DW_ATE_void: printf ("(void)"); break; |
| case DW_ATE_address: printf ("(machine address)"); break; |
| case DW_ATE_boolean: printf ("(boolean)"); break; |
| case DW_ATE_complex_float: printf ("(complex float)"); break; |
| case DW_ATE_float: printf ("(float)"); break; |
| case DW_ATE_signed: printf ("(signed)"); break; |
| case DW_ATE_signed_char: printf ("(signed char)"); break; |
| case DW_ATE_unsigned: printf ("(unsigned)"); break; |
| case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; |
| /* DWARF 2.1 values: */ |
| case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; |
| case DW_ATE_decimal_float: printf ("(decimal float)"); break; |
| /* DWARF 3 values: */ |
| case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; |
| case DW_ATE_numeric_string: printf ("(numeric_string)"); break; |
| case DW_ATE_edited: printf ("(edited)"); break; |
| case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; |
| case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; |
| /* DWARF 4 values: */ |
| case DW_ATE_UTF: printf ("(unicode string)"); break; |
| /* DWARF 5 values: */ |
| case DW_ATE_UCS: printf ("(UCS)"); break; |
| case DW_ATE_ASCII: printf ("(ASCII)"); break; |
| |
| /* HP extensions: */ |
| case DW_ATE_HP_float80: printf ("(HP_float80)"); break; |
| case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; |
| case DW_ATE_HP_float128: printf ("(HP_float128)"); break; |
| case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; |
| case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; |
| case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; |
| case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; |
| |
| default: |
| if (uvalue >= DW_ATE_lo_user |
| && uvalue <= DW_ATE_hi_user) |
| printf (_("(user defined type)")); |
| else |
| printf (_("(unknown type)")); |
| break; |
| } |
| break; |
| |
| case DW_AT_accessibility: |
| printf ("\t"); |
| switch (uvalue) |
| { |
| case DW_ACCESS_public: printf ("(public)"); break; |
| case DW_ACCESS_protected: printf ("(protected)"); break; |
| case DW_ACCESS_private: printf ("(private)"); break; |
| default: |
| printf (_("(unknown accessibility)")); |
| break; |
| } |
| break; |
| |
| case DW_AT_visibility: |
| printf ("\t"); |
| switch (uvalue) |
| { |
| case DW_VIS_local: printf ("(local)"); break; |
| case DW_VIS_exported: printf ("(exported)"); break; |
| case DW_VIS_qualified: printf ("(qualified)"); break; |
| default: printf (_("(unknown visibility)")); break; |
| } |
| break; |
| |
| case DW_AT_endianity: |
| printf ("\t"); |
| switch (uvalue) |
| {
|