diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/dwarf2 | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | gdb-users/simark/clang-format.zip gdb-users/simark/clang-format.tar.gz gdb-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/dwarf2')
40 files changed, 4260 insertions, 4812 deletions
diff --git a/gdb/dwarf2/abbrev-cache.c b/gdb/dwarf2/abbrev-cache.c index 6de81cd..73df4d7 100644 --- a/gdb/dwarf2/abbrev-cache.c +++ b/gdb/dwarf2/abbrev-cache.c @@ -43,8 +43,8 @@ abbrev_cache::eq_table (const void *lhs, const void *rhs) abbrev_cache::abbrev_cache () : m_tables (htab_create_alloc (20, hash_table, eq_table, - htab_delete_entry<abbrev_table>, - xcalloc, xfree)) + htab_delete_entry<abbrev_table>, xcalloc, + xfree)) { } @@ -56,9 +56,9 @@ abbrev_cache::add (abbrev_table_up table) return; search_key key = { table->section, table->sect_off }; - void **slot = htab_find_slot_with_hash (m_tables.get (), &key, - to_underlying (table->sect_off), - INSERT); + void **slot + = htab_find_slot_with_hash (m_tables.get (), &key, + to_underlying (table->sect_off), INSERT); /* If this one already existed, then it should have been reused. */ gdb_assert (*slot == nullptr); *slot = (void *) table.release (); diff --git a/gdb/dwarf2/abbrev-cache.h b/gdb/dwarf2/abbrev-cache.h index d940653..4197982 100644 --- a/gdb/dwarf2/abbrev-cache.h +++ b/gdb/dwarf2/abbrev-cache.h @@ -26,6 +26,7 @@ class abbrev_cache { public: + abbrev_cache (); DISABLE_COPY_AND_ASSIGN (abbrev_cache); diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c index 1ebf8f6..4e55cb4 100644 --- a/gdb/dwarf2/abbrev.c +++ b/gdb/dwarf2/abbrev.c @@ -61,8 +61,8 @@ eq_abbrev (const void *lhs, const void *rhs) abbrev_table::abbrev_table (sect_offset off, struct dwarf2_section_info *sect) : sect_off (off), section (sect), - m_abbrevs (htab_create_alloc (20, hash_abbrev, eq_abbrev, - nullptr, xcalloc, xfree)) + m_abbrevs (htab_create_alloc (20, hash_abbrev, eq_abbrev, nullptr, xcalloc, + xfree)) { } @@ -117,8 +117,7 @@ tag_interesting_for_index (dwarf_tag tag) /* Read in an abbrev table. */ abbrev_table_up -abbrev_table::read (struct dwarf2_section_info *section, - sect_offset sect_off) +abbrev_table::read (struct dwarf2_section_info *section, sect_offset sect_off) { bfd *abfd = section->get_bfd_owner (); const gdb_byte *abbrev_ptr; @@ -135,8 +134,8 @@ abbrev_table::read (struct dwarf2_section_info *section, { unsigned int bytes_read; /* Loop until we reach an abbrev number of 0. */ - unsigned int abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, - &bytes_read); + unsigned int abbrev_number + = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); if (abbrev_number == 0) break; abbrev_ptr += bytes_read; @@ -181,8 +180,8 @@ abbrev_table::read (struct dwarf2_section_info *section, abbrev_ptr += bytes_read; if (cur_attr.form == DW_FORM_implicit_const) { - cur_attr.implicit_const = read_signed_leb128 (abfd, abbrev_ptr, - &bytes_read); + cur_attr.implicit_const + = read_signed_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; } else diff --git a/gdb/dwarf2/abbrev.h b/gdb/dwarf2/abbrev.h index 00cfbac..81f6db4 100644 --- a/gdb/dwarf2/abbrev.h +++ b/gdb/dwarf2/abbrev.h @@ -31,8 +31,8 @@ struct attr_abbrev { - ENUM_BITFIELD(dwarf_attribute) name : 16; - ENUM_BITFIELD(dwarf_form) form : 16; + ENUM_BITFIELD (dwarf_attribute) name : 16; + ENUM_BITFIELD (dwarf_form) form : 16; /* It is valid only if FORM is DW_FORM_implicit_const. */ LONGEST implicit_const; @@ -80,8 +80,7 @@ struct abbrev_table search.number = abbrev_number; return (struct abbrev_info *) htab_find_with_hash (m_abbrevs.get (), - &search, - abbrev_number); + &search, abbrev_number); } /* Where the abbrev table came from. diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 3b14757..bbd69e5 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -67,14 +67,10 @@ bool attribute::form_is_string () const { return (form == DW_FORM_strp || form == DW_FORM_line_strp - || form == DW_FORM_string - || form == DW_FORM_strx - || form == DW_FORM_strx1 - || form == DW_FORM_strx2 - || form == DW_FORM_strx3 - || form == DW_FORM_strx4 - || form == DW_FORM_GNU_str_index - || form == DW_FORM_GNU_strp_alt); + || form == DW_FORM_string || form == DW_FORM_strx + || form == DW_FORM_strx1 || form == DW_FORM_strx2 + || form == DW_FORM_strx3 || form == DW_FORM_strx4 + || form == DW_FORM_GNU_str_index || form == DW_FORM_GNU_strp_alt); } /* See attribute.h. */ @@ -93,12 +89,9 @@ attribute::as_string () const bool attribute::form_is_block () const { - return (form == DW_FORM_block1 - || form == DW_FORM_block2 - || form == DW_FORM_block4 - || form == DW_FORM_block - || form == DW_FORM_exprloc - || form == DW_FORM_data16); + return (form == DW_FORM_block1 || form == DW_FORM_block2 + || form == DW_FORM_block4 || form == DW_FORM_block + || form == DW_FORM_exprloc || form == DW_FORM_data16); } /* See attribute.h. */ @@ -106,10 +99,8 @@ attribute::form_is_block () const bool attribute::form_is_section_offset () const { - return (form == DW_FORM_data4 - || form == DW_FORM_data8 - || form == DW_FORM_sec_offset - || form == DW_FORM_loclistx); + return (form == DW_FORM_data4 || form == DW_FORM_data8 + || form == DW_FORM_sec_offset || form == DW_FORM_loclistx); } /* See attribute.h. */ @@ -137,7 +128,7 @@ attribute::form_is_constant () const void attribute::get_ref_die_offset_complaint () const { - complaint (_("unsupported die ref attribute form: '%s'"), + complaint (_ ("unsupported die ref attribute form: '%s'"), dwarf_form_name (form)); } @@ -148,16 +139,14 @@ attribute::constant_value (int default_value) const { if (form == DW_FORM_sdata || form == DW_FORM_implicit_const) return u.snd; - else if (form == DW_FORM_udata - || form == DW_FORM_data1 - || form == DW_FORM_data2 - || form == DW_FORM_data4 + else if (form == DW_FORM_udata || form == DW_FORM_data1 + || form == DW_FORM_data2 || form == DW_FORM_data4 || form == DW_FORM_data8) return u.unsnd; else { /* For DW_FORM_data16 see attribute::form_is_constant. */ - complaint (_("Attribute value is not a constant (%s)"), + complaint (_ ("Attribute value is not a constant (%s)"), dwarf_form_name (form)); return default_value; } @@ -168,22 +157,14 @@ attribute::constant_value (int default_value) const bool attribute::form_is_unsigned () const { - return (form == DW_FORM_ref_addr - || form == DW_FORM_GNU_ref_alt - || form == DW_FORM_data2 - || form == DW_FORM_data4 - || form == DW_FORM_data8 - || form == DW_FORM_sec_offset - || form == DW_FORM_data1 - || form == DW_FORM_flag - || form == DW_FORM_flag_present - || form == DW_FORM_udata - || form == DW_FORM_rnglistx - || form == DW_FORM_loclistx - || form == DW_FORM_ref1 - || form == DW_FORM_ref2 - || form == DW_FORM_ref4 - || form == DW_FORM_ref8 + return (form == DW_FORM_ref_addr || form == DW_FORM_GNU_ref_alt + || form == DW_FORM_data2 || form == DW_FORM_data4 + || form == DW_FORM_data8 || form == DW_FORM_sec_offset + || form == DW_FORM_data1 || form == DW_FORM_flag + || form == DW_FORM_flag_present || form == DW_FORM_udata + || form == DW_FORM_rnglistx || form == DW_FORM_loclistx + || form == DW_FORM_ref1 || form == DW_FORM_ref2 + || form == DW_FORM_ref4 || form == DW_FORM_ref8 || form == DW_FORM_ref_udata); } @@ -200,16 +181,11 @@ attribute::form_is_signed () const bool attribute::form_requires_reprocessing () const { - return (form == DW_FORM_strx - || form == DW_FORM_strx1 - || form == DW_FORM_strx2 - || form == DW_FORM_strx3 - || form == DW_FORM_strx4 - || form == DW_FORM_GNU_str_index - || form == DW_FORM_addrx - || form == DW_FORM_GNU_addr_index - || form == DW_FORM_rnglistx - || form == DW_FORM_loclistx); + return (form == DW_FORM_strx || form == DW_FORM_strx1 + || form == DW_FORM_strx2 || form == DW_FORM_strx3 + || form == DW_FORM_strx4 || form == DW_FORM_GNU_str_index + || form == DW_FORM_addrx || form == DW_FORM_GNU_addr_index + || form == DW_FORM_rnglistx || form == DW_FORM_loclistx); } /* See attribute.h. */ @@ -230,7 +206,7 @@ attribute::defaulted () const /* If the form was not constant, we already complained in constant_value, so there's no need to complain again. */ if (form_is_constant ()) - complaint (_("unrecognized DW_AT_defaulted value (%s)"), + complaint (_ ("unrecognized DW_AT_defaulted value (%s)"), plongest (value)); return DW_DEFAULTED_no; } @@ -253,7 +229,7 @@ attribute::as_virtuality () const /* If the form was not constant, we already complained in constant_value, so there's no need to complain again. */ if (form_is_constant ()) - complaint (_("unrecognized DW_AT_virtuality value (%s)"), + complaint (_ ("unrecognized DW_AT_virtuality value (%s)"), plongest (value)); return DW_VIRTUALITY_none; } diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index e13822a..406a0a1 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -110,7 +110,7 @@ struct attribute if (form_is_unsigned ()) return as_unsigned (); if (form_is_signed ()) - return (ULONGEST)as_signed (); + return (ULONGEST) as_signed (); gdb_assert (false); } @@ -149,12 +149,9 @@ struct attribute bool form_is_ref () const { - return (form == DW_FORM_ref_addr - || form == DW_FORM_ref1 - || form == DW_FORM_ref2 - || form == DW_FORM_ref4 - || form == DW_FORM_ref8 - || form == DW_FORM_ref_udata + return (form == DW_FORM_ref_addr || form == DW_FORM_ref1 + || form == DW_FORM_ref2 || form == DW_FORM_ref4 + || form == DW_FORM_ref8 || form == DW_FORM_ref_udata || form == DW_FORM_GNU_ref_alt); } @@ -264,18 +261,14 @@ struct attribute void set_address (CORE_ADDR addr) { gdb_assert (form == DW_FORM_addr - || ((form == DW_FORM_addrx - || form == DW_FORM_GNU_addr_index) + || ((form == DW_FORM_addrx || form == DW_FORM_GNU_addr_index) && requires_reprocessing)); u.addr = addr; requires_reprocessing = 0; } /* True if this attribute requires reprocessing. */ - bool requires_reprocessing_p () const - { - return requires_reprocessing; - } + bool requires_reprocessing_p () const { return requires_reprocessing; } /* Return the value as one of the recognized enum dwarf_defaulted_attribute constants according to DWARF5 spec, @@ -293,7 +286,7 @@ struct attribute will issue a complaint and return false. */ bool as_boolean () const; - ENUM_BITFIELD(dwarf_attribute) name : 15; + ENUM_BITFIELD (dwarf_attribute) name : 15; /* A boolean that is used for forms that require reprocessing. A form may require data not directly available in the attribute. @@ -306,7 +299,7 @@ struct attribute forms. */ unsigned int requires_reprocessing : 1; - ENUM_BITFIELD(dwarf_form) form : 15; + ENUM_BITFIELD (dwarf_form) form : 15; /* Has u.str already been updated by dwarf2_canonicalize_name? This field should be in u.str but it is kept here for better struct @@ -314,15 +307,14 @@ struct attribute unsigned int string_is_canonical : 1; union - { - const char *str; - struct dwarf_block *blk; - ULONGEST unsnd; - LONGEST snd; - CORE_ADDR addr; - ULONGEST signature; - } - u; + { + const char *str; + struct dwarf_block *blk; + ULONGEST unsnd; + LONGEST snd; + CORE_ADDR addr; + ULONGEST signature; + } u; private: diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h index c8a1e8b..6288bb8 100644 --- a/gdb/dwarf2/call-site.h +++ b/gdb/dwarf2/call-site.h @@ -66,16 +66,16 @@ struct call_site_target } void set_loc_physname (const char *physname) - { - m_loc_kind = PHYSNAME; - m_loc.physname = physname; - } + { + m_loc_kind = PHYSNAME; + m_loc.physname = physname; + } void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block) - { - m_loc_kind = DWARF_BLOCK; - m_loc.dwarf_block = dwarf_block; - } + { + m_loc_kind = DWARF_BLOCK; + m_loc.dwarf_block = dwarf_block; + } void set_loc_array (unsigned length, const CORE_ADDR *data) { @@ -107,6 +107,7 @@ private: const char *physname; /* DWARF block. */ struct dwarf2_locexpr_baton *dwarf_block; + /* Array of addresses. */ struct { @@ -165,31 +166,27 @@ struct call_site { call_site (CORE_ADDR pc, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) - : per_cu (per_cu), per_objfile (per_objfile), m_unrelocated_pc (pc) - {} - - static int - eq (const call_site *a, const call_site *b) + : per_cu (per_cu), + per_objfile (per_objfile), + m_unrelocated_pc (pc) { - return a->m_unrelocated_pc == b->m_unrelocated_pc; } - static hashval_t - hash (const call_site *a) + static int eq (const call_site *a, const call_site *b) { - return a->m_unrelocated_pc; + return a->m_unrelocated_pc == b->m_unrelocated_pc; } - static int - eq (const void *a, const void *b) + static hashval_t hash (const call_site *a) { return a->m_unrelocated_pc; } + + static int eq (const void *a, const void *b) { - return eq ((const call_site *)a, (const call_site *)b); + return eq ((const call_site *) a, (const call_site *) b); } - static hashval_t - hash (const void *a) + static hashval_t hash (const void *a) { - return hash ((const call_site *)a); + return hash ((const call_site *) a); } /* Return the address of the first instruction after this call. */ @@ -202,8 +199,7 @@ struct call_site void iterate_over_addresses (struct gdbarch *call_site_gdbarch, frame_info_ptr caller_frame, - call_site_target::iterate_ftype callback) - const + call_site_target::iterate_ftype callback) const { return target.iterate_over_addresses (call_site_gdbarch, this, caller_frame, callback); @@ -216,7 +212,9 @@ struct call_site /* * Describe DW_AT_call_target. Missing attribute uses FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL. */ - struct call_site_target target {}; + struct call_site_target target + { + }; /* * Size of the PARAMETER array. */ @@ -232,10 +230,12 @@ struct call_site dwarf2_per_objfile *const per_objfile = nullptr; private: + /* Unrelocated address of the first instruction after this call. */ const CORE_ADDR m_unrelocated_pc; public: + /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */ struct call_site_parameter parameter[]; diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c index 2deceb5..29bec7d 100644 --- a/gdb/dwarf2/comp-unit-head.c +++ b/gdb/dwarf2/comp-unit-head.c @@ -50,8 +50,8 @@ read_comp_unit_head (struct comp_unit_head *cu_header, info_ptr += bytes_read; unsigned version = read_2_bytes (abfd, info_ptr); if (version < 2 || version > 5) - error (_("Dwarf Error: wrong version in compilation unit header " - "(is %d, should be 2, 3, 4 or 5) [in module %s]"), + error (_ ("Dwarf Error: wrong version in compilation unit header " + "(is %d, should be 2, 3, 4 or 5) [in module %s]"), version, filename); cu_header->version = version; info_ptr += 2; @@ -65,12 +65,12 @@ read_comp_unit_head (struct comp_unit_head *cu_header, cu_header->unit_type = DW_UT_type; break; default: - internal_error (_("read_comp_unit_head: invalid section_kind")); + internal_error (_ ("read_comp_unit_head: invalid section_kind")); } else { - cu_header->unit_type = static_cast<enum dwarf_unit_type> - (read_1_byte (abfd, info_ptr)); + cu_header->unit_type + = static_cast<enum dwarf_unit_type> (read_1_byte (abfd, info_ptr)); info_ptr += 1; switch (cu_header->unit_type) { @@ -79,20 +79,21 @@ read_comp_unit_head (struct comp_unit_head *cu_header, case DW_UT_skeleton: case DW_UT_split_compile: if (section_kind != rcuh_kind::COMPILE) - error (_("Dwarf Error: wrong unit_type in compilation unit header " - "(is %s, should be %s) [in module %s]"), - dwarf_unit_type_name (cu_header->unit_type), - dwarf_unit_type_name (DW_UT_type), filename); + error ( + _ ("Dwarf Error: wrong unit_type in compilation unit header " + "(is %s, should be %s) [in module %s]"), + dwarf_unit_type_name (cu_header->unit_type), + dwarf_unit_type_name (DW_UT_type), filename); break; case DW_UT_type: case DW_UT_split_type: section_kind = rcuh_kind::TYPE; break; default: - error (_("Dwarf Error: wrong unit_type in compilation unit header " - "(is %#04x, should be one of: %s, %s, %s, %s or %s) " - "[in module %s]"), cu_header->unit_type, - dwarf_unit_type_name (DW_UT_compile), + error (_ ("Dwarf Error: wrong unit_type in compilation unit header " + "(is %#04x, should be one of: %s, %s, %s, %s or %s) " + "[in module %s]"), + cu_header->unit_type, dwarf_unit_type_name (DW_UT_compile), dwarf_unit_type_name (DW_UT_skeleton), dwarf_unit_type_name (DW_UT_split_compile), dwarf_unit_type_name (DW_UT_type), @@ -112,12 +113,12 @@ read_comp_unit_head (struct comp_unit_head *cu_header, } signed_addr = bfd_get_sign_extend_vma (abfd); if (signed_addr < 0) - internal_error (_("read_comp_unit_head: dwarf from non elf file")); + internal_error (_ ("read_comp_unit_head: dwarf from non elf file")); cu_header->signed_addr_p = signed_addr; bool header_has_signature = section_kind == rcuh_kind::TYPE - || cu_header->unit_type == DW_UT_skeleton - || cu_header->unit_type == DW_UT_split_compile; + || cu_header->unit_type == DW_UT_skeleton + || cu_header->unit_type == DW_UT_split_compile; if (header_has_signature) { @@ -132,9 +133,9 @@ read_comp_unit_head (struct comp_unit_head *cu_header, info_ptr += bytes_read; cu_header->type_cu_offset_in_tu = (cu_offset) type_offset; if (to_underlying (cu_header->type_cu_offset_in_tu) != type_offset) - error (_("Dwarf Error: Too big type_offset in compilation unit " - "header (is %s) [in module %s]"), plongest (type_offset), - filename); + error (_ ("Dwarf Error: Too big type_offset in compilation unit " + "header (is %s) [in module %s]"), + plongest (type_offset), filename); } return info_ptr; @@ -154,20 +155,19 @@ error_check_comp_unit_head (dwarf2_per_objfile *per_objfile, if (to_underlying (header->abbrev_sect_off) >= abbrev_section->get_size (per_objfile->objfile)) - error (_("Dwarf Error: bad offset (%s) in compilation unit header " - "(offset %s + 6) [in module %s]"), + error (_ ("Dwarf Error: bad offset (%s) in compilation unit header " + "(offset %s + 6) [in module %s]"), sect_offset_str (header->abbrev_sect_off), - sect_offset_str (header->sect_off), - filename); + sect_offset_str (header->sect_off), filename); /* Cast to ULONGEST to use 64-bit arithmetic when possible to avoid potential 32-bit overflow. */ if (((ULONGEST) header->sect_off + header->get_length_with_initial ()) > section->size) - error (_("Dwarf Error: bad length (0x%x) in compilation unit header " - "(offset %s + 0) [in module %s]"), - header->get_length_without_initial (), sect_offset_str (header->sect_off), - filename); + error (_ ("Dwarf Error: bad length (0x%x) in compilation unit header " + "(offset %s + 0) [in module %s]"), + header->get_length_without_initial (), + sect_offset_str (header->sect_off), filename); } /* See comp-unit-head.h. */ @@ -213,8 +213,9 @@ comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf, retval = bfd_get_signed_64 (abfd, buf); break; default: - internal_error (_("read_address: bad switch, signed [in module %s]"), - bfd_get_filename (abfd)); + internal_error ( + _ ("read_address: bad switch, signed [in module %s]"), + bfd_get_filename (abfd)); } } else @@ -231,8 +232,8 @@ comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf, retval = bfd_get_64 (abfd, buf); break; default: - internal_error (_("read_address: bad switch, " - "unsigned [in module %s]"), + internal_error (_ ("read_address: bad switch, " + "unsigned [in module %s]"), bfd_get_filename (abfd)); } } diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h index 65a16f4..2cd8f04 100644 --- a/gdb/dwarf2/comp-unit-head.h +++ b/gdb/dwarf2/comp-unit-head.h @@ -38,8 +38,11 @@ struct dwarf2_per_objfile; struct comp_unit_head { private: + unsigned int m_length = 0; + public: + unsigned char version = 0; unsigned char addr_size = 0; unsigned char signed_addr_p = 0; @@ -51,7 +54,9 @@ public: /* Size of the length field; either 4 or 12. */ unsigned int initial_length_size = 0; - enum dwarf_unit_type unit_type {}; + enum dwarf_unit_type unit_type + { + }; /* Offset to first die in this cu from the start of the cu. This will be the first byte following the compilation unit header. */ @@ -70,10 +75,7 @@ public: DW_UT_skeleton or DW_UT_split_compile. */ ULONGEST signature = 0; - void set_length (unsigned int length) - { - m_length = length; - } + void set_length (unsigned int length) { m_length = length; } /* Return the total length of the CU described by this header, including the initial length field. */ @@ -84,10 +86,7 @@ public: /* Return the total length of the CU described by this header, excluding the initial length field. */ - unsigned int get_length_without_initial () const - { - return m_length; - } + unsigned int get_length_without_initial () const { return m_length; } /* Return TRUE if OFF is within this CU. */ bool offset_in_cu_p (sect_offset off) const @@ -113,27 +112,27 @@ public: }; /* Expected enum dwarf_unit_type for read_comp_unit_head. */ -enum class rcuh_kind { COMPILE, TYPE }; +enum class rcuh_kind +{ + COMPILE, + TYPE +}; /* Read in the comp unit header information from the debug_info at info_ptr. Use rcuh_kind::COMPILE as the default type if not known by the caller. NOTE: This leaves members offset, first_die_offset to be filled in by the caller. */ -extern const gdb_byte *read_comp_unit_head - (struct comp_unit_head *cu_header, - const gdb_byte *info_ptr, - struct dwarf2_section_info *section, - rcuh_kind section_kind); +extern const gdb_byte *read_comp_unit_head ( + struct comp_unit_head *cu_header, const gdb_byte *info_ptr, + struct dwarf2_section_info *section, rcuh_kind section_kind); /* Read in a CU/TU header and perform some basic error checking. The contents of the header are stored in HEADER. The result is a pointer to the start of the first DIE. */ -extern const gdb_byte *read_and_check_comp_unit_head - (dwarf2_per_objfile *per_objfile, - struct comp_unit_head *header, - struct dwarf2_section_info *section, - struct dwarf2_section_info *abbrev_section, - const gdb_byte *info_ptr, - rcuh_kind section_kind); +extern const gdb_byte *read_and_check_comp_unit_head ( + dwarf2_per_objfile *per_objfile, struct comp_unit_head *header, + struct dwarf2_section_info *section, + struct dwarf2_section_info *abbrev_section, const gdb_byte *info_ptr, + rcuh_kind section_kind); #endif /* GDB_DWARF2_COMP_UNIT_H */ diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index f253a42..54e6af5 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -51,18 +51,15 @@ int cooked_index_entry::compare (const char *stra, const char *strb, comparison_mode mode) { - auto munge = [] (char c) -> unsigned char - { - /* We want to sort '<' before any other printable character. + auto munge = [] (char c) -> unsigned char { + /* We want to sort '<' before any other printable character. So, rewrite '<' to something just before ' '. */ - if (c == '<') - return '\x1f'; - return TOLOWER ((unsigned char) c); - }; - - while (*stra != '\0' - && *strb != '\0' - && (munge (*stra) == munge (*strb))) + if (c == '<') + return '\x1f'; + return TOLOWER ((unsigned char) c); + }; + + while (*stra != '\0' && *strb != '\0' && (munge (*stra) == munge (*strb))) { ++stra; ++strb; @@ -88,7 +85,8 @@ cooked_index_entry::compare (const char *stra, const char *strb, #if GDB_SELF_TEST -namespace { +namespace +{ void test_compare () @@ -98,60 +96,65 @@ test_compare () const auto mode_sort = cooked_index_entry::SORT; const auto mode_complete = cooked_index_entry::COMPLETE; - SELF_CHECK (cooked_index_entry::compare ("abcd", "abcd", - mode_compare) == 0); - SELF_CHECK (cooked_index_entry::compare ("abcd", "abcd", - mode_complete) == 0); - - SELF_CHECK (cooked_index_entry::compare ("abcd", "ABCDE", - mode_compare) < 0); - SELF_CHECK (cooked_index_entry::compare ("ABCDE", "abcd", - mode_compare) > 0); - SELF_CHECK (cooked_index_entry::compare ("abcd", "ABCDE", - mode_complete) < 0); - SELF_CHECK (cooked_index_entry::compare ("ABCDE", "abcd", - mode_complete) == 0); - - SELF_CHECK (cooked_index_entry::compare ("name", "name<>", - mode_compare) < 0); - SELF_CHECK (cooked_index_entry::compare ("name<>", "name", - mode_compare) == 0); - SELF_CHECK (cooked_index_entry::compare ("name", "name<>", - mode_complete) < 0); - SELF_CHECK (cooked_index_entry::compare ("name<>", "name", - mode_complete) == 0); + SELF_CHECK (cooked_index_entry::compare ("abcd", "abcd", mode_compare) == 0); + SELF_CHECK (cooked_index_entry::compare ("abcd", "abcd", mode_complete) + == 0); + + SELF_CHECK (cooked_index_entry::compare ("abcd", "ABCDE", mode_compare) < 0); + SELF_CHECK (cooked_index_entry::compare ("ABCDE", "abcd", mode_compare) > 0); + SELF_CHECK (cooked_index_entry::compare ("abcd", "ABCDE", mode_complete) + < 0); + SELF_CHECK (cooked_index_entry::compare ("ABCDE", "abcd", mode_complete) + == 0); + + SELF_CHECK (cooked_index_entry::compare ("name", "name<>", mode_compare) + < 0); + SELF_CHECK (cooked_index_entry::compare ("name<>", "name", mode_compare) + == 0); + SELF_CHECK (cooked_index_entry::compare ("name", "name<>", mode_complete) + < 0); + SELF_CHECK (cooked_index_entry::compare ("name<>", "name", mode_complete) + == 0); SELF_CHECK (cooked_index_entry::compare ("name<arg>", "name<arg>", - mode_compare) == 0); + mode_compare) + == 0); SELF_CHECK (cooked_index_entry::compare ("name<arg>", "name<ag>", - mode_compare) > 0); + mode_compare) + > 0); SELF_CHECK (cooked_index_entry::compare ("name<arg>", "name<arg>", - mode_complete) == 0); + mode_complete) + == 0); SELF_CHECK (cooked_index_entry::compare ("name<arg>", "name<ag>", - mode_complete) > 0); + mode_complete) + > 0); SELF_CHECK (cooked_index_entry::compare ("name<arg<more>>", - "name<arg<more>>", - mode_compare) == 0); + "name<arg<more>>", mode_compare) + == 0); SELF_CHECK (cooked_index_entry::compare ("name", "name<arg<more>>", - mode_compare) < 0); + mode_compare) + < 0); SELF_CHECK (cooked_index_entry::compare ("name<arg<more>>", "name", - mode_compare) == 0); + mode_compare) + == 0); SELF_CHECK (cooked_index_entry::compare ("name<arg<more>>", "name<arg<", - mode_compare) > 0); + mode_compare) + > 0); SELF_CHECK (cooked_index_entry::compare ("name<arg<more>>", "name<arg<", - mode_complete) == 0); + mode_complete) + == 0); SELF_CHECK (cooked_index_entry::compare ("", "abcd", mode_compare) < 0); SELF_CHECK (cooked_index_entry::compare ("", "abcd", mode_complete) < 0); SELF_CHECK (cooked_index_entry::compare ("abcd", "", mode_compare) > 0); SELF_CHECK (cooked_index_entry::compare ("abcd", "", mode_complete) == 0); - SELF_CHECK (cooked_index_entry::compare ("func", "func<type>", - mode_sort) < 0); - SELF_CHECK (cooked_index_entry::compare ("func<type>", "func1", - mode_sort) < 0); + SELF_CHECK (cooked_index_entry::compare ("func", "func<type>", mode_sort) + < 0); + SELF_CHECK (cooked_index_entry::compare ("func<type>", "func1", mode_sort) + < 0); } } /* anonymous namespace */ @@ -209,16 +212,15 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, const cooked_index_entry *parent_entry, dwarf2_per_cu_data *per_cu) { - cooked_index_entry *result = create (die_offset, tag, flags, name, - parent_entry, per_cu); + cooked_index_entry *result + = create (die_offset, tag, flags, name, parent_entry, per_cu); m_entries.push_back (result); /* An explicitly-tagged main program should always override the implicit "main" discovery. */ if ((flags & IS_MAIN) != 0) m_main = result; - else if (per_cu->lang () != language_ada - && m_main == nullptr + else if (per_cu->lang () != language_ada && m_main == nullptr && strcmp (name, "main") == 0) m_main = result; @@ -230,10 +232,9 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, void cooked_index_shard::finalize () { - m_future = gdb::thread_pool::g_thread_pool->post_task ([this] () - { - do_finalize (); - }); + m_future = gdb::thread_pool::g_thread_pool->post_task ([this] () { + do_finalize (); + }); } /* See cooked-index.h. */ @@ -245,8 +246,8 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, std::string canonical = ada_decode (entry->name, false, false); if (canonical.empty ()) return {}; - std::vector<gdb::string_view> names = split_name (canonical.c_str (), - split_style::DOT); + std::vector<gdb::string_view> names + = split_name (canonical.c_str (), split_style::DOT); gdb::string_view tail = names.back (); names.pop_back (); @@ -254,8 +255,8 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, for (const auto &name : names) { uint32_t hashval = dwarf5_djb_hash (name); - void **slot = htab_find_slot_with_hash (gnat_entries, &name, - hashval, INSERT); + void **slot + = htab_find_slot_with_hash (gnat_entries, &name, hashval, INSERT); /* CUs are processed in order, so we only need to check the most recent entry. */ cooked_index_entry *last = (cooked_index_entry *) *slot; @@ -263,9 +264,8 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, { gdb::unique_xmalloc_ptr<char> new_name = make_unique_xstrndup (name.data (), name.length ()); - last = create (entry->die_offset, DW_TAG_namespace, - 0, new_name.get (), parent, - entry->per_cu); + last = create (entry->die_offset, DW_TAG_namespace, 0, + new_name.get (), parent, entry->per_cu); last->canonical = last->name; m_names.push_back (std::move (new_name)); *slot = last; @@ -283,18 +283,16 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, void cooked_index_shard::do_finalize () { - auto hash_name_ptr = [] (const void *p) - { - const cooked_index_entry *entry = (const cooked_index_entry *) p; - return htab_hash_pointer (entry->name); - }; + auto hash_name_ptr = [] (const void *p) { + const cooked_index_entry *entry = (const cooked_index_entry *) p; + return htab_hash_pointer (entry->name); + }; - auto eq_name_ptr = [] (const void *a, const void *b) -> int - { - const cooked_index_entry *ea = (const cooked_index_entry *) a; - const cooked_index_entry *eb = (const cooked_index_entry *) b; - return ea->name == eb->name; - }; + auto eq_name_ptr = [] (const void *a, const void *b) -> int { + const cooked_index_entry *ea = (const cooked_index_entry *) a; + const cooked_index_entry *eb = (const cooked_index_entry *) b; + return ea->name == eb->name; + }; /* We can use pointer equality here because names come from .debug_str, which will normally be unique-ified by the linker. @@ -303,22 +301,20 @@ cooked_index_shard::do_finalize () htab_up seen_names (htab_create_alloc (10, hash_name_ptr, eq_name_ptr, nullptr, xcalloc, xfree)); - auto hash_entry = [] (const void *e) - { - const cooked_index_entry *entry = (const cooked_index_entry *) e; - return dwarf5_djb_hash (entry->canonical); - }; + auto hash_entry = [] (const void *e) { + const cooked_index_entry *entry = (const cooked_index_entry *) e; + return dwarf5_djb_hash (entry->canonical); + }; - auto eq_entry = [] (const void *a, const void *b) -> int - { - const cooked_index_entry *ae = (const cooked_index_entry *) a; - const gdb::string_view *sv = (const gdb::string_view *) b; - return (strlen (ae->canonical) == sv->length () - && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0); - }; + auto eq_entry = [] (const void *a, const void *b) -> int { + const cooked_index_entry *ae = (const cooked_index_entry *) a; + const gdb::string_view *sv = (const gdb::string_view *) b; + return (strlen (ae->canonical) == sv->length () + && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0); + }; - htab_up gnat_entries (htab_create_alloc (10, hash_entry, eq_entry, - nullptr, xcalloc, xfree)); + htab_up gnat_entries (htab_create_alloc (10, hash_entry, eq_entry, nullptr, + xcalloc, xfree)); for (cooked_index_entry *entry : m_entries) { @@ -340,14 +336,13 @@ cooked_index_shard::do_finalize () else if (entry->per_cu->lang () == language_cplus || entry->per_cu->lang () == language_c) { - void **slot = htab_find_slot (seen_names.get (), entry, - INSERT); + void **slot = htab_find_slot (seen_names.get (), entry, INSERT); if (*slot == nullptr) { gdb::unique_xmalloc_ptr<char> canon_name = (entry->per_cu->lang () == language_cplus - ? cp_canonicalize_string (entry->name) - : c_canonicalize_name (entry->name)); + ? cp_canonicalize_string (entry->name) + : c_canonicalize_name (entry->name)); if (canon_name == nullptr) entry->canonical = entry->name; else @@ -370,10 +365,9 @@ cooked_index_shard::do_finalize () m_names.shrink_to_fit (); m_entries.shrink_to_fit (); std::sort (m_entries.begin (), m_entries.end (), - [] (const cooked_index_entry *a, const cooked_index_entry *b) - { - return *a < *b; - }); + [] (const cooked_index_entry *a, const cooked_index_entry *b) { + return *a < *b; + }); } /* See cooked-index.h. */ @@ -383,22 +377,21 @@ cooked_index_shard::find (const std::string &name, bool completing) const { wait (); - cooked_index_entry::comparison_mode mode = (completing - ? cooked_index_entry::COMPLETE - : cooked_index_entry::MATCH); + cooked_index_entry::comparison_mode mode + = (completing ? cooked_index_entry::COMPLETE : cooked_index_entry::MATCH); auto lower = std::lower_bound (m_entries.cbegin (), m_entries.cend (), name, [=] (const cooked_index_entry *entry, - const std::string &n) - { - return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) < 0; + const std::string &n) { + return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) + < 0; }); auto upper = std::upper_bound (m_entries.cbegin (), m_entries.cend (), name, [=] (const std::string &n, - const cooked_index_entry *entry) - { - return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) > 0; + const cooked_index_entry *entry) { + return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) + > 0; }); return range (lower, upper); @@ -459,8 +452,7 @@ cooked_index::get_main () const { const cooked_index_entry *entry = index->get_main (); if (result == nullptr - || ((result->flags & IS_MAIN) == 0 - && entry != nullptr + || ((result->flags & IS_MAIN) == 0 && entry != nullptr && (entry->flags & IS_MAIN) != 0)) result = entry; } @@ -504,7 +496,7 @@ cooked_index::dump (gdbarch *arch) const const cooked_index_entry *main_entry = this->get_main (); if (main_entry != nullptr) gdb_printf (" main: ((cooked_index_entry *) %p) [%s]\n", main_entry, - main_entry->name); + main_entry->name); else gdb_printf (" main: ((cooked_index_entry *) 0)\n"); @@ -520,31 +512,31 @@ cooked_index::dump (gdbarch *arch) const gdb_printf (" [%zu] ((addrmap *) %p)\n", i, &addrmap); gdb_printf ("\n"); - addrmap.foreach ([arch] (CORE_ADDR start_addr, const void *obj) - { - QUIT; + addrmap.foreach ([arch] (CORE_ADDR start_addr, const void *obj) { + QUIT; - const char *start_addr_str = paddress (arch, start_addr); + const char *start_addr_str = paddress (arch, start_addr); - if (obj != nullptr) - { - const dwarf2_per_cu_data *per_cu - = static_cast<const dwarf2_per_cu_data *> (obj); - gdb_printf (" [%s] ((dwarf2_per_cu_data *) %p)\n", - start_addr_str, per_cu); - } - else - gdb_printf (" [%s] ((dwarf2_per_cu_data *) 0)\n", - start_addr_str); + if (obj != nullptr) + { + const dwarf2_per_cu_data *per_cu + = static_cast<const dwarf2_per_cu_data *> (obj); + gdb_printf (" [%s] ((dwarf2_per_cu_data *) %p)\n", + start_addr_str, per_cu); + } + else + gdb_printf (" [%s] ((dwarf2_per_cu_data *) 0)\n", + start_addr_str); - return 0; - }); + return 0; + }); gdb_printf ("\n"); } } void _initialize_cooked_index (); + void _initialize_cooked_index () { diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 7a8216a..38bd1f1 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -52,6 +52,7 @@ enum cooked_index_flag_enum : unsigned char definition. */ IS_TYPE_DECLARATION = 16, }; + DEF_ENUM_FLAGS_TYPE (enum cooked_index_flag_enum, cooked_index_flag); /* Return a string representation of FLAGS. */ @@ -87,11 +88,9 @@ struct cooked_index_entry : public allocate_on_obstack if ((flags & IS_TYPE_DECLARATION) != 0) return false; - if ((search_flags & SEARCH_STATIC_BLOCK) != 0 - && (flags & IS_STATIC) != 0) + if ((search_flags & SEARCH_STATIC_BLOCK) != 0 && (flags & IS_STATIC) != 0) return true; - if ((search_flags & SEARCH_GLOBAL_BLOCK) != 0 - && (flags & IS_STATIC) == 0) + if ((search_flags & SEARCH_GLOBAL_BLOCK) != 0 && (flags & IS_STATIC) == 0) return true; return false; } @@ -128,8 +127,7 @@ struct cooked_index_entry : public allocate_on_obstack switch (kind) { case VARIABLES_DOMAIN: - return (tag == DW_TAG_variable - || tag == DW_TAG_constant + return (tag == DW_TAG_variable || tag == DW_TAG_constant || tag == DW_TAG_enumerator); case FUNCTIONS_DOMAIN: return tag == DW_TAG_subprogram; @@ -192,7 +190,7 @@ struct cooked_index_entry : public allocate_on_obstack comparison_mode mode); /* Compare two entries by canonical name. */ - bool operator< (const cooked_index_entry &other) const + bool operator<(const cooked_index_entry &other) const { return compare (canonical, other.canonical, SORT) < 0; } @@ -235,14 +233,14 @@ class cooked_index; class cooked_index_shard { public: + cooked_index_shard () = default; DISABLE_COPY_AND_ASSIGN (cooked_index_shard); /* Create a new cooked_index_entry and register it with this object. Entries are owned by this object. The new item is returned. */ const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, + cooked_index_flag flags, const char *name, const cooked_index_entry *parent_entry, dwarf2_per_cu_data *per_cu); @@ -259,16 +257,13 @@ public: void finalize (); /* Wait for this index's finalization to be complete. */ - void wait () const - { - m_future.wait (); - } + void wait () const { m_future.wait (); } friend class cooked_index; /* A simple range over part of m_entries. */ typedef iterator_range<std::vector<cooked_index_entry *>::const_iterator> - range; + range; /* Return a range of all the entries. */ range all_entries () const @@ -286,10 +281,7 @@ private: /* Return the entry that is believed to represent the program's "main". This will return NULL if no such entry is available. */ - const cooked_index_entry *get_main () const - { - return m_main; - } + const cooked_index_entry *get_main () const { return m_main; } /* Look up ADDR in the address map, and return either the corresponding CU, or nullptr if the address could not be @@ -301,16 +293,13 @@ private: /* Create a new cooked_index_entry and register it with this object. Entries are owned by this object. The new item is returned. */ - cooked_index_entry *create (sect_offset die_offset, - enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, + cooked_index_entry *create (sect_offset die_offset, enum dwarf_tag tag, + cooked_index_flag flags, const char *name, const cooked_index_entry *parent_entry, dwarf2_per_cu_data *per_cu) { - return new (&m_storage) cooked_index_entry (die_offset, tag, flags, - name, parent_entry, - per_cu); + return new (&m_storage) + cooked_index_entry (die_offset, tag, flags, name, parent_entry, per_cu); } /* GNAT only emits mangled ("encoded") names in the DWARF, and does @@ -318,8 +307,8 @@ private: to do lookups. This function recreates that structure for an existing entry. It returns the base name (last element) of the full decoded name. */ - gdb::unique_xmalloc_ptr<char> handle_gnat_encoded_entry - (cooked_index_entry *entry, htab_t gnat_entries); + gdb::unique_xmalloc_ptr<char> + handle_gnat_encoded_entry (cooked_index_entry *entry, htab_t gnat_entries); /* A helper method that does the work of 'finalize'. */ void do_finalize (); @@ -408,10 +397,7 @@ public: "main". This will return NULL if no such entry is available. */ const cooked_index_entry *get_main () const; - cooked_index *index_for_writing () override - { - return this; - } + cooked_index *index_for_writing () override { return this; } quick_symbol_functions_up make_quick_functions () const override; diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 9c1691c..0dd51cb 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -76,9 +76,9 @@ dwarf2_cu::start_compunit_symtab (const char *name, const char *comp_dir, name_for_id = name_for_id_holder.c_str (); } - m_builder.reset (new struct buildsym_compunit - (this->per_objfile->objfile, - name, comp_dir, name_for_id, lang (), low_pc)); + m_builder.reset (new struct buildsym_compunit (this->per_objfile->objfile, + name, comp_dir, name_for_id, + lang (), low_pc)); list_in_scope = get_builder ()->get_file_symbols (); @@ -158,9 +158,8 @@ dwarf2_cu::add_dependence (struct dwarf2_per_cu_data *ref_per_cu) if (m_dependencies == nullptr) m_dependencies - = htab_create_alloc_ex (5, htab_hash_pointer, htab_eq_pointer, - NULL, &comp_unit_obstack, - hashtab_obstack_allocate, + = htab_create_alloc_ex (5, htab_hash_pointer, htab_eq_pointer, NULL, + &comp_unit_obstack, hashtab_obstack_allocate, dummy_obstack_deallocate); slot = htab_find_slot (m_dependencies, ref_per_cu, INSERT); diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 8059b70..f54b173 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -83,16 +83,10 @@ struct dwarf2_cu void mark (); /* Clear the mark on this CU. */ - void clear_mark () - { - m_mark = false; - } + void clear_mark () { m_mark = false; } /* True if this CU has been marked. */ - bool is_marked () const - { - return m_mark; - } + bool is_marked () const { return m_mark; } /* Add a dependence relationship from this cu to REF_PER_CU. */ void add_dependence (struct dwarf2_per_cu_data *ref_per_cu); @@ -115,6 +109,7 @@ struct dwarf2_cu const char *producer = nullptr; private: + /* The symtab builder for this CU. This is only non-NULL when full symbols are being read. */ std::unique_ptr<buildsym_compunit> m_builder; @@ -125,6 +120,7 @@ private: htab_t m_dependencies = nullptr; public: + /* The generic symbol table building routines have separate lists for file scope symbols and all all other scopes (local scopes). So we need to select the right one to pass to add_symbol_to_list(). diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h index ae46514..944c238 100644 --- a/gdb/dwarf2/die.h +++ b/gdb/dwarf2/die.h @@ -42,14 +42,14 @@ struct die_info { for (unsigned i = 0; i < num_attrs; ++i) if (attrs[i].name == DW_AT_addr_base - || attrs[i].name == DW_AT_GNU_addr_base) + || attrs[i].name == DW_AT_GNU_addr_base) { if (attrs[i].form_is_unsigned ()) { /* If both exist, just use the first one. */ return attrs[i].as_unsigned (); } - complaint (_("address base attribute (offset %s) as wrong form"), + complaint (_ ("address base attribute (offset %s) as wrong form"), sect_offset_str (sect_off)); } return gdb::optional<ULONGEST> (); @@ -66,7 +66,7 @@ struct die_info if (attrs[i].form_is_unsigned ()) return attrs[i].as_unsigned (); - complaint (_("ranges base attribute (offset %s) has wrong form"), + complaint (_ ("ranges base attribute (offset %s) has wrong form"), sect_offset_str (sect_off)); } @@ -83,7 +83,7 @@ struct die_info if (attrs[i].form_is_unsigned ()) return attrs[i].as_unsigned (); - complaint (_("rnglists base attribute (offset %s) has wrong form"), + complaint (_ ("rnglists base attribute (offset %s) has wrong form"), sect_offset_str (sect_off)); } @@ -91,7 +91,7 @@ struct die_info } /* DWARF-2 tag for this DIE. */ - ENUM_BITFIELD(dwarf_tag) tag : 16; + ENUM_BITFIELD (dwarf_tag) tag : 16; /* Number of attributes */ unsigned char num_attrs; @@ -116,9 +116,9 @@ struct die_info points to this die's parent; CHILD points to the first child of this node; and all the children of a given node are chained together via their SIBLING fields. */ - struct die_info *child; /* Its first child, if any. */ - struct die_info *sibling; /* Its next sibling, if any. */ - struct die_info *parent; /* Its parent, if any. */ + struct die_info *child; /* Its first child, if any. */ + struct die_info *sibling; /* Its next sibling, if any. */ + struct die_info *parent; /* Its parent, if any. */ /* An array of attributes, with NUM_ATTRS elements. There may be zero, but it's not common and zero-sized arrays are not diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c index 447c942..3a09856 100644 --- a/gdb/dwarf2/dwz.c +++ b/gdb/dwarf2/dwz.c @@ -36,12 +36,12 @@ dwz_file::read_string (struct objfile *objfile, LONGEST str_offset) str.read (objfile); if (str.buffer == NULL) - error (_("DW_FORM_GNU_strp_alt used without .debug_str " - "section [in module %s]"), + error (_ ("DW_FORM_GNU_strp_alt used without .debug_str " + "section [in module %s]"), bfd_get_filename (dwz_bfd.get ())); if (str_offset >= str.size) - error (_("DW_FORM_GNU_strp_alt pointing outside of " - ".debug_str section [in module %s]"), + error (_ ("DW_FORM_GNU_strp_alt pointing outside of " + ".debug_str section [in module %s]"), bfd_get_filename (dwz_bfd.get ())); gdb_assert (HOST_CHAR_BIT == 8); if (str.buffer[str_offset] == '\0') @@ -195,18 +195,17 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require) return per_bfd->dwz_file.get (); bfd_set_error (bfd_error_no_error); - gdb::unique_xmalloc_ptr<char> data - (bfd_get_alt_debug_link_info (per_bfd->obfd, - &buildid_len_arg, &buildid)); + gdb::unique_xmalloc_ptr<char> data ( + bfd_get_alt_debug_link_info (per_bfd->obfd, &buildid_len_arg, &buildid)); if (data == NULL) { if (bfd_get_error () == bfd_error_no_error) { if (!require) return nullptr; - error (_("could not read '.gnu_debugaltlink' section")); + error (_ ("could not read '.gnu_debugaltlink' section")); } - error (_("could not read '.gnu_debugaltlink' section: %s"), + error (_ ("could not read '.gnu_debugaltlink' section: %s"), bfd_errmsg (bfd_get_error ())); } @@ -248,9 +247,7 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require) gdb::unique_xmalloc_ptr<char> alt_filename; const char *origname = bfd_get_filename (per_bfd->obfd); - scoped_fd fd (debuginfod_debuginfo_query (buildid, - buildid_len, - origname, + scoped_fd fd (debuginfod_debuginfo_query (buildid, buildid_len, origname, &alt_filename)); if (fd.get () >= 0) @@ -259,7 +256,7 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require) dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget); if (dwz_bfd == nullptr) - warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), + warning (_ ("File \"%s\" from debuginfod cannot be opened as bfd"), alt_filename.get ()); else if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid)) dwz_bfd.reset (nullptr); @@ -267,11 +264,11 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require) } if (dwz_bfd == NULL) - error (_("could not find '.gnu_debugaltlink' file for %s"), + error (_ ("could not find '.gnu_debugaltlink' file for %s"), bfd_get_filename (per_bfd->obfd)); - std::unique_ptr<struct dwz_file> result - (new struct dwz_file (std::move (dwz_bfd))); + std::unique_ptr<struct dwz_file> result ( + new struct dwz_file (std::move (dwz_bfd))); for (asection *sec : gdb_bfd_sections (result->dwz_bfd)) locate_dwz_sections (result->dwz_bfd.get (), sec, result.get ()); diff --git a/gdb/dwarf2/dwz.h b/gdb/dwarf2/dwz.h index 232b4db..f3fd81b 100644 --- a/gdb/dwarf2/dwz.h +++ b/gdb/dwarf2/dwz.h @@ -41,13 +41,33 @@ struct dwz_file } /* A dwz file can only contain a few sections. */ - struct dwarf2_section_info abbrev {}; - struct dwarf2_section_info info {}; - struct dwarf2_section_info str {}; - struct dwarf2_section_info line {}; - struct dwarf2_section_info macro {}; - struct dwarf2_section_info gdb_index {}; - struct dwarf2_section_info debug_names {}; + struct dwarf2_section_info abbrev + { + }; + + struct dwarf2_section_info info + { + }; + + struct dwarf2_section_info str + { + }; + + struct dwarf2_section_info line + { + }; + + struct dwarf2_section_info macro + { + }; + + struct dwarf2_section_info gdb_index + { + }; + + struct dwarf2_section_info debug_names + { + }; /* The dwz's BFD. */ gdb_bfd_ref_ptr dwz_bfd; diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index eecd18f..c9aa2e0 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -52,18 +52,18 @@ static void ensure_have_frame (frame_info_ptr frame, const char *op_name) { if (frame == nullptr) - throw_error (GENERIC_ERROR, - _("%s evaluation requires a frame."), op_name); + throw_error (GENERIC_ERROR, _ ("%s evaluation requires a frame."), + op_name); } /* Ensure that a PER_CU is defined and throw an exception otherwise. */ static void -ensure_have_per_cu (dwarf2_per_cu_data *per_cu, const char* op_name) +ensure_have_per_cu (dwarf2_per_cu_data *per_cu, const char *op_name) { if (per_cu == nullptr) throw_error (GENERIC_ERROR, - _("%s evaluation requires a compilation unit."), op_name); + _ ("%s evaluation requires a compilation unit."), op_name); } /* Return the number of bytes overlapping a contiguous chunk of N_BITS @@ -148,8 +148,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) LONGEST offset = 0, max_offset; gdb_byte *v_contents; const gdb_byte *from_contents; - piece_closure *c - = (piece_closure *) value_computed_closure (v); + piece_closure *c = (piece_closure *) value_computed_closure (v); gdb::byte_vector buffer; bool bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG; @@ -171,11 +170,9 @@ rw_pieced_value (value *v, value *from, bool check_optimized) ULONGEST bits_to_skip = 8 * value_offset (v); if (value_bitsize (v)) { - bits_to_skip += (8 * value_offset (value_parent (v)) - + value_bitpos (v)); + bits_to_skip += (8 * value_offset (value_parent (v)) + value_bitpos (v)); if (from != nullptr - && (type_byte_order (value_type (from)) - == BFD_ENDIAN_BIG)) + && (type_byte_order (value_type (from)) == BFD_ENDIAN_BIG)) { /* Use the least significant bits of FROM. */ max_offset = 8 * value_type (from)->length (); @@ -226,8 +223,8 @@ rw_pieced_value (value *v, value *from, bool check_optimized) { /* Read mode. */ if (!get_frame_register_bytes (frame, gdb_regnum, - bits_to_skip / 8, - buffer, &optim, &unavail)) + bits_to_skip / 8, buffer, + &optim, &unavail)) { if (optim) { @@ -237,15 +234,14 @@ rw_pieced_value (value *v, value *from, bool check_optimized) this_size_bits); } if (unavail && !check_optimized) - mark_value_bits_unavailable (v, offset, - this_size_bits); + mark_value_bits_unavailable (v, offset, this_size_bits); break; } if (!check_optimized) - copy_bitwise (v_contents, offset, - buffer.data (), bits_to_skip % 8, - this_size_bits, bits_big_endian); + copy_bitwise (v_contents, offset, buffer.data (), + bits_to_skip % 8, this_size_bits, + bits_big_endian); } else { @@ -255,25 +251,23 @@ rw_pieced_value (value *v, value *from, bool check_optimized) /* Data is copied non-byte-aligned into the register. Need some bits from original register value. */ get_frame_register_bytes (frame, gdb_regnum, - bits_to_skip / 8, - buffer, &optim, &unavail); + bits_to_skip / 8, buffer, &optim, + &unavail); if (optim) throw_error (OPTIMIZED_OUT_ERROR, - _("Can't do read-modify-write to " - "update bitfield; containing word " - "has been optimized out")); + _ ("Can't do read-modify-write to " + "update bitfield; containing word " + "has been optimized out")); if (unavail) throw_error (NOT_AVAILABLE_ERROR, - _("Can't do read-modify-write to " - "update bitfield; containing word " - "is unavailable")); + _ ("Can't do read-modify-write to " + "update bitfield; containing word " + "is unavailable")); } - copy_bitwise (buffer.data (), bits_to_skip % 8, - from_contents, offset, - this_size_bits, bits_big_endian); - put_frame_register_bytes (frame, gdb_regnum, - bits_to_skip / 8, + copy_bitwise (buffer.data (), bits_to_skip % 8, from_contents, + offset, this_size_bits, bits_big_endian); + put_frame_register_bytes (frame, gdb_regnum, bits_to_skip / 8, buffer); } } @@ -294,12 +288,10 @@ rw_pieced_value (value *v, value *from, bool check_optimized) /* Everything is byte-aligned; no buffer needed. */ if (from != nullptr) write_memory_with_notification (start_addr, - (from_contents - + offset / 8), + (from_contents + offset / 8), this_size_bits / 8); else - read_value_memory (v, offset, - p->v.mem.in_stack_memory, + read_value_memory (v, offset, p->v.mem.in_stack_memory, p->v.mem.addr + bits_to_skip / 8, v_contents + offset / 8, this_size_bits / 8); @@ -312,13 +304,12 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (from == nullptr) { /* Read mode. */ - read_value_memory (v, offset, - p->v.mem.in_stack_memory, + read_value_memory (v, offset, p->v.mem.in_stack_memory, p->v.mem.addr + bits_to_skip / 8, buffer.data (), this_size); - copy_bitwise (v_contents, offset, - buffer.data (), bits_to_skip % 8, - this_size_bits, bits_big_endian); + copy_bitwise (v_contents, offset, buffer.data (), + bits_to_skip % 8, this_size_bits, + bits_big_endian); } else { @@ -328,8 +319,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (this_size <= 8) { /* Perform a single read for small sizes. */ - read_memory (start_addr, buffer.data (), - this_size); + read_memory (start_addr, buffer.data (), this_size); } else { @@ -341,11 +331,9 @@ rw_pieced_value (value *v, value *from, bool check_optimized) } } - copy_bitwise (buffer.data (), bits_to_skip % 8, - from_contents, offset, - this_size_bits, bits_big_endian); - write_memory_with_notification (start_addr, - buffer.data (), + copy_bitwise (buffer.data (), bits_to_skip % 8, from_contents, + offset, this_size_bits, bits_big_endian); + write_memory_with_notification (start_addr, buffer.data (), this_size); } } @@ -378,8 +366,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) copy_bitwise (v_contents, offset, value_contents_all (p->v.value).data (), - bits_to_skip, - this_size_bits, bits_big_endian); + bits_to_skip, this_size_bits, bits_big_endian); } break; @@ -404,18 +391,17 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (n > literal_size_bits - bits_to_skip) n = literal_size_bits - bits_to_skip; - copy_bitwise (v_contents, offset, - p->v.literal.data, bits_to_skip, + copy_bitwise (v_contents, offset, p->v.literal.data, bits_to_skip, n, bits_big_endian); } break; case DWARF_VALUE_IMPLICIT_POINTER: - if (from != nullptr) - { - mark_value_bits_optimized_out (v, offset, this_size_bits); - break; - } + if (from != nullptr) + { + mark_value_bits_optimized_out (v, offset, this_size_bits); + break; + } /* These bits show up as zeros -- but do not cause the value to be considered optimized-out. */ @@ -428,7 +414,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) break; default: - internal_error (_("invalid location type")); + internal_error (_ ("invalid location type")); } offset += this_size_bits; @@ -502,8 +488,7 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, static value * indirect_pieced_value (value *value) { - piece_closure *c - = (piece_closure *) value_computed_closure (value); + piece_closure *c = (piece_closure *) value_computed_closure (value); int i; dwarf_expr_piece *piece = NULL; @@ -539,14 +524,14 @@ indirect_pieced_value (value *value) return NULL; if (bit_length != 0) - error (_("Invalid use of DW_OP_implicit_pointer")); + error (_ ("Invalid use of DW_OP_implicit_pointer")); piece = p; break; } gdb_assert (piece != NULL && c->per_cu != nullptr); - frame_info_ptr frame = get_selected_frame (_("No frame selected.")); + frame_info_ptr frame = get_selected_frame (_ ("No frame selected.")); /* This is an offset requested by GDB, such as value subscripts. However, due to how synthetic pointers are implemented, this is @@ -563,9 +548,8 @@ indirect_pieced_value (value *value) = extract_signed_integer (value_contents (value), byte_order); byte_offset += piece->v.ptr.offset; - return indirect_synthetic_pointer (piece->v.ptr.die_sect_off, - byte_offset, c->per_cu, - c->per_objfile, frame, type); + return indirect_synthetic_pointer (piece->v.ptr.die_sect_off, byte_offset, + c->per_cu, c->per_objfile, frame, type); } /* Implementation of the coerce_ref method of lval_funcs for synthetic C++ @@ -581,18 +565,17 @@ coerce_pieced_ref (const value *value) { const piece_closure *closure = (piece_closure *) value_computed_closure (value); - frame_info_ptr frame - = get_selected_frame (_("No frame selected.")); + frame_info_ptr frame = get_selected_frame (_ ("No frame selected.")); /* gdb represents synthetic pointers as pieced values with a single piece. */ gdb_assert (closure != NULL); gdb_assert (closure->pieces.size () == 1); - return indirect_synthetic_pointer - (closure->pieces[0].v.ptr.die_sect_off, - closure->pieces[0].v.ptr.offset, - closure->per_cu, closure->per_objfile, frame, type); + return indirect_synthetic_pointer (closure->pieces[0].v.ptr.die_sect_off, + closure->pieces[0].v.ptr.offset, + closure->per_cu, closure->per_objfile, + frame, type); } else { @@ -627,24 +610,22 @@ free_pieced_value_closure (value *v) } /* Functions for accessing a variable described by DW_OP_piece. */ -static const struct lval_funcs pieced_value_funcs = { - read_pieced_value, - write_pieced_value, - is_optimized_out_pieced_value, - indirect_pieced_value, - coerce_pieced_ref, - check_pieced_synthetic_pointer, - copy_pieced_value_closure, - free_pieced_value_closure -}; +static const struct lval_funcs pieced_value_funcs + = { read_pieced_value, + write_pieced_value, + is_optimized_out_pieced_value, + indirect_pieced_value, + coerce_pieced_ref, + check_pieced_synthetic_pointer, + copy_pieced_value_closure, + free_pieced_value_closure }; /* Given context CTX, section offset SECT_OFF, and compilation unit data PER_CU, execute the "variable value" operation on the DIE found at SECT_OFF. */ static value * -sect_variable_value (sect_offset sect_off, - dwarf2_per_cu_data *per_cu, +sect_variable_value (sect_offset sect_off, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { const char *var_name = nullptr; @@ -653,15 +634,15 @@ sect_variable_value (sect_offset sect_off, &var_name); if (die_type == NULL) - error (_("Bad DW_OP_GNU_variable_value DIE.")); + error (_ ("Bad DW_OP_GNU_variable_value DIE.")); /* Note: Things still work when the following test is removed. This test and error is here to conform to the proposed specification. */ - if (die_type->code () != TYPE_CODE_INT - && die_type->code () != TYPE_CODE_ENUM + if (die_type->code () != TYPE_CODE_INT && die_type->code () != TYPE_CODE_ENUM && die_type->code () != TYPE_CODE_RANGE && die_type->code () != TYPE_CODE_PTR) - error (_("Type of DW_OP_GNU_variable_value DIE must be an integer or pointer.")); + error (_ ( + "Type of DW_OP_GNU_variable_value DIE must be an integer or pointer.")); if (var_name != nullptr) { @@ -671,7 +652,7 @@ sect_variable_value (sect_offset sect_off, } struct type *type = lookup_pointer_type (die_type); - frame_info_ptr frame = get_selected_frame (_("No frame selected.")); + frame_info_ptr frame = get_selected_frame (_ ("No frame selected.")); return indirect_synthetic_pointer (sect_off, 0, per_cu, per_objfile, frame, type, true); } @@ -696,13 +677,12 @@ dwarf_expr_context::address_type () const else if (this->m_addr_size == 8) ndx = 2; else - error (_("Unsupported address size in DWARF expressions: %d bits"), + error (_ ("Unsupported address size in DWARF expressions: %d bits"), 8 * this->m_addr_size); if (types->dw_types[ndx] == NULL) - types->dw_types[ndx] - = arch_integer_type (arch, 8 * this->m_addr_size, - 0, "<signed DWARF address type>"); + types->dw_types[ndx] = arch_integer_type (arch, 8 * this->m_addr_size, 0, + "<signed DWARF address type>"); return types->dw_types[ndx]; } @@ -711,8 +691,8 @@ dwarf_expr_context::address_type () const dwarf_expr_context::dwarf_expr_context (dwarf2_per_objfile *per_objfile, int addr_size) -: m_addr_size (addr_size), - m_per_objfile (per_objfile) + : m_addr_size (addr_size), + m_per_objfile (per_objfile) { } @@ -738,7 +718,7 @@ void dwarf_expr_context::pop () { if (this->m_stack.empty ()) - error (_("dwarf expression stack underflow")); + error (_ ("dwarf expression stack underflow")); this->m_stack.pop_back (); } @@ -749,24 +729,23 @@ struct value * dwarf_expr_context::fetch (int n) { if (this->m_stack.size () <= n) - error (_("Asked for position %d of stack, " + error (_ ("Asked for position %d of stack, " "stack only has %zu elements on it."), - n, this->m_stack.size ()); + n, this->m_stack.size ()); return this->m_stack[this->m_stack.size () - (1 + n)].value; } /* See expr.h. */ void -dwarf_expr_context::get_frame_base (const gdb_byte **start, - size_t * length) +dwarf_expr_context::get_frame_base (const gdb_byte **start, size_t *length) { ensure_have_frame (this->m_frame, "DW_OP_fbreg"); const block *bl = get_frame_block (this->m_frame, NULL); if (bl == NULL) - error (_("frame address is not available.")); + error (_ ("frame address is not available.")); /* Use block_linkage_function, which returns a real (not inlined) function, instead of get_frame_function, which may return an @@ -791,11 +770,11 @@ dwarf_expr_context::get_base_type (cu_offset die_cu_off) if (this->m_per_cu == nullptr) return builtin_type (this->m_per_objfile->objfile->arch ())->builtin_int; - struct type *result = dwarf2_get_die_type (die_cu_off, this->m_per_cu, - this->m_per_objfile); + struct type *result + = dwarf2_get_die_type (die_cu_off, this->m_per_cu, this->m_per_objfile); if (result == nullptr) - error (_("Could not find type for operation")); + error (_ ("Could not find type for operation")); return result; } @@ -809,11 +788,10 @@ dwarf_expr_context::dwarf_call (cu_offset die_cu_off) frame_info_ptr frame = this->m_frame; - auto get_pc_from_frame = [frame] () - { - ensure_have_frame (frame, "DW_OP_call"); - return get_frame_address_in_block (frame); - }; + auto get_pc_from_frame = [frame] () { + ensure_have_frame (frame, "DW_OP_call"); + return get_frame_address_in_block (frame); + }; dwarf2_locexpr_baton block = dwarf2_fetch_die_loc_cu_off (die_cu_off, this->m_per_cu, @@ -828,8 +806,7 @@ dwarf_expr_context::dwarf_call (cu_offset die_cu_off) /* See expr.h. */ void -dwarf_expr_context::read_mem (gdb_byte *buf, CORE_ADDR addr, - size_t length) +dwarf_expr_context::read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) { if (length == 0) return; @@ -865,8 +842,7 @@ dwarf_expr_context::push_dwarf_reg_entry_value (call_site_parameter_kind kind, frame_info_ptr caller_frame = get_prev_frame (this->m_frame); call_site_parameter *parameter = dwarf_expr_reg_to_entry_parameter (this->m_frame, kind, kind_u, - &caller_per_cu, - &caller_per_objfile); + &caller_per_cu, &caller_per_objfile); const gdb_byte *data_src = deref_size == -1 ? parameter->value : parameter->data_value; size_t size @@ -875,7 +851,7 @@ dwarf_expr_context::push_dwarf_reg_entry_value (call_site_parameter_kind kind, /* DEREF_SIZE size is not verified here. */ if (data_src == nullptr) throw_error (NO_ENTRY_VALUE_ERROR, - _("Cannot resolve DW_AT_call_data_value")); + _ ("Cannot resolve DW_AT_call_data_value")); /* We are about to evaluate an expression in the context of the caller of the current frame. This evaluation context may be different from @@ -883,14 +859,14 @@ dwarf_expr_context::push_dwarf_reg_entry_value (call_site_parameter_kind kind, It is possible for the caller to be from a different objfile from the callee if the call is made through a function pointer. */ - scoped_restore save_frame = make_scoped_restore (&this->m_frame, - caller_frame); - scoped_restore save_per_cu = make_scoped_restore (&this->m_per_cu, - caller_per_cu); - scoped_restore save_addr_info = make_scoped_restore (&this->m_addr_info, - nullptr); - scoped_restore save_per_objfile = make_scoped_restore (&this->m_per_objfile, - caller_per_objfile); + scoped_restore save_frame + = make_scoped_restore (&this->m_frame, caller_frame); + scoped_restore save_per_cu + = make_scoped_restore (&this->m_per_cu, caller_per_cu); + scoped_restore save_addr_info + = make_scoped_restore (&this->m_addr_info, nullptr); + scoped_restore save_per_objfile + = make_scoped_restore (&this->m_per_objfile, caller_per_objfile); scoped_restore save_addr_size = make_scoped_restore (&this->m_addr_size); this->m_addr_size = this->m_per_cu->addr_size (); @@ -932,8 +908,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, piece_closure *c = allocate_piece_closure (this->m_per_cu, this->m_per_objfile, std::move (this->m_pieces), this->m_frame); - retval = allocate_computed_value (subobj_type, - &pieced_value_funcs, c); + retval = allocate_computed_value (subobj_type, &pieced_value_funcs, c); set_value_offset (retval, subobj_offset); } else @@ -950,16 +925,16 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, gdbarch *f_arch = get_frame_arch (this->m_frame); int dwarf_regnum = longest_to_int (value_as_long (this->fetch (0))); - int gdb_regnum = dwarf_reg_to_regnum_or_error (f_arch, - dwarf_regnum); + int gdb_regnum + = dwarf_reg_to_regnum_or_error (f_arch, dwarf_regnum); if (subobj_offset != 0) - error (_("cannot use offset on synthetic pointer to register")); + error (_ ("cannot use offset on synthetic pointer to register")); gdb_assert (this->m_frame != NULL); - retval = value_from_register (subobj_type, gdb_regnum, - this->m_frame); + retval + = value_from_register (subobj_type, gdb_regnum, this->m_frame); if (value_optimized_out (retval)) { /* This means the register has undefined value / was @@ -992,18 +967,18 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, switch (subobj_type->code ()) { - case TYPE_CODE_FUNC: - case TYPE_CODE_METHOD: - ptr_type = builtin_type (arch)->builtin_func_ptr; - break; - default: - ptr_type = builtin_type (arch)->builtin_data_ptr; - break; + case TYPE_CODE_FUNC: + case TYPE_CODE_METHOD: + ptr_type = builtin_type (arch)->builtin_func_ptr; + break; + default: + ptr_type = builtin_type (arch)->builtin_data_ptr; + break; } - address = value_as_address (value_from_pointer (ptr_type, address)); + address + = value_as_address (value_from_pointer (ptr_type, address)); - retval = value_at_lazy (subobj_type, - address + subobj_offset); + retval = value_at_lazy (subobj_type, address + subobj_offset); if (in_stack_memory) set_value_stack (retval, 1); } @@ -1053,7 +1028,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, /* DWARF_VALUE_OPTIMIZED_OUT can't occur in this context -- it can only be encountered when making a piece. */ default: - internal_error (_("invalid location type")); + internal_error (_ ("invalid location type")); } } @@ -1084,10 +1059,9 @@ dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len, bool as_lval, static void dwarf_require_integral (struct type *type) { - if (type->code () != TYPE_CODE_INT - && type->code () != TYPE_CODE_CHAR + if (type->code () != TYPE_CODE_INT && type->code () != TYPE_CODE_CHAR && type->code () != TYPE_CODE_BOOL) - error (_("integral type expected in DWARF expression")); + error (_ ("integral type expected in DWARF expression")); } /* Return the unsigned form of TYPE. TYPE is necessarily an integral @@ -1107,8 +1081,8 @@ get_unsigned_type (struct gdbarch *gdbarch, struct type *type) case 8: return builtin_type (gdbarch)->builtin_uint64; default: - error (_("no unsigned variant found for type, while evaluating " - "DWARF expression")); + error (_ ("no unsigned variant found for type, while evaluating " + "DWARF expression")); } } @@ -1129,8 +1103,8 @@ get_signed_type (struct gdbarch *gdbarch, struct type *type) case 8: return builtin_type (gdbarch)->builtin_int64; default: - error (_("no signed variant found for type, while evaluating " - "DWARF expression")); + error (_ ("no signed variant found for type, while evaluating " + "DWARF expression")); } } @@ -1156,8 +1130,7 @@ dwarf_expr_context::fetch_address (int n) if (gdbarch_integer_to_address_p (arch)) { gdb_byte *buf = (gdb_byte *) alloca (this->m_addr_size); - type *int_type = get_unsigned_type (arch, - value_type (result_val)); + type *int_type = get_unsigned_type (arch, value_type (result_val)); store_unsigned_integer (buf, this->m_addr_size, byte_order, result); return gdbarch_integer_to_address (arch, int_type, buf); @@ -1172,9 +1145,9 @@ bool dwarf_expr_context::fetch_in_stack_memory (int n) { if (this->m_stack.size () <= n) - error (_("Asked for position %d of stack, " + error (_ ("Asked for position %d of stack, " "stack only has %zu elements on it."), - n, this->m_stack.size ()); + n, this->m_stack.size ()); return this->m_stack[this->m_stack.size () - (1 + n)].in_stack_memory; } @@ -1246,24 +1219,24 @@ dwarf_expr_context::eval (const gdb_byte *addr, size_t len) /* Helper to read a uleb128 value or throw an error. */ const gdb_byte * -safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, - uint64_t *r) +safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r) { buf = gdb_read_uleb128 (buf, buf_end, r); if (buf == NULL) - error (_("DWARF expression error: ran off end of buffer reading uleb128 value")); + error (_ ( + "DWARF expression error: ran off end of buffer reading uleb128 value")); return buf; } /* Helper to read a sleb128 value or throw an error. */ const gdb_byte * -safe_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end, - int64_t *r) +safe_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r) { buf = gdb_read_sleb128 (buf, buf_end, r); if (buf == NULL) - error (_("DWARF expression error: ran off end of buffer reading sleb128 value")); + error (_ ( + "DWARF expression error: ran off end of buffer reading sleb128 value")); return buf; } @@ -1272,10 +1245,10 @@ safe_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end) { buf = gdb_skip_leb128 (buf, buf_end); if (buf == NULL) - error (_("DWARF expression error: ran off end of buffer reading leb128 value")); + error (_ ( + "DWARF expression error: ran off end of buffer reading leb128 value")); return buf; } - /* Check that the current operator is either at the end of an expression, or that it is followed by a composition operator or by @@ -1287,9 +1260,9 @@ dwarf_expr_require_composition (const gdb_byte *op_ptr, const gdb_byte *op_end, { if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece && *op_ptr != DW_OP_GNU_uninit) - error (_("DWARF-2 expression error: `%s' operations must be " - "used either alone or in conjunction with DW_OP_piece " - "or DW_OP_bit_piece."), + error (_ ("DWARF-2 expression error: `%s' operations must be " + "used either alone or in conjunction with DW_OP_piece " + "or DW_OP_bit_piece."), op_name); } @@ -1377,7 +1350,7 @@ dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf, const gdb_byte *buf_end, if (buf == NULL) return -1; if ((int) dwarf_reg != dwarf_reg) - return -1; + return -1; } else return -1; @@ -1397,7 +1370,7 @@ dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf, const gdb_byte *buf_end, { buf++; if (buf >= buf_end) - return -1; + return -1; *deref_size_return = *buf++; } else @@ -1456,15 +1429,14 @@ dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf, else { if (*buf != DW_OP_bregx) - return 0; + return 0; buf++; buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg); if (buf == NULL) return 0; } - if (dwarf_reg_to_regnum (gdbarch, dwarf_reg) - != gdbarch_sp_regnum (gdbarch)) + if (dwarf_reg_to_regnum (gdbarch, dwarf_reg) != gdbarch_sp_regnum (gdbarch)) return 0; buf = gdb_read_sleb128 (buf, buf_end, &sp_offset); @@ -1496,10 +1468,10 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, type *address_type = this->address_type (); this->m_location = DWARF_VALUE_MEMORY; - this->m_initialized = 1; /* Default is initialized. */ + this->m_initialized = 1; /* Default is initialized. */ if (this->m_recursion_depth > this->m_max_recursion_depth) - error (_("DWARF-2 expression error: Loop detected (%d)."), + error (_ ("DWARF-2 expression error: Loop detected (%d)."), this->m_recursion_depth); this->m_recursion_depth++; @@ -1561,8 +1533,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, break; case DW_OP_addr: - result = extract_unsigned_integer (op_ptr, - this->m_addr_size, byte_order); + result + = extract_unsigned_integer (op_ptr, this->m_addr_size, byte_order); op_ptr += this->m_addr_size; /* Some versions of GCC emit DW_OP_addr before DW_OP_GNU_push_tls_address. In this case the value is an @@ -1699,7 +1671,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, op_ptr = safe_read_uleb128 (op_ptr, op_end, &len); if (op_ptr + len > op_end) - error (_("DW_OP_implicit_value: too few bytes available.")); + error (_ ("DW_OP_implicit_value: too few bytes available.")); this->m_len = len; this->m_data = op_ptr; this->m_location = DWARF_VALUE_LITERAL; @@ -1723,8 +1695,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, int ref_addr_size = this->m_per_cu->ref_addr_size (); /* The referred-to DIE of sect_offset kind. */ - this->m_len = extract_unsigned_integer (op_ptr, ref_addr_size, - byte_order); + this->m_len + = extract_unsigned_integer (op_ptr, ref_addr_size, byte_order); op_ptr += ref_addr_size; /* The byte offset into the data. */ @@ -1801,7 +1773,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, backup the current stack locally and install a new empty stack, then reset it afterwards, effectively erasing whatever the recursive call put there. */ - std::vector<dwarf_stack_value> saved_stack = std::move (this->m_stack); + std::vector<dwarf_stack_value> saved_stack + = std::move (this->m_stack); this->m_stack.clear (); /* FIXME: cagney/2003-03-26: This code should be using @@ -1812,11 +1785,11 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, if (this->m_location == DWARF_VALUE_MEMORY) result = fetch_address (0); else if (this->m_location == DWARF_VALUE_REGISTER) - result - = read_addr_from_reg (this->m_frame, value_as_long (fetch (0))); + result = read_addr_from_reg (this->m_frame, + value_as_long (fetch (0))); else - error (_("Not implemented: computing frame " - "base using explicit value operator")); + error (_ ("Not implemented: computing frame " + "base using explicit value operator")); result = result + offset; result_val = value_from_ulongest (address_type, result); in_stack_memory = true; @@ -1842,13 +1815,13 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = fetch (offset); in_stack_memory = fetch_in_stack_memory (offset); break; - + case DW_OP_swap: { if (this->m_stack.size () < 2) - error (_("Not enough elements for " + error (_ ("Not enough elements for " "DW_OP_swap. Need 2, have %zu."), - this->m_stack.size ()); + this->m_stack.size ()); dwarf_stack_value &t1 = this->m_stack[this->m_stack.size () - 1]; dwarf_stack_value &t2 = this->m_stack[this->m_stack.size () - 2]; @@ -1864,15 +1837,15 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_rot: { if (this->m_stack.size () < 3) - error (_("Not enough elements for " + error (_ ("Not enough elements for " "DW_OP_rot. Need 3, have %zu."), - this->m_stack.size ()); + this->m_stack.size ()); dwarf_stack_value temp = this->m_stack[this->m_stack.size () - 1]; this->m_stack[this->m_stack.size () - 1] = this->m_stack[this->m_stack.size () - 2]; this->m_stack[this->m_stack.size () - 2] - = this->m_stack[this->m_stack.size () - 3]; + = this->m_stack[this->m_stack.size () - 3]; this->m_stack[this->m_stack.size () - 3] = temp; goto no_push; } @@ -1882,7 +1855,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_deref_type: case DW_OP_GNU_deref_type: { - int addr_size = (op == DW_OP_deref ? this->m_addr_size : *op_ptr++); + int addr_size + = (op == DW_OP_deref ? this->m_addr_size : *op_ptr++); gdb_byte *buf = (gdb_byte *) alloca (addr_size); CORE_ADDR addr = fetch_address (0); struct type *type; @@ -1904,12 +1878,12 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, from the type length, we need to zero-extend it. */ if (type->length () != addr_size) { - ULONGEST datum = - extract_unsigned_integer (buf, addr_size, byte_order); + ULONGEST datum + = extract_unsigned_integer (buf, addr_size, byte_order); buf = (gdb_byte *) alloca (type->length ()); - store_unsigned_integer (buf, type->length (), - byte_order, datum); + store_unsigned_integer (buf, type->length (), byte_order, + datum); } result_val = value_from_contents_and_address (type, buf, addr); @@ -1929,7 +1903,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, { case DW_OP_abs: if (value_less (result_val, - value_zero (value_type (result_val), not_lval))) + value_zero (value_type (result_val), + not_lval))) result_val = value_neg (result_val); break; case DW_OP_neg: @@ -1977,8 +1952,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, first = fetch (0); pop (); - if (! base_types_equal_p (value_type (first), value_type (second))) - error (_("Incompatible types on DWARF stack")); + if (!base_types_equal_p (value_type (first), value_type (second))) + error (_ ("Incompatible types on DWARF stack")); switch (op) { @@ -2073,12 +2048,12 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, break; case DW_OP_le: /* A <= B is !(B < A). */ - result = ! value_less (second, first); + result = !value_less (second, first); result_val = value_from_ulongest (address_type, result); break; case DW_OP_ge: /* A >= B is !(A < B). */ - result = ! value_less (first, second); + result = !value_less (first, second); result_val = value_from_ulongest (address_type, result); break; case DW_OP_eq: @@ -2095,11 +2070,11 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = value_from_ulongest (address_type, result); break; case DW_OP_ne: - result = ! value_equal (first, second); + result = !value_equal (first, second); result_val = value_from_ulongest (address_type, result); break; default: - internal_error (_("Can't be reached.")); + internal_error (_ ("Can't be reached.")); } } break; @@ -2189,8 +2164,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_GNU_uninit: if (op_ptr != op_end) - error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always " - "be the very last op.")); + error (_ ("DWARF-2 expression error: DW_OP_GNU_uninit must always " + "be the very last op.")); this->m_initialized = 0; goto no_push; @@ -2219,8 +2194,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, int ref_addr_size = this->m_per_cu->ref_addr_size (); sect_offset sect_off - = (sect_offset) extract_unsigned_integer (op_ptr, - ref_addr_size, + = (sect_offset) extract_unsigned_integer (op_ptr, ref_addr_size, byte_order); op_ptr += ref_addr_size; result_val = sect_variable_value (sect_off, this->m_per_cu, @@ -2228,7 +2202,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = value_cast (address_type, result_val); } break; - + case DW_OP_entry_value: case DW_OP_GNU_entry_value: { @@ -2238,34 +2212,33 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, op_ptr = safe_read_uleb128 (op_ptr, op_end, &len); if (op_ptr + len > op_end) - error (_("DW_OP_entry_value: too few bytes available.")); + error (_ ("DW_OP_entry_value: too few bytes available.")); kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len); if (kind_u.dwarf_reg != -1) { op_ptr += len; - this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG, - kind_u, - -1 /* deref_size */); + this->push_dwarf_reg_entry_value ( + CALL_SITE_PARAMETER_DWARF_REG, kind_u, -1 /* deref_size */); goto no_push; } - kind_u.dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr, - op_ptr + len, - &deref_size); + kind_u.dwarf_reg + = dwarf_block_to_dwarf_reg_deref (op_ptr, op_ptr + len, + &deref_size); if (kind_u.dwarf_reg != -1) { if (deref_size == -1) deref_size = this->m_addr_size; op_ptr += len; - this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG, - kind_u, deref_size); + this->push_dwarf_reg_entry_value ( + CALL_SITE_PARAMETER_DWARF_REG, kind_u, deref_size); goto no_push; } - error (_("DWARF-2 expression error: DW_OP_entry_value is " - "supported only for single DW_OP_reg* " - "or for DW_OP_breg*(0)+DW_OP_deref*")); + error (_ ("DWARF-2 expression error: DW_OP_entry_value is " + "supported only for single DW_OP_reg* " + "or for DW_OP_breg*(0)+DW_OP_deref*")); } case DW_OP_GNU_parameter_ref: @@ -2276,8 +2249,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, = (cu_offset) extract_unsigned_integer (op_ptr, 4, byte_order); op_ptr += 4; this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_PARAM_OFFSET, - kind_u, - -1 /* deref_size */); + kind_u, -1 /* deref_size */); } goto no_push; @@ -2298,7 +2270,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, type = get_base_type (type_die_cu_off); if (type->length () != n) - error (_("DW_OP_const_type has different sizes for type and data")); + error ( + _ ("DW_OP_const_type has different sizes for type and data")); result_val = value_from_contents (type, data); } @@ -2345,13 +2318,11 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, { /* Nothing. */ } - else if (type->length () - != value_type (result_val)->length ()) - error (_("DW_OP_reinterpret has wrong size")); + else if (type->length () != value_type (result_val)->length ()) + error (_ ("DW_OP_reinterpret has wrong size")); else - result_val - = value_from_contents (type, - value_contents_all (result_val).data ()); + result_val = value_from_contents ( + type, value_contents_all (result_val).data ()); } break; @@ -2360,21 +2331,20 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, if (this->m_addr_info == nullptr || (this->m_addr_info->valaddr.data () == nullptr && this->m_addr_info->addr == 0)) - error (_("Location address is not set.")); + error (_ ("Location address is not set.")); result_val = value_from_ulongest (address_type, this->m_addr_info->addr); break; default: - error (_("Unhandled dwarf expression opcode 0x%x"), op); + error (_ ("Unhandled dwarf expression opcode 0x%x"), op); } /* Most things push a result value. */ gdb_assert (result_val != NULL); push (result_val, in_stack_memory); - no_push: - ; + no_push:; } /* To simplify our main caller, if the result is an implicit diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 44fc645..51c9ba7 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#if !defined (DWARF2EXPR_H) +#if !defined(DWARF2EXPR_H) #define DWARF2EXPR_H #include "leb128.h" @@ -103,8 +103,10 @@ struct dwarf_expr_piece struct dwarf_stack_value { dwarf_stack_value (struct value *value_, int in_stack_memory_) - : value (value_), in_stack_memory (in_stack_memory_) - {} + : value (value_), + in_stack_memory (in_stack_memory_) + { + } struct value *value; @@ -119,8 +121,7 @@ struct dwarf_stack_value its current state and its callbacks. */ struct dwarf_expr_context { - dwarf_expr_context (dwarf2_per_objfile *per_objfile, - int addr_size); + dwarf_expr_context (dwarf2_per_objfile *per_objfile, int addr_size); virtual ~dwarf_expr_context () = default; void push_address (CORE_ADDR value, bool in_stack_memory); @@ -144,6 +145,7 @@ struct dwarf_expr_context LONGEST subobj_offset = 0); private: + /* The stack of values. */ std::vector<dwarf_stack_value> m_stack; @@ -278,8 +280,7 @@ int dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf, purposes. */ static inline const gdb_byte * -gdb_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, - uint64_t *r) +gdb_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r) { size_t bytes_read = read_uleb128_to_uint64 (buf, buf_end, r); @@ -289,8 +290,7 @@ gdb_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, } static inline const gdb_byte * -gdb_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end, - int64_t *r) +gdb_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r) { size_t bytes_read = read_sleb128_to_int64 (buf, buf_end, r); @@ -309,13 +309,11 @@ gdb_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end) return buf + bytes_read; } -extern const gdb_byte *safe_read_uleb128 (const gdb_byte *buf, - const gdb_byte *buf_end, - uint64_t *r); +extern const gdb_byte * +safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r); extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf, - const gdb_byte *buf_end, - int64_t *r); + const gdb_byte *buf_end, int64_t *r); extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end); diff --git a/gdb/dwarf2/file-and-dir.h b/gdb/dwarf2/file-and-dir.h index 193a138..3dcb057 100644 --- a/gdb/dwarf2/file-and-dir.h +++ b/gdb/dwarf2/file-and-dir.h @@ -43,10 +43,7 @@ struct file_and_directory } /* Return true if the file name is unknown. */ - bool is_unknown () const - { - return m_name == nullptr; - } + bool is_unknown () const { return m_name == nullptr; } /* Set the compilation directory. */ void set_comp_dir (std::string &&dir) @@ -100,10 +97,7 @@ struct file_and_directory } /* Forget the full name. */ - void forget_fullname () - { - m_fullname.reset (); - } + void forget_fullname () { m_fullname.reset (); } private: diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c index cfa7072..c0947a5 100644 --- a/gdb/dwarf2/frame-tailcall.c +++ b/gdb/dwarf2/frame-tailcall.c @@ -158,7 +158,7 @@ cache_find (frame_info_ptr fi) gdb_assert (fi != NULL); } - search.next_bottom_frame = fi.get(); + search.next_bottom_frame = fi.get (); search.refc = 1; slot = htab_find_slot (cache_htab, &search, NO_INSERT); if (slot == NULL) @@ -173,11 +173,11 @@ cache_find (frame_info_ptr fi) If THIS_FRAME is CACHE-> NEXT_BOTTOM_FRAME return -1. */ static int -existing_next_levels (frame_info_ptr this_frame, - struct tailcall_cache *cache) +existing_next_levels (frame_info_ptr this_frame, struct tailcall_cache *cache) { - int retval = (frame_relative_level (this_frame) - - frame_relative_level (frame_info_ptr (cache->next_bottom_frame)) - 1); + int retval + = (frame_relative_level (this_frame) + - frame_relative_level (frame_info_ptr (cache->next_bottom_frame)) - 1); gdb_assert (retval >= -1); @@ -223,8 +223,8 @@ tailcall_frame_this_id (frame_info_ptr this_frame, void **this_cache, *this_id = get_frame_id (next_frame); (*this_id).code_addr = get_frame_pc (this_frame); (*this_id).code_addr_p = true; - (*this_id).artificial_depth = (cache->chain_levels - - existing_next_levels (this_frame, cache)); + (*this_id).artificial_depth + = (cache->chain_levels - existing_next_levels (this_frame, cache)); gdb_assert ((*this_id).artificial_depth > 0); } @@ -294,8 +294,8 @@ dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame, dwarf2_tailcall_prev_register_first. */ static struct value * -tailcall_frame_prev_register (frame_info_ptr this_frame, - void **this_cache, int regnum) +tailcall_frame_prev_register (frame_info_ptr this_frame, void **this_cache, + int regnum) { struct tailcall_cache *cache = (struct tailcall_cache *) *this_cache; struct value *val; @@ -316,7 +316,7 @@ tailcall_frame_prev_register (frame_info_ptr this_frame, static int tailcall_frame_sniffer (const struct frame_unwind *self, - frame_info_ptr this_frame, void **this_cache) + frame_info_ptr this_frame, void **this_cache) { frame_info_ptr next_frame; int next_levels; @@ -367,7 +367,7 @@ dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame, void **tailcall_cachep, const LONGEST *entry_cfa_sp_offsetp) { - CORE_ADDR prev_pc = 0, prev_sp = 0; /* GCC warning. */ + CORE_ADDR prev_pc = 0, prev_sp = 0; /* GCC warning. */ int prev_sp_p = 0; CORE_ADDR this_pc; struct gdbarch *prev_gdbarch; @@ -461,7 +461,8 @@ static struct gdbarch * tailcall_frame_prev_arch (frame_info_ptr this_frame, void **this_prologue_cache) { - struct tailcall_cache *cache = (struct tailcall_cache *) *this_prologue_cache; + struct tailcall_cache *cache + = (struct tailcall_cache *) *this_prologue_cache; return get_frame_arch (frame_info_ptr (cache->next_bottom_frame)); } @@ -469,23 +470,22 @@ tailcall_frame_prev_arch (frame_info_ptr this_frame, /* Virtual tail call frame unwinder if dwarf2_tailcall_sniffer_first finds a chain to create. */ -const struct frame_unwind dwarf2_tailcall_frame_unwind = -{ - "dwarf2 tailcall", - TAILCALL_FRAME, - default_frame_unwind_stop_reason, - tailcall_frame_this_id, - tailcall_frame_prev_register, - NULL, - tailcall_frame_sniffer, - tailcall_frame_dealloc_cache, - tailcall_frame_prev_arch -}; +const struct frame_unwind dwarf2_tailcall_frame_unwind + = { "dwarf2 tailcall", + TAILCALL_FRAME, + default_frame_unwind_stop_reason, + tailcall_frame_this_id, + tailcall_frame_prev_register, + NULL, + tailcall_frame_sniffer, + tailcall_frame_dealloc_cache, + tailcall_frame_prev_arch }; void _initialize_tailcall_frame (); + void _initialize_tailcall_frame () { - cache_htab = htab_create_alloc (50, cache_hash, cache_eq, NULL, xcalloc, - xfree); + cache_htab + = htab_create_alloc (50, cache_hash, cache_eq, NULL, xcalloc, xfree); } diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h index a4359e2..27eccfc 100644 --- a/gdb/dwarf2/frame-tailcall.h +++ b/gdb/dwarf2/frame-tailcall.h @@ -26,13 +26,13 @@ struct frame_unwind; /* The tail call frame unwinder. */ extern void - dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame, - void **tailcall_cachep, - const LONGEST *entry_cfa_sp_offsetp); +dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame, + void **tailcall_cachep, + const LONGEST *entry_cfa_sp_offsetp); extern struct value * - dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame, - void **tailcall_cachep, int regnum); +dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame, + void **tailcall_cachep, int regnum); extern const struct frame_unwind dwarf2_tailcall_frame_unwind; diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 7f2bcf2..61a407e 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -167,8 +167,8 @@ struct comp_unit auto_obstack obstack; }; -static struct dwarf2_fde *dwarf2_frame_find_fde - (CORE_ADDR *pc, dwarf2_per_objfile **out_per_objfile); +static struct dwarf2_fde * +dwarf2_frame_find_fde (CORE_ADDR *pc, dwarf2_per_objfile **out_per_objfile); static int dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum, int eh_frame_p); @@ -177,7 +177,6 @@ static CORE_ADDR read_encoded_value (struct comp_unit *unit, gdb_byte encoding, int ptr_len, const gdb_byte *buf, unsigned int *bytes_read_ptr, CORE_ADDR func_base); - /* See dwarf2/frame.h. */ bool dwarf2_frame_unwinders_enabled_p = true; @@ -187,7 +186,8 @@ bool dwarf2_frame_unwinders_enabled_p = true; #define cfa_exp_len cfa_reg dwarf2_frame_state::dwarf2_frame_state (CORE_ADDR pc_, struct dwarf2_cie *cie) - : pc (pc_), data_align (cie->data_alignment_factor), + : pc (pc_), + data_align (cie->data_alignment_factor), code_align (cie->code_alignment_factor), retaddr_column (cie->return_address_register) { @@ -216,7 +216,7 @@ dwarf2_restore_rule (struct gdbarch *gdbarch, ULONGEST reg_num, { int regnum = dwarf_reg_to_regnum (gdbarch, reg); - complaint (_("\ + complaint (_ ("\ incomplete CFI data; DW_CFA_restore unspecified\n\ register %s (#%d) at %s"), gdbarch_register_name (gdbarch, regnum), regnum, @@ -240,7 +240,6 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size, else return value_as_address (result_val); } - /* Execute FDE program from INSN_PTR possibly up to INSN_END or up to inferior PC. Modify FS state accordingly. Return current INSN_PTR where the @@ -362,7 +361,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr, if (old_rs == NULL) { - complaint (_("\ + complaint (_ ("\ bad CFI data; mismatched DW_CFA_restore_state at %s"), paddress (gdbarch, fs->pc)); } @@ -385,8 +384,8 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"), case DW_CFA_def_cfa_register: insn_ptr = safe_read_uleb128 (insn_ptr, insn_end, ®); - fs->regs.cfa_reg = dwarf2_frame_adjust_regnum (gdbarch, reg, - eh_frame_p); + fs->regs.cfa_reg + = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p); fs->regs.cfa_how = CFA_REG_OFFSET; break; @@ -462,8 +461,8 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"), case DW_CFA_def_cfa_sf: insn_ptr = safe_read_uleb128 (insn_ptr, insn_end, ®); - fs->regs.cfa_reg = dwarf2_frame_adjust_regnum (gdbarch, reg, - eh_frame_p); + fs->regs.cfa_reg + = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p); insn_ptr = safe_read_sleb128 (insn_ptr, insn_end, &offset); fs->regs.cfa_offset = offset * fs->data_align; fs->regs.cfa_how = CFA_REG_OFFSET; @@ -495,12 +494,13 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"), { /* Handle vendor-specific CFI for different architectures. */ if (!gdbarch_execute_dwarf_cfa_vendor_op (gdbarch, insn, fs)) - error (_("Call Frame Instruction op %d in vendor extension " - "space is not handled on this architecture."), - insn); + error ( + _ ("Call Frame Instruction op %d in vendor extension " + "space is not handled on this architecture."), + insn); } else - internal_error (_("Unknown CFI encountered.")); + internal_error (_ ("Unknown CFI encountered.")); } } } @@ -517,7 +517,8 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"), #if GDB_SELF_TEST -namespace selftests { +namespace selftests +{ /* Unit test to function execute_cfa_program. */ @@ -536,17 +537,19 @@ execute_cfa_program_test (struct gdbarch *gdbarch) dwarf2_frame_state fs (0, fde.cie); - gdb_byte insns[] = - { - DW_CFA_def_cfa, 1, 4, /* DW_CFA_def_cfa: r1 ofs 4 */ - DW_CFA_offset | 0x2, 1, /* DW_CFA_offset: r2 at cfa-4 */ - DW_CFA_remember_state, - DW_CFA_restore_state, - }; + gdb_byte insns[] = { + DW_CFA_def_cfa, + 1, + 4, /* DW_CFA_def_cfa: r1 ofs 4 */ + DW_CFA_offset | 0x2, + 1, /* DW_CFA_offset: r2 at cfa-4 */ + DW_CFA_remember_state, + DW_CFA_restore_state, + }; const gdb_byte *insn_end = insns + sizeof (insns); - const gdb_byte *out = execute_cfa_program (&fde, insns, insn_end, gdbarch, - 0, &fs, 0); + const gdb_byte *out + = execute_cfa_program (&fde, insns, insn_end, gdbarch, 0, &fs, 0); SELF_CHECK (out == insn_end); SELF_CHECK (fs.pc == 0); @@ -575,12 +578,9 @@ execute_cfa_program_test (struct gdbarch *gdbarch) } // namespace selftests #endif /* GDB_SELF_TEST */ - - /* Architecture-specific operations. */ -static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, - int regnum, +static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, frame_info_ptr this_frame); @@ -710,8 +710,8 @@ dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch, void dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch, - int (*adjust_regnum) (struct gdbarch *, - int, int)) + int (*adjust_regnum) (struct gdbarch *, int, + int)) { struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); @@ -722,8 +722,8 @@ dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch, register. */ static int -dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, - int regnum, int eh_frame_p) +dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum, + int eh_frame_p) { struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); @@ -764,15 +764,13 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs, return; } } - /* See dwarf2/frame.h. */ int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, - struct dwarf2_per_cu_data *data, - int *regnum_out, LONGEST *offset_out, - CORE_ADDR *text_offset_out, + struct dwarf2_per_cu_data *data, int *regnum_out, + LONGEST *offset_out, CORE_ADDR *text_offset_out, const gdb_byte **cfa_start_out, const gdb_byte **cfa_end_out) { @@ -783,7 +781,7 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, /* Find the correct FDE. */ fde = dwarf2_frame_find_fde (&pc1, &per_objfile); if (fde == NULL) - error (_("Could not compute CFA; needed to translate this expression")); + error (_ ("Could not compute CFA; needed to translate this expression")); gdb_assert (per_objfile != nullptr); @@ -793,8 +791,8 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, dwarf2_frame_find_quirks (&fs, fde); /* First decode all the insns in the CIE. */ - execute_cfa_program (fde, fde->cie->initial_instructions, - fde->cie->end, gdbarch, pc, &fs, + execute_cfa_program (fde, fde->cie->initial_instructions, fde->cie->end, + gdbarch, pc, &fs, per_objfile->objfile->text_section_offset ()); /* Save the initialized register set. */ @@ -826,11 +824,10 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, return 0; default: - internal_error (_("Unknown CFA rule.")); + internal_error (_ ("Unknown CFA rule.")); } } - /* Custom function data object for architecture specific prev_register implementation. Main purpose of this object is to allow caching of expensive data lookups in the prev_register handling. */ @@ -931,9 +928,8 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) dwarf2_frame_find_quirks (&fs, fde); /* First decode all the insns in the CIE. */ - execute_cfa_program (fde, fde->cie->initial_instructions, - fde->cie->end, gdbarch, - get_frame_address_in_block (this_frame), &fs, + execute_cfa_program (fde, fde->cie->initial_instructions, fde->cie->end, + gdbarch, get_frame_address_in_block (this_frame), &fs, cache->per_objfile->objfile->text_section_offset ()); /* Save the initialized register set. */ @@ -950,9 +946,9 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) && entry_pc < fde->initial_location + fde->address_range) { /* Decode the insns in the FDE up to the entry PC. */ - instr = execute_cfa_program - (fde, fde->instructions, fde->end, gdbarch, entry_pc, &fs, - cache->per_objfile->objfile->text_section_offset ()); + instr = execute_cfa_program ( + fde, fde->instructions, fde->end, gdbarch, entry_pc, &fs, + cache->per_objfile->objfile->text_section_offset ()); if (fs.regs.cfa_how == CFA_REG_OFFSET && (dwarf_reg_to_regnum (gdbarch, fs.regs.cfa_reg) @@ -984,14 +980,13 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) break; case CFA_EXP: - cache->cfa = - execute_stack_op (fs.regs.cfa_exp, fs.regs.cfa_exp_len, - cache->addr_size, this_frame, 0, 0, - cache->per_objfile); + cache->cfa = execute_stack_op (fs.regs.cfa_exp, fs.regs.cfa_exp_len, + cache->addr_size, this_frame, 0, 0, + cache->per_objfile); break; default: - internal_error (_("Unknown CFA rule.")); + internal_error (_ ("Unknown CFA rule.")); } } catch (const gdb_exception_error &ex) @@ -1018,7 +1013,7 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) return address column; it's perfectly all right for it to correspond to a real register. */ { - int column; /* CFI speak for "register number". */ + int column; /* CFI speak for "register number". */ for (column = 0; column < fs.regs.reg.size (); column++) { @@ -1043,7 +1038,7 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) if (fs.regs.reg[column].how == DWARF2_FRAME_REG_UNSPECIFIED) { if (cache->reg[regnum].how == DWARF2_FRAME_REG_UNSPECIFIED) - complaint (_("\ + complaint (_ ("\ incomplete CFI data; unspecified registers (e.g., %s) at %s"), gdbarch_register_name (gdbarch, regnum), paddress (gdbarch, fs.pc)); @@ -1105,15 +1100,14 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), cache->undefined_retaddr = 1; dwarf2_tailcall_sniffer_first (this_frame, &cache->tailcall_cache, - (entry_cfa_sp_offset_p - ? &entry_cfa_sp_offset : NULL)); + (entry_cfa_sp_offset_p ? &entry_cfa_sp_offset + : NULL)); return cache; } static enum unwind_stop_reason -dwarf2_frame_unwind_stop_reason (frame_info_ptr this_frame, - void **this_cache) +dwarf2_frame_unwind_stop_reason (frame_info_ptr this_frame, void **this_cache) { struct dwarf2_frame_cache *cache = dwarf2_frame_cache (this_frame, this_cache); @@ -1131,11 +1125,12 @@ static void dwarf2_frame_this_id (frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id) { - struct dwarf2_frame_cache *cache = - dwarf2_frame_cache (this_frame, this_cache); + struct dwarf2_frame_cache *cache + = dwarf2_frame_cache (this_frame, this_cache); if (cache->unavailable_retaddr) - (*this_id) = frame_id_build_unavailable_stack (get_frame_func (this_frame)); + (*this_id) + = frame_id_build_unavailable_stack (get_frame_func (this_frame)); else if (cache->undefined_retaddr) return; else @@ -1147,8 +1142,8 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, int regnum) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct dwarf2_frame_cache *cache = - dwarf2_frame_cache (this_frame, this_cache); + struct dwarf2_frame_cache *cache + = dwarf2_frame_cache (this_frame, this_cache); CORE_ADDR addr; int realnum; @@ -1160,10 +1155,10 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, if (cache->tailcall_cache) { struct value *val; - - val = dwarf2_tailcall_prev_register_first (this_frame, - &cache->tailcall_cache, - regnum); + + val + = dwarf2_tailcall_prev_register_first (this_frame, + &cache->tailcall_cache, regnum); if (val) return val; } @@ -1180,16 +1175,15 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, return frame_unwind_got_memory (this_frame, regnum, addr); case DWARF2_FRAME_REG_SAVED_REG: - realnum = dwarf_reg_to_regnum_or_error - (gdbarch, cache->reg[regnum].loc.reg); + realnum + = dwarf_reg_to_regnum_or_error (gdbarch, cache->reg[regnum].loc.reg); return frame_unwind_got_register (this_frame, regnum, realnum); case DWARF2_FRAME_REG_SAVED_EXP: - addr = execute_stack_op (cache->reg[regnum].loc.exp.start, - cache->reg[regnum].loc.exp.len, - cache->addr_size, - this_frame, cache->cfa, 1, - cache->per_objfile); + addr + = execute_stack_op (cache->reg[regnum].loc.exp.start, + cache->reg[regnum].loc.exp.len, cache->addr_size, + this_frame, cache->cfa, 1, cache->per_objfile); return frame_unwind_got_memory (this_frame, regnum, addr); case DWARF2_FRAME_REG_SAVED_VAL_OFFSET: @@ -1197,11 +1191,10 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, return frame_unwind_got_constant (this_frame, regnum, addr); case DWARF2_FRAME_REG_SAVED_VAL_EXP: - addr = execute_stack_op (cache->reg[regnum].loc.exp.start, - cache->reg[regnum].loc.exp.len, - cache->addr_size, - this_frame, cache->cfa, 1, - cache->per_objfile); + addr + = execute_stack_op (cache->reg[regnum].loc.exp.start, + cache->reg[regnum].loc.exp.len, cache->addr_size, + this_frame, cache->cfa, 1, cache->per_objfile); return frame_unwind_got_constant (this_frame, regnum, addr); case DWARF2_FRAME_REG_UNSPECIFIED: @@ -1226,8 +1219,8 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, case DWARF2_FRAME_REG_RA_OFFSET: addr = cache->reg[regnum].loc.offset; - regnum = dwarf_reg_to_regnum_or_error - (gdbarch, cache->retaddr_reg.loc.reg); + regnum + = dwarf_reg_to_regnum_or_error (gdbarch, cache->retaddr_reg.loc.reg); addr += get_frame_register_unsigned (this_frame, regnum); return frame_unwind_got_address (this_frame, regnum, addr); @@ -1235,7 +1228,7 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache, return cache->reg[regnum].loc.fn (this_frame, this_cache, regnum); default: - internal_error (_("Unknown register rule.")); + internal_error (_ ("Unknown register rule.")); } } @@ -1288,7 +1281,7 @@ static void dwarf2_frame_dealloc_cache (frame_info *self, void *this_cache) { struct dwarf2_frame_cache *cache - = dwarf2_frame_cache (frame_info_ptr (self), &this_cache); + = dwarf2_frame_cache (frame_info_ptr (self), &this_cache); if (cache->tailcall_cache) dwarf2_tailcall_frame_unwind.dealloc_cache (self, cache->tailcall_cache); @@ -1319,8 +1312,7 @@ dwarf2_frame_sniffer (const struct frame_unwind *self, correctly. */ if (fde->cie->signal_frame - || dwarf2_frame_signal_frame_p (get_frame_arch (this_frame), - this_frame)) + || dwarf2_frame_signal_frame_p (get_frame_arch (this_frame), this_frame)) return self->type == SIGTRAMP_FRAME; if (self->type != NORMAL_FRAME) @@ -1329,31 +1321,23 @@ dwarf2_frame_sniffer (const struct frame_unwind *self, return 1; } -static const struct frame_unwind dwarf2_frame_unwind = -{ - "dwarf2", - NORMAL_FRAME, - dwarf2_frame_unwind_stop_reason, - dwarf2_frame_this_id, - dwarf2_frame_prev_register, - NULL, - dwarf2_frame_sniffer, - dwarf2_frame_dealloc_cache -}; +static const struct frame_unwind dwarf2_frame_unwind + = { "dwarf2", + NORMAL_FRAME, + dwarf2_frame_unwind_stop_reason, + dwarf2_frame_this_id, + dwarf2_frame_prev_register, + NULL, + dwarf2_frame_sniffer, + dwarf2_frame_dealloc_cache }; -static const struct frame_unwind dwarf2_signal_frame_unwind = -{ - "dwarf2 signal", - SIGTRAMP_FRAME, - dwarf2_frame_unwind_stop_reason, - dwarf2_frame_this_id, - dwarf2_frame_prev_register, - NULL, - dwarf2_frame_sniffer, - - /* TAILCALL_CACHE can never be in such frame to need dealloc_cache. */ - NULL -}; +static const struct frame_unwind dwarf2_signal_frame_unwind + = { "dwarf2 signal", SIGTRAMP_FRAME, dwarf2_frame_unwind_stop_reason, + dwarf2_frame_this_id, dwarf2_frame_prev_register, NULL, + dwarf2_frame_sniffer, + + /* TAILCALL_CACHE can never be in such frame to need dealloc_cache. */ + NULL }; /* Append the DWARF-2 frame unwinders to GDBARCH's list. */ @@ -1363,7 +1347,6 @@ dwarf2_append_unwinders (struct gdbarch *gdbarch) frame_unwind_append_unwinder (gdbarch, &dwarf2_frame_unwind); frame_unwind_append_unwinder (gdbarch, &dwarf2_signal_frame_unwind); } - /* There is no explicitly defined relationship between the CFA and the location of frame's local variables and arguments/parameters. @@ -1374,19 +1357,15 @@ dwarf2_append_unwinders (struct gdbarch *gdbarch) static CORE_ADDR dwarf2_frame_base_address (frame_info_ptr this_frame, void **this_cache) { - struct dwarf2_frame_cache *cache = - dwarf2_frame_cache (this_frame, this_cache); + struct dwarf2_frame_cache *cache + = dwarf2_frame_cache (this_frame, this_cache); return cache->cfa; } -static const struct frame_base dwarf2_frame_base = -{ - &dwarf2_frame_unwind, - dwarf2_frame_base_address, - dwarf2_frame_base_address, - dwarf2_frame_base_address -}; +static const struct frame_base dwarf2_frame_base + = { &dwarf2_frame_unwind, dwarf2_frame_base_address, + dwarf2_frame_base_address, dwarf2_frame_base_address }; const struct frame_base * dwarf2_frame_base_sniffer (frame_info_ptr this_frame) @@ -1409,23 +1388,22 @@ dwarf2_frame_cfa (frame_info_ptr this_frame) if (frame_unwinder_is (this_frame, &record_btrace_tailcall_frame_unwind) || frame_unwinder_is (this_frame, &record_btrace_frame_unwind)) throw_error (NOT_AVAILABLE_ERROR, - _("cfa not available for record btrace target")); + _ ("cfa not available for record btrace target")); while (get_frame_type (this_frame) == INLINE_FRAME) this_frame = get_prev_frame (this_frame); if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE) throw_error (NOT_AVAILABLE_ERROR, - _("can't compute CFA for this frame: " - "required registers or memory are unavailable")); + _ ("can't compute CFA for this frame: " + "required registers or memory are unavailable")); if (get_frame_id (this_frame).stack_status != FID_STACK_VALID) - throw_error (NOT_AVAILABLE_ERROR, - _("can't compute CFA for this frame: " - "frame base not available")); + throw_error (NOT_AVAILABLE_ERROR, _ ("can't compute CFA for this frame: " + "frame base not available")); return get_frame_base (this_frame); } - + /* We store the frame data on the BFD. This is only done if it is independent of the address space and so can be shared. */ static const registry<bfd>::key<comp_unit> dwarf2_frame_bfd_data; @@ -1434,7 +1412,6 @@ static const registry<bfd>::key<comp_unit> dwarf2_frame_bfd_data; any debug info requires relocations), then we store the frame data on the objfile instead, and do not share it. */ static const registry<objfile>::key<comp_unit> dwarf2_frame_objfile_data; - /* Pointer encoding helper functions. */ @@ -1464,14 +1441,13 @@ encoding_for_size (unsigned int size) case 8: return DW_EH_PE_udata8; default: - internal_error (_("Unsupported address size")); + internal_error (_ ("Unsupported address size")); } } static CORE_ADDR -read_encoded_value (struct comp_unit *unit, gdb_byte encoding, - int ptr_len, const gdb_byte *buf, - unsigned int *bytes_read_ptr, +read_encoded_value (struct comp_unit *unit, gdb_byte encoding, int ptr_len, + const gdb_byte *buf, unsigned int *bytes_read_ptr, CORE_ADDR func_base) { ptrdiff_t offset; @@ -1480,7 +1456,7 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding, /* GCC currently doesn't generate DW_EH_PE_indirect encodings for FDE's. */ if (encoding & DW_EH_PE_indirect) - internal_error (_("Unsupported encoding: DW_EH_PE_indirect")); + internal_error (_ ("Unsupported encoding: DW_EH_PE_indirect")); *bytes_read_ptr = 0; @@ -1512,7 +1488,7 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding, } break; default: - internal_error (_("Invalid or unsupported encoding")); + internal_error (_ ("Invalid or unsupported encoding")); } if ((encoding & 0x07) == 0x00) @@ -1559,10 +1535,9 @@ read_encoded_value (struct comp_unit *unit, gdb_byte encoding, *bytes_read_ptr += 8; return (base + bfd_get_signed_64 (unit->abfd, (bfd_byte *) buf)); default: - internal_error (_("Invalid or unsupported encoding")); + internal_error (_ ("Invalid or unsupported encoding")); } } - /* Find CIE with the given CIE_POINTER in CIE_TABLE. */ static struct dwarf2_cie * @@ -1680,23 +1655,19 @@ enum eh_frame_type EH_CIE_OR_FDE_TYPE_ID = EH_CIE_TYPE_ID | EH_FDE_TYPE_ID }; -static const gdb_byte *decode_frame_entry (struct gdbarch *gdbarch, - struct comp_unit *unit, - const gdb_byte *start, - int eh_frame_p, - dwarf2_cie_table &cie_table, - dwarf2_fde_table *fde_table, - enum eh_frame_type entry_type); +static const gdb_byte * +decode_frame_entry (struct gdbarch *gdbarch, struct comp_unit *unit, + const gdb_byte *start, int eh_frame_p, + dwarf2_cie_table &cie_table, dwarf2_fde_table *fde_table, + enum eh_frame_type entry_type); /* Decode the next CIE or FDE, entry_type specifies the expected type. Return NULL if invalid input, otherwise the next byte to be processed. */ static const gdb_byte * -decode_frame_entry_1 (struct gdbarch *gdbarch, - struct comp_unit *unit, const gdb_byte *start, - int eh_frame_p, - dwarf2_cie_table &cie_table, - dwarf2_fde_table *fde_table, +decode_frame_entry_1 (struct gdbarch *gdbarch, struct comp_unit *unit, + const gdb_byte *start, int eh_frame_p, + dwarf2_cie_table &cie_table, dwarf2_fde_table *fde_table, enum eh_frame_type entry_type) { const gdb_byte *buf, *end; @@ -1751,7 +1722,7 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, /* Check that a CIE was expected. */ if ((entry_type & EH_CIE_TYPE_ID) == 0) - error (_("Found a CIE when not expecting it.")); + error (_ ("Found a CIE when not expecting it.")); /* Record the offset into the .debug_frame section of this CIE. */ cie_pointer = start - unit->dwarf_frame_buffer; @@ -1844,8 +1815,7 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, } cie->return_address_register - = dwarf2_frame_adjust_regnum (gdbarch, - cie->return_address_register, + = dwarf2_frame_adjust_regnum (gdbarch, cie->return_address_register, eh_frame_p); cie->saw_z_augmentation = (*augmentation == 'z'); @@ -1882,8 +1852,8 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, { /* Skip. Avoid indirection since we throw away the result. */ gdb_byte encoding = (*buf++) & ~DW_EH_PE_indirect; - read_encoded_value (unit, encoding, cie->ptr_size, - buf, &bytes_read, 0); + read_encoded_value (unit, encoding, cie->ptr_size, buf, + &bytes_read, 0); buf += bytes_read; augmentation++; } @@ -1923,7 +1893,7 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, /* Check that an FDE was expected. */ if ((entry_type & EH_FDE_TYPE_ID) == 0) - error (_("Found an FDE when not expecting it.")); + error (_ ("Found an FDE when not expecting it.")); /* In an .eh_frame section, the CIE pointer is the delta between the address within the FDE where the CIE pointer is stored and the @@ -1957,9 +1927,9 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, fde->initial_location = gdbarch_adjust_dwarf2_addr (gdbarch, addr); buf += bytes_read; - fde->address_range = - read_encoded_value (unit, fde->cie->encoding & 0x0f, - fde->cie->ptr_size, buf, &bytes_read, 0); + fde->address_range + = read_encoded_value (unit, fde->cie->encoding & 0x0f, + fde->cie->ptr_size, buf, &bytes_read, 0); addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + fde->address_range); fde->address_range = addr - fde->initial_location; buf += bytes_read; @@ -1995,21 +1965,27 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, expect an FDE or a CIE. */ static const gdb_byte * -decode_frame_entry (struct gdbarch *gdbarch, - struct comp_unit *unit, const gdb_byte *start, - int eh_frame_p, - dwarf2_cie_table &cie_table, - dwarf2_fde_table *fde_table, +decode_frame_entry (struct gdbarch *gdbarch, struct comp_unit *unit, + const gdb_byte *start, int eh_frame_p, + dwarf2_cie_table &cie_table, dwarf2_fde_table *fde_table, enum eh_frame_type entry_type) { - enum { NONE, ALIGN4, ALIGN8, FAIL } workaround = NONE; + enum + { + NONE, + ALIGN4, + ALIGN8, + FAIL + } workaround + = NONE; + const gdb_byte *ret; ptrdiff_t start_offset; while (1) { - ret = decode_frame_entry_1 (gdbarch, unit, start, eh_frame_p, - cie_table, fde_table, entry_type); + ret = decode_frame_entry_1 (gdbarch, unit, start, eh_frame_p, cie_table, + fde_table, entry_type); if (ret != NULL) break; @@ -2066,21 +2042,21 @@ decode_frame_entry (struct gdbarch *gdbarch, break; case ALIGN4: - complaint (_("\ + complaint (_ ("\ Corrupt data in %s:%s; align 4 workaround apparently succeeded"), bfd_get_filename (unit->dwarf_frame_section->owner), bfd_section_name (unit->dwarf_frame_section)); break; case ALIGN8: - complaint (_("\ + complaint (_ ("\ Corrupt data in %s:%s; align 8 workaround apparently succeeded"), bfd_get_filename (unit->dwarf_frame_section->owner), bfd_section_name (unit->dwarf_frame_section)); break; default: - complaint (_("Corrupt data in %s:%s"), + complaint (_ ("Corrupt data in %s:%s"), bfd_get_filename (unit->dwarf_frame_section->owner), bfd_section_name (unit->dwarf_frame_section)); break; @@ -2088,14 +2064,14 @@ Corrupt data in %s:%s; align 8 workaround apparently succeeded"), return ret; } - + static bool fde_is_less_than (const dwarf2_fde *aa, const dwarf2_fde *bb) { if (aa->initial_location == bb->initial_location) { - if (aa->address_range != bb->address_range - && aa->eh_frame_p == 0 && bb->eh_frame_p == 0) + if (aa->address_range != bb->address_range && aa->eh_frame_p == 0 + && bb->eh_frame_p == 0) /* Linker bug, e.g. gold/10400. Work around it by keeping stable sort order. */ return aa < bb; @@ -2148,16 +2124,17 @@ dwarf2_build_frame_info (struct objfile *objfile) try { frame_ptr = unit->dwarf_frame_buffer; - while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) - frame_ptr = decode_frame_entry (gdbarch, unit.get (), - frame_ptr, 1, - cie_table, &fde_table, - EH_CIE_OR_FDE_TYPE_ID); + while (frame_ptr + < unit->dwarf_frame_buffer + unit->dwarf_frame_size) + frame_ptr + = decode_frame_entry (gdbarch, unit.get (), frame_ptr, 1, + cie_table, &fde_table, + EH_CIE_OR_FDE_TYPE_ID); } catch (const gdb_exception_error &e) { - warning (_("skipping .eh_frame info of %s: %s"), + warning (_ ("skipping .eh_frame info of %s: %s"), objfile_name (objfile), e.what ()); fde_table.clear (); @@ -2170,8 +2147,7 @@ dwarf2_build_frame_info (struct objfile *objfile) dwarf2_get_section_info (objfile, DWARF2_DEBUG_FRAME, &unit->dwarf_frame_section, - &unit->dwarf_frame_buffer, - &unit->dwarf_frame_size); + &unit->dwarf_frame_buffer, &unit->dwarf_frame_size); if (unit->dwarf_frame_size) { size_t num_old_fde_entries = fde_table.size (); @@ -2186,7 +2162,7 @@ dwarf2_build_frame_info (struct objfile *objfile) } catch (const gdb_exception_error &e) { - warning (_("skipping .debug_frame info of %s: %s"), + warning (_ ("skipping .debug_frame info of %s: %s"), objfile_name (objfile), e.what ()); fde_table.resize (num_old_fde_entries); @@ -2225,8 +2201,7 @@ dwarf2_build_frame_info (struct objfile *objfile) Also discard leftovers from --gc-sections. */ for (struct dwarf2_fde *fde : fde_table) { - if (fde->initial_location == 0 - && first_non_zero_fde != NULL + if (fde->initial_location == 0 && first_non_zero_fde != NULL && (first_non_zero_fde->initial_location < fde->initial_location + fde->address_range)) continue; @@ -2247,29 +2222,28 @@ dwarf2_build_frame_info (struct objfile *objfile) static void show_dwarf_unwinders_enabled_p (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) + struct cmd_list_element *c, const char *value) { - gdb_printf (file, - _("The DWARF stack unwinders are currently %s.\n"), + gdb_printf (file, _ ("The DWARF stack unwinders are currently %s.\n"), value); } void _initialize_dwarf2_frame (); + void _initialize_dwarf2_frame () { add_setshow_boolean_cmd ("unwinders", class_obscure, - &dwarf2_frame_unwinders_enabled_p , _("\ -Set whether the DWARF stack frame unwinders are used."), _("\ -Show whether the DWARF stack frame unwinders are used."), _("\ + &dwarf2_frame_unwinders_enabled_p, _ ("\ +Set whether the DWARF stack frame unwinders are used."), + _ ("\ +Show whether the DWARF stack frame unwinders are used."), + _ ("\ When enabled the DWARF stack frame unwinders can be used for architectures\n\ that support the DWARF unwinders. Enabling the DWARF unwinders for an\n\ architecture that doesn't support them will have no effect."), - NULL, - show_dwarf_unwinders_enabled_p, - &set_dwarf_cmdlist, - &show_dwarf_cmdlist); + NULL, show_dwarf_unwinders_enabled_p, + &set_dwarf_cmdlist, &show_dwarf_cmdlist); #if GDB_SELF_TEST selftests::register_test_foreach_arch ("execute_cfa_program", diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h index 5643e55..3dfa936 100644 --- a/gdb/dwarf2/frame.h +++ b/gdb/dwarf2/frame.h @@ -57,11 +57,11 @@ enum dwarf2_frame_reg_rule /* These aren't defined by the DWARF2 CFI specification, but are used internally by GDB. */ - DWARF2_FRAME_REG_FN, /* Call a registered function. */ - DWARF2_FRAME_REG_RA, /* Return Address. */ - DWARF2_FRAME_REG_RA_OFFSET, /* Return Address with offset. */ - DWARF2_FRAME_REG_CFA, /* Call Frame Address. */ - DWARF2_FRAME_REG_CFA_OFFSET /* Call Frame Address with offset. */ + DWARF2_FRAME_REG_FN, /* Call a registered function. */ + DWARF2_FRAME_REG_RA, /* Return Address. */ + DWARF2_FRAME_REG_RA_OFFSET, /* Return Address with offset. */ + DWARF2_FRAME_REG_CFA, /* Call Frame Address. */ + DWARF2_FRAME_REG_CFA_OFFSET /* Call Frame Address with offset. */ }; /* Register state. */ @@ -73,14 +73,17 @@ struct dwarf2_frame_state_reg { /* Each register save state can be described in terms of a CFA slot, another register, or a location expression. */ - union { + union + { LONGEST offset; ULONGEST reg; + struct { const gdb_byte *start; ULONGEST len; } exp; + fn_prev_register fn; } loc; enum dwarf2_frame_reg_rule how; @@ -96,22 +99,22 @@ enum cfa_how_kind struct dwarf2_frame_state_reg_info { dwarf2_frame_state_reg_info () = default; - ~dwarf2_frame_state_reg_info () - { - delete prev; - } + + ~dwarf2_frame_state_reg_info () { delete prev; } /* Copy constructor. */ dwarf2_frame_state_reg_info (const dwarf2_frame_state_reg_info &src) - : reg (src.reg), cfa_offset (src.cfa_offset), - cfa_reg (src.cfa_reg), cfa_how (src.cfa_how), cfa_exp (src.cfa_exp), + : reg (src.reg), + cfa_offset (src.cfa_offset), + cfa_reg (src.cfa_reg), + cfa_how (src.cfa_how), + cfa_exp (src.cfa_exp), prev (src.prev) { } /* Assignment operator for both move-assignment and copy-assignment. */ - dwarf2_frame_state_reg_info& - operator= (dwarf2_frame_state_reg_info rhs) + dwarf2_frame_state_reg_info &operator= (dwarf2_frame_state_reg_info rhs) { swap (*this, rhs); return *this; @@ -119,8 +122,11 @@ struct dwarf2_frame_state_reg_info /* Move constructor. */ dwarf2_frame_state_reg_info (dwarf2_frame_state_reg_info &&rhs) noexcept - : reg (std::move (rhs.reg)), cfa_offset (rhs.cfa_offset), - cfa_reg (rhs.cfa_reg), cfa_how (rhs.cfa_how), cfa_exp (rhs.cfa_exp), + : reg (std::move (rhs.reg)), + cfa_offset (rhs.cfa_offset), + cfa_reg (rhs.cfa_reg), + cfa_how (rhs.cfa_how), + cfa_exp (rhs.cfa_exp), prev (rhs.prev) { rhs.prev = nullptr; @@ -149,8 +155,9 @@ struct dwarf2_frame_state_reg_info struct dwarf2_frame_state_reg_info *prev = NULL; private: - friend void swap (dwarf2_frame_state_reg_info& lhs, - dwarf2_frame_state_reg_info& rhs) + + friend void swap (dwarf2_frame_state_reg_info &lhs, + dwarf2_frame_state_reg_info &rhs) { using std::swap; @@ -173,14 +180,18 @@ struct dwarf2_frame_state /* Each register save state can be described in terms of a CFA slot, another register, or a location expression. */ - struct dwarf2_frame_state_reg_info regs {}; + struct dwarf2_frame_state_reg_info regs + { + }; /* The PC described by the current frame state. */ CORE_ADDR pc; /* Initial register set from the CIE. Used to implement DW_CFA_restore. */ - struct dwarf2_frame_state_reg_info initial {}; + struct dwarf2_frame_state_reg_info initial + { + }; /* The information we care about from the CIE. */ const LONGEST data_align; @@ -207,26 +218,23 @@ extern bool dwarf2_frame_unwinders_enabled_p; /* Set the architecture-specific register state initialization function for GDBARCH to INIT_REG. */ -extern void dwarf2_frame_set_init_reg (struct gdbarch *gdbarch, - void (*init_reg) (struct gdbarch *, int, - struct dwarf2_frame_state_reg *, - frame_info_ptr)); +extern void dwarf2_frame_set_init_reg ( + struct gdbarch *gdbarch, + void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *, + frame_info_ptr)); /* Set the architecture-specific signal trampoline recognition function for GDBARCH to SIGNAL_FRAME_P. */ -extern void - dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch, - int (*signal_frame_p) (struct gdbarch *, - frame_info_ptr)); +extern void dwarf2_frame_set_signal_frame_p ( + struct gdbarch *gdbarch, + int (*signal_frame_p) (struct gdbarch *, frame_info_ptr)); /* Set the architecture-specific adjustment of .eh_frame and .debug_frame register numbers. */ -extern void - dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch, - int (*adjust_regnum) (struct gdbarch *, - int, int)); +extern void dwarf2_frame_set_adjust_regnum ( + struct gdbarch *gdbarch, int (*adjust_regnum) (struct gdbarch *, int, int)); /* Append the DWARF-2 frame unwinders to GDBARCH's list. */ @@ -236,7 +244,7 @@ void dwarf2_append_unwinders (struct gdbarch *gdbarch); NULL if it can't be handled by the DWARF CFI frame unwinder. */ extern const struct frame_base * - dwarf2_frame_base_sniffer (frame_info_ptr this_frame); +dwarf2_frame_base_sniffer (frame_info_ptr this_frame); /* Compute the DWARF CFA for a frame. */ @@ -264,7 +272,6 @@ extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, const gdb_byte **cfa_start_out, const gdb_byte **cfa_end_out); - /* Allocate a new instance of the function unique data. The main purpose of this custom function data object is to allow caching the diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index a748479..969104a 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -37,9 +37,9 @@ /* When set to true, show debug messages about the index cache. */ static bool debug_index_cache = false; -#define index_cache_debug(FMT, ...) \ - debug_prefixed_printf_cond_nofunc (debug_index_cache, "index-cache", \ - FMT, ## __VA_ARGS__) +#define index_cache_debug(FMT, ...) \ + debug_prefixed_printf_cond_nofunc (debug_index_cache, "index-cache", FMT, \ + ##__VA_ARGS__) /* The index cache directory, used for "set/show index-cache directory". */ static std::string index_cache_directory; @@ -104,8 +104,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile) const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ()); if (build_id == nullptr) { - index_cache_debug ("objfile %s has no build id", - objfile_name (obj)); + index_cache_debug ("objfile %s has no build id", objfile_name (obj)); return; } @@ -118,7 +117,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile) if (dwz != nullptr) { - const bfd_build_id *dwz_build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); + const bfd_build_id *dwz_build_id + = build_id_bfd_get (dwz->dwz_bfd.get ()); if (dwz_build_id == nullptr) { @@ -133,7 +133,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile) if (m_dir.empty ()) { - warning (_("The index cache directory name is empty, skipping store.")); + warning (_ ("The index cache directory name is empty, skipping store.")); return; } @@ -142,7 +142,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile) /* Try to create the containing directory. */ if (!mkdir_recursive (m_dir.c_str ())) { - warning (_("index cache: could not make cache directory: %s"), + warning (_ ("index cache: could not make cache directory: %s"), safe_strerror (errno)); return; } @@ -152,9 +152,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile) /* Write the index itself to the directory, using the build id as the filename. */ - write_dwarf_index (per_objfile, m_dir.c_str (), - build_id_str.c_str (), dwz_build_id_ptr, - dw_index_kind::GDB_INDEX); + write_dwarf_index (per_objfile, m_dir.c_str (), build_id_str.c_str (), + dwz_build_id_ptr, dw_index_kind::GDB_INDEX); } catch (const gdb_exception_error &except) { @@ -173,7 +172,8 @@ struct index_cache_resource_mmap final : public index_cache_resource file doesn't exist. */ index_cache_resource_mmap (const char *filename) : mapping (mmap_file (filename)) - {} + { + } scoped_mmap mapping; }; @@ -189,8 +189,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, if (m_dir.empty ()) { - warning (_("The index cache directory name is empty, skipping cache " - "lookup.")); + warning (_ ("The index cache directory name is empty, skipping cache " + "lookup.")); return {}; } @@ -199,8 +199,7 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, try { - index_cache_debug ("trying to read %s", - filename.c_str ()); + index_cache_debug ("trying to read %s", filename.c_str ()); /* Try to map that file. */ index_cache_resource_mmap *mmap_resource @@ -209,14 +208,14 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, /* Yay, it worked! Hand the resource to the caller. */ resource->reset (mmap_resource); - return gdb::array_view<const gdb_byte> - ((const gdb_byte *) mmap_resource->mapping.get (), - mmap_resource->mapping.size ()); + return gdb::array_view<const gdb_byte> ((const gdb_byte *) + mmap_resource->mapping.get (), + mmap_resource->mapping.size ()); } catch (const gdb_exception_error &except) { - index_cache_debug ("couldn't read %s: %s", - filename.c_str (), except.what ()); + index_cache_debug ("couldn't read %s: %s", filename.c_str (), + except.what ()); } return {}; @@ -262,9 +261,8 @@ show_index_cache_command (const char *arg, int from_tty) cmd_show_list (show_index_cache_prefix_list, from_tty); gdb_printf ("\n"); - gdb_printf - (_("The index cache is currently %s.\n"), - global_index_cache.enabled () ? _("enabled") : _("disabled")); + gdb_printf (_ ("The index cache is currently %s.\n"), + global_index_cache.enabled () ? _ ("enabled") : _ ("disabled")); } /* "set/show index-cache enabled" set callback. */ @@ -292,7 +290,7 @@ static void show_index_cache_enabled_command (ui_file *stream, int from_tty, cmd_list_element *cmd, const char *value) { - gdb_printf (stream, _("The index cache is %s.\n"), value); + gdb_printf (stream, _ ("The index cache is %s.\n"), value); } /* "set index-cache directory" handler. */ @@ -321,13 +319,14 @@ show_index_cache_stats_command (const char *arg, int from_tty) gdb_printf ("\n"); } - gdb_printf (_("%s Cache hits (this session): %u\n"), - indent, global_index_cache.n_hits ()); - gdb_printf (_("%sCache misses (this session): %u\n"), - indent, global_index_cache.n_misses ()); + gdb_printf (_ ("%s Cache hits (this session): %u\n"), indent, + global_index_cache.n_hits ()); + gdb_printf (_ ("%sCache misses (this session): %u\n"), indent, + global_index_cache.n_misses ()); } void _initialize_index_cache (); + void _initialize_index_cache () { @@ -339,30 +338,27 @@ _initialize_index_cache () global_index_cache.set_directory (std::move (cache_dir)); } else - warning (_("Couldn't determine a path for the index cache directory.")); + warning (_ ("Couldn't determine a path for the index cache directory.")); /* set index-cache */ add_basic_prefix_cmd ("index-cache", class_files, - _("Set index-cache options."), - &set_index_cache_prefix_list, - false, &setlist); + _ ("Set index-cache options."), + &set_index_cache_prefix_list, false, &setlist); /* show index-cache */ add_prefix_cmd ("index-cache", class_files, show_index_cache_command, - _("Show index-cache options."), &show_index_cache_prefix_list, - false, &showlist); + _ ("Show index-cache options."), + &show_index_cache_prefix_list, false, &showlist); /* set/show index-cache enabled */ set_show_commands setshow_index_cache_enabled_cmds - = add_setshow_boolean_cmd ("enabled", class_files, - _("Enable the index cache."), - _("Show whether the index cache is enabled."), - _("When on, enable the use of the index cache."), - set_index_cache_enabled_command, - get_index_cache_enabled_command, - show_index_cache_enabled_command, - &set_index_cache_prefix_list, - &show_index_cache_prefix_list); + = add_setshow_boolean_cmd ( + "enabled", class_files, _ ("Enable the index cache."), + _ ("Show whether the index cache is enabled."), + _ ("When on, enable the use of the index cache."), + set_index_cache_enabled_command, get_index_cache_enabled_command, + show_index_cache_enabled_command, &set_index_cache_prefix_list, + &show_index_cache_prefix_list); /* set index-cache on */ cmd_list_element *set_index_cache_on_cmd @@ -380,25 +376,23 @@ _initialize_index_cache () /* set index-cache directory */ add_setshow_filename_cmd ("directory", class_files, &index_cache_directory, - _("Set the directory of the index cache."), - _("Show the directory of the index cache."), - NULL, + _ ("Set the directory of the index cache."), + _ ("Show the directory of the index cache."), NULL, set_index_cache_directory_command, NULL, &set_index_cache_prefix_list, &show_index_cache_prefix_list); /* show index-cache stats */ add_cmd ("stats", class_files, show_index_cache_stats_command, - _("Show some stats about the index cache."), + _ ("Show some stats about the index cache."), &show_index_cache_prefix_list); /* set debug index-cache */ add_setshow_boolean_cmd ("index-cache", class_maintenance, &debug_index_cache, - _("Set display of index-cache debug messages."), - _("Show display of index-cache debug messages."), - _("\ + _ ("Set display of index-cache debug messages."), + _ ("Show display of index-cache debug messages."), + _ ("\ When non-zero, debugging output for the index cache is displayed."), - NULL, NULL, - &setdebuglist, &showdebuglist); + NULL, NULL, &setdebuglist, &showdebuglist); } diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index c4cadd0..095dc21 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -37,14 +37,12 @@ struct index_cache_resource class index_cache { public: + /* Change the directory used to save/load index files. */ void set_directory (std::string dir); /* Return true if the usage of the cache is enabled. */ - bool enabled () const - { - return m_enabled; - } + bool enabled () const { return m_enabled; } /* Enable the cache. */ void enable (); @@ -66,8 +64,7 @@ public: std::unique_ptr<index_cache_resource> *resource); /* Return the number of cache hits. */ - unsigned int n_hits () const - { return m_n_hits; } + unsigned int n_hits () const { return m_n_hits; } /* Record a cache hit. */ void hit () @@ -77,8 +74,7 @@ public: } /* Return the number of cache misses. */ - unsigned int n_misses () const - { return m_n_misses; } + unsigned int n_misses () const { return m_n_misses; } /* Record a cache miss. */ void miss () diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 52f6054..d3bf59f 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -48,25 +48,31 @@ /* Ensure only legit values are used. */ #define DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \ - do { \ - gdb_assert ((unsigned int) (value) <= 1); \ - GDB_INDEX_SYMBOL_STATIC_SET_VALUE((cu_index), (value)); \ - } while (0) + do \ + { \ + gdb_assert ((unsigned int) (value) <= 1); \ + GDB_INDEX_SYMBOL_STATIC_SET_VALUE ((cu_index), (value)); \ + } \ + while (0) /* Ensure only legit values are used. */ -#define DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \ - do { \ - gdb_assert ((value) >= GDB_INDEX_SYMBOL_KIND_TYPE \ - && (value) <= GDB_INDEX_SYMBOL_KIND_OTHER); \ - GDB_INDEX_SYMBOL_KIND_SET_VALUE((cu_index), (value)); \ - } while (0) +#define DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \ + do \ + { \ + gdb_assert ((value) >= GDB_INDEX_SYMBOL_KIND_TYPE \ + && (value) <= GDB_INDEX_SYMBOL_KIND_OTHER); \ + GDB_INDEX_SYMBOL_KIND_SET_VALUE ((cu_index), (value)); \ + } \ + while (0) /* Ensure we don't use more than the allotted number of bits for the CU. */ -#define DW2_GDB_INDEX_CU_SET_VALUE(cu_index, value) \ - do { \ - gdb_assert (((value) & ~GDB_INDEX_CU_MASK) == 0); \ - GDB_INDEX_CU_SET_VALUE((cu_index), (value)); \ - } while (0) +#define DW2_GDB_INDEX_CU_SET_VALUE(cu_index, value) \ + do \ + { \ + gdb_assert (((value) & ~GDB_INDEX_CU_MASK) == 0); \ + GDB_INDEX_CU_SET_VALUE ((cu_index), (value)); \ + } \ + while (0) /* The "save gdb-index" command. */ @@ -77,7 +83,7 @@ static void file_write (FILE *file, const void *data, size_t size) { if (fwrite (data, 1, size, file) != size) - error (_("couldn't data write to file")); + error (_ ("couldn't data write to file")); } /* Write the contents of VEC to FILE, with error checking. */ @@ -94,6 +100,7 @@ file_write (FILE *file, const std::vector<Elem, Alloc> &vec) class data_buf { public: + /* Copy ARRAY to the end of the buffer. */ void append_array (gdb::array_view<const gdb_byte> array) { @@ -137,24 +144,16 @@ public: } /* Return the size of the buffer. */ - size_t size () const - { - return m_vec.size (); - } + size_t size () const { return m_vec.size (); } /* Return true iff the buffer is empty. */ - bool empty () const - { - return m_vec.empty (); - } + bool empty () const { return m_vec.empty (); } /* Write the buffer to FILE. */ - void file_write (FILE *file) const - { - ::file_write (file, m_vec); - } + void file_write (FILE *file) const { ::file_write (file, m_vec); } private: + /* Grow SIZE bytes at the end of the buffer. Returns a pointer to the start of the new block. */ gdb_byte *grow (size_t size) @@ -185,10 +184,7 @@ struct symtab_index_entry /* The symbol table. This is a power-of-2-sized hash table. */ struct mapped_symtab { - mapped_symtab () - { - data.resize (1024); - } + mapped_symtab () { data.resize (1024); } /* Minimize each entry in the symbol table, removing duplicates. */ void minimize () @@ -250,9 +246,8 @@ hash_expand (struct mapped_symtab *symtab) IS_STATIC is one if the symbol is static, otherwise zero (global). */ static void -add_index_entry (struct mapped_symtab *symtab, const char *name, - int is_static, gdb_index_symbol_kind kind, - offset_type cu_index) +add_index_entry (struct mapped_symtab *symtab, const char *name, int is_static, + gdb_index_symbol_kind kind, offset_type cu_index) { offset_type cu_index_and_attrs; @@ -301,16 +296,15 @@ symtab_index_entry::minimize () similar to what gdb historically did for partial symbols. */ std::unordered_set<offset_type> seen; from = std::remove_if (cu_indices.begin (), cu_indices.end (), - [&] (offset_type val) - { - gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val); - if (kind != GDB_INDEX_SYMBOL_KIND_TYPE - && kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) - return false; - - val &= ~GDB_INDEX_CU_MASK; - return !seen.insert (val).second; - }); + [&] (offset_type val) { + gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val); + if (kind != GDB_INDEX_SYMBOL_KIND_TYPE + && kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) + return false; + + val &= ~GDB_INDEX_CU_MASK; + return !seen.insert (val).second; + }); cu_indices.erase (from, cu_indices.end ()); } @@ -320,9 +314,11 @@ symtab_index_entry::minimize () class c_str_view { public: + c_str_view (const char *cstr) : m_cstr (cstr) - {} + { + } bool operator== (const c_str_view &other) const { @@ -331,12 +327,10 @@ public: /* Return the underlying C string. Note, the returned string is only a reference with lifetime of this object. */ - const char *c_str () const - { - return m_cstr; - } + const char *c_str () const { return m_cstr; } private: + friend class c_str_view_hasher; const char *const m_cstr; }; @@ -346,7 +340,8 @@ private: class c_str_view_hasher { public: - size_t operator () (const c_str_view &x) const + + size_t operator() (const c_str_view &x) const { return mapped_index_string_hash (INT_MAX, x.m_cstr); } @@ -357,10 +352,11 @@ template<typename T> class vector_hasher { public: - size_t operator () (const std::vector<T> &key) const + + size_t operator() (const std::vector<T> &key) const { - return iterative_hash (key.data (), - sizeof (key.front ()) * key.size (), 0); + return iterative_hash (key.data (), sizeof (key.front ()) * key.size (), + 0); } }; @@ -390,8 +386,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool) lookup, and then destroys the new node if another node already had the same key. C++17 try_emplace will avoid this. */ - const auto found - = symbol_hash_table.find (entry.cu_indices); + const auto found = symbol_hash_table.find (entry.cu_indices); if (found != symbol_hash_table.end ()) { entry.index_offset = found->second; @@ -414,7 +409,8 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool) if (entry.name != NULL) { - const auto insertpair = str_table.emplace (entry.name, cpool.size ()); + const auto insertpair + = str_table.emplace (entry.name, cpool.size ()); if (insertpair.second) cpool.append_cstr0 (entry.name); str_off = insertpair.first->second; @@ -442,7 +438,8 @@ struct addrmap_index_data addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_) : addr_vec (addr_vec_), cu_index_htab (cu_index_htab_) - {} + { + } data_buf &addr_vec; cu_index_map &cu_index_htab; @@ -462,8 +459,8 @@ struct addrmap_index_data /* Write an address entry to ADDR_VEC. */ static void -add_address_entry (data_buf &addr_vec, - CORE_ADDR start, CORE_ADDR end, unsigned int cu_index) +add_address_entry (data_buf &addr_vec, CORE_ADDR start, CORE_ADDR end, + unsigned int cu_index) { addr_vec.append_uint (8, BFD_ENDIAN_LITTLE, start); addr_vec.append_uint (8, BFD_ENDIAN_LITTLE, end); @@ -479,8 +476,7 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, const void *obj) = static_cast<const dwarf2_per_cu_data *> (obj); if (previous_valid) - add_address_entry (addr_vec, - previous_cu_start, start_addr, + add_address_entry (addr_vec, previous_cu_start, start_addr, previous_cu_index); previous_cu_start = start_addr; @@ -515,27 +511,27 @@ write_address_map (const addrmap *addrmap, data_buf &addr_vec, doesn't work here. To cope we pass 0xff...ff, this is a rare situation anyway. */ if (addrmap_index_data.previous_valid) - add_address_entry (addr_vec, - addrmap_index_data.previous_cu_start, (CORE_ADDR) -1, - addrmap_index_data.previous_cu_index); + add_address_entry (addr_vec, addrmap_index_data.previous_cu_start, + (CORE_ADDR) -1, addrmap_index_data.previous_cu_index); } /* DWARF-5 .debug_names builder. */ class debug_names { public: + debug_names (dwarf2_per_objfile *per_objfile, bool is_dwarf64, bfd_endian dwarf5_byte_order) : m_dwarf5_byte_order (dwarf5_byte_order), m_dwarf32 (dwarf5_byte_order), m_dwarf64 (dwarf5_byte_order), - m_dwarf (is_dwarf64 - ? static_cast<dwarf &> (m_dwarf64) - : static_cast<dwarf &> (m_dwarf32)), + m_dwarf (is_dwarf64 ? static_cast<dwarf &> (m_dwarf64) + : static_cast<dwarf &> (m_dwarf32)), m_name_table_string_offs (m_dwarf.name_table_string_offs), m_name_table_entry_offs (m_dwarf.name_table_entry_offs), m_debugstrlookup (per_objfile) - {} + { + } int dwarf5_offset_size () const { @@ -544,7 +540,11 @@ public: } /* Is this symbol from DW_TAG_compile_unit or DW_TAG_type_unit? */ - enum class unit_kind { cu, tu }; + enum class unit_kind + { + cu, + tu + }; /* Insert one symbol. */ void insert (const cooked_index_entry *entry) @@ -565,9 +565,8 @@ public: int cu_index = it->second; bool is_static = (entry->flags & IS_STATIC) != 0; - unit_kind kind = (entry->per_cu->is_debug_types - ? unit_kind::tu - : unit_kind::cu); + unit_kind kind + = (entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu); if (entry->per_cu->lang () == language_ada) { @@ -596,9 +595,9 @@ public: see PR symtab/24820 for details. */ std::string decoded = ada_decode (name); if (decoded[0] == '<') - name = (char *) obstack_copy0 (&m_string_obstack, - decoded.c_str () + 1, - decoded.length () - 2); + name + = (char *) obstack_copy0 (&m_string_obstack, decoded.c_str () + 1, + decoded.length () - 2); else name = obstack_strdup (&m_string_obstack, ada_encode (decoded.c_str ())); @@ -619,8 +618,8 @@ public: /* Verify the build method has not be called twice. */ gdb_assert (m_abbrev_table.empty ()); const size_t name_count = m_name_to_value_set.size (); - m_bucket_table.resize - (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3)))); + m_bucket_table.resize (std::pow (2, std::ceil (std::log2 (name_count * 4 + / 3)))); m_hash_table.reserve (name_count); m_name_table_string_offs.reserve (name_count); m_name_table_entry_offs.reserve (name_count); @@ -631,19 +630,19 @@ public: uint32_t hash; decltype (m_name_to_value_set)::const_iterator it; }; + std::vector<std::forward_list<hash_it_pair>> bucket_hash; bucket_hash.resize (m_bucket_table.size ()); for (decltype (m_name_to_value_set)::const_iterator it - = m_name_to_value_set.cbegin (); - it != m_name_to_value_set.cend (); - ++it) + = m_name_to_value_set.cbegin (); + it != m_name_to_value_set.cend (); ++it) { const char *const name = it->first.c_str (); const uint32_t hash = dwarf5_djb_hash (name); hash_it_pair hashitpair; hashitpair.hash = hash; hashitpair.it = it; - auto &slot = bucket_hash[hash % bucket_hash.size()]; + auto &slot = bucket_hash[hash % bucket_hash.size ()]; slot.push_front (std::move (hashitpair)); } for (size_t bucket_ix = 0; bucket_ix < bucket_hash.size (); ++bucket_ix) @@ -660,34 +659,35 @@ public: for (const hash_it_pair &hashitpair : hashitlist) { m_hash_table.push_back (0); - store_unsigned_integer (reinterpret_cast<gdb_byte *> - (&m_hash_table.back ()), - sizeof (m_hash_table.back ()), - m_dwarf5_byte_order, hashitpair.hash); + store_unsigned_integer ( + reinterpret_cast<gdb_byte *> (&m_hash_table.back ()), + sizeof (m_hash_table.back ()), m_dwarf5_byte_order, + hashitpair.hash); const c_str_view &name = hashitpair.it->first; const std::set<symbol_value> &value_set = hashitpair.it->second; - m_name_table_string_offs.push_back_reorder - (m_debugstrlookup.lookup (name.c_str ())); + m_name_table_string_offs.push_back_reorder ( + m_debugstrlookup.lookup (name.c_str ())); m_name_table_entry_offs.push_back_reorder (m_entry_pool.size ()); gdb_assert (!value_set.empty ()); for (const symbol_value &value : value_set) { - int &idx = m_indexkey_to_idx[index_key (value.dwarf_tag, - value.is_static, - value.kind)]; + int &idx + = m_indexkey_to_idx[index_key (value.dwarf_tag, + value.is_static, value.kind)]; if (idx == 0) { idx = m_idx_next++; m_abbrev_table.append_unsigned_leb128 (idx); m_abbrev_table.append_unsigned_leb128 (value.dwarf_tag); - m_abbrev_table.append_unsigned_leb128 - (value.kind == unit_kind::cu ? DW_IDX_compile_unit - : DW_IDX_type_unit); + m_abbrev_table.append_unsigned_leb128 ( + value.kind == unit_kind::cu ? DW_IDX_compile_unit + : DW_IDX_type_unit); m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata); - m_abbrev_table.append_unsigned_leb128 (value.is_static - ? DW_IDX_GNU_internal - : DW_IDX_GNU_external); - m_abbrev_table.append_unsigned_leb128 (DW_FORM_flag_present); + m_abbrev_table.append_unsigned_leb128 ( + value.is_static ? DW_IDX_GNU_internal + : DW_IDX_GNU_external); + m_abbrev_table.append_unsigned_leb128 ( + DW_FORM_flag_present); /* Terminate attributes list. */ m_abbrev_table.append_unsigned_leb128 (0); @@ -805,8 +805,8 @@ private: = m_str_table.emplace (c_str_view (s), data - per_objfile->per_bfd->str.buffer); if (!insertpair.second) - complaint (_("Duplicate string \"%s\" in " - ".debug_str section [in module %s]"), + complaint (_ ("Duplicate string \"%s\" in " + ".debug_str section [in module %s]"), s, bfd_get_filename (m_abfd)); data += strlen (s) + 1; } @@ -820,20 +820,18 @@ private: const auto it = m_str_table.find (c_str_view (s)); if (it != m_str_table.end ()) return it->second; - const size_t offset = (m_per_objfile->per_bfd->str.size - + m_str_add_buf.size ()); + const size_t offset + = (m_per_objfile->per_bfd->str.size + m_str_add_buf.size ()); m_str_table.emplace (c_str_view (s), offset); m_str_add_buf.append_cstr0 (s); return offset; } /* Append the end of the .debug_str section to FILE. */ - void file_write (FILE *file) const - { - m_str_add_buf.file_write (file); - } + void file_write (FILE *file) const { m_str_add_buf.file_write (file); } private: + std::unordered_map<c_str_view, size_t, c_str_view_hasher> m_str_table; bfd *const m_abfd; dwarf2_per_objfile *m_per_objfile; @@ -847,13 +845,15 @@ private: class index_key { public: + index_key (int dwarf_tag_, bool is_static_, unit_kind kind_) - : dwarf_tag (dwarf_tag_), is_static (is_static_), kind (kind_) + : dwarf_tag (dwarf_tag_), + is_static (is_static_), + kind (kind_) { } - bool - operator== (const index_key &other) const + bool operator== (const index_key &other) const { return (dwarf_tag == other.dwarf_tag && is_static == other.is_static && kind == other.kind); @@ -868,10 +868,10 @@ private: class index_key_hasher { public: - size_t - operator () (const index_key &key) const + + size_t operator() (const index_key &key) const { - return (std::hash<int>() (key.dwarf_tag) << 1) | key.is_static; + return (std::hash<int> () (key.dwarf_tag) << 1) | key.is_static; } }; @@ -879,27 +879,30 @@ private: class symbol_value { public: + const int dwarf_tag, cu_index; const bool is_static; const unit_kind kind; symbol_value (int dwarf_tag_, int cu_index_, bool is_static_, unit_kind kind_) - : dwarf_tag (dwarf_tag_), cu_index (cu_index_), is_static (is_static_), + : dwarf_tag (dwarf_tag_), + cu_index (cu_index_), + is_static (is_static_), kind (kind_) - {} + { + } - bool - operator< (const symbol_value &other) const + bool operator<(const symbol_value &other) const { -#define X(n) \ - do \ - { \ +#define X(n) \ + do \ + { \ if (n < other.n) \ - return true; \ + return true; \ if (n > other.n) \ - return false; \ - } \ + return false; \ + } \ while (0) X (dwarf_tag); X (is_static); @@ -915,11 +918,15 @@ private: class offset_vec { protected: + const bfd_endian dwarf5_byte_order; + public: + explicit offset_vec (bfd_endian dwarf5_byte_order_) : dwarf5_byte_order (dwarf5_byte_order_) - {} + { + } /* Call std::vector::reserve for NELEM elements. */ virtual void reserve (size_t nelem) = 0; @@ -940,16 +947,15 @@ private: class offset_vec_tmpl : public offset_vec { public: + explicit offset_vec_tmpl (bfd_endian dwarf5_byte_order_) : offset_vec (dwarf5_byte_order_) - {} - - /* Implement offset_vec::reserve. */ - void reserve (size_t nelem) override { - m_vec.reserve (nelem); } + /* Implement offset_vec::reserve. */ + void reserve (size_t nelem) override { m_vec.reserve (nelem); } + /* Implement offset_vec::push_back_reorder. */ void push_back_reorder (size_t elem) override { @@ -967,12 +973,10 @@ private: } /* Implement offset_vec::file_write. */ - void file_write (FILE *file) const override - { - ::file_write (file, m_vec); - } + void file_write (FILE *file) const override { ::file_write (file, m_vec); } private: + std::vector<OffsetSize> m_vec; }; @@ -981,6 +985,7 @@ private: class dwarf { public: + offset_vec &name_table_string_offs, &name_table_entry_offs; dwarf (offset_vec &name_table_string_offs_, @@ -997,13 +1002,16 @@ private: class dwarf_tmpl : public dwarf { public: + explicit dwarf_tmpl (bfd_endian dwarf5_byte_order_) : dwarf (m_name_table_string_offs, m_name_table_entry_offs), m_name_table_string_offs (dwarf5_byte_order_), m_name_table_entry_offs (dwarf5_byte_order_) - {} + { + } private: + offset_vec_tmpl<OffsetSize> m_name_table_string_offs; offset_vec_tmpl<OffsetSize> m_name_table_entry_offs; }; @@ -1075,12 +1083,9 @@ assert_file_size (FILE *file, size_t expected_size) arguments. */ static void -write_gdbindex_1 (FILE *out_file, - const data_buf &cu_list, - const data_buf &types_cu_list, - const data_buf &addr_vec, - const data_buf &symtab_vec, - const data_buf &constant_pool) +write_gdbindex_1 (FILE *out_file, const data_buf &cu_list, + const data_buf &types_cu_list, const data_buf &addr_vec, + const data_buf &symtab_vec, const data_buf &constant_pool) { data_buf contents; const offset_type size_of_header = 6 * sizeof (offset_type); @@ -1124,8 +1129,7 @@ write_gdbindex_1 (FILE *out_file, /* Write the contents of the internal "cooked" index. */ static void -write_cooked_index (cooked_index *table, - const cu_index_map &cu_index_htab, +write_cooked_index (cooked_index *table, const cu_index_map &cu_index_htab, struct mapped_symtab *symtab) { const char *main_for_ada = main_name (); @@ -1155,8 +1159,8 @@ write_cooked_index (cooked_index *table, gdb, it has to use the encoded name, with any suffixes stripped. */ std::string encoded = ada_encode (name, false); - name = obstack_strdup (&symtab->m_string_obstack, - encoded.c_str ()); + name + = obstack_strdup (&symtab->m_string_obstack, encoded.c_str ()); } } else if (entry->per_cu->lang () == language_cplus @@ -1178,8 +1182,7 @@ write_cooked_index (cooked_index *table, gdb_index_symbol_kind kind; if (entry->tag == DW_TAG_subprogram) kind = GDB_INDEX_SYMBOL_KIND_FUNCTION; - else if (entry->tag == DW_TAG_variable - || entry->tag == DW_TAG_constant + else if (entry->tag == DW_TAG_variable || entry->tag == DW_TAG_constant || entry->tag == DW_TAG_enumerator) kind = GDB_INDEX_SYMBOL_KIND_VARIABLE; else if (entry->tag == DW_TAG_module @@ -1188,8 +1191,8 @@ write_cooked_index (cooked_index *table, else kind = GDB_INDEX_SYMBOL_KIND_TYPE; - add_index_entry (symtab, name, (entry->flags & IS_STATIC) != 0, - kind, it->second); + add_index_entry (symtab, name, (entry->flags & IS_STATIC) != 0, kind, + it->second); } } @@ -1224,8 +1227,7 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, cooked_index *table, int types_counter = 0; for (int i = 0; i < per_objfile->per_bfd->all_units.size (); ++i) { - dwarf2_per_cu_data *per_cu - = per_objfile->per_bfd->all_units[i].get (); + dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->all_units[i].get (); int &this_counter = per_cu->is_debug_types ? types_counter : counter; @@ -1235,9 +1237,9 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, cooked_index *table, /* The all_units list contains CUs read from the objfile as well as from the eventual dwz file. We need to place the entry in the corresponding index. */ - data_buf &cu_list = (per_cu->is_debug_types - ? types_cu_list - : per_cu->is_dwz ? dwz_cu_list : objfile_cu_list); + data_buf &cu_list = (per_cu->is_debug_types ? types_cu_list + : per_cu->is_dwz ? dwz_cu_list + : objfile_cu_list); cu_list.append_uint (8, BFD_ENDIAN_LITTLE, to_underlying (per_cu->sect_off)); if (per_cu->is_debug_types) @@ -1245,8 +1247,7 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, cooked_index *table, signatured_type *sig_type = (signatured_type *) per_cu; cu_list.append_uint (8, BFD_ENDIAN_LITTLE, to_underlying (sig_type->type_offset_in_tu)); - cu_list.append_uint (8, BFD_ENDIAN_LITTLE, - sig_type->signature); + cu_list.append_uint (8, BFD_ENDIAN_LITTLE, sig_type->signature); } else cu_list.append_uint (8, BFD_ENDIAN_LITTLE, per_cu->length ()); @@ -1271,8 +1272,8 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, cooked_index *table, write_hash_table (&symtab, symtab_vec, constant_pool); - write_gdbindex_1(out_file, objfile_cu_list, types_cu_list, addr_vec, - symtab_vec, constant_pool); + write_gdbindex_1 (out_file, objfile_cu_list, types_cu_list, addr_vec, + symtab_vec, constant_pool); if (dwz_out_file != NULL) write_gdbindex_1 (dwz_out_file, dwz_cu_list, {}, {}, {}, {}); @@ -1306,8 +1307,7 @@ write_debug_names (dwarf2_per_objfile *per_objfile, cooked_index *table, int types_counter = 0; for (int i = 0; i < per_objfile->per_bfd->all_units.size (); ++i) { - dwarf2_per_cu_data *per_cu - = per_objfile->per_bfd->all_units[i].get (); + dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->all_units[i].get (); int &this_counter = per_cu->is_debug_types ? types_counter : counter; data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list; @@ -1319,7 +1319,7 @@ write_debug_names (dwarf2_per_objfile *per_objfile, cooked_index *table, ++this_counter; } - /* Verify that all units are represented. */ + /* Verify that all units are represented. */ gdb_assert (counter == per_objfile->per_bfd->all_comp_units.size ()); gdb_assert (types_counter == per_objfile->per_bfd->all_type_units.size ()); @@ -1331,8 +1331,7 @@ write_debug_names (dwarf2_per_objfile *per_objfile, cooked_index *table, /* No addr_vec - DWARF-5 uses .debug_aranges generated by GCC. */ const offset_type bytes_of_header - = ((dwarf5_is_dwarf64 ? 12 : 4) - + 2 + 2 + 7 * 4 + = ((dwarf5_is_dwarf64 ? 12 : 4) + 2 + 2 + 7 * 4 + sizeof (dwarf5_gdb_augmentation)); size_t expected_bytes = 0; expected_bytes += bytes_of_header; @@ -1407,23 +1406,21 @@ write_debug_names (dwarf2_per_objfile *per_objfile, cooked_index *table, struct index_wip_file { - index_wip_file (const char *dir, const char *basename, - const char *suffix) + index_wip_file (const char *dir, const char *basename, const char *suffix) { - filename = (std::string (dir) + SLASH_STRING + basename - + suffix); + filename = (std::string (dir) + SLASH_STRING + basename + suffix); filename_temp = make_temp_filename (filename); - scoped_fd out_file_fd = gdb_mkostemp_cloexec (filename_temp.data (), - O_BINARY); + scoped_fd out_file_fd + = gdb_mkostemp_cloexec (filename_temp.data (), O_BINARY); if (out_file_fd.get () == -1) perror_with_name (("mkstemp")); out_file = out_file_fd.to_file ("wb"); if (out_file == nullptr) - error (_("Can't open `%s' for writing"), filename_temp.data ()); + error (_ ("Can't open `%s' for writing"), filename_temp.data ()); unlink_file.emplace (filename_temp.data ()); } @@ -1461,23 +1458,25 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile, const char *dir, struct objfile *objfile = per_objfile->objfile; if (per_objfile->per_bfd->index_table == nullptr) - error (_("No debugging symbols")); - cooked_index *table = per_objfile->per_bfd->index_table->index_for_writing (); + error (_ ("No debugging symbols")); + cooked_index *table + = per_objfile->per_bfd->index_table->index_for_writing (); if (per_objfile->per_bfd->types.size () > 1) - error (_("Cannot make an index when the file has multiple .debug_types sections")); - + error (_ ("Cannot make an index when the file has multiple .debug_types " + "sections")); gdb_assert ((objfile->flags & OBJF_NOT_FILENAME) == 0); - const char *index_suffix = (index_kind == dw_index_kind::DEBUG_NAMES - ? INDEX5_SUFFIX : INDEX4_SUFFIX); + const char *index_suffix + = (index_kind == dw_index_kind::DEBUG_NAMES ? INDEX5_SUFFIX + : INDEX4_SUFFIX); index_wip_file objfile_index_wip (dir, basename, index_suffix); gdb::optional<index_wip_file> dwz_index_wip; if (dwz_basename != NULL) - dwz_index_wip.emplace (dir, dwz_basename, index_suffix); + dwz_index_wip.emplace (dir, dwz_basename, index_suffix); if (index_kind == dw_index_kind::DEBUG_NAMES) { @@ -1491,7 +1490,8 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile, const char *dir, else write_gdbindex (per_objfile, table, objfile_index_wip.out_file.get (), (dwz_index_wip.has_value () - ? dwz_index_wip->out_file.get () : NULL)); + ? dwz_index_wip->out_file.get () + : NULL)); objfile_index_wip.finalize (); @@ -1523,7 +1523,7 @@ save_gdb_index_command (const char *arg, int from_tty) } if (!*arg) - error (_("usage: save gdb-index [-dwarf-5] DIRECTORY")); + error (_ ("usage: save gdb-index [-dwarf-5] DIRECTORY")); for (objfile *objfile : current_program_space->objfiles ()) { @@ -1550,20 +1550,20 @@ save_gdb_index_command (const char *arg, int from_tty) catch (const gdb_exception_error &except) { exception_fprintf (gdb_stderr, except, - _("Error while writing index for `%s': "), + _ ("Error while writing index for `%s': "), objfile_name (objfile)); } - } - + } } } void _initialize_dwarf_index_write (); + void _initialize_dwarf_index_write () { - cmd_list_element *c = add_cmd ("gdb-index", class_files, - save_gdb_index_command, _("\ + cmd_list_element *c + = add_cmd ("gdb-index", class_files, save_gdb_index_command, _ ("\ Save a gdb-index file.\n\ Usage: save gdb-index [-dwarf-5] DIRECTORY\n\ \n\ diff --git a/gdb/dwarf2/index-write.h b/gdb/dwarf2/index-write.h index be8052a..c81698b 100644 --- a/gdb/dwarf2/index-write.h +++ b/gdb/dwarf2/index-write.h @@ -32,8 +32,9 @@ derived from INDEX_KIND is added to this base name. DWZ_BASENAME is the same, but for the dwz file's index. */ -extern void write_dwarf_index - (dwarf2_per_objfile *per_objfile, const char *dir, const char *basename, - const char *dwz_basename, dw_index_kind index_kind); +extern void write_dwarf_index (dwarf2_per_objfile *per_objfile, + const char *dir, const char *basename, + const char *dwz_basename, + dw_index_kind index_kind); #endif /* DWARF_INDEX_WRITE_H */ diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c index 8dbfac2..9144cdd 100644 --- a/gdb/dwarf2/leb.c +++ b/gdb/dwarf2/leb.c @@ -29,7 +29,7 @@ ULONGEST read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf, - unsigned int *bytes_read_ptr) + unsigned int *bytes_read_ptr) { ULONGEST result; unsigned int num_read; @@ -127,7 +127,7 @@ read_offset (bfd *abfd, const gdb_byte *buf, unsigned int offset_size) retval = bfd_get_64 (abfd, buf); break; default: - internal_error (_("read_offset_1: bad switch [in module %s]"), + internal_error (_ ("read_offset_1: bad switch [in module %s]"), bfd_get_filename (abfd)); } diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index 9d74c8f..f81f918 100644 --- a/gdb/dwarf2/line-header.c +++ b/gdb/dwarf2/line-header.c @@ -36,20 +36,17 @@ line_header::add_include_dir (const char *include_dir) new_size = m_include_dirs.size (); else new_size = m_include_dirs.size () + 1; - gdb_printf (gdb_stdlog, "Adding dir %zu: %s\n", - new_size, include_dir); + gdb_printf (gdb_stdlog, "Adding dir %zu: %s\n", new_size, include_dir); } m_include_dirs.push_back (include_dir); } void -line_header::add_file_name (const char *name, - dir_index d_index, - unsigned int mod_time, - unsigned int length) +line_header::add_file_name (const char *name, dir_index d_index, + unsigned int mod_time, unsigned int length) { file_name_index index - = version >= 5 ? file_names_size (): file_names_size () + 1; + = version >= 5 ? file_names_size () : file_names_size () + 1; if (dwarf_line_debug >= 2) gdb_printf (gdb_stdlog, "Adding file %d: %s\n", index, name); @@ -83,7 +80,7 @@ line_header::file_file_name (const file_entry &fe) const static void dwarf2_statement_list_fits_in_line_number_section_complaint (void) { - complaint (_("statement list doesn't fit in .debug_line section")); + complaint (_ ("statement list doesn't fit in .debug_line section")); } /* Cover function for read_initial_length. @@ -107,7 +104,7 @@ read_checked_initial_length_and_offset (bfd *abfd, const gdb_byte *buf, || cu_header->initial_length_size == 12); if (cu_header->initial_length_size != *bytes_read) - complaint (_("intermixed 32-bit and 64-bit DWARF sections")); + complaint (_ ("intermixed 32-bit and 64-bit DWARF sections")); *offset_size = (*bytes_read == 4) ? 4 : 8; return length; @@ -123,8 +120,7 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, const gdb_byte **bufp, struct line_header *lh, unsigned int offset_size, void (*callback) (struct line_header *lh, - const char *name, - dir_index d_index, + const char *name, dir_index d_index, unsigned int mod_time, unsigned int length)) { @@ -154,10 +150,11 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, for (formati = 0; formati < format_count; formati++) { - ULONGEST content_type = read_unsigned_leb128 (abfd, format, &bytes_read); + ULONGEST content_type + = read_unsigned_leb128 (abfd, format, &bytes_read); format += bytes_read; - ULONGEST form = read_unsigned_leb128 (abfd, format, &bytes_read); + ULONGEST form = read_unsigned_leb128 (abfd, format, &bytes_read); format += bytes_read; gdb::optional<const char *> string; @@ -236,7 +233,7 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, case DW_LNCT_MD5: break; default: - complaint (_("Unknown format content type %s"), + complaint (_ ("Unknown format content type %s"), pulongest (content_type)); } } @@ -250,11 +247,11 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, /* See line-header.h. */ line_header_up -dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, - dwarf2_per_objfile *per_objfile, - struct dwarf2_section_info *section, - const struct comp_unit_head *cu_header, - const char *comp_dir) +dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, + dwarf2_per_objfile *per_objfile, + struct dwarf2_section_info *section, + const struct comp_unit_head *cu_header, + const char *comp_dir) { const gdb_byte *line_ptr; unsigned int bytes_read, offset_size; @@ -298,7 +295,7 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, { /* This is a version we don't understand. The format could have changed in ways we don't handle properly so just punt. */ - complaint (_("unsupported version in .debug_line section")); + complaint (_ ("unsupported version in .debug_line section")); return NULL; } if (lh->version >= 5) @@ -313,8 +310,8 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, line_ptr += 1; if (segment_selector_size != 0) { - complaint (_("unsupported segment selector size %u " - "in .debug_line section"), + complaint (_ ("unsupported segment selector size %u " + "in .debug_line section"), segment_selector_size); return NULL; } @@ -337,8 +334,8 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, if (lh->maximum_ops_per_instruction == 0) { lh->maximum_ops_per_instruction = 1; - complaint (_("invalid maximum_ops_per_instruction " - "in `.debug_line' section")); + complaint (_ ("invalid maximum_ops_per_instruction " + "in `.debug_line' section")); } lh->default_is_stmt = read_1_byte (abfd, line_ptr); @@ -351,7 +348,7 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, line_ptr += 1; lh->standard_opcode_lengths.reset (new unsigned char[lh->opcode_base]); - lh->standard_opcode_lengths[0] = 1; /* This should never be used anyway. */ + lh->standard_opcode_lengths[0] = 1; /* This should never be used anyway. */ for (i = 1; i < lh->opcode_base; ++i) { lh->standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr); @@ -365,25 +362,24 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, offset_size, [] (struct line_header *header, const char *name, dir_index d_index, unsigned int mod_time, - unsigned int length) - { - header->add_include_dir (name); - }); + unsigned int length) { + header->add_include_dir (name); + }); /* Read file name table. */ read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (), offset_size, [] (struct line_header *header, const char *name, dir_index d_index, unsigned int mod_time, - unsigned int length) - { - header->add_file_name (name, d_index, mod_time, length); - }); + unsigned int length) { + header->add_file_name (name, d_index, mod_time, length); + }); } else { /* Read directory table. */ - while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL) + while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) + != NULL) { line_ptr += bytes_read; lh->add_include_dir (cur_dir); @@ -391,13 +387,15 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, line_ptr += bytes_read; /* Read file name table. */ - while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL) + while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) + != NULL) { unsigned int mod_time, length; dir_index d_index; line_ptr += bytes_read; - d_index = (dir_index) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + d_index + = (dir_index) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); line_ptr += bytes_read; mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); line_ptr += bytes_read; @@ -410,8 +408,8 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz, } if (line_ptr > (section->buffer + section->size)) - complaint (_("line number info header doesn't " - "fit in `.debug_line' section")); + complaint (_ ("line number info header doesn't " + "fit in `.debug_line' section")); return lh; } diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h index 59a42e3..7472e9d 100644 --- a/gdb/dwarf2/line-header.h +++ b/gdb/dwarf2/line-header.h @@ -41,7 +41,8 @@ struct file_entry d_index (d_index_), mod_time (mod_time_), length (length_) - {} + { + } /* Return the include directory at D_INDEX stored in LH. Returns NULL if D_INDEX is out of bounds. */ @@ -74,15 +75,18 @@ struct line_header unit in the context of which we are reading this line header, or nullptr if unknown or not applicable. */ explicit line_header (const char *comp_dir) - : offset_in_dwz {}, m_comp_dir (comp_dir) - {} + : offset_in_dwz {}, + m_comp_dir (comp_dir) + { + } /* This constructor should only be used to create line_header intances to do hash table lookups. */ line_header (sect_offset sect_off, bool offset_in_dwz) : sect_off (sect_off), offset_in_dwz (offset_in_dwz) - {} + { + } /* Add an entry to the include directory table. */ void add_include_dir (const char *include_dir); @@ -136,11 +140,10 @@ struct line_header /* The indexes are 0-based in DWARF 5 and 1-based in DWARF 4. Therefore, this method should only be used to iterate through all file entries in an index-agnostic manner. */ - std::vector<file_entry> &file_names () - { return m_file_names; } + std::vector<file_entry> &file_names () { return m_file_names; } + /* A const overload of the same. */ - const std::vector<file_entry> &file_names () const - { return m_file_names; } + const std::vector<file_entry> &file_names () const { return m_file_names; } /* Offset of line number information in .debug_line section. */ sect_offset sect_off {}; @@ -162,8 +165,7 @@ struct line_header element is standard_opcode_lengths[opcode_base - 1]. */ std::unique_ptr<unsigned char[]> standard_opcode_lengths; - int file_names_size () const - { return m_file_names.size(); } + int file_names_size () const { return m_file_names.size (); } /* The start and end of the statement program following this header. These point into dwarf2_per_objfile->line_buffer. */ @@ -177,10 +179,10 @@ struct line_header /* Return the compilation directory of the compilation unit in the context of which this line header is read. Return nullptr if non applicable. */ - const char *comp_dir () const - { return m_comp_dir; } + const char *comp_dir () const { return m_comp_dir; } + +private: - private: /* The include_directories table. Note these are observing pointers. The memory is owned by debug_line_buffer. */ std::vector<const char *> m_include_dirs; @@ -212,9 +214,9 @@ file_entry::include_dir (const line_header *lh) const the returned object point into the dwarf line section buffer, and must not be freed. */ -extern line_header_up dwarf_decode_line_header - (sect_offset sect_off, bool is_dwz, dwarf2_per_objfile *per_objfile, - struct dwarf2_section_info *section, const struct comp_unit_head *cu_header, - const char *comp_dir); +extern line_header_up dwarf_decode_line_header ( + sect_offset sect_off, bool is_dwz, dwarf2_per_objfile *per_objfile, + struct dwarf2_section_info *section, const struct comp_unit_head *cu_header, + const char *comp_dir); #endif /* DWARF2_LINE_HEADER_H */ diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 236ad82..da0ede5 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -47,10 +47,10 @@ #include "gdbsupport/underlying.h" #include "gdbsupport/byte-vector.h" -static struct value *dwarf2_evaluate_loc_desc_full - (struct type *type, frame_info_ptr frame, const gdb_byte *data, - size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, - struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true); +static struct value *dwarf2_evaluate_loc_desc_full ( + struct type *type, frame_info_ptr frame, const gdb_byte *data, size_t size, + dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, + struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true); /* Until these have formal names, we define these here. ref: http://gcc.gnu.org/wiki/DebugFission @@ -95,8 +95,8 @@ enum debug_loc_kind void invalid_synthetic_pointer (void) { - error (_("access outside bounds of object " - "referenced via synthetic pointer")); + error (_ ("access outside bounds of object " + "referenced via synthetic pointer")); } /* Decode the addresses in a non-dwo .debug_loc entry. @@ -106,13 +106,11 @@ invalid_synthetic_pointer (void) static enum debug_loc_kind decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end, - const gdb_byte **new_ptr, - CORE_ADDR *low, CORE_ADDR *high, - enum bfd_endian byte_order, - unsigned int addr_size, - int signed_addr_p) + const gdb_byte **new_ptr, CORE_ADDR *low, + CORE_ADDR *high, enum bfd_endian byte_order, + unsigned int addr_size, int signed_addr_p) { - CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); + CORE_ADDR base_mask = ~(~(CORE_ADDR) 1 << (addr_size * 8 - 1)); if (buf_end - loc_ptr < 2 * addr_size) return DEBUG_LOC_BUFFER_OVERFLOW; @@ -154,11 +152,9 @@ decode_debug_loclists_addresses (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, const gdb_byte *loc_ptr, const gdb_byte *buf_end, - const gdb_byte **new_ptr, - CORE_ADDR *low, CORE_ADDR *high, - enum bfd_endian byte_order, - unsigned int addr_size, - int signed_addr_p) + const gdb_byte **new_ptr, CORE_ADDR *low, + CORE_ADDR *high, enum bfd_endian byte_order, + unsigned int addr_size, int signed_addr_p) { uint64_t u64; @@ -171,7 +167,7 @@ decode_debug_loclists_addresses (dwarf2_per_cu_data *per_cu, *low = 0; loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); if (loc_ptr == NULL) - return DEBUG_LOC_BUFFER_OVERFLOW; + return DEBUG_LOC_BUFFER_OVERFLOW; *high = dwarf2_read_addr_index (per_cu, per_objfile, u64); *new_ptr = loc_ptr; @@ -180,13 +176,13 @@ decode_debug_loclists_addresses (dwarf2_per_cu_data *per_cu, case DW_LLE_startx_length: loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); if (loc_ptr == NULL) - return DEBUG_LOC_BUFFER_OVERFLOW; + return DEBUG_LOC_BUFFER_OVERFLOW; *low = dwarf2_read_addr_index (per_cu, per_objfile, u64); *high = *low; loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); if (loc_ptr == NULL) - return DEBUG_LOC_BUFFER_OVERFLOW; + return DEBUG_LOC_BUFFER_OVERFLOW; *high += u64; *new_ptr = loc_ptr; @@ -194,19 +190,19 @@ decode_debug_loclists_addresses (dwarf2_per_cu_data *per_cu, case DW_LLE_start_length: if (buf_end - loc_ptr < addr_size) - return DEBUG_LOC_BUFFER_OVERFLOW; + return DEBUG_LOC_BUFFER_OVERFLOW; if (signed_addr_p) - *low = extract_signed_integer (loc_ptr, addr_size, byte_order); + *low = extract_signed_integer (loc_ptr, addr_size, byte_order); else - *low = extract_unsigned_integer (loc_ptr, addr_size, byte_order); + *low = extract_unsigned_integer (loc_ptr, addr_size, byte_order); loc_ptr += addr_size; *high = *low; loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); if (loc_ptr == NULL) - return DEBUG_LOC_BUFFER_OVERFLOW; + return DEBUG_LOC_BUFFER_OVERFLOW; *high += u64; *new_ptr = loc_ptr; @@ -280,9 +276,8 @@ decode_debug_loc_dwo_addresses (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, const gdb_byte *loc_ptr, const gdb_byte *buf_end, - const gdb_byte **new_ptr, - CORE_ADDR *low, CORE_ADDR *high, - enum bfd_endian byte_order) + const gdb_byte **new_ptr, CORE_ADDR *low, + CORE_ADDR *high, enum bfd_endian byte_order) { uint64_t low_index, high_index; @@ -372,21 +367,20 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, const gdb_byte *new_ptr = NULL; /* init for gcc -Wall */ if (baton->per_cu->version () < 5 && baton->from_dwo) - kind = decode_debug_loc_dwo_addresses (baton->per_cu, - baton->per_objfile, - loc_ptr, buf_end, &new_ptr, - &low, &high, byte_order); + kind + = decode_debug_loc_dwo_addresses (baton->per_cu, baton->per_objfile, + loc_ptr, buf_end, &new_ptr, &low, + &high, byte_order); else if (baton->per_cu->version () < 5) - kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, - &low, &high, - byte_order, addr_size, + kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, &low, + &high, byte_order, addr_size, signed_addr_p); else - kind = decode_debug_loclists_addresses (baton->per_cu, - baton->per_objfile, - loc_ptr, buf_end, &new_ptr, - &low, &high, byte_order, - addr_size, signed_addr_p); + kind + = decode_debug_loclists_addresses (baton->per_cu, baton->per_objfile, + loc_ptr, buf_end, &new_ptr, &low, + &high, byte_order, addr_size, + signed_addr_p); loc_ptr = new_ptr; switch (kind) @@ -406,8 +400,8 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, case DEBUG_LOC_BUFFER_OVERFLOW: case DEBUG_LOC_INVALID_ENTRY: - error (_("dwarf2_find_location_expression: " - "Corrupted DWARF expression.")); + error (_ ("dwarf2_find_location_expression: " + "Corrupted DWARF expression.")); default: gdb_assert_not_reached ("bad debug_loc_kind"); @@ -506,8 +500,9 @@ locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) type = builtin_type (gdbarch)->builtin_data_ptr; dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (framefunc); - SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location - (framefunc, get_frame_pc (frame), &start, &length); + SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location (framefunc, + get_frame_pc (frame), + &start, &length); result = dwarf2_evaluate_loc_desc (type, frame, start, length, dlbaton->per_cu, dlbaton->per_objfile); @@ -522,11 +517,8 @@ locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior function uses DWARF expression for its DW_AT_frame_base. */ -const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs = -{ - locexpr_find_frame_base_location, - locexpr_get_frame_base -}; +const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs + = { locexpr_find_frame_base_location, locexpr_get_frame_base }; /* Implement find_frame_base_location method for LOC_BLOCK functions using DWARF location list for its DW_AT_frame_base. */ @@ -563,8 +555,9 @@ loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) type = builtin_type (gdbarch)->builtin_data_ptr; dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (framefunc); - SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location - (framefunc, get_frame_pc (frame), &start, &length); + SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location (framefunc, + get_frame_pc (frame), + &start, &length); result = dwarf2_evaluate_loc_desc (type, frame, start, length, dlbaton->per_cu, dlbaton->per_objfile); @@ -579,11 +572,8 @@ loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior function uses DWARF location list for its DW_AT_frame_base. */ -const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs = -{ - loclist_find_frame_base_location, - loclist_get_frame_base -}; +const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs + = { loclist_find_frame_base_location, loclist_get_frame_base }; /* See dwarf2/loc.h. */ @@ -601,7 +591,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc, *length = 0; if (*length == 0) - error (_("Could not find the frame base for \"%s\"."), + error (_ ("Could not find the frame base for \"%s\"."), framefunc->natural_name ()); } @@ -610,8 +600,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc, value * compute_var_value (const char *name) { - struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, - nullptr); + struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, nullptr); if (sym.symbol != nullptr) return value_of_variable (sym.symbol, sym.block); return nullptr; @@ -627,19 +616,17 @@ static void show_entry_values_debug (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, - _("Entry values and tail call frames debugging is %s.\n"), + gdb_printf (file, _ ("Entry values and tail call frames debugging is %s.\n"), value); } /* See gdbtypes.h. */ void -call_site_target::iterate_over_addresses - (struct gdbarch *call_site_gdbarch, - const struct call_site *call_site, - frame_info_ptr caller_frame, - iterate_ftype callback) const +call_site_target::iterate_over_addresses (struct gdbarch *call_site_gdbarch, + const struct call_site *call_site, + frame_info_ptr caller_frame, + iterate_ftype callback) const { switch (m_loc_kind) { @@ -654,28 +641,26 @@ call_site_target::iterate_over_addresses if (dwarf_block == NULL) { struct bound_minimal_symbol msym; - + msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_AT_call_target is not specified at %s in %s"), + _ ("DW_AT_call_target is not specified at %s in %s"), paddress (call_site_gdbarch, call_site->pc ()), (msym.minsym == NULL ? "???" - : msym.minsym->print_name ())); - + : msym.minsym->print_name ())); } if (caller_frame == NULL) { struct bound_minimal_symbol msym; - + msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_AT_call_target DWARF block resolving " - "requires known frame which is currently not " - "available at %s in %s"), + _ ("DW_AT_call_target DWARF block resolving " + "requires known frame which is currently not " + "available at %s in %s"), paddress (call_site_gdbarch, call_site->pc ()), (msym.minsym == NULL ? "???" - : msym.minsym->print_name ())); - + : msym.minsym->print_name ())); } caller_arch = get_frame_arch (caller_frame); caller_core_addr_type = builtin_type (caller_arch)->builtin_func_ptr; @@ -703,13 +688,12 @@ call_site_target::iterate_over_addresses if (msym.minsym == NULL) { msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); - throw_error (NO_ENTRY_VALUE_ERROR, - _("Cannot find function \"%s\" for a call site target " - "at %s in %s"), - physname, paddress (call_site_gdbarch, call_site->pc ()), - (msym.minsym == NULL ? "???" - : msym.minsym->print_name ())); - + throw_error ( + NO_ENTRY_VALUE_ERROR, + _ ("Cannot find function \"%s\" for a call site target " + "at %s in %s"), + physname, paddress (call_site_gdbarch, call_site->pc ()), + (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); } callback (msym.value_address ()); } @@ -735,7 +719,7 @@ call_site_target::iterate_over_addresses break; default: - internal_error (_("invalid call site target kind")); + internal_error (_ ("invalid call site target kind")); } } @@ -751,8 +735,8 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr) if (sym == NULL || sym->value_block ()->entry_pc () != addr) throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_TAG_call_site resolving failed to find function " - "name for address %s"), + _ ("DW_TAG_call_site resolving failed to find function " + "name for address %s"), paddress (gdbarch, addr)); type = sym->type (); @@ -794,31 +778,30 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr) func_sym = func_addr_to_tail_call_list (gdbarch, addr); - for (call_site = TYPE_TAIL_CALL_LIST (func_sym->type ()); - call_site; call_site = call_site->tail_call_next) + for (call_site = TYPE_TAIL_CALL_LIST (func_sym->type ()); call_site; + call_site = call_site->tail_call_next) { /* CALLER_FRAME with registers is not available for tail-call jumped frames. */ call_site->iterate_over_addresses (gdbarch, nullptr, - [&] (CORE_ADDR target_addr) - { - if (target_addr == verify_addr) - { - struct bound_minimal_symbol msym; - - msym = lookup_minimal_symbol_by_pc (verify_addr); - throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_OP_entry_value resolving has found " - "function \"%s\" at %s can call itself via tail " - "calls"), - (msym.minsym == NULL ? "???" - : msym.minsym->print_name ()), - paddress (gdbarch, verify_addr)); - } - - if (addr_hash.insert (target_addr).second) - todo.push_back (target_addr); - }); + [&] (CORE_ADDR target_addr) { + if (target_addr == verify_addr) + { + struct bound_minimal_symbol msym; + + msym = lookup_minimal_symbol_by_pc (verify_addr); + throw_error ( + NO_ENTRY_VALUE_ERROR, + _ ("DW_OP_entry_value resolving has found " + "function \"%s\" at %s can call itself via tail " + "calls"), + (msym.minsym == NULL ? "???" : msym.minsym->print_name ()), + paddress (gdbarch, verify_addr)); + } + + if (addr_hash.insert (target_addr).second) + todo.push_back (target_addr); + }); } } } @@ -833,9 +816,7 @@ tailcall_dump (struct gdbarch *gdbarch, const struct call_site *call_site) struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (addr - 1); gdb_printf (gdb_stdlog, " %s(%s)", paddress (gdbarch, addr), - (msym.minsym == NULL ? "???" - : msym.minsym->print_name ())); - + (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); } /* Intersect RESULTP with CHAIN to keep RESULTP unambiguous, keep in RESULTP @@ -857,10 +838,8 @@ chain_candidate (struct gdbarch *gdbarch, { /* Create the initial chain containing all the passed PCs. */ - struct call_site_chain *result - = ((struct call_site_chain *) - xmalloc (sizeof (*result) - + sizeof (*result->call_site) * (length - 1))); + struct call_site_chain *result = ((struct call_site_chain *) xmalloc ( + sizeof (*result) + sizeof (*result->call_site) * (length - 1))); result->length = length; result->callers = result->callees = length; if (!chain.empty ()) @@ -947,24 +926,21 @@ chain_candidate (struct gdbarch *gdbarch, true. */ static bool -call_site_find_chain_2 - (struct gdbarch *gdbarch, - gdb::unique_xmalloc_ptr<struct call_site_chain> *resultp, - std::vector<struct call_site *> &chain, - std::unordered_set<CORE_ADDR> &addr_hash, - struct call_site *call_site, - CORE_ADDR callee_pc) +call_site_find_chain_2 ( + struct gdbarch *gdbarch, + gdb::unique_xmalloc_ptr<struct call_site_chain> *resultp, + std::vector<struct call_site *> &chain, + std::unordered_set<CORE_ADDR> &addr_hash, struct call_site *call_site, + CORE_ADDR callee_pc) { std::vector<CORE_ADDR> addresses; bool found_exact = false; - call_site->iterate_over_addresses (gdbarch, nullptr, - [&] (CORE_ADDR addr) - { - if (addr == callee_pc) - found_exact = true; - else - addresses.push_back (addr); - }); + call_site->iterate_over_addresses (gdbarch, nullptr, [&] (CORE_ADDR addr) { + if (addr == callee_pc) + found_exact = true; + else + addresses.push_back (addr); + }); if (found_exact) { @@ -979,7 +955,7 @@ call_site_find_chain_2 struct symbol *target_func = func_addr_to_tail_call_list (gdbarch, target_func_addr); for (struct call_site *target_call_site - = TYPE_TAIL_CALL_LIST (target_func->type ()); + = TYPE_TAIL_CALL_LIST (target_func->type ()); target_call_site != nullptr; target_call_site = target_call_site->tail_call_next) { @@ -988,9 +964,8 @@ call_site_find_chain_2 /* Successfully entered TARGET_CALL_SITE. */ chain.push_back (target_call_site); - if (!call_site_find_chain_2 (gdbarch, resultp, chain, - addr_hash, target_call_site, - callee_pc)) + if (!call_site_find_chain_2 (gdbarch, resultp, chain, addr_hash, + target_call_site, callee_pc)) return false; size_t removed = addr_hash.erase (target_call_site->pc ()); @@ -1030,7 +1005,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, /* We are not interested in the specific PC inside the callee function. */ callee_pc = get_pc_function_start (callee_pc); if (callee_pc == 0) - throw_error (NO_ENTRY_VALUE_ERROR, _("Unable to find function for PC %s"), + throw_error (NO_ENTRY_VALUE_ERROR, _ ("Unable to find function for PC %s"), paddress (gdbarch, save_callee_pc)); /* Mark CALL_SITEs so we do not visit the same ones twice. */ @@ -1049,19 +1024,20 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, if (retval == NULL) { struct bound_minimal_symbol msym_caller, msym_callee; - + msym_caller = lookup_minimal_symbol_by_pc (caller_pc); msym_callee = lookup_minimal_symbol_by_pc (callee_pc); - throw_error (NO_ENTRY_VALUE_ERROR, - _("There are no unambiguously determinable intermediate " - "callers or callees between caller function \"%s\" at %s " - "and callee function \"%s\" at %s"), - (msym_caller.minsym == NULL - ? "???" : msym_caller.minsym->print_name ()), - paddress (gdbarch, caller_pc), - (msym_callee.minsym == NULL - ? "???" : msym_callee.minsym->print_name ()), - paddress (gdbarch, callee_pc)); + throw_error ( + NO_ENTRY_VALUE_ERROR, + _ ("There are no unambiguously determinable intermediate " + "callers or callees between caller function \"%s\" at %s " + "and callee function \"%s\" at %s"), + (msym_caller.minsym == NULL ? "???" + : msym_caller.minsym->print_name ()), + paddress (gdbarch, caller_pc), + (msym_callee.minsym == NULL ? "???" + : msym_callee.minsym->print_name ()), + paddress (gdbarch, callee_pc)); } return retval; @@ -1153,12 +1129,11 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, struct gdbarch *caller_gdbarch = frame_unwind_arch (frame); throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_OP_entry_value resolving callee gdbarch %s " - "(of %s (%s)) does not match caller gdbarch %s"), + _ ("DW_OP_entry_value resolving callee gdbarch %s " + "(of %s (%s)) does not match caller gdbarch %s"), gdbarch_bfd_arch_info (gdbarch)->printable_name, paddress (gdbarch, func_addr), - (msym.minsym == NULL ? "???" - : msym.minsym->print_name ()), + (msym.minsym == NULL ? "???" : msym.minsym->print_name ()), gdbarch_bfd_arch_info (caller_gdbarch)->printable_name); } @@ -1167,11 +1142,11 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (func_addr); - throw_error (NO_ENTRY_VALUE_ERROR, _("DW_OP_entry_value resolving " - "requires caller of %s (%s)"), + throw_error (NO_ENTRY_VALUE_ERROR, + _ ("DW_OP_entry_value resolving " + "requires caller of %s (%s)"), paddress (gdbarch, func_addr), - (msym.minsym == NULL ? "???" - : msym.minsym->print_name ())); + (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); } caller_pc = get_frame_pc (caller_frame); call_site = call_site_for_pc (gdbarch, caller_pc); @@ -1179,31 +1154,29 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, bool found = false; unsigned count = 0; call_site->iterate_over_addresses (gdbarch, caller_frame, - [&] (CORE_ADDR addr) - { - /* Preserve any address. */ - target_addr = addr; - ++count; - if (addr == func_addr) - found = true; - }); + [&] (CORE_ADDR addr) { + /* Preserve any address. */ + target_addr = addr; + ++count; + if (addr == func_addr) + found = true; + }); if (!found) { struct minimal_symbol *target_msym, *func_msym; target_msym = lookup_minimal_symbol_by_pc (target_addr).minsym; func_msym = lookup_minimal_symbol_by_pc (func_addr).minsym; - throw_error (NO_ENTRY_VALUE_ERROR, - _("DW_OP_entry_value resolving expects callee %s at %s %s" - "but the called frame is for %s at %s"), - (target_msym == NULL ? "???" - : target_msym->print_name ()), - paddress (gdbarch, target_addr), - (count > 0 - ? _("(but note there are multiple addresses not listed)") - : ""), - func_msym == NULL ? "???" : func_msym->print_name (), - paddress (gdbarch, func_addr)); + throw_error ( + NO_ENTRY_VALUE_ERROR, + _ ("DW_OP_entry_value resolving expects callee %s at %s %s" + "but the called frame is for %s at %s"), + (target_msym == NULL ? "???" : target_msym->print_name ()), + paddress (gdbarch, target_addr), + (count > 0 ? _ ("(but note there are multiple addresses not listed)") + : ""), + func_msym == NULL ? "???" : func_msym->print_name (), + paddress (gdbarch, func_addr)); } /* No entry value based parameters would be reliable if this function can @@ -1223,10 +1196,11 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, /* DW_TAG_call_site_parameter will be missing just if GCC could not determine its value. */ - throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find matching parameter " - "at DW_TAG_call_site %s at %s"), + throw_error (NO_ENTRY_VALUE_ERROR, + _ ("Cannot find matching parameter " + "at DW_TAG_call_site %s at %s"), paddress (gdbarch, caller_pc), - msym == NULL ? "???" : msym->print_name ()); + msym == NULL ? "???" : msym->print_name ()); } *per_cu_return = call_site->per_cu; @@ -1260,7 +1234,7 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, /* DEREF_SIZE size is not verified here. */ if (data_src == NULL) throw_error (NO_ENTRY_VALUE_ERROR, - _("Cannot resolve DW_AT_call_data_value")); + _ ("Cannot resolve DW_AT_call_data_value")); return dwarf2_evaluate_loc_desc (type, caller_frame, data_src, size, per_cu, per_objfile, false); @@ -1309,17 +1283,15 @@ entry_data_value_free_closure (struct value *v) is stored in the caller. On the first dereference use DW_AT_call_data_value in the caller. */ -static const struct lval_funcs entry_data_value_funcs = -{ - NULL, /* read */ - NULL, /* write */ - nullptr, - NULL, /* indirect */ - entry_data_value_coerce_ref, - NULL, /* check_synthetic_pointer */ - entry_data_value_copy_closure, - entry_data_value_free_closure -}; +static const struct lval_funcs entry_data_value_funcs + = { NULL, /* read */ + NULL, /* write */ + nullptr, + NULL, /* indirect */ + entry_data_value_coerce_ref, + NULL, /* check_synthetic_pointer */ + entry_data_value_copy_closure, + entry_data_value_free_closure }; /* See dwarf2/loc.h. */ struct value * @@ -1335,14 +1307,14 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, dwarf2_per_cu_data *caller_per_cu; dwarf2_per_objfile *caller_per_objfile; - parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu, - &caller_per_objfile); + parameter + = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, &caller_per_cu, + &caller_per_objfile); - outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, - type, caller_frame, - caller_per_cu, - caller_per_objfile); + outer_val + = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, type, + caller_frame, caller_per_cu, + caller_per_objfile); /* Check if DW_AT_call_data_value cannot be used. If it should be used and it is not available do not fall back to OUTER_VAL - dereferencing @@ -1353,19 +1325,17 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, || checked_type->target_type () == NULL) return outer_val; - target_val = dwarf_entry_parameter_to_value (parameter, - target_type->length (), - target_type, caller_frame, - caller_per_cu, - caller_per_objfile); + target_val + = dwarf_entry_parameter_to_value (parameter, target_type->length (), + target_type, caller_frame, caller_per_cu, + caller_per_objfile); val = allocate_computed_value (type, &entry_data_value_funcs, release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ memcpy (value_contents_raw (val).data (), - value_contents_raw (outer_val).data (), - checked_type->length ()); + value_contents_raw (outer_val).data (), checked_type->length ()); set_value_lazy (val, 0); return val; @@ -1386,19 +1356,19 @@ value_of_dwarf_block_entry (struct type *type, frame_info_ptr frame, kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len); if (kind_u.dwarf_reg != -1) - return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_DWARF_REG, - kind_u); + return value_of_dwarf_reg_entry (type, frame, + CALL_SITE_PARAMETER_DWARF_REG, kind_u); if (dwarf_block_to_fb_offset (block, block + block_len, &kind_u.fb_offset)) - return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_FB_OFFSET, - kind_u); + return value_of_dwarf_reg_entry (type, frame, + CALL_SITE_PARAMETER_FB_OFFSET, kind_u); /* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message suppressed during normal operation. The expression can be arbitrary if there is no caller-callee entry value binding expected. */ throw_error (NO_ENTRY_VALUE_ERROR, - _("DWARF-2 expression error: DW_OP_entry_value is supported " - "only for single DW_OP_reg* or for DW_OP_fbreg(*)")); + _ ("DWARF-2 expression error: DW_OP_entry_value is supported " + "only for single DW_OP_reg* or for DW_OP_fbreg(*)")); } /* Fetch a DW_AT_const_value through a synthetic pointer. */ @@ -1414,8 +1384,8 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset, LONGEST len; auto_obstack temp_obstack; - bytes = dwarf2_fetch_constant_bytes (die, per_cu, per_objfile, - &temp_obstack, &len); + bytes = dwarf2_fetch_constant_bytes (die, per_cu, per_objfile, &temp_obstack, + &len); if (bytes != NULL) { @@ -1444,18 +1414,16 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, bool resolve_abstract_p) { /* Fetch the location expression of the DIE we're pointing to. */ - auto get_frame_address_in_block_wrapper = [frame] () - { - return get_frame_address_in_block (frame); - }; + auto get_frame_address_in_block_wrapper + = [frame] () { return get_frame_address_in_block (frame); }; struct dwarf2_locexpr_baton baton = dwarf2_fetch_die_loc_sect_off (die, per_cu, per_objfile, get_frame_address_in_block_wrapper, resolve_abstract_p); /* Get type of pointed-to DIE. */ - struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu, - per_objfile); + struct type *orig_type + = dwarf2_fetch_die_type_sect_off (die, per_cu, per_objfile); if (orig_type == NULL) invalid_synthetic_pointer (); @@ -1466,8 +1434,7 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, return dwarf2_evaluate_loc_desc_full (orig_type, frame, baton.data, baton.size, baton.per_cu, baton.per_objfile, - type->target_type (), - byte_offset); + type->target_type (), byte_offset); else return fetch_const_value_from_synthetic_pointer (die, byte_offset, per_cu, per_objfile, type); @@ -1485,8 +1452,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, struct type *subobj_type, - LONGEST subobj_byte_offset, - bool as_lval) + LONGEST subobj_byte_offset, bool as_lval) { if (subobj_type == NULL) { @@ -1506,8 +1472,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, try { - retval = ctx.evaluate (data, size, as_lval, per_cu, frame, nullptr, - type, subobj_type, subobj_byte_offset); + retval = ctx.evaluate (data, size, as_lval, per_cu, frame, nullptr, type, + subobj_type, subobj_byte_offset); } catch (const gdb_exception_error &ex) { @@ -1515,8 +1481,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, { free_values.free_to_mark (); retval = allocate_value (subobj_type); - mark_value_bytes_unavailable (retval, 0, - subobj_type->length ()); + mark_value_bytes_unavailable (retval, 0, subobj_type->length ()); return retval; } else if (ex.error == NO_ENTRY_VALUE_ERROR) @@ -1590,8 +1555,8 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, try { - result = ctx.evaluate (dlbaton->data, dlbaton->size, - true, per_cu, frame, addr_stack); + result = ctx.evaluate (dlbaton->data, dlbaton->size, true, per_cu, frame, + addr_stack); } catch (const gdb_exception_error &ex) { @@ -1674,11 +1639,10 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, is signed, we have to sign-extend the value because CORE_ADDR on 64bit machine has 8 bytes but address size of an 32bit application is bytes. */ - const int addr_size - = (baton->locexpr.per_cu->addr_size () - * TARGET_CHAR_BIT); + const int addr_size = (baton->locexpr.per_cu->addr_size () + * TARGET_CHAR_BIT); const CORE_ADDR neg_mask - = (~((CORE_ADDR) 0) << (addr_size - 1)); + = (~((CORE_ADDR) 0) << (addr_size - 1)); /* Check if signed bit is set and sign-extend values. */ if (*value & neg_mask) @@ -1737,11 +1701,11 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, break; } if (pinfo == NULL) - error (_("cannot find reference address for offset property")); + error (_ ("cannot find reference address for offset property")); if (pinfo->valaddr.data () != NULL) - val = value_from_contents - (baton->offset_info.type, - pinfo->valaddr.data () + baton->offset_info.offset); + val = value_from_contents (baton->offset_info.type, + pinfo->valaddr.data () + + baton->offset_info.offset); else val = value_at (baton->offset_info.type, pinfo->addr + baton->offset_info.offset); @@ -1767,12 +1731,10 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, /* See dwarf2/loc.h. */ void -dwarf2_compile_property_to_c (string_file *stream, - const char *result_name, +dwarf2_compile_property_to_c (string_file *stream, const char *result_name, struct gdbarch *gdbarch, std::vector<bool> ®isters_used, - const struct dynamic_prop *prop, - CORE_ADDR pc, + const struct dynamic_prop *prop, CORE_ADDR pc, struct symbol *sym) { struct dwarf2_property_baton *baton @@ -1798,10 +1760,9 @@ dwarf2_compile_property_to_c (string_file *stream, per_objfile = baton->loclist.per_objfile; } - compile_dwarf_bounds_to_c (stream, result_name, prop, sym, pc, - gdbarch, registers_used, - per_cu->addr_size (), - data, data + size, per_cu, per_objfile); + compile_dwarf_bounds_to_c (stream, result_name, prop, sym, pc, gdbarch, + registers_used, per_cu->addr_size (), data, + data + size, per_cu, per_objfile); } /* Compute the correct symbol_needs_kind value for the location @@ -1814,10 +1775,8 @@ static enum symbol_needs_kind dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, - bfd_endian byte_order, - int addr_size, - int ref_addr_size, - int depth = 0) + bfd_endian byte_order, int addr_size, + int ref_addr_size, int depth = 0) { enum symbol_needs_kind symbol_needs = SYMBOL_NEEDS_NONE; @@ -1837,23 +1796,22 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, /* Insert OP in OPS_TO_VISIT if it is within the expression's range and hasn't been visited yet. */ auto insert_in_ops_to_visit - = [expr_end, &visited_ops, &ops_to_visit] (const gdb_byte *op_ptr) - { - if (op_ptr >= expr_end) - return; + = [expr_end, &visited_ops, &ops_to_visit] (const gdb_byte *op_ptr) { + if (op_ptr >= expr_end) + return; - if (visited_ops.find (op_ptr) != visited_ops.end ()) - return; + if (visited_ops.find (op_ptr) != visited_ops.end ()) + return; - ops_to_visit.push_back (op_ptr); - }; + ops_to_visit.push_back (op_ptr); + }; /* Expressions can invoke other expressions with DW_OP_call*. Protect against a loop of calls. */ const int max_depth = 256; if (depth > max_depth) - error (_("DWARF-2 expression error: Loop detected.")); + error (_ ("DWARF-2 expression error: Loop detected.")); depth++; @@ -2128,15 +2086,13 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, = (cu_offset) extract_unsigned_integer (op_ptr, len, byte_order); op_ptr += len; - auto get_frame_pc = [&symbol_needs] () - { - symbol_needs = SYMBOL_NEEDS_FRAME; - return 0; - }; + auto get_frame_pc = [&symbol_needs] () { + symbol_needs = SYMBOL_NEEDS_FRAME; + return 0; + }; struct dwarf2_locexpr_baton baton - = dwarf2_fetch_die_loc_cu_off (cu_off, per_cu, - per_objfile, + = dwarf2_fetch_die_loc_cu_off (cu_off, per_cu, per_objfile, get_frame_pc); /* If SYMBOL_NEEDS_FRAME is returned from the previous call, @@ -2146,14 +2102,10 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, gdbarch *arch = baton.per_objfile->objfile->arch (); gdb::array_view<const gdb_byte> sub_expr (baton.data, baton.size); - symbol_needs - = dwarf2_get_symbol_read_needs (sub_expr, - baton.per_cu, - baton.per_objfile, - gdbarch_byte_order (arch), - baton.per_cu->addr_size (), - baton.per_cu->ref_addr_size (), - depth); + symbol_needs = dwarf2_get_symbol_read_needs ( + sub_expr, baton.per_cu, baton.per_objfile, + gdbarch_byte_order (arch), baton.per_cu->addr_size (), + baton.per_cu->ref_addr_size (), depth); } break; } @@ -2161,35 +2113,31 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, case DW_OP_GNU_variable_value: { sect_offset sect_off - = (sect_offset) extract_unsigned_integer (op_ptr, - ref_addr_size, + = (sect_offset) extract_unsigned_integer (op_ptr, ref_addr_size, byte_order); op_ptr += ref_addr_size; struct type *die_type - = dwarf2_fetch_die_type_sect_off (sect_off, per_cu, - per_objfile); + = dwarf2_fetch_die_type_sect_off (sect_off, per_cu, per_objfile); if (die_type == NULL) - error (_("Bad DW_OP_GNU_variable_value DIE.")); + error (_ ("Bad DW_OP_GNU_variable_value DIE.")); /* Note: Things still work when the following test is removed. This test and error is here to conform to the proposed specification. */ if (die_type->code () != TYPE_CODE_INT - && die_type->code () != TYPE_CODE_PTR) - error (_("Type of DW_OP_GNU_variable_value DIE must be " - "an integer or pointer.")); + && die_type->code () != TYPE_CODE_PTR) + error (_ ("Type of DW_OP_GNU_variable_value DIE must be " + "an integer or pointer.")); - auto get_frame_pc = [&symbol_needs] () - { - symbol_needs = SYMBOL_NEEDS_FRAME; - return 0; - }; + auto get_frame_pc = [&symbol_needs] () { + symbol_needs = SYMBOL_NEEDS_FRAME; + return 0; + }; struct dwarf2_locexpr_baton baton - = dwarf2_fetch_die_loc_sect_off (sect_off, per_cu, - per_objfile, + = dwarf2_fetch_die_loc_sect_off (sect_off, per_cu, per_objfile, get_frame_pc, true); /* If SYMBOL_NEEDS_FRAME is returned from the previous call, @@ -2199,14 +2147,10 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, gdbarch *arch = baton.per_objfile->objfile->arch (); gdb::array_view<const gdb_byte> sub_expr (baton.data, baton.size); - symbol_needs - = dwarf2_get_symbol_read_needs (sub_expr, - baton.per_cu, - baton.per_objfile, - gdbarch_byte_order (arch), - baton.per_cu->addr_size (), - baton.per_cu->ref_addr_size (), - depth); + symbol_needs = dwarf2_get_symbol_read_needs ( + sub_expr, baton.per_cu, baton.per_objfile, + gdbarch_byte_order (arch), baton.per_cu->addr_size (), + baton.per_cu->ref_addr_size (), depth); } break; } @@ -2222,7 +2166,7 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr, } default: - error (_("Unhandled DWARF expression opcode 0x%x"), op); + error (_ ("Unhandled DWARF expression opcode 0x%x"), op); } /* If it is known that a frame information is @@ -2245,11 +2189,11 @@ unimplemented (unsigned int op) const char *name = get_DW_OP_name (op); if (name) - error (_("DWARF operator %s cannot be translated to an agent expression"), + error (_ ("DWARF operator %s cannot be translated to an agent expression"), name); else - error (_("Unknown DWARF operator 0x%02x cannot be translated " - "to an agent expression"), + error (_ ("Unknown DWARF operator 0x%02x cannot be translated " + "to an agent expression"), op); } @@ -2266,7 +2210,7 @@ dwarf_reg_to_regnum (struct gdbarch *arch, int dwarf_reg) if (reg == -1) { - complaint (_("bad DWARF register number %d"), dwarf_reg); + complaint (_ ("bad DWARF register number %d"), dwarf_reg); } return reg; } @@ -2281,8 +2225,8 @@ throw_bad_regnum_error (ULONGEST dwarf_reg) We *could* have int and ULONGEST versions of dwarf2_reg_to_regnum_or_error but that's overkill for now. */ if ((int) dwarf_reg == dwarf_reg) - error (_("Unable to access DWARF register number %d"), (int) dwarf_reg); - error (_("Unable to access DWARF register number %s"), + error (_ ("Unable to access DWARF register number %d"), (int) dwarf_reg); + error (_ ("Unable to access DWARF register number %s"), pulongest (dwarf_reg)); } @@ -2362,13 +2306,12 @@ access_memory (struct gdbarch *arch, struct agent_expr *expr, ULONGEST nbits) static void dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, unsigned int addr_size, const gdb_byte *op_ptr, - const gdb_byte *op_end, - dwarf2_per_cu_data *per_cu, + const gdb_byte *op_end, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { gdbarch *arch = expr->gdbarch; std::vector<int> dw_labels, patches; - const gdb_byte * const base = op_ptr; + const gdb_byte *const base = op_ptr; const gdb_byte *previous_piece = op_ptr; enum bfd_endian byte_order = gdbarch_byte_order (arch); ULONGEST bits_collected = 0; @@ -2382,7 +2325,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, while (op_ptr < op_end) { - enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; + enum dwarf_location_atom op = (enum dwarf_location_atom) * op_ptr; uint64_t uoffset, reg; int64_t offset; int i; @@ -2555,13 +2498,13 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, op_ptr = safe_read_uleb128 (op_ptr, op_end, &len); if (op_ptr + len > op_end) - error (_("DW_OP_implicit_value: too few bytes available.")); + error (_ ("DW_OP_implicit_value: too few bytes available.")); if (len > sizeof (ULONGEST)) - error (_("Cannot translate DW_OP_implicit_value of %d bytes"), + error (_ ("Cannot translate DW_OP_implicit_value of %d bytes"), (int) len); - ax_const_l (expr, extract_unsigned_integer (op_ptr, len, - byte_order)); + ax_const_l (expr, + extract_unsigned_integer (op_ptr, len, byte_order)); op_ptr += len; dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_implicit_value"); @@ -2641,12 +2584,12 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, b = block_for_pc (expr->scope); if (!b) - error (_("No block found for address")); + error (_ ("No block found for address")); framefunc = block_linkage_function (b); if (!framefunc) - error (_("No function found for block")); + error (_ ("No function found for block")); func_get_frame_base_dwarf_block (framefunc, expr->scope, &datastart, &datalen); @@ -2704,8 +2647,8 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, size = addr_size; if (size != 1 && size != 2 && size != 4 && size != 8) - error (_("Unsupported size %d in %s"), - size, get_DW_OP_name (op)); + error (_ ("Unsupported size %d in %s"), size, + get_DW_OP_name (op)); access_memory (arch, expr, size * TARGET_CHAR_BIT); } break; @@ -2863,9 +2806,9 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, LONGEST off; const gdb_byte *cfa_start, *cfa_end; - if (dwarf2_fetch_cfa_info (arch, expr->scope, per_cu, - ®num, &off, - &text_offset, &cfa_start, &cfa_end)) + if (dwarf2_fetch_cfa_info (arch, expr->scope, per_cu, ®num, + &off, &text_offset, &cfa_start, + &cfa_end)) { /* Register. */ ax_reg (expr, regnum); @@ -2923,7 +2866,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, uint64_t size; if (op_ptr - 1 == previous_piece) - error (_("Cannot translate empty pieces to agent expressions")); + error (_ ("Cannot translate empty pieces to agent expressions")); previous_piece = op_ptr - 1; op_ptr = safe_read_uleb128 (op_ptr, op_end, &size); @@ -2936,7 +2879,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset); if (bits_collected + size > 8 * sizeof (LONGEST)) - error (_("Expression pieces exceed word size")); + error (_ ("Expression pieces exceed word size")); /* Access the bits. */ switch (loc->kind) @@ -2997,10 +2940,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, uoffset = extract_unsigned_integer (op_ptr, size, byte_order); op_ptr += size; - auto get_frame_pc_from_expr = [expr] () - { - return expr->scope; - }; + auto get_frame_pc_from_expr = [expr] () { return expr->scope; }; cu_offset cuoffset = (cu_offset) uoffset; block = dwarf2_fetch_die_loc_cu_off (cuoffset, per_cu, per_objfile, get_frame_pc_from_expr); @@ -3030,12 +2970,11 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, { int targ = offsets[dw_labels[i]]; if (targ == -1) - internal_error (_("invalid label")); + internal_error (_ ("invalid label")); ax_label (expr, patches[i], targ); } } - /* Return the value of SYMBOL in FRAME using the DWARF-2 expression evaluator to calculate the location. */ static struct value * @@ -3078,8 +3017,7 @@ locexpr_get_symbol_read_needs (struct symbol *symbol) gdbarch *arch = dlbaton->per_objfile->objfile->arch (); gdb::array_view<const gdb_byte> expr (dlbaton->data, dlbaton->size); - return dwarf2_get_symbol_read_needs (expr, - dlbaton->per_cu, + return dwarf2_get_symbol_read_needs (expr, dlbaton->per_cu, dlbaton->per_objfile, gdbarch_byte_order (arch), dlbaton->per_cu->addr_size (), @@ -3112,7 +3050,7 @@ locexpr_regname (struct gdbarch *gdbarch, int dwarf_regnum) { /* The text is output as "$bad_register_number". That is why we use the underscores. */ - return _("bad_register_number"); + return _ ("bad_register_number"); } return gdbarch_register_name (gdbarch, regnum); } @@ -3136,7 +3074,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, if (data[0] >= DW_OP_reg0 && data[0] <= DW_OP_reg31) { - gdb_printf (stream, _("a variable in $%s"), + gdb_printf (stream, _ ("a variable in $%s"), locexpr_regname (gdbarch, data[0] - DW_OP_reg0)); data += 1; } @@ -3145,7 +3083,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, uint64_t reg; data = safe_read_uleb128 (data + 1, end, ®); - gdb_printf (stream, _("a variable in $%s"), + gdb_printf (stream, _ ("a variable in $%s"), locexpr_regname (gdbarch, reg)); } else if (data[0] == DW_OP_fbreg) @@ -3166,27 +3104,28 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, b = block_for_pc (addr); if (!b) - error (_("No block found for address for symbol \"%s\"."), + error (_ ("No block found for address for symbol \"%s\"."), symbol->print_name ()); framefunc = block_linkage_function (b); if (!framefunc) - error (_("No function found for block for symbol \"%s\"."), + error (_ ("No function found for block for symbol \"%s\"."), symbol->print_name ()); - func_get_frame_base_dwarf_block (framefunc, addr, &base_data, &base_size); + func_get_frame_base_dwarf_block (framefunc, addr, &base_data, + &base_size); if (base_data[0] >= DW_OP_breg0 && base_data[0] <= DW_OP_breg31) { const gdb_byte *buf_end; - + frame_reg = base_data[0] - DW_OP_breg0; buf_end = safe_read_sleb128 (base_data + 1, base_data + base_size, &base_offset); if (buf_end != base_data + base_size) - error (_("Unexpected opcode after " - "DW_OP_breg%u for symbol \"%s\"."), + error (_ ("Unexpected opcode after " + "DW_OP_breg%u for symbol \"%s\"."), frame_reg, symbol->print_name ()); } else if (base_data[0] >= DW_OP_reg0 && base_data[0] <= DW_OP_reg31) @@ -3202,10 +3141,9 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, return save_data; } - gdb_printf (stream, - _("a variable at frame base reg $%s offset %s+%s"), - locexpr_regname (gdbarch, frame_reg), - plongest (base_offset), plongest (frame_offset)); + gdb_printf (stream, _ ("a variable at frame base reg $%s offset %s+%s"), + locexpr_regname (gdbarch, frame_reg), plongest (base_offset), + plongest (frame_offset)); } else if (data[0] >= DW_OP_breg0 && data[0] <= DW_OP_breg31 && piece_end_p (data, end)) @@ -3214,8 +3152,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, data = safe_read_sleb128 (data + 1, end, &offset); - gdb_printf (stream, - _("a variable at offset %s from base reg $%s"), + gdb_printf (stream, _ ("a variable at offset %s from base reg $%s"), plongest (offset), locexpr_regname (gdbarch, data[0] - DW_OP_breg0)); } @@ -3246,9 +3183,9 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, offset = extract_unsigned_integer (data + 1, addr_size, gdbarch_byte_order (gdbarch)); - gdb_printf (stream, - _("a thread-local variable at offset 0x%s " - "in the thread-local storage for `%s'"), + gdb_printf (stream, + _ ("a thread-local variable at offset 0x%s " + "in the thread-local storage for `%s'"), phex_nz (offset, addr_size), objfile_name (objfile)); data += 1 + addr_size + 1; @@ -3260,8 +3197,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, DW_OP_GNU_push_tls_address) */ else if (data + 3 <= end && data + 1 + (leb128_size = skip_leb128 (data + 1, end)) < end - && data[0] == DW_OP_GNU_const_index - && leb128_size > 0 + && data[0] == DW_OP_GNU_const_index && leb128_size > 0 && (data[1 + leb128_size] == DW_OP_GNU_push_tls_address || data[1 + leb128_size] == DW_OP_form_tls_address) && piece_end_p (data + 2 + leb128_size, end)) @@ -3270,19 +3206,17 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, data = safe_read_uleb128 (data + 1, end, &offset); offset = dwarf2_read_addr_index (per_cu, per_objfile, offset); - gdb_printf (stream, - _("a thread-local variable at offset 0x%s " - "in the thread-local storage for `%s'"), + gdb_printf (stream, + _ ("a thread-local variable at offset 0x%s " + "in the thread-local storage for `%s'"), phex_nz (offset, addr_size), objfile_name (objfile)); ++data; } - else if (data[0] >= DW_OP_lit0 - && data[0] <= DW_OP_lit31 - && data + 1 < end + else if (data[0] >= DW_OP_lit0 && data[0] <= DW_OP_lit31 && data + 1 < end && data[1] == DW_OP_stack_value) { - gdb_printf (stream, _("the constant %d"), data[0] - DW_OP_lit0); + gdb_printf (stream, _ ("the constant %d"), data[0] - DW_OP_lit0); data += 2; } @@ -3297,19 +3231,17 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, of the buffer, an error is thrown. */ static const gdb_byte * -disassemble_dwarf_expression (struct ui_file *stream, - struct gdbarch *arch, unsigned int addr_size, - int offset_size, const gdb_byte *start, - const gdb_byte *data, const gdb_byte *end, - int indent, int all, +disassemble_dwarf_expression (struct ui_file *stream, struct gdbarch *arch, + unsigned int addr_size, int offset_size, + const gdb_byte *start, const gdb_byte *data, + const gdb_byte *end, int indent, int all, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { while (data < end - && (all - || (data[0] != DW_OP_piece && data[0] != DW_OP_bit_piece))) + && (all || (data[0] != DW_OP_piece && data[0] != DW_OP_bit_piece))) { - enum dwarf_location_atom op = (enum dwarf_location_atom) *data++; + enum dwarf_location_atom op = (enum dwarf_location_atom) * data++; uint64_t ul; int64_t l; const char *name; @@ -3317,10 +3249,10 @@ disassemble_dwarf_expression (struct ui_file *stream, name = get_DW_OP_name (op); if (!name) - error (_("Unrecognized DWARF opcode 0x%02x at %ld"), - op, (long) (data - 1 - start)); - gdb_printf (stream, " %*ld: %s", indent + 4, - (long) (data - 1 - start), name); + error (_ ("Unrecognized DWARF opcode 0x%02x at %ld"), op, + (long) (data - 1 - start)); + gdb_printf (stream, " %*ld: %s", indent + 4, (long) (data - 1 - start), + name); switch (op) { @@ -3477,10 +3409,8 @@ disassemble_dwarf_expression (struct ui_file *stream, case DW_OP_bregx: data = safe_read_uleb128 (data, end, &ul); data = safe_read_sleb128 (data, end, &l); - gdb_printf (stream, " register %s [$%s] offset %s", - pulongest (ul), - locexpr_regname (arch, (int) ul), - plongest (l)); + gdb_printf (stream, " register %s [$%s] offset %s", pulongest (ul), + locexpr_regname (arch, (int) ul), plongest (l)); break; case DW_OP_fbreg: @@ -3503,15 +3433,13 @@ disassemble_dwarf_expression (struct ui_file *stream, case DW_OP_skip: l = extract_signed_integer (data, 2, gdbarch_byte_order (arch)); data += 2; - gdb_printf (stream, " to %ld", - (long) (data + l - start)); + gdb_printf (stream, " to %ld", (long) (data + l - start)); break; case DW_OP_bra: l = extract_signed_integer (data, 2, gdbarch_byte_order (arch)); data += 2; - gdb_printf (stream, " %ld", - (long) (data + l - start)); + gdb_printf (stream, " %ld", (long) (data + l - start)); break; case DW_OP_call2: @@ -3544,8 +3472,8 @@ disassemble_dwarf_expression (struct ui_file *stream, data = safe_read_uleb128 (data, end, &ul); data = safe_read_uleb128 (data, end, &offset); - gdb_printf (stream, " size %s offset %s (bits)", - pulongest (ul), pulongest (offset)); + gdb_printf (stream, " size %s offset %s (bits)", pulongest (ul), + pulongest (offset)); } break; @@ -3558,8 +3486,7 @@ disassemble_dwarf_expression (struct ui_file *stream, data = safe_read_sleb128 (data, end, &l); - gdb_printf (stream, " DIE %s offset %s", - phex_nz (ul, offset_size), + gdb_printf (stream, " DIE %s offset %s", phex_nz (ul, offset_size), plongest (l)); } break; @@ -3576,8 +3503,7 @@ disassemble_dwarf_expression (struct ui_file *stream, gdb_printf (stream, "<"); type_print (type, "", stream, -1); gdb_printf (stream, " [0x%s]> %d", - phex_nz (to_underlying (offset), 0), - deref_addr_size); + phex_nz (to_underlying (offset), 0), deref_addr_size); } break; @@ -3694,8 +3620,8 @@ show_dwarf_always_disassemble (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { gdb_printf (file, - _("Whether to always disassemble " - "DWARF expressions is %s.\n"), + _ ("Whether to always disassemble " + "DWARF expressions is %s.\n"), value); } @@ -3704,9 +3630,8 @@ show_dwarf_always_disassemble (struct ui_file *file, int from_tty, static void locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, - struct ui_file *stream, - const gdb_byte *data, size_t size, - unsigned int addr_size, + struct ui_file *stream, const gdb_byte *data, + size_t size, unsigned int addr_size, int offset_size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { @@ -3722,35 +3647,33 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, if (first_piece) first_piece = 0; else - gdb_printf (stream, _(", and ")); + gdb_printf (stream, _ (", and ")); if (!dwarf_always_disassemble) { - data = locexpr_describe_location_piece (symbol, stream, - addr, per_cu, per_objfile, - data, end, addr_size); + data = locexpr_describe_location_piece (symbol, stream, addr, per_cu, + per_objfile, data, end, + addr_size); /* If we printed anything, or if we have an empty piece, then don't disassemble. */ - if (data != here - || data[0] == DW_OP_piece + if (data != here || data[0] == DW_OP_piece || data[0] == DW_OP_bit_piece) disassemble = 0; } if (disassemble) { - gdb_printf (stream, _("a complex DWARF expression:\n")); - data = disassemble_dwarf_expression (stream, - objfile->arch (), - addr_size, offset_size, data, - data, end, 0, - dwarf_always_disassemble, - per_cu, per_objfile); + gdb_printf (stream, _ ("a complex DWARF expression:\n")); + data + = disassemble_dwarf_expression (stream, objfile->arch (), + addr_size, offset_size, data, data, + end, 0, dwarf_always_disassemble, + per_cu, per_objfile); } if (data < end) { int empty = data == here; - + if (disassemble) gdb_printf (stream, " "); if (data[0] == DW_OP_piece) @@ -3760,11 +3683,10 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, data = safe_read_uleb128 (data + 1, end, &bytes); if (empty) - gdb_printf (stream, _("an empty %s-byte piece"), + gdb_printf (stream, _ ("an empty %s-byte piece"), pulongest (bytes)); else - gdb_printf (stream, _(" [%s-byte piece]"), - pulongest (bytes)); + gdb_printf (stream, _ (" [%s-byte piece]"), pulongest (bytes)); } else if (data[0] == DW_OP_bit_piece) { @@ -3774,12 +3696,10 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, data = safe_read_uleb128 (data, end, &offset); if (empty) - gdb_printf (stream, - _("an empty %s-bit piece"), + gdb_printf (stream, _ ("an empty %s-bit piece"), pulongest (bits)); else - gdb_printf (stream, - _(" [%s-bit piece, offset %s bits]"), + gdb_printf (stream, _ (" [%s-bit piece, offset %s bits]"), pulongest (bits), pulongest (offset)); } else @@ -3791,7 +3711,7 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, } if (bad || data > end) - error (_("Corrupted DWARF2 expression for \"%s\"."), + error (_ ("Corrupted DWARF2 expression for \"%s\"."), symbol->print_name ()); } @@ -3807,9 +3727,8 @@ locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr, unsigned int addr_size = dlbaton->per_cu->addr_size (); int offset_size = dlbaton->per_cu->offset_size (); - locexpr_describe_location_1 (symbol, addr, stream, - dlbaton->data, dlbaton->size, - addr_size, offset_size, + locexpr_describe_location_1 (symbol, addr, stream, dlbaton->data, + dlbaton->size, addr_size, offset_size, dlbaton->per_cu, dlbaton->per_objfile); } @@ -3837,34 +3756,32 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax, static void locexpr_generate_c_location (struct symbol *sym, string_file *stream, struct gdbarch *gdbarch, - std::vector<bool> ®isters_used, - CORE_ADDR pc, const char *result_name) + std::vector<bool> ®isters_used, CORE_ADDR pc, + const char *result_name) { struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym); unsigned int addr_size = dlbaton->per_cu->addr_size (); if (dlbaton->size == 0) - error (_("symbol \"%s\" is optimized out"), sym->natural_name ()); + error (_ ("symbol \"%s\" is optimized out"), sym->natural_name ()); - compile_dwarf_expr_to_c (stream, result_name, - sym, pc, gdbarch, registers_used, addr_size, - dlbaton->data, dlbaton->data + dlbaton->size, - dlbaton->per_cu, dlbaton->per_objfile); + compile_dwarf_expr_to_c (stream, result_name, sym, pc, gdbarch, + registers_used, addr_size, dlbaton->data, + dlbaton->data + dlbaton->size, dlbaton->per_cu, + dlbaton->per_objfile); } /* The set of location functions used with the DWARF-2 expression evaluator. */ -const struct symbol_computed_ops dwarf2_locexpr_funcs = { - locexpr_read_variable, - locexpr_read_variable_at_entry, - locexpr_get_symbol_read_needs, - locexpr_describe_location, - 0, /* location_has_loclist */ - locexpr_tracepoint_var_ref, - locexpr_generate_c_location -}; - +const struct symbol_computed_ops dwarf2_locexpr_funcs + = { locexpr_read_variable, + locexpr_read_variable_at_entry, + locexpr_get_symbol_read_needs, + locexpr_describe_location, + 0, /* location_has_loclist */ + locexpr_tracepoint_var_ref, + locexpr_generate_c_location }; /* Wrapper functions for location lists. These generally find the appropriate location expression and call something above. */ @@ -3956,7 +3873,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, loc_ptr = dlbaton->data; buf_end = dlbaton->data + dlbaton->size; - gdb_printf (stream, _("multi-location:\n")); + gdb_printf (stream, _ ("multi-location:\n")); /* Iterate through locations until we run out. */ while (!done) @@ -3968,20 +3885,19 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, if (dlbaton->per_cu->version () < 5 && dlbaton->from_dwo) kind = decode_debug_loc_dwo_addresses (dlbaton->per_cu, - dlbaton->per_objfile, - loc_ptr, buf_end, &new_ptr, - &low, &high, byte_order); + dlbaton->per_objfile, loc_ptr, + buf_end, &new_ptr, &low, &high, + byte_order); else if (dlbaton->per_cu->version () < 5) - kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, - &low, &high, - byte_order, addr_size, + kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, &low, + &high, byte_order, addr_size, signed_addr_p); else kind = decode_debug_loclists_addresses (dlbaton->per_cu, - dlbaton->per_objfile, - loc_ptr, buf_end, &new_ptr, - &low, &high, byte_order, - addr_size, signed_addr_p); + dlbaton->per_objfile, loc_ptr, + buf_end, &new_ptr, &low, &high, + byte_order, addr_size, + signed_addr_p); loc_ptr = new_ptr; switch (kind) { @@ -3991,7 +3907,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, case DEBUG_LOC_BASE_ADDRESS: base_address = high; - gdb_printf (stream, _(" Base address %s"), + gdb_printf (stream, _ (" Base address %s"), paddress (gdbarch, base_address)); continue; @@ -4002,7 +3918,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, case DEBUG_LOC_BUFFER_OVERFLOW: case DEBUG_LOC_INVALID_ENTRY: - error (_("Corrupted DWARF expression for symbol \"%s\"."), + error (_ ("Corrupted DWARF expression for symbol \"%s\"."), symbol->print_name ()); default: @@ -4022,26 +3938,26 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, high = gdbarch_adjust_dwarf2_addr (gdbarch, high); if (dlbaton->per_cu->version () < 5) - { - length = extract_unsigned_integer (loc_ptr, 2, byte_order); - loc_ptr += 2; - } + { + length = extract_unsigned_integer (loc_ptr, 2, byte_order); + loc_ptr += 2; + } else - { - unsigned int bytes_read; - length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read); - loc_ptr += bytes_read; - } + { + unsigned int bytes_read; + length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read); + loc_ptr += bytes_read; + } /* (It would improve readability to print only the minimum necessary digits of the second number of the range.) */ - gdb_printf (stream, _(" Range %s-%s: "), - paddress (gdbarch, low), paddress (gdbarch, high)); + gdb_printf (stream, _ (" Range %s-%s: "), paddress (gdbarch, low), + paddress (gdbarch, high)); /* Now describe this particular location. */ locexpr_describe_location_1 (symbol, low, stream, loc_ptr, length, - addr_size, offset_size, - dlbaton->per_cu, dlbaton->per_objfile); + addr_size, offset_size, dlbaton->per_cu, + dlbaton->per_objfile); gdb_printf (stream, "\n"); @@ -4074,8 +3990,8 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax, static void loclist_generate_c_location (struct symbol *sym, string_file *stream, struct gdbarch *gdbarch, - std::vector<bool> ®isters_used, - CORE_ADDR pc, const char *result_name) + std::vector<bool> ®isters_used, CORE_ADDR pc, + const char *result_name) { struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym); @@ -4085,53 +4001,50 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream, data = dwarf2_find_location_expression (dlbaton, &size, pc); if (size == 0) - error (_("symbol \"%s\" is optimized out"), sym->natural_name ()); + error (_ ("symbol \"%s\" is optimized out"), sym->natural_name ()); - compile_dwarf_expr_to_c (stream, result_name, - sym, pc, gdbarch, registers_used, addr_size, - data, data + size, - dlbaton->per_cu, - dlbaton->per_objfile); + compile_dwarf_expr_to_c (stream, result_name, sym, pc, gdbarch, + registers_used, addr_size, data, data + size, + dlbaton->per_cu, dlbaton->per_objfile); } /* The set of location functions used with the DWARF-2 expression evaluator and location lists. */ -const struct symbol_computed_ops dwarf2_loclist_funcs = { - loclist_read_variable, - loclist_read_variable_at_entry, - loclist_symbol_needs, - loclist_describe_location, - 1, /* location_has_loclist */ - loclist_tracepoint_var_ref, - loclist_generate_c_location -}; +const struct symbol_computed_ops dwarf2_loclist_funcs + = { loclist_read_variable, + loclist_read_variable_at_entry, + loclist_symbol_needs, + loclist_describe_location, + 1, /* location_has_loclist */ + loclist_tracepoint_var_ref, + loclist_generate_c_location }; void _initialize_dwarf2loc (); + void _initialize_dwarf2loc () { add_setshow_zuinteger_cmd ("entry-values", class_maintenance, &entry_values_debug, - _("Set entry values and tail call frames " - "debugging."), - _("Show entry values and tail call frames " - "debugging."), - _("When non-zero, the process of determining " - "parameter values from function entry point " - "and tail call frames will be printed."), - NULL, - show_entry_values_debug, - &setdebuglist, &showdebuglist); + _ ("Set entry values and tail call frames " + "debugging."), + _ ("Show entry values and tail call frames " + "debugging."), + _ ("When non-zero, the process of determining " + "parameter values from function entry point " + "and tail call frames will be printed."), + NULL, show_entry_values_debug, &setdebuglist, + &showdebuglist); add_setshow_boolean_cmd ("always-disassemble", class_obscure, - &dwarf_always_disassemble, _("\ -Set whether `info address' always disassembles DWARF expressions."), _("\ -Show whether `info address' always disassembles DWARF expressions."), _("\ + &dwarf_always_disassemble, _ ("\ +Set whether `info address' always disassembles DWARF expressions."), + _ ("\ +Show whether `info address' always disassembles DWARF expressions."), + _ ("\ When enabled, DWARF expressions are always printed in an assembly-like\n\ syntax. When disabled, expressions will be printed in a more\n\ conversational style, when possible."), - NULL, - show_dwarf_always_disassemble, - &set_dwarf_cmdlist, - &show_dwarf_cmdlist); + NULL, show_dwarf_always_disassemble, + &set_dwarf_cmdlist, &show_dwarf_cmdlist); } diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 37925f4..4a8c512 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#if !defined (DWARF2LOC_H) +#if !defined(DWARF2LOC_H) #define DWARF2LOC_H #include "dwarf2/expr.h" @@ -36,10 +36,9 @@ struct axs_value; extern unsigned int entry_values_debug; /* Find a particular location expression from a location list. */ -const gdb_byte *dwarf2_find_location_expression - (struct dwarf2_loclist_baton *baton, - size_t *locexpr_length, - CORE_ADDR pc); +const gdb_byte * +dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, + size_t *locexpr_length, CORE_ADDR pc); /* Find the frame base information for FRAMEFUNC at PC. START is an out parameter which is set to point to the DWARF expression to @@ -64,11 +63,10 @@ value *compute_var_value (const char *name); Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR otherwise. */ -struct call_site_parameter *dwarf_expr_reg_to_entry_parameter - (frame_info_ptr frame, enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, dwarf2_per_cu_data **per_cu_return, - dwarf2_per_objfile **per_objfile_return); - +struct call_site_parameter *dwarf_expr_reg_to_entry_parameter ( + frame_info_ptr frame, enum call_site_parameter_kind kind, + union call_site_parameter_u kind_u, dwarf2_per_cu_data **per_cu_return, + dwarf2_per_objfile **per_objfile_return); /* Evaluate a location description, starting at DATA and with length SIZE, to find the current location of variable of TYPE in the context @@ -77,8 +75,7 @@ struct call_site_parameter *dwarf_expr_reg_to_entry_parameter struct value *dwarf2_evaluate_loc_desc (struct type *type, frame_info_ptr frame, - const gdb_byte *data, - size_t size, + const gdb_byte *data, size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, bool as_lval = true); @@ -143,8 +140,7 @@ void dwarf2_compile_property_to_c (string_file *stream, struct gdbarch *gdbarch, std::vector<bool> ®isters_used, const struct dynamic_prop *prop, - CORE_ADDR address, - struct symbol *sym); + CORE_ADDR address, struct symbol *sym); /* The symbol location baton types used by the DWARF-2 reader (i.e. SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct @@ -230,6 +226,7 @@ struct dwarf2_property_baton by value then it will be of PROPERTY_TYPE. This field should never be NULL. */ struct type *property_type; + union { /* Location expression either evaluated in the context of @@ -253,19 +250,20 @@ extern const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs; /* Determined tail calls for constructing virtual tail call frames. */ struct call_site_chain - { - /* Initially CALLERS == CALLEES == LENGTH. For partially ambiguous result +{ + /* Initially CALLERS == CALLEES == LENGTH. For partially ambiguous result CALLERS + CALLEES < LENGTH. */ - int callers, callees, length; + int callers, callees, length; - /* Variably sized array with LENGTH elements. Later [0..CALLERS-1] contain + /* Variably sized array with LENGTH elements. Later [0..CALLERS-1] contain top (GDB "prev") sites and [LENGTH-CALLEES..LENGTH-1] contain bottom (GDB "next") sites. One is interested primarily in the PC field. */ - struct call_site *call_site[1]; - }; + struct call_site *call_site[1]; +}; -extern gdb::unique_xmalloc_ptr<call_site_chain> call_site_find_chain - (struct gdbarch *gdbarch, CORE_ADDR caller_pc, CORE_ADDR callee_pc); +extern gdb::unique_xmalloc_ptr<call_site_chain> +call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, + CORE_ADDR callee_pc); /* A helper function to convert a DWARF register to an arch register. ARCH is the architecture. @@ -291,10 +289,10 @@ extern void invalid_synthetic_pointer (); /* Fetch the value pointed to by a synthetic pointer. */ -extern struct value *indirect_synthetic_pointer - (sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, frame_info_ptr frame, - struct type *type, bool resolve_abstract_p = false); +extern struct value *indirect_synthetic_pointer ( + sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, frame_info_ptr frame, struct type *type, + bool resolve_abstract_p = false); /* Read parameter of TYPE at (callee) FRAME's function entry. KIND and KIND_U are used to match DW_AT_location at the caller's @@ -303,8 +301,8 @@ extern struct value *indirect_synthetic_pointer Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it cannot resolve the parameter for any reason. */ -extern struct value *value_of_dwarf_reg_entry (struct type *type, - struct frame_info_ptr frame, - enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u); +extern struct value * +value_of_dwarf_reg_entry (struct type *type, struct frame_info_ptr frame, + enum call_site_parameter_kind kind, + union call_site_parameter_u kind_u); #endif /* DWARF2LOC_H */ diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 78cce2d..ba21c82 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -40,14 +40,13 @@ static void dwarf2_macro_malformed_definition_complaint (const char *arg1) { - complaint (_("macro debug info contains a " - "malformed macro definition:\n`%s'"), + complaint (_ ("macro debug info contains a " + "malformed macro definition:\n`%s'"), arg1); } static struct macro_source_file * -macro_start_file (buildsym_compunit *builder, - int file, int line, +macro_start_file (buildsym_compunit *builder, int file, int line, struct macro_source_file *current_file, const struct line_header *lh) { @@ -62,13 +61,12 @@ macro_start_file (buildsym_compunit *builder, /* The compiler produced a bogus file number. We can at least record the macro definitions made in the file, even if we won't be able to find the file by name. */ - complaint (_("bad file number in macro information (%d)"), - file); + complaint (_ ("bad file number in macro information (%d)"), file); file_name = string_printf ("<bad macro file number %d>", file); } - if (! current_file) + if (!current_file) { /* Note: We don't create a macro table for this compilation unit at all until we actually get a filename. */ @@ -90,8 +88,8 @@ consume_improper_spaces (const char *p, const char *body) { if (*p == ' ') { - complaint (_("macro definition contains spaces " - "in formal argument list:\n`%s'"), + complaint (_ ("macro definition contains spaces " + "in formal argument list:\n`%s'"), body); while (*p == ' ') @@ -101,7 +99,6 @@ consume_improper_spaces (const char *p, const char *body) return p; } - static void parse_macro_definition (struct macro_source_file *file, int line, const char *body) @@ -131,7 +128,6 @@ parse_macro_definition (struct macro_source_file *file, int line, but versions of GCC around March 2002 include spaces after the commas. */ - /* Find the extent of the macro name. The macro name is terminated by either a space or null character (for an object-like macro) or an opening paren (for a function-like macro). */ @@ -177,7 +173,7 @@ parse_macro_definition (struct macro_source_file *file, int line, while (*p && *p != ',' && *p != ')' && *p != ' ') p++; - if (! *p || p == arg_start) + if (!*p || p == arg_start) dwarf2_macro_malformed_definition_complaint (body); else { @@ -208,16 +204,14 @@ parse_macro_definition (struct macro_source_file *file, int line, if (*p == ' ') /* Perfectly formed definition, no complaints. */ - macro_define_function (file, line, name.c_str (), - argc, (const char **) argv, - p + 1); + macro_define_function (file, line, name.c_str (), argc, + (const char **) argv, p + 1); else if (*p == '\0') { /* Complain, but do define it. */ dwarf2_macro_malformed_definition_complaint (body); - macro_define_function (file, line, name.c_str (), - argc, (const char **) argv, - p); + macro_define_function (file, line, name.c_str (), argc, + (const char **) argv, p); } else /* Just complain. */ @@ -244,8 +238,7 @@ parse_macro_definition (struct macro_source_file *file, int line, static const gdb_byte * skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end, - enum dwarf_form form, - unsigned int offset_size, + enum dwarf_form form, unsigned int offset_size, const struct dwarf2_section_info *section) { unsigned int bytes_read; @@ -318,8 +311,8 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end, default: { - complaint (_("invalid form 0x%x in `%s'"), - form, section->get_name ()); + complaint (_ ("invalid form 0x%x in `%s'"), form, + section->get_name ()); return NULL; } } @@ -332,11 +325,9 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end, on error, issues a complaint and returns NULL. */ static const gdb_byte * -skip_unknown_opcode (unsigned int opcode, - const gdb_byte **opcode_definitions, +skip_unknown_opcode (unsigned int opcode, const gdb_byte **opcode_definitions, const gdb_byte *mac_ptr, const gdb_byte *mac_end, - bfd *abfd, - unsigned int offset_size, + bfd *abfd, unsigned int offset_size, const struct dwarf2_section_info *section) { unsigned int bytes_read, i; @@ -345,7 +336,7 @@ skip_unknown_opcode (unsigned int opcode, if (opcode_definitions[opcode] == NULL) { - complaint (_("unrecognized DW_MACINFO or DW_MACRO opcode 0x%x"), + complaint (_ ("unrecognized DW_MACINFO or DW_MACRO opcode 0x%x"), opcode); return NULL; } @@ -356,9 +347,9 @@ skip_unknown_opcode (unsigned int opcode, for (i = 0; i < arg; ++i) { - mac_ptr = skip_form_bytes (abfd, mac_ptr, mac_end, - (enum dwarf_form) defn[i], offset_size, - section); + mac_ptr + = skip_form_bytes (abfd, mac_ptr, mac_end, (enum dwarf_form) defn[i], + offset_size, section); if (mac_ptr == NULL) { /* skip_form_bytes already issued the complaint. */ @@ -375,10 +366,8 @@ skip_unknown_opcode (unsigned int opcode, the header, or issues a complaint and returns NULL on error. */ static const gdb_byte * -dwarf_parse_macro_header (const gdb_byte **opcode_definitions, - bfd *abfd, - const gdb_byte *mac_ptr, - unsigned int *offset_size, +dwarf_parse_macro_header (const gdb_byte **opcode_definitions, bfd *abfd, + const gdb_byte *mac_ptr, unsigned int *offset_size, int section_is_gnu) { memset (opcode_definitions, 0, 256 * sizeof (gdb_byte *)); @@ -390,7 +379,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions, version = read_2_bytes (abfd, mac_ptr); if (version != 4 && version != 5) { - complaint (_("unrecognized version `%d' in .debug_macro section"), + complaint (_ ("unrecognized version `%d' in .debug_macro section"), version); return NULL; } @@ -434,8 +423,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions, static void dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, - buildsym_compunit *builder, - bfd *abfd, + buildsym_compunit *builder, bfd *abfd, const gdb_byte *mac_ptr, const gdb_byte *mac_end, struct macro_source_file *current_file, const struct line_header *lh, @@ -478,7 +466,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, break; } - macinfo_type = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr); + macinfo_type + = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr); mac_ptr++; /* Note that we rely on the fact that the corresponding GNU and @@ -521,38 +510,39 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, mac_ptr += offset_size; if (macinfo_type == DW_MACRO_define_sup - || macinfo_type == DW_MACRO_undef_sup - || section_is_dwz) + || macinfo_type == DW_MACRO_undef_sup || section_is_dwz) { - dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd, - true); + dwz_file *dwz + = dwarf2_get_dwz_file (per_objfile->per_bfd, true); body = dwz->read_string (objfile, str_offset); } else - body = per_objfile->per_bfd->str.read_string (objfile, - str_offset, - "DW_FORM_strp"); + body + = per_objfile->per_bfd->str.read_string (objfile, + str_offset, + "DW_FORM_strp"); } is_define = (macinfo_type == DW_MACRO_define || macinfo_type == DW_MACRO_define_strp || macinfo_type == DW_MACRO_define_sup); - if (! current_file) + if (!current_file) { /* DWARF violation as no main source is present. */ - complaint (_("debug info with no main source gives macro %s " - "on line %d: %s"), - is_define ? _("definition") : _("undefinition"), + complaint (_ ("debug info with no main source gives macro %s " + "on line %d: %s"), + is_define ? _ ("definition") : _ ("undefinition"), line, body); break; } if ((line == 0 && !at_commandline) || (line != 0 && at_commandline)) - complaint (_("debug info gives %s macro %s with %s line %d: %s"), - at_commandline ? _("command-line") : _("in-file"), - is_define ? _("definition") : _("undefinition"), - line == 0 ? _("zero") : _("non-zero"), line, body); + complaint ( + _ ("debug info gives %s macro %s with %s line %d: %s"), + at_commandline ? _ ("command-line") : _ ("in-file"), + is_define ? _ ("definition") : _ ("undefinition"), + line == 0 ? _ ("zero") : _ ("non-zero"), line, body); if (body == NULL) { @@ -561,11 +551,11 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, For more info, see https://bugzilla.redhat.com/show_bug.cgi?id=1708786 */ - complaint (_("debug info gives %s invalid macro %s " - "without body (corrupted?) at line %d " - "on file %s"), - at_commandline ? _("command-line") : _("in-file"), - is_define ? _("definition") : _("undefinition"), + complaint (_ ("debug info gives %s invalid macro %s " + "without body (corrupted?) at line %d " + "on file %s"), + at_commandline ? _ ("command-line") : _ ("in-file"), + is_define ? _ ("definition") : _ ("undefinition"), line, current_file->filename); } else if (is_define) @@ -587,48 +577,54 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, int line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); mac_ptr += bytes_read; - int offset_index = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); + int offset_index + = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); mac_ptr += bytes_read; /* Use of the strx operators requires a DW_AT_str_offsets_base. */ if (!str_offsets_base.has_value ()) { - complaint (_("use of %s with unknown string offsets base " - "[in module %s]"), + complaint (_ ("use of %s with unknown string offsets base " + "[in module %s]"), (macinfo_type == DW_MACRO_define_strx - ? "DW_MACRO_define_strx" - : "DW_MACRO_undef_strx"), + ? "DW_MACRO_define_strx" + : "DW_MACRO_undef_strx"), objfile_name (objfile)); break; } str_offsets_section->read (objfile); - const gdb_byte *info_ptr = (str_offsets_section->buffer - + *str_offsets_base - + offset_index * offset_size); + const gdb_byte *info_ptr + = (str_offsets_section->buffer + *str_offsets_base + + offset_index * offset_size); - const char *macinfo_str = (macinfo_type == DW_MACRO_define_strx ? - "DW_MACRO_define_strx" : "DW_MACRO_undef_strx"); + const char *macinfo_str + = (macinfo_type == DW_MACRO_define_strx ? "DW_MACRO_define_strx" + : "DW_MACRO_undef_strx"); if (*str_offsets_base + offset_index * offset_size >= str_offsets_section->size) { - complaint (_("%s pointing outside of .debug_str_offsets section " - "[in module %s]"), macinfo_str, objfile_name (objfile)); + complaint ( + _ ("%s pointing outside of .debug_str_offsets section " + "[in module %s]"), + macinfo_str, objfile_name (objfile)); break; } ULONGEST str_offset = read_offset (abfd, info_ptr, offset_size); - const char *body = str_section->read_string (objfile, str_offset, - macinfo_str); + const char *body + = str_section->read_string (objfile, str_offset, macinfo_str); if (current_file == nullptr) { /* DWARF violation as no main source is present. */ - complaint (_("debug info with no main source gives macro %s " - "on line %d: %s"), - macinfo_type == DW_MACRO_define_strx ? _("definition") - : _("undefinition"), line, body); + complaint (_ ("debug info with no main source gives macro %s " + "on line %d: %s"), + macinfo_type == DW_MACRO_define_strx + ? _ ("definition") + : _ ("undefinition"), + line, body); break; } @@ -636,8 +632,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, parse_macro_definition (current_file, line, body); else macro_undef (current_file, line, body); - } - break; + } + break; case DW_MACRO_start_file: { @@ -651,10 +647,11 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, if ((line == 0 && !at_commandline) || (line != 0 && at_commandline)) - complaint (_("debug info gives source %d included " - "from %s at %s line %d"), - file, at_commandline ? _("command-line") : _("file"), - line == 0 ? _("zero") : _("non-zero"), line); + complaint (_ ("debug info gives source %d included " + "from %s at %s line %d"), + file, + at_commandline ? _ ("command-line") : _ ("file"), + line == 0 ? _ ("zero") : _ ("non-zero"), line); if (at_commandline) { @@ -663,15 +660,15 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, at_commandline = 0; } else - current_file = macro_start_file (builder, file, line, - current_file, lh); + current_file + = macro_start_file (builder, file, line, current_file, lh); } break; case DW_MACRO_end_file: - if (! current_file) - complaint (_("macro debug info has an unmatched " - "`close_file' directive")); + if (!current_file) + complaint (_ ("macro debug info has an unmatched " + "`close_file' directive")); else if (current_file->included_by == nullptr && producer_is_clang (cu)) { @@ -686,7 +683,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, else { current_file = current_file->included_by; - if (! current_file) + if (!current_file) { enum dwarf_macro_record_type next_type; @@ -708,8 +705,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr); if (next_type != 0) - complaint (_("no terminating 0-type entry for " - "macros in `.debug_macinfo' section")); + complaint (_ ("no terminating 0-type entry for " + "macros in `.debug_macinfo' section")); return; } @@ -732,8 +729,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, if (macinfo_type == DW_MACRO_import_sup) { - dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd, - true); + dwz_file *dwz + = dwarf2_get_dwz_file (per_objfile->per_bfd, true); dwz->macro.read (objfile); @@ -750,8 +747,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, { /* This has actually happened; see http://sourceware.org/bugzilla/show_bug.cgi?id=13568. */ - complaint (_("recursive DW_MACRO_import in " - ".debug_macro section")); + complaint (_ ("recursive DW_MACRO_import in " + ".debug_macro section")); } else { @@ -787,15 +784,16 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, /* FALLTHROUGH */ default: - mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions, - mac_ptr, mac_end, abfd, offset_size, - section); + mac_ptr + = skip_unknown_opcode (macinfo_type, opcode_definitions, mac_ptr, + mac_end, abfd, offset_size, section); if (mac_ptr == NULL) return; break; } DIAGNOSTIC_POP - } while (macinfo_type != 0); + } + while (macinfo_type != 0); } void @@ -803,7 +801,8 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, buildsym_compunit *builder, const dwarf2_section_info *section, const struct line_header *lh, unsigned int offset_size, - unsigned int offset, struct dwarf2_section_info *str_section, + unsigned int offset, + struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, gdb::optional<ULONGEST> str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu) @@ -850,7 +849,8 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, break; } - macinfo_type = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr); + macinfo_type + = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr); mac_ptr++; /* Note that we rely on the fact that the corresponding GNU and @@ -887,8 +887,8 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); mac_ptr += bytes_read; - current_file = macro_start_file (builder, file, line, - current_file, lh); + current_file + = macro_start_file (builder, file, line, current_file, lh); } break; @@ -942,15 +942,16 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, /* FALLTHROUGH */ default: - mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions, - mac_ptr, mac_end, abfd, offset_size, - section); + mac_ptr + = skip_unknown_opcode (macinfo_type, opcode_definitions, mac_ptr, + mac_end, abfd, offset_size, section); if (mac_ptr == NULL) return; break; } DIAGNOSTIC_POP - } while (macinfo_type != 0 && current_file == NULL); + } + while (macinfo_type != 0 && current_file == NULL); /* Second pass: Process all entries. @@ -959,8 +960,8 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, reach the first DW_MACINFO_start_file entry. */ htab_up include_hash (htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + htab_eq_pointer, NULL, xcalloc, + xfree)); mac_ptr = section->buffer + offset; slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT); *slot = (void *) mac_ptr; diff --git a/gdb/dwarf2/macro.h b/gdb/dwarf2/macro.h index d92994f..dc92c18 100644 --- a/gdb/dwarf2/macro.h +++ b/gdb/dwarf2/macro.h @@ -26,8 +26,7 @@ extern void dwarf_decode_macros (dwarf2_per_objfile *per_objfile, buildsym_compunit *builder, const dwarf2_section_info *section, const struct line_header *lh, - unsigned int offset_size, - unsigned int offset, + unsigned int offset_size, unsigned int offset, dwarf2_section_info *str_section, dwarf2_section_info *str_offsets_section, gdb::optional<ULONGEST> str_offsets_base, diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h index 29c7291..ad4aab3 100644 --- a/gdb/dwarf2/mapped-index.h +++ b/gdb/dwarf2/mapped-index.h @@ -64,10 +64,7 @@ struct dwarf_scanner_base /* An ad hoc version check. This is needed for .gdb_index to check whether a version 8 or above index is in use. Returns true if the index is usable, false otherwise. */ - virtual bool version_check () const - { - return true; - } + virtual bool version_check () const { return true; } /* This is called when writing an index. For a cooked index, it will return 'this' as a cooked index. For other forms, it will @@ -94,8 +91,9 @@ struct mapped_index_base : public dwarf_scanner_base virtual size_t symbol_name_count () const = 0; /* Get the name of the symbol at IDX in the symbol table. */ - virtual const char *symbol_name_at - (offset_type idx, dwarf2_per_objfile *per_objfile) const = 0; + virtual const char *symbol_name_at (offset_type idx, + dwarf2_per_objfile *per_objfile) const + = 0; /* Return whether the name at IDX in the symbol table should be ignored. */ @@ -113,13 +111,13 @@ struct mapped_index_base : public dwarf_scanner_base vector. */ std::pair<std::vector<name_component>::const_iterator, std::vector<name_component>::const_iterator> - find_name_components_bounds (const lookup_name_info &ln_no_params, - enum language lang, - dwarf2_per_objfile *per_objfile) const; + find_name_components_bounds (const lookup_name_info &ln_no_params, + enum language lang, + dwarf2_per_objfile *per_objfile) const; cooked_index *index_for_writing () override { - error (_("Cannot use an index to create the index")); + error (_ ("Cannot use an index to create the index")); } }; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index fb5aa7b..d5e274e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -52,7 +52,7 @@ #include "dwarf2.h" #include "demangle.h" #include "gdb-demangle.h" -#include "filenames.h" /* for DOSish file names */ +#include "filenames.h" /* for DOSish file names */ #include "language.h" #include "complaints.h" #include "dwarf2/expr.h" @@ -101,13 +101,13 @@ static unsigned int dwarf_read_debug = 0; /* Print a "dwarf-read" debug statement if dwarf_read_debug is >= 1. */ -#define dwarf_read_debug_printf(fmt, ...) \ +#define dwarf_read_debug_printf(fmt, ...) \ debug_prefixed_printf_cond (dwarf_read_debug >= 1, "dwarf-read", fmt, \ ##__VA_ARGS__) /* Print a "dwarf-read" debug statement if dwarf_read_debug is >= 2. */ -#define dwarf_read_debug_printf_v(fmt, ...) \ +#define dwarf_read_debug_printf_v(fmt, ...) \ debug_prefixed_printf_cond (dwarf_read_debug >= 2, "dwarf-read", fmt, \ ##__VA_ARGS__) @@ -125,7 +125,7 @@ static bool use_deprecated_index_sections = false; /* This is used to store the data that is always per objfile. */ static const registry<objfile>::key<dwarf2_per_objfile> - dwarf2_objfile_data_key; + dwarf2_objfile_data_key; /* These are used to store the dwarf2_per_bfd objects. @@ -165,6 +165,7 @@ static int dwarf2_loclist_block_index; class offset_view { public: + offset_view () = default; explicit offset_view (gdb::array_view<const gdb_byte> bytes) @@ -176,24 +177,18 @@ public: offset_type operator[] (size_t index) const { const gdb_byte *bytes = &m_bytes[index * sizeof (offset_type)]; - return (offset_type) extract_unsigned_integer (bytes, - sizeof (offset_type), + return (offset_type) extract_unsigned_integer (bytes, sizeof (offset_type), BFD_ENDIAN_LITTLE); } /* Return the number of offset_types in this array. */ - size_t size () const - { - return m_bytes.size () / sizeof (offset_type); - } + size_t size () const { return m_bytes.size () / sizeof (offset_type); } /* Return true if this view is empty. */ - bool empty () const - { - return m_bytes.empty (); - } + bool empty () const { return m_bytes.empty (); } private: + /* The underlying bytes. */ gdb::array_view<const gdb_byte> m_bytes; }; @@ -230,28 +225,26 @@ struct mapped_index final : public mapped_index_base bool symbol_name_slot_invalid (offset_type idx) const override { - return (symbol_name_index (idx) == 0 - && symbol_vec_index (idx) == 0); + return (symbol_name_index (idx) == 0 && symbol_vec_index (idx) == 0); } /* Convenience method to get at the name of the symbol at IDX in the symbol table. */ - const char *symbol_name_at - (offset_type idx, dwarf2_per_objfile *per_objfile) const override + const char *symbol_name_at (offset_type idx, + dwarf2_per_objfile *per_objfile) const override { return (const char *) (this->constant_pool.data () + symbol_name_index (idx)); } size_t symbol_name_count () const override - { return this->symbol_table.size () / 2; } + { + return this->symbol_table.size () / 2; + } quick_symbol_functions_up make_quick_functions () const override; - bool version_check () const override - { - return version >= 8; - } + bool version_check () const override { return version >= 8; } }; /* A description of the mapped .debug_names. @@ -273,6 +266,7 @@ struct mapped_debug_names final : public mapped_index_base struct index_val { ULONGEST dwarf_tag; + struct attr { /* Attribute name DW_IDX_*. */ @@ -284,23 +278,25 @@ struct mapped_debug_names final : public mapped_index_base /* Value if FORM is DW_FORM_implicit_const. */ LONGEST implicit_const; }; + std::vector<attr> attr_vec; }; std::unordered_map<ULONGEST, index_val> abbrev_map; - const char *namei_to_name - (uint32_t namei, dwarf2_per_objfile *per_objfile) const; + const char *namei_to_name (uint32_t namei, + dwarf2_per_objfile *per_objfile) const; /* Implementation of the mapped_index_base virtual interface, for the name_components cache. */ - const char *symbol_name_at - (offset_type idx, dwarf2_per_objfile *per_objfile) const override - { return namei_to_name (idx, per_objfile); } + const char *symbol_name_at (offset_type idx, + dwarf2_per_objfile *per_objfile) const override + { + return namei_to_name (idx, per_objfile); + } - size_t symbol_name_count () const override - { return this->name_count; } + size_t symbol_name_count () const override { return this->name_count; } quick_symbol_functions_up make_quick_functions () const override; }; @@ -318,29 +314,27 @@ get_dwarf2_per_objfile (struct objfile *objfile) /* Note that if the debugging section has been compressed, it might have a name like .zdebug_info. */ -const struct dwarf2_debug_sections dwarf2_elf_names = -{ - { ".debug_info", ".zdebug_info" }, - { ".debug_abbrev", ".zdebug_abbrev" }, - { ".debug_line", ".zdebug_line" }, - { ".debug_loc", ".zdebug_loc" }, - { ".debug_loclists", ".zdebug_loclists" }, - { ".debug_macinfo", ".zdebug_macinfo" }, - { ".debug_macro", ".zdebug_macro" }, - { ".debug_str", ".zdebug_str" }, - { ".debug_str_offsets", ".zdebug_str_offsets" }, - { ".debug_line_str", ".zdebug_line_str" }, - { ".debug_ranges", ".zdebug_ranges" }, - { ".debug_rnglists", ".zdebug_rnglists" }, - { ".debug_types", ".zdebug_types" }, - { ".debug_addr", ".zdebug_addr" }, - { ".debug_frame", ".zdebug_frame" }, - { ".eh_frame", NULL }, - { ".gdb_index", ".zgdb_index" }, - { ".debug_names", ".zdebug_names" }, - { ".debug_aranges", ".zdebug_aranges" }, - 23 -}; +const struct dwarf2_debug_sections dwarf2_elf_names + = { { ".debug_info", ".zdebug_info" }, + { ".debug_abbrev", ".zdebug_abbrev" }, + { ".debug_line", ".zdebug_line" }, + { ".debug_loc", ".zdebug_loc" }, + { ".debug_loclists", ".zdebug_loclists" }, + { ".debug_macinfo", ".zdebug_macinfo" }, + { ".debug_macro", ".zdebug_macro" }, + { ".debug_str", ".zdebug_str" }, + { ".debug_str_offsets", ".zdebug_str_offsets" }, + { ".debug_line_str", ".zdebug_line_str" }, + { ".debug_ranges", ".zdebug_ranges" }, + { ".debug_rnglists", ".zdebug_rnglists" }, + { ".debug_types", ".zdebug_types" }, + { ".debug_addr", ".zdebug_addr" }, + { ".debug_frame", ".zdebug_frame" }, + { ".eh_frame", NULL }, + { ".gdb_index", ".zgdb_index" }, + { ".debug_names", ".zdebug_names" }, + { ".debug_aranges", ".zdebug_aranges" }, + 23 }; /* List of DWO/DWP sections. */ @@ -359,9 +353,7 @@ static const struct dwop_section_names struct dwarf2_section_names types_dwo; struct dwarf2_section_names cu_index; struct dwarf2_section_names tu_index; -} -dwop_section_names = -{ +} dwop_section_names = { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo" }, { ".debug_info.dwo", ".zdebug_info.dwo" }, { ".debug_line.dwo", ".zdebug_line.dwo" }, @@ -423,7 +415,9 @@ struct stmt_list_hash struct type_unit_group { /* The data used to construct the hash key. */ - struct stmt_list_hash hash {}; + struct stmt_list_hash hash + { + }; }; /* These sections are what may appear in a (real or virtual) DWO file. */ @@ -508,7 +502,9 @@ struct dwo_file /* The sections that make up this DWO file. Remember that for virtual DWO files in DWP V2 or DWP V5, these are virtual sections (for lack of a better name). */ - struct dwo_sections sections {}; + struct dwo_sections sections + { + }; /* The CUs in the file. Each element is a struct dwo_unit. Multiple CUs per DWO are supported as @@ -610,38 +606,41 @@ struct dwp_hash_table uint32_t version, nr_columns; uint32_t nr_units, nr_slots; const gdb_byte *hash_table, *unit_table; + union { struct { const gdb_byte *indices; } v1; + struct { /* This is indexed by column number and gives the id of the section in that column. */ -#define MAX_NR_V2_DWO_SECTIONS \ - (1 /* .debug_info or .debug_types */ \ - + 1 /* .debug_abbrev */ \ - + 1 /* .debug_line */ \ - + 1 /* .debug_loc */ \ - + 1 /* .debug_str_offsets */ \ +#define MAX_NR_V2_DWO_SECTIONS \ + (1 /* .debug_info or .debug_types */ \ + + 1 /* .debug_abbrev */ \ + + 1 /* .debug_line */ \ + + 1 /* .debug_loc */ \ + + 1 /* .debug_str_offsets */ \ + 1 /* .debug_macro or .debug_macinfo */) int section_ids[MAX_NR_V2_DWO_SECTIONS]; const gdb_byte *offsets; const gdb_byte *sizes; } v2; + struct { /* This is indexed by column number and gives the id of the section in that column. */ -#define MAX_NR_V5_DWO_SECTIONS \ - (1 /* .debug_info */ \ - + 1 /* .debug_abbrev */ \ - + 1 /* .debug_line */ \ - + 1 /* .debug_loclists */ \ +#define MAX_NR_V5_DWO_SECTIONS \ + (1 /* .debug_info */ \ + + 1 /* .debug_abbrev */ \ + + 1 /* .debug_line */ \ + + 1 /* .debug_loclists */ \ + 1 /* .debug_str_offsets */ \ - + 1 /* .debug_macro */ \ + + 1 /* .debug_macro */ \ + 1 /* .debug_rnglists */) int section_ids[MAX_NR_V5_DWO_SECTIONS]; const gdb_byte *offsets; @@ -670,7 +669,9 @@ struct dwp_file gdb_bfd_ref_ptr dbfd; /* Section info for this file. */ - struct dwp_sections sections {}; + struct dwp_sections sections + { + }; /* Table of CUs in the file. */ const struct dwp_hash_table *cus = nullptr; @@ -725,12 +726,9 @@ class cutu_reader : public die_reader_specs { public: - cutu_reader (dwarf2_per_cu_data *this_cu, - dwarf2_per_objfile *per_objfile, - struct abbrev_table *abbrev_table, - dwarf2_cu *existing_cu, - bool skip_partial, - abbrev_cache *cache = nullptr); + cutu_reader (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, + struct abbrev_table *abbrev_table, dwarf2_cu *existing_cu, + bool skip_partial, abbrev_cache *cache = nullptr); explicit cutu_reader (struct dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, @@ -757,6 +755,7 @@ public: } private: + void init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, dwarf2_cu *existing_cu); @@ -822,7 +821,10 @@ struct nextfield reference. We track the section offset of each field to make this link. */ sect_offset offset; - struct field field {}; + + struct field field + { + }; }; struct fnfieldlist @@ -864,10 +866,7 @@ struct field_info std::vector<variant_part_builder> variant_parts; /* Return the total number of fields (including baseclasses). */ - int nfields () const - { - return fields.size () + baseclasses.size (); - } + int nfields () const { return fields.size () + baseclasses.size (); } }; /* Loaded secondary compilation units are kept in memory until they @@ -876,15 +875,17 @@ struct field_info sizes of up to at least twenty will improve startup time for typical inter-CU-reference binaries, at an obvious memory cost. */ static int dwarf_max_cache_age = 5; + static void show_dwarf_max_cache_age (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("The upper bound on the age of cached " - "DWARF compilation units is %s.\n"), + gdb_printf (file, + _ ("The upper bound on the age of cached " + "DWARF compilation units is %s.\n"), value); } - + /* local function prototypes */ static void dwarf2_find_base_address (struct die_info *die, @@ -896,8 +897,7 @@ static void build_type_psymtabs_reader (cutu_reader *reader, static void dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile); -static void var_decode_location (struct attribute *attr, - struct symbol *sym, +static void var_decode_location (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu); static unsigned int peek_abbrev_code (bfd *, const gdb_byte *); @@ -910,17 +910,20 @@ static const gdb_byte *read_attribute (const struct die_reader_specs *, static void read_attribute_reprocess (const struct die_reader_specs *reader, struct attribute *attr, dwarf_tag tag); -static CORE_ADDR read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index); +static CORE_ADDR read_addr_index (struct dwarf2_cu *cu, + unsigned int addr_index); static sect_offset read_abbrev_offset (dwarf2_per_objfile *per_objfile, dwarf2_section_info *, sect_offset); -static const char *read_indirect_string - (dwarf2_per_objfile *per_objfile, bfd *, const gdb_byte *, - const struct comp_unit_head *, unsigned int *); +static const char *read_indirect_string (dwarf2_per_objfile *per_objfile, + bfd *, const gdb_byte *, + const struct comp_unit_head *, + unsigned int *); -static const char *read_indirect_string_at_offset - (dwarf2_per_objfile *per_objfile, LONGEST str_offset); +static const char * +read_indirect_string_at_offset (dwarf2_per_objfile *per_objfile, + LONGEST str_offset); static CORE_ADDR read_addr_index_from_leb128 (struct dwarf2_cu *, const gdb_byte *, @@ -938,7 +941,8 @@ static struct attribute *dwarf2_attr (struct die_info *, unsigned int, static const char *dwarf2_string_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu); -static const char *dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu); +static const char *dwarf2_dwo_name (struct die_info *die, + struct dwarf2_cu *cu); static int dwarf2_flag_true_p (struct die_info *die, unsigned name, struct dwarf2_cu *cu); @@ -952,8 +956,7 @@ static line_header_up dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu, const char *comp_dir); -static void dwarf_decode_lines (struct line_header *, - struct dwarf2_cu *, +static void dwarf_decode_lines (struct line_header *, struct dwarf2_cu *, CORE_ADDR, int decode_mapping); static void dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe, @@ -966,8 +969,7 @@ static void dwarf2_const_value (const struct attribute *, struct symbol *, struct dwarf2_cu *); static void dwarf2_const_value_attr (const struct attribute *attr, - struct type *type, - const char *name, + struct type *type, const char *name, struct obstack *obstack, struct dwarf2_cu *cu, LONGEST *value, const gdb_byte **bytes, @@ -989,7 +991,8 @@ static void set_descriptive_type (struct type *, struct die_info *, static struct type *die_containing_type (struct die_info *, struct dwarf2_cu *); -static struct type *lookup_die_type (struct die_info *, const struct attribute *, +static struct type *lookup_die_type (struct die_info *, + const struct attribute *, struct dwarf2_cu *); static struct type *read_type_die (struct die_info *, struct dwarf2_cu *); @@ -1018,8 +1021,8 @@ static void read_variable (struct die_info *die, struct dwarf2_cu *cu); static struct dwarf2_section_info *cu_debug_loc_section (struct dwarf2_cu *cu); /* Return the .debug_rnglists section to use for cu. */ -static struct dwarf2_section_info *cu_debug_rnglists_section - (struct dwarf2_cu *cu, dwarf_tag tag); +static struct dwarf2_section_info * +cu_debug_rnglists_section (struct dwarf2_cu *cu, dwarf_tag tag); /* How dwarf2_get_pc_bounds constructed its *LOWPC and *HIGHPC return values. Keep the items ordered with increasing constraints compliance. */ @@ -1041,12 +1044,10 @@ enum pc_bounds_kind static enum pc_bounds_kind dwarf2_get_pc_bounds (struct die_info *, CORE_ADDR *, CORE_ADDR *, - struct dwarf2_cu *, - addrmap *, + struct dwarf2_cu *, addrmap *, void *); -static void get_scope_pc_bounds (struct die_info *, - CORE_ADDR *, CORE_ADDR *, +static void get_scope_pc_bounds (struct die_info *, CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *); static void dwarf2_record_block_ranges (struct die_info *, struct block *, @@ -1055,12 +1056,11 @@ static void dwarf2_record_block_ranges (struct die_info *, struct block *, static void dwarf2_add_field (struct field_info *, struct die_info *, struct dwarf2_cu *); -static void dwarf2_attach_fields_to_type (struct field_info *, - struct type *, struct dwarf2_cu *); +static void dwarf2_attach_fields_to_type (struct field_info *, struct type *, + struct dwarf2_cu *); -static void dwarf2_add_member_fn (struct field_info *, - struct die_info *, struct type *, - struct dwarf2_cu *); +static void dwarf2_add_member_fn (struct field_info *, struct die_info *, + struct type *, struct dwarf2_cu *); static void dwarf2_attach_fn_fields_to_type (struct field_info *, struct type *, @@ -1083,8 +1083,8 @@ static bool read_alias (struct die_info *die, struct dwarf2_cu *cu); static struct type *read_module_type (struct die_info *die, struct dwarf2_cu *cu); -static const char *namespace_name (struct die_info *die, - int *is_anonymous, struct dwarf2_cu *); +static const char *namespace_name (struct die_info *die, int *is_anonymous, + struct dwarf2_cu *); static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *); @@ -1094,9 +1094,9 @@ static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *, static enum dwarf_array_dim_ordering read_array_order (struct die_info *, struct dwarf2_cu *); -static struct die_info *read_die_and_siblings_1 - (const struct die_reader_specs *, const gdb_byte *, const gdb_byte **, - struct die_info *); +static struct die_info * +read_die_and_siblings_1 (const struct die_reader_specs *, const gdb_byte *, + const gdb_byte **, struct die_info *); static struct die_info *read_die_and_siblings (const struct die_reader_specs *, const gdb_byte *info_ptr, @@ -1117,8 +1117,7 @@ static const char *dwarf2_canonicalize_name (const char *, struct dwarf2_cu *, static const char *dwarf2_name (struct die_info *die, struct dwarf2_cu *); -static const char *dwarf2_full_name (const char *name, - struct die_info *die, +static const char *dwarf2_full_name (const char *name, struct die_info *die, struct dwarf2_cu *cu); static const char *dwarf2_physname (const char *name, struct die_info *die, @@ -1136,8 +1135,7 @@ static void dump_die_1 (struct ui_file *, int level, int max_level, /*static*/ void dump_die (struct die_info *, int max_level); -static void store_in_ref_table (struct die_info *, - struct dwarf2_cu *); +static void store_in_ref_table (struct die_info *, struct dwarf2_cu *); static struct die_info *follow_die_ref_or_sig (struct die_info *, const struct attribute *, @@ -1182,17 +1180,15 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, static void dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, - struct dwarf2_cu *cu, - int is_block); + struct dwarf2_cu *cu, int is_block); static const gdb_byte *skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, const struct abbrev_info *abbrev, bool do_skip_children = true); -static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit - (sect_offset sect_off, unsigned int offset_in_dwz, - dwarf2_per_bfd *per_bfd); +static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit ( + sect_offset sect_off, unsigned int offset_in_dwz, dwarf2_per_bfd *per_bfd); static void prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, @@ -1205,8 +1201,7 @@ static void create_all_units (dwarf2_per_objfile *per_objfile); static void load_full_comp_unit (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, - dwarf2_cu *existing_cu, - bool skip_partial, + dwarf2_cu *existing_cu, bool skip_partial, enum language pretend_language); static void process_full_comp_unit (dwarf2_cu *cu, @@ -1235,6 +1230,7 @@ static void process_queue (dwarf2_per_objfile *per_objfile); class dwarf2_queue_guard { public: + explicit dwarf2_queue_guard (dwarf2_per_objfile *per_objfile) : m_per_objfile (per_objfile) { @@ -1255,6 +1251,7 @@ public: DISABLE_COPY_AND_ASSIGN (dwarf2_queue_guard); private: + dwarf2_per_objfile *m_per_objfile; }; @@ -1280,31 +1277,33 @@ dwarf2_per_cu_data_deleter::operator() (dwarf2_per_cu_data *data) delete data; } -static file_and_directory &find_file_and_directory - (struct die_info *die, struct dwarf2_cu *cu); +static file_and_directory &find_file_and_directory (struct die_info *die, + struct dwarf2_cu *cu); -static const char *compute_include_file_name - (const struct line_header *lh, - const file_entry &fe, - const file_and_directory &cu_info, - std::string &name_holder); +static const char * +compute_include_file_name (const struct line_header *lh, const file_entry &fe, + const file_and_directory &cu_info, + std::string &name_holder); static htab_up allocate_signatured_type_table (); static htab_up allocate_dwo_unit_table (); -static struct dwo_unit *lookup_dwo_unit_in_dwp - (dwarf2_per_objfile *per_objfile, struct dwp_file *dwp_file, - const char *comp_dir, ULONGEST signature, int is_debug_types); +static struct dwo_unit * +lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, + struct dwp_file *dwp_file, const char *comp_dir, + ULONGEST signature, int is_debug_types); static struct dwp_file *get_dwp_file (dwarf2_per_objfile *per_objfile); -static struct dwo_unit *lookup_dwo_comp_unit - (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, - ULONGEST signature); +static struct dwo_unit *lookup_dwo_comp_unit (dwarf2_cu *cu, + const char *dwo_name, + const char *comp_dir, + ULONGEST signature); -static struct dwo_unit *lookup_dwo_type_unit - (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir); +static struct dwo_unit *lookup_dwo_type_unit (dwarf2_cu *cu, + const char *dwo_name, + const char *comp_dir); static void queue_and_load_all_dwo_tus (dwarf2_cu *cu); @@ -1315,41 +1314,41 @@ typedef std::unique_ptr<struct dwo_file> dwo_file_up; static void process_cu_includes (dwarf2_per_objfile *per_objfile); static void check_producer (struct dwarf2_cu *cu); - + /* Various complaints about symbol reading that don't abort the process. */ static void dwarf2_debug_line_missing_file_complaint (void) { - complaint (_(".debug_line section has line data without a file")); + complaint (_ (".debug_line section has line data without a file")); } static void dwarf2_debug_line_missing_end_sequence_complaint (void) { - complaint (_(".debug_line section has line " - "program sequence without an end")); + complaint (_ (".debug_line section has line " + "program sequence without an end")); } static void dwarf2_complex_location_expr_complaint (void) { - complaint (_("location expression too complex")); + complaint (_ ("location expression too complex")); } static void dwarf2_const_value_length_mismatch_complaint (const char *arg1, int arg2, int arg3) { - complaint (_("const value length mismatch for '%s', got %d, expected %d"), + complaint (_ ("const value length mismatch for '%s', got %d, expected %d"), arg1, arg2, arg3); } static void dwarf2_invalid_attrib_class_complaint (const char *arg1, const char *arg2) { - complaint (_("invalid attribute class or form for '%s' in '%s'"), - arg1, arg2); + complaint (_ ("invalid attribute class or form for '%s' in '%s'"), arg1, + arg2); } /* Hash function for line_header_hash. */ @@ -1382,8 +1381,6 @@ line_header_eq_voidp (const void *item_lhs, const void *item_rhs) && ofs_lhs->offset_in_dwz == ofs_rhs->offset_in_dwz); } - - /* An iterator for all_units that is based on index. This approach makes it possible to iterate over all_units safely, when some caller in the loop may add new units. */ @@ -1414,7 +1411,6 @@ public: return m_index == other.m_index; } - bool operator!= (const all_units_iterator &other) const { return m_index != other.m_index; @@ -1436,15 +1432,9 @@ public: { } - all_units_iterator begin () - { - return all_units_iterator (m_per_bfd, true); - } + all_units_iterator begin () { return all_units_iterator (m_per_bfd, true); } - all_units_iterator end () - { - return all_units_iterator (m_per_bfd, false); - } + all_units_iterator end () { return all_units_iterator (m_per_bfd, false); } private: @@ -1498,10 +1488,7 @@ public: { } - ~free_cached_comp_units () - { - m_per_objfile->remove_all_cus (); - } + ~free_cached_comp_units () { m_per_objfile->remove_all_cus (); } DISABLE_COPY_AND_ASSIGN (free_cached_comp_units); @@ -1551,8 +1538,7 @@ dwarf2_per_objfile::set_symtab (const dwarf2_per_cu_data *per_cu, bool dwarf2_has_info (struct objfile *objfile, - const struct dwarf2_debug_sections *names, - bool can_copy) + const struct dwarf2_debug_sections *names, bool can_copy) { if (objfile->flags & OBJF_READNEVER) return false; @@ -1578,8 +1564,8 @@ dwarf2_has_info (struct objfile *objfile, if (per_bfd == nullptr) { /* No, create it now. */ - per_bfd = new dwarf2_per_bfd (objfile->obfd.get (), names, - can_copy); + per_bfd + = new dwarf2_per_bfd (objfile->obfd.get (), names, can_copy); dwarf2_per_bfd_bfd_data_key.set (objfile->obfd.get (), per_bfd); } } @@ -1590,7 +1576,8 @@ dwarf2_has_info (struct objfile *objfile, dwarf2_per_bfd_objfile_data_key.set (objfile, per_bfd); } - per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd); + per_objfile + = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd); } return (!per_objfile->per_bfd->info.is_virtual @@ -1614,8 +1601,8 @@ dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp, > bfd_get_file_size (abfd)) { bfd_size_type size = elf_section_data (sectp)->this_hdr.sh_size; - warning (_("Discarding section %s which has a section size (%s" - ") larger than the file size [in module %s]"), + warning (_ ("Discarding section %s which has a section size (%s" + ") larger than the file size [in module %s]"), bfd_section_name (sectp), phex_nz (size, sizeof (size)), bfd_get_filename (abfd)); } @@ -1730,9 +1717,8 @@ dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp, void dwarf2_get_section_info (struct objfile *objfile, - enum dwarf2_section_enum sect, - asection **sectp, const gdb_byte **bufp, - bfd_size_type *sizep) + enum dwarf2_section_enum sect, asection **sectp, + const gdb_byte **bufp, bfd_size_type *sizep) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); struct dwarf2_section_info *info; @@ -1784,7 +1770,6 @@ dwarf2_per_bfd::map_info_sections (struct objfile *objfile) section.read (objfile); } - /* DWARF quick_symbol_functions support. */ /* TUs can share .debug_line entries, and there can be a lot more TUs than @@ -1841,13 +1826,13 @@ struct dwarf2_base_index_functions : public quick_symbol_functions virtual dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, CORE_ADDR adjusted_pc); - struct compunit_symtab *find_pc_sect_compunit_symtab - (struct objfile *objfile, struct bound_minimal_symbol msymbol, - CORE_ADDR pc, struct obj_section *section, int warn_if_readin) - override final; + struct compunit_symtab *find_pc_sect_compunit_symtab ( + struct objfile *objfile, struct bound_minimal_symbol msymbol, CORE_ADDR pc, + struct obj_section *section, int warn_if_readin) override final; - struct compunit_symtab *find_compunit_symtab_by_address - (struct objfile *objfile, CORE_ADDR address) override + struct compunit_symtab * + find_compunit_symtab_by_address (struct objfile *objfile, + CORE_ADDR address) override { return nullptr; } @@ -1864,28 +1849,23 @@ struct dwarf2_base_index_functions : public quick_symbol_functions struct readnow_functions : public dwarf2_base_index_functions { - void dump (struct objfile *objfile) override - { - } + void dump (struct objfile *objfile) override {} - void expand_matching_symbols - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) override + void expand_matching_symbols (struct objfile *, + const lookup_name_info &lookup_name, + domain_enum domain, int global, + symbol_compare_ftype *ordered_compare) override { } - bool expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) override + bool expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, + enum search_domain kind) override { return true; } @@ -1895,44 +1875,36 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions { void dump (struct objfile *objfile) override; - void expand_matching_symbols - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) override; - - bool expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) override; + void expand_matching_symbols ( + struct objfile *, const lookup_name_info &lookup_name, domain_enum domain, + int global, symbol_compare_ftype *ordered_compare) override; + + bool expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, + enum search_domain kind) override; }; struct dwarf2_debug_names_index : public dwarf2_base_index_functions { void dump (struct objfile *objfile) override; - void expand_matching_symbols - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) override; - - bool expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) override; + void expand_matching_symbols ( + struct objfile *, const lookup_name_info &lookup_name, domain_enum domain, + int global, symbol_compare_ftype *ordered_compare) override; + + bool expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, + enum search_domain kind) override; }; quick_symbol_functions_up @@ -2002,9 +1974,9 @@ eq_file_name_entry (const void *a, const void *b) static htab_up create_quick_file_names_table (unsigned int nr_initial_entries) { - return htab_up (htab_create_alloc (nr_initial_entries, - hash_file_name_entry, eq_file_name_entry, - nullptr, xcalloc, xfree)); + return htab_up (htab_create_alloc (nr_initial_entries, hash_file_name_entry, + eq_file_name_entry, nullptr, xcalloc, + xfree)); } /* Read in CU (dwarf2_cu object) for PER_CU in the context of PER_OBJFILE. This @@ -2023,7 +1995,7 @@ load_cu (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, dwarf2_cu *cu = per_objfile->get_cu (per_cu); if (cu == nullptr) - return nullptr; /* Dummy CU. */ + return nullptr; /* Dummy CU. */ dwarf2_find_base_address (cu->dies, cu); @@ -2050,9 +2022,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu, /* If we just loaded a CU from a DWO, and we're working with an index that may badly handle TUs, load all the TUs in that DWO as well. http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */ - if (!per_cu->is_debug_types - && cu != NULL - && cu->dwo_unit != NULL + if (!per_cu->is_debug_types && cu != NULL && cu->dwo_unit != NULL && per_objfile->per_bfd->index_table != NULL && !per_objfile->per_bfd->index_table->version_check () /* DWP files aren't supported yet. */ @@ -2075,8 +2045,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu, static struct compunit_symtab * dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - bool skip_partial) + dwarf2_per_objfile *per_objfile, bool skip_partial) { if (!per_objfile->symtab_set_p (per_cu)) { @@ -2118,8 +2087,7 @@ dwarf2_per_bfd::allocate_signatured_type (ULONGEST signature) static dwarf2_per_cu_data_up create_cu_from_index_list (dwarf2_per_bfd *per_bfd, - struct dwarf2_section_info *section, - int is_dwz, + struct dwarf2_section_info *section, int is_dwz, sect_offset sect_off, ULONGEST length) { dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (); @@ -2134,18 +2102,19 @@ create_cu_from_index_list (dwarf2_per_bfd *per_bfd, CUs. */ static void -create_cus_from_index_list (dwarf2_per_bfd *per_bfd, - const gdb_byte *cu_list, offset_type n_elements, - struct dwarf2_section_info *section, - int is_dwz) +create_cus_from_index_list (dwarf2_per_bfd *per_bfd, const gdb_byte *cu_list, + offset_type n_elements, + struct dwarf2_section_info *section, int is_dwz) { for (offset_type i = 0; i < n_elements; i += 2) { gdb_static_assert (sizeof (ULONGEST) >= 8); sect_offset sect_off - = (sect_offset) extract_unsigned_integer (cu_list, 8, BFD_ENDIAN_LITTLE); - ULONGEST length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE); + = (sect_offset) extract_unsigned_integer (cu_list, 8, + BFD_ENDIAN_LITTLE); + ULONGEST length + = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE); cu_list += 2 * 8; dwarf2_per_cu_data_up per_cu @@ -2159,9 +2128,9 @@ create_cus_from_index_list (dwarf2_per_bfd *per_bfd, the CU objects for PER_BFD. */ static void -create_cus_from_index (dwarf2_per_bfd *per_bfd, - const gdb_byte *cu_list, offset_type cu_list_elements, - const gdb_byte *dwz_list, offset_type dwz_elements) +create_cus_from_index (dwarf2_per_bfd *per_bfd, const gdb_byte *cu_list, + offset_type cu_list_elements, const gdb_byte *dwz_list, + offset_type dwz_elements) { gdb_assert (per_bfd->all_units.empty ()); per_bfd->all_units.reserve ((cu_list_elements + dwz_elements) / 2); @@ -2173,16 +2142,16 @@ create_cus_from_index (dwarf2_per_bfd *per_bfd, return; dwz_file *dwz = dwarf2_get_dwz_file (per_bfd); - create_cus_from_index_list (per_bfd, dwz_list, dwz_elements, - &dwz->info, 1); + create_cus_from_index_list (per_bfd, dwz_list, dwz_elements, &dwz->info, 1); } /* Create the signatured type hash table from the index. */ static void -create_signatured_type_table_from_index - (dwarf2_per_bfd *per_bfd, struct dwarf2_section_info *section, - const gdb_byte *bytes, offset_type elements) +create_signatured_type_table_from_index (dwarf2_per_bfd *per_bfd, + struct dwarf2_section_info *section, + const gdb_byte *bytes, + offset_type elements) { htab_up sig_types_hash = allocate_signatured_type_table (); @@ -2219,11 +2188,10 @@ create_signatured_type_table_from_index /* Create the signatured type hash table from .debug_names. */ static void -create_signatured_type_table_from_debug_names - (dwarf2_per_objfile *per_objfile, - const mapped_debug_names &map, - struct dwarf2_section_info *section, - struct dwarf2_section_info *abbrev_section) +create_signatured_type_table_from_debug_names ( + dwarf2_per_objfile *per_objfile, const mapped_debug_names &map, + struct dwarf2_section_info *section, + struct dwarf2_section_info *abbrev_section) { struct objfile *objfile = per_objfile->objfile; @@ -2237,20 +2205,19 @@ create_signatured_type_table_from_debug_names signatured_type_up sig_type; void **slot; - sect_offset sect_off - = (sect_offset) (extract_unsigned_integer - (map.tu_table_reordered + i * map.offset_size, - map.offset_size, - map.dwarf5_byte_order)); + sect_offset sect_off = (sect_offset) (extract_unsigned_integer ( + map.tu_table_reordered + i * map.offset_size, map.offset_size, + map.dwarf5_byte_order)); comp_unit_head cu_header; read_and_check_comp_unit_head (per_objfile, &cu_header, section, abbrev_section, - section->buffer + to_underlying (sect_off), + section->buffer + + to_underlying (sect_off), rcuh_kind::TYPE); - sig_type = per_objfile->per_bfd->allocate_signatured_type - (cu_header.signature); + sig_type + = per_objfile->per_bfd->allocate_signatured_type (cu_header.signature); sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu; sig_type->section = section; sig_type->sect_off = sect_off; @@ -2296,14 +2263,15 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, if (lo > hi) { - complaint (_(".gdb_index address table has invalid range (%s - %s)"), - hex_string (lo), hex_string (hi)); + complaint ( + _ (".gdb_index address table has invalid range (%s - %s)"), + hex_string (lo), hex_string (hi)); continue; } if (cu_index >= per_bfd->all_units.size ()) { - complaint (_(".gdb_index address table has invalid CU number %u"), + complaint (_ (".gdb_index address table has invalid CU number %u"), (unsigned) cu_index); continue; } @@ -2332,8 +2300,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, const CORE_ADDR baseaddr = objfile->text_section_offset (); dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; - std::unordered_map<sect_offset, - dwarf2_per_cu_data *, + std::unordered_map<sect_offset, dwarf2_per_cu_data *, gdb::hash_enum<sect_offset>> debug_info_offset_to_per_cu; for (const auto &per_cu : per_bfd->all_units) @@ -2366,8 +2333,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, const gdb_byte *const entry_addr = addr; unsigned int bytes_read; - const LONGEST entry_length = read_initial_length (abfd, addr, - &bytes_read); + const LONGEST entry_length + = read_initial_length (abfd, addr, &bytes_read); addr += bytes_read; const gdb_byte *const entry_end = addr + entry_length; @@ -2375,9 +2342,9 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, const uint8_t offset_size = dwarf5_is_dwarf64 ? 8 : 4; if (addr + entry_length > section->buffer + section->size) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "length %s exceeds section length %s, " - "ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "length %s exceeds section length %s, " + "ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), plongest (bytes_read + entry_length), @@ -2390,8 +2357,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, addr += 2; if (version != 2) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "has unsupported version %d, ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "has unsupported version %d, ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), version); return false; @@ -2404,9 +2371,9 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, = debug_info_offset_to_per_cu.find (sect_offset (debug_info_offset)); if (per_cu_it == debug_info_offset_to_per_cu.cend ()) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "debug_info_offset %s does not exists, " - "ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "debug_info_offset %s does not exists, " + "ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), pulongest (debug_info_offset)); @@ -2416,8 +2383,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, = debug_info_offset_seen.insert (sect_offset (debug_info_offset)); if (!insertpair.second) { - warning (_("Section .debug_aranges in %s has duplicate " - "debug_info_offset %s, ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s has duplicate " + "debug_info_offset %s, ignoring .debug_aranges."), objfile_name (objfile), sect_offset_str (sect_offset (debug_info_offset))); return false; @@ -2427,8 +2394,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, const uint8_t address_size = *addr++; if (address_size < 1 || address_size > 8) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "address_size %u is invalid, ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "address_size %u is invalid, ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), address_size); return false; @@ -2437,9 +2404,9 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, const uint8_t segment_selector_size = *addr++; if (segment_selector_size != 0) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "segment_selector_size %u is not supported, " - "ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "segment_selector_size %u is not supported, " + "ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), segment_selector_size); @@ -2459,18 +2426,18 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, { if (addr + 2 * address_size > entry_end) { - warning (_("Section .debug_aranges in %s entry at offset %s " - "address list is not properly terminated, " - "ignoring .debug_aranges."), + warning (_ ("Section .debug_aranges in %s entry at offset %s " + "address list is not properly terminated, " + "ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer)); return false; } - ULONGEST start = extract_unsigned_integer (addr, address_size, - dwarf5_byte_order); + ULONGEST start + = extract_unsigned_integer (addr, address_size, dwarf5_byte_order); addr += address_size; - ULONGEST length = extract_unsigned_integer (addr, address_size, - dwarf5_byte_order); + ULONGEST length + = extract_unsigned_integer (addr, address_size, dwarf5_byte_order); addr += address_size; if (start == 0 && length == 0) { @@ -2512,9 +2479,8 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, addrmap_mutable mutable_map; if (read_addrmap_from_aranges (per_objfile, section, &mutable_map)) - per_bfd->index_addrmap - = new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack, - &mutable_map); + per_bfd->index_addrmap = new (&per_bfd->obstack) + addrmap_fixed (&per_bfd->obstack, &mutable_map); } /* A helper function that reads the .gdb_index from BUFFER and fills @@ -2529,11 +2495,9 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, Returns true if all went well, false otherwise. */ static bool -read_gdb_index_from_buffer (const char *filename, - bool deprecated_ok, +read_gdb_index_from_buffer (const char *filename, bool deprecated_ok, gdb::array_view<const gdb_byte> buffer, - struct mapped_index *map, - const gdb_byte **cu_list, + struct mapped_index *map, const gdb_byte **cu_list, offset_type *cu_list_elements, const gdb_byte **types_list, offset_type *types_list_elements) @@ -2552,7 +2516,7 @@ read_gdb_index_from_buffer (const char *filename, static int warning_printed = 0; if (!warning_printed) { - warning (_("Skipping obsolete .gdb_index section in %s."), + warning (_ ("Skipping obsolete .gdb_index section in %s."), filename); warning_printed = 1; } @@ -2571,7 +2535,7 @@ read_gdb_index_from_buffer (const char *filename, static int warning_printed = 0; if (!warning_printed) { - warning (_("\ + warning (_ ("\ Skipping deprecated .gdb_index section in %s.\n\ Do \"set use-deprecated-index-sections on\" before the file is read\n\ to use the section anyway."), @@ -2635,21 +2599,21 @@ static void finalize_all_units (dwarf2_per_bfd *per_bfd); /* Callback types for dwarf2_read_gdb_index. */ -typedef gdb::function_view - <gdb::array_view<const gdb_byte>(objfile *, dwarf2_per_bfd *)> - get_gdb_index_contents_ftype; -typedef gdb::function_view - <gdb::array_view<const gdb_byte>(objfile *, dwz_file *)> - get_gdb_index_contents_dwz_ftype; +typedef gdb::function_view<gdb::array_view<const gdb_byte> (objfile *, + dwarf2_per_bfd *)> + get_gdb_index_contents_ftype; +typedef gdb::function_view<gdb::array_view<const gdb_byte> (objfile *, + dwz_file *)> + get_gdb_index_contents_dwz_ftype; /* Read .gdb_index. If everything went ok, initialize the "quick" elements of all the CUs and return 1. Otherwise, return 0. */ static int -dwarf2_read_gdb_index - (dwarf2_per_objfile *per_objfile, - get_gdb_index_contents_ftype get_gdb_index_contents, - get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz) +dwarf2_read_gdb_index ( + dwarf2_per_objfile *per_objfile, + get_gdb_index_contents_ftype get_gdb_index_contents, + get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz) { const gdb_byte *cu_list, *types_list, *dwz_list = NULL; offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; @@ -2696,7 +2660,7 @@ dwarf2_read_gdb_index &dwz_types_ignore, &dwz_types_elements_ignore)) { - warning (_("could not read '.gdb_index' section from %s; skipping"), + warning (_ ("could not read '.gdb_index' section from %s; skipping"), bfd_get_filename (dwz->dwz_bfd.get ())); return 0; } @@ -2716,9 +2680,7 @@ dwarf2_read_gdb_index } dwarf2_section_info *section - = (per_bfd->types.size () == 1 - ? &per_bfd->types[0] - : &per_bfd->info); + = (per_bfd->types.size () == 1 ? &per_bfd->types[0] : &per_bfd->info); create_signatured_type_table_from_index (per_bfd, section, types_list, types_list_elements); @@ -2729,8 +2691,8 @@ dwarf2_read_gdb_index create_addrmap_from_index (per_objfile, map.get ()); per_bfd->index_table = std::move (map); - per_bfd->quick_file_names_table = - create_quick_file_names_table (per_bfd->all_units.size ()); + per_bfd->quick_file_names_table + = create_quick_file_names_table (per_bfd->all_units.size ()); return 1; } @@ -2749,7 +2711,7 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, void **slot; struct quick_file_names *qfn; - gdb_assert (! this_cu->is_debug_types); + gdb_assert (!this_cu->is_debug_types); this_cu->files_read = true; /* Our callers never want to match partial units -- instead they @@ -2776,8 +2738,9 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, If we have we're done. */ find_entry.hash.dwo_unit = cu->dwo_unit; find_entry.hash.line_sect_off = line_offset; - slot = htab_find_slot (per_objfile->per_bfd->quick_file_names_table.get (), - &find_entry, INSERT); + slot + = htab_find_slot (per_objfile->per_bfd->quick_file_names_table.get (), + &find_entry, INSERT); if (*slot != NULL) { lh_cu->file_names = (struct quick_file_names *) *slot; @@ -2806,8 +2769,8 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, for (const auto &entry : lh->file_names ()) { std::string name_holder; - const char *include_name = - compute_include_file_name (lh.get (), entry, fnd, name_holder); + const char *include_name + = compute_include_file_name (lh.get (), entry, fnd, name_holder); if (include_name != nullptr) { include_name = per_objfile->objfile->intern (include_name); @@ -2818,9 +2781,8 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, qfn->num_file_names = offset + include_names.size (); qfn->comp_dir = fnd.intern_comp_dir (per_objfile->objfile); - qfn->file_names = - XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *, - qfn->num_file_names); + qfn->file_names = XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *, + qfn->num_file_names); if (offset != 0) qfn->file_names[0] = per_objfile->objfile->intern (fnd.get_name ()); @@ -2841,7 +2803,7 @@ dw2_get_file_names (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile) { /* This should never be called for TUs. */ - gdb_assert (! this_cu->is_debug_types); + gdb_assert (!this_cu->is_debug_types); if (this_cu->files_read) return this_cu->file_names; @@ -2886,7 +2848,8 @@ dwarf2_base_index_functions::find_last_source_symtab (struct objfile *objfile) dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); dwarf2_per_cu_data *dwarf_cu = per_objfile->per_bfd->all_units.back ().get (); - compunit_symtab *cust = dw2_instantiate_symtab (dwarf_cu, per_objfile, false); + compunit_symtab *cust + = dw2_instantiate_symtab (dwarf_cu, per_objfile, false); if (cust == NULL) return NULL; @@ -2917,8 +2880,8 @@ dwarf2_per_cu_data::free_cached_file_names () } void -dwarf2_base_index_functions::forget_cached_source_info - (struct objfile *objfile) +dwarf2_base_index_functions::forget_cached_source_info ( + struct objfile *objfile) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -2978,29 +2941,29 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, /* Return the next matching CU or NULL if there are no more. */ static struct dwarf2_per_cu_data * -dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, - mapped_index &index) +dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, mapped_index &index) { dwarf2_per_objfile *per_objfile = iter->per_objfile; - for ( ; iter->next < iter->length; ++iter->next) + for (; iter->next < iter->length; ++iter->next) { offset_type cu_index_and_attrs = iter->vec[iter->next + 1]; offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs); - gdb_index_symbol_kind symbol_kind = - GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); + gdb_index_symbol_kind symbol_kind + = GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); /* Only check the symbol attributes if they're present. Indices prior to version 7 don't record them, and indices >= 7 may elide them for certain symbols (gold does this). */ - int attrs_valid = (index.version >= 7 - && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); + int attrs_valid + = (index.version >= 7 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); /* Don't crash on bad data. */ if (cu_index >= per_objfile->per_bfd->all_units.size ()) { - complaint (_(".gdb_index entry has bad CU index" - " [in module %s]"), objfile_name (per_objfile->objfile)); + complaint (_ (".gdb_index entry has bad CU index" + " [in module %s]"), + objfile_name (per_objfile->objfile)); continue; } @@ -3024,8 +2987,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, } /* Work around gold/15646. */ - if (!is_static - && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE) + if (!is_static && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE) { if (iter->global_seen) continue; @@ -3088,8 +3050,8 @@ dwarf2_base_index_functions::print_stats (struct objfile *objfile, if (!per_objfile->symtab_set_p (per_cu)) ++count; } - gdb_printf (_(" Number of read CUs: %d\n"), total - count); - gdb_printf (_(" Number of unread CUs: %d\n"), count); + gdb_printf (_ (" Number of read CUs: %d\n"), total - count); + gdb_printf (_ (" Number of unread CUs: %d\n"), count); } /* This dumps minimal information about the index. @@ -3102,8 +3064,8 @@ dwarf2_gdb_index::dump (struct objfile *objfile) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - mapped_index *index = (gdb::checked_static_cast<mapped_index *> - (per_objfile->per_bfd->index_table.get ())); + mapped_index *index = (gdb::checked_static_cast<mapped_index *> ( + per_objfile->per_bfd->index_table.get ())); gdb_printf (".gdb_index: version %d\n", index->version); gdb_printf ("\n"); } @@ -3127,58 +3089,50 @@ dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile) } } -static bool -dw2_expand_symtabs_matching_symbol - (mapped_index_base &index, - const lookup_name_info &lookup_name_in, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<bool (offset_type)> match_callback, - dwarf2_per_objfile *per_objfile); +static bool dw2_expand_symtabs_matching_symbol ( + mapped_index_base &index, const lookup_name_info &lookup_name_in, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<bool (offset_type)> match_callback, + dwarf2_per_objfile *per_objfile); -static bool -dw2_expand_symtabs_matching_one - (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify); +static bool dw2_expand_symtabs_matching_one ( + dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify); void -dwarf2_gdb_index::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) +dwarf2_gdb_index::expand_matching_symbols ( + struct objfile *objfile, const lookup_name_info &name, domain_enum domain, + int global, symbol_compare_ftype *ordered_compare) { /* Used for Ada. */ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; - mapped_index &index - = *(gdb::checked_static_cast<mapped_index *> - (per_objfile->per_bfd->index_table.get ())); + mapped_index &index = *(gdb::checked_static_cast<mapped_index *> ( + per_objfile->per_bfd->index_table.get ())); const char *match_name = name.ada ().lookup_name ().c_str (); - auto matcher = [&] (const char *symname) - { + auto matcher = [&] (const char *symname) { if (ordered_compare == nullptr) return true; return ordered_compare (symname, match_name) == 0; }; - dw2_expand_symtabs_matching_symbol (index, name, matcher, - [&] (offset_type namei) - { - struct dw2_symtab_iterator iter; - struct dwarf2_per_cu_data *per_cu; + dw2_expand_symtabs_matching_symbol ( + index, name, matcher, + [&] (offset_type namei) { + struct dw2_symtab_iterator iter; + struct dwarf2_per_cu_data *per_cu; - dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei, - index); - while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL) - dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, - nullptr); - return true; - }, per_objfile); + dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei, + index); + while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL) + dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, nullptr); + return true; + }, + per_objfile); } /* Starting from a search name, return the string that finds the upper @@ -3258,9 +3212,9 @@ make_sort_after_prefix_name (const char *search_name) std::pair<std::vector<name_component>::const_iterator, std::vector<name_component>::const_iterator> -mapped_index_base::find_name_components_bounds - (const lookup_name_info &lookup_name_without_params, language lang, - dwarf2_per_objfile *per_objfile) const +mapped_index_base::find_name_components_bounds ( + const lookup_name_info &lookup_name_without_params, language lang, + dwarf2_per_objfile *per_objfile) const { auto *name_cmp = this->name_components_casing == case_sensitive_on ? strcmp : strcasecmp; @@ -3270,42 +3224,38 @@ mapped_index_base::find_name_components_bounds /* Comparison function object for lower_bound that matches against a given symbol name. */ - auto lookup_compare_lower = [&] (const name_component &elem, - const char *name) - { - const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile); - const char *elem_name = elem_qualified + elem.name_offset; - return name_cmp (elem_name, name) < 0; - }; + auto lookup_compare_lower + = [&] (const name_component &elem, const char *name) { + const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile); + const char *elem_name = elem_qualified + elem.name_offset; + return name_cmp (elem_name, name) < 0; + }; /* Comparison function object for upper_bound that matches against a given symbol name. */ - auto lookup_compare_upper = [&] (const char *name, - const name_component &elem) - { - const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile); - const char *elem_name = elem_qualified + elem.name_offset; - return name_cmp (name, elem_name) < 0; - }; + auto lookup_compare_upper + = [&] (const char *name, const name_component &elem) { + const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile); + const char *elem_name = elem_qualified + elem.name_offset; + return name_cmp (name, elem_name) < 0; + }; auto begin = this->name_components.begin (); auto end = this->name_components.end (); /* Find the lower bound. */ - auto lower = [&] () - { - if (lookup_name_without_params.completion_mode () && lang_name[0] == '\0') - return begin; - else - return std::lower_bound (begin, end, lang_name, lookup_compare_lower); - } (); + auto lower = [&] () { + if (lookup_name_without_params.completion_mode () && lang_name[0] == '\0') + return begin; + else + return std::lower_bound (begin, end, lang_name, lookup_compare_lower); + }(); /* Find the upper bound. */ - auto upper = [&] () - { - if (lookup_name_without_params.completion_mode ()) - { - /* In completion mode, we want UPPER to point past all + auto upper = [&] () { + if (lookup_name_without_params.completion_mode ()) + { + /* In completion mode, we want UPPER to point past all symbols names that have the same prefix. I.e., with these symbols, and completing "func": @@ -3316,17 +3266,17 @@ mapped_index_base::find_name_components_bounds We find the upper bound by looking for the insertion point of "func"-with-last-character-incremented, i.e. "fund". */ - std::string after = make_sort_after_prefix_name (lang_name); - if (after.empty ()) - return end; - return std::lower_bound (lower, end, after.c_str (), - lookup_compare_lower); - } - else - return std::upper_bound (lower, end, lang_name, lookup_compare_upper); - } (); + std::string after = make_sort_after_prefix_name (lang_name); + if (after.empty ()) + return end; + return std::lower_bound (lower, end, after.c_str (), + lookup_compare_lower); + } + else + return std::upper_bound (lower, end, lang_name, lookup_compare_upper); + }(); - return {lower, upper}; + return { lower, upper }; } /* See declaration. */ @@ -3362,7 +3312,7 @@ mapped_index_base::build_name_components (dwarf2_per_objfile *per_objfile) current_len += cp_find_first_component (name + current_len)) { gdb_assert (name[current_len] == ':'); - this->name_components.push_back ({previous_len, idx}); + this->name_components.push_back ({ previous_len, idx }); /* Skip the '::'. */ current_len += 2; previous_len = current_len; @@ -3371,36 +3321,32 @@ mapped_index_base::build_name_components (dwarf2_per_objfile *per_objfile) else { /* Handle the Ada encoded (aka mangled) form here. */ - for (const char *iter = strstr (name, "__"); - iter != nullptr; + for (const char *iter = strstr (name, "__"); iter != nullptr; iter = strstr (iter, "__")) { - this->name_components.push_back ({previous_len, idx}); + this->name_components.push_back ({ previous_len, idx }); iter += 2; previous_len = iter - name; } } - this->name_components.push_back ({previous_len, idx}); + this->name_components.push_back ({ previous_len, idx }); } /* Sort name_components elements by name. */ - auto name_comp_compare = [&] (const name_component &left, - const name_component &right) - { - const char *left_qualified - = this->symbol_name_at (left.idx, per_objfile); - const char *right_qualified - = this->symbol_name_at (right.idx, per_objfile); + auto name_comp_compare + = [&] (const name_component &left, const name_component &right) { + const char *left_qualified = this->symbol_name_at (left.idx, per_objfile); + const char *right_qualified + = this->symbol_name_at (right.idx, per_objfile); - const char *left_name = left_qualified + left.name_offset; - const char *right_name = right_qualified + right.name_offset; + const char *left_name = left_qualified + left.name_offset; + const char *right_name = right_qualified + right.name_offset; - return name_cmp (left_name, right_name) < 0; - }; + return name_cmp (left_name, right_name) < 0; + }; - std::sort (this->name_components.begin (), - this->name_components.end (), + std::sort (this->name_components.begin (), this->name_components.end (), name_comp_compare); } @@ -3412,12 +3358,11 @@ mapped_index_base::build_name_components (dwarf2_per_objfile *per_objfile) symbol's index in the mapped_index_base symbol table. */ static bool -dw2_expand_symtabs_matching_symbol - (mapped_index_base &index, - const lookup_name_info &lookup_name_in, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<bool (offset_type)> match_callback, - dwarf2_per_objfile *per_objfile) +dw2_expand_symtabs_matching_symbol ( + mapped_index_base &index, const lookup_name_info &lookup_name_in, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<bool (offset_type)> match_callback, + dwarf2_per_objfile *per_objfile) { lookup_name_info lookup_name_without_params = lookup_name_in.make_ignore_params (); @@ -3459,8 +3404,7 @@ dw2_expand_symtabs_matching_symbol = lang->get_symbol_name_matcher (lookup_name_without_params); name_and_matcher key { - name_matcher, - lookup_name_without_params.language_lookup_name (lang_e) + name_matcher, lookup_name_without_params.language_lookup_name (lang_e) }; /* Don't insert the same comparison routine more than once. @@ -3519,7 +3463,10 @@ dw2_expand_symtabs_matching_symbol #if GDB_SELF_TEST -namespace selftests { namespace dw2_expand_symtabs_matching { +namespace selftests +{ +namespace dw2_expand_symtabs_matching +{ /* A mock .gdb_index/.debug_names-like name index table, enough to exercise dw2_expand_symtabs_matching_symbol, which works with the @@ -3528,21 +3475,20 @@ namespace selftests { namespace dw2_expand_symtabs_matching { class mock_mapped_index : public mapped_index_base { public: + mock_mapped_index (gdb::array_view<const char *> symbols) : m_symbol_table (symbols) - {} + { + } DISABLE_COPY_AND_ASSIGN (mock_mapped_index); /* Return the number of names in the symbol table. */ - size_t symbol_name_count () const override - { - return m_symbol_table.size (); - } + size_t symbol_name_count () const override { return m_symbol_table.size (); } /* Get the name of the symbol at IDX in the symbol table. */ - const char *symbol_name_at - (offset_type idx, dwarf2_per_objfile *per_objfile) const override + const char *symbol_name_at (offset_type idx, + dwarf2_per_objfile *per_objfile) const override { return m_symbol_table[idx]; } @@ -3553,6 +3499,7 @@ public: } private: + gdb::array_view<const char *> m_symbol_table; }; @@ -3573,8 +3520,7 @@ string_or_null (const char *str) indicating the file:line that failed, and returns false. */ static bool -check_match (const char *file, int line, - mock_mapped_index &mock_index, +check_match (const char *file, int line, mock_mapped_index &mock_index, const char *name, symbol_name_match_type match_type, bool completion_mode, std::initializer_list<const char *> expected_list, @@ -3584,14 +3530,11 @@ check_match (const char *file, int line, bool matched = true; - auto mismatch = [&] (const char *expected_str, - const char *got) - { - warning (_("%s:%d: match_type=%s, looking-for=\"%s\", " - "expected=\"%s\", got=\"%s\"\n"), + auto mismatch = [&] (const char *expected_str, const char *got) { + warning (_ ("%s:%d: match_type=%s, looking-for=\"%s\", " + "expected=\"%s\", got=\"%s\"\n"), file, line, - (match_type == symbol_name_match_type::FULL - ? "FULL" : "WILD"), + (match_type == symbol_name_match_type::FULL ? "FULL" : "WILD"), name, string_or_null (expected_str), string_or_null (got)); matched = false; }; @@ -3599,10 +3542,9 @@ check_match (const char *file, int line, auto expected_it = expected_list.begin (); auto expected_end = expected_list.end (); - dw2_expand_symtabs_matching_symbol (mock_index, lookup_name, - nullptr, - [&] (offset_type idx) - { + dw2_expand_symtabs_matching_symbol ( + mock_index, lookup_name, nullptr, + [&] (offset_type idx) { const char *matched_name = mock_index.symbol_name_at (idx, per_objfile); const char *expected_str = expected_it == expected_end ? NULL : *expected_it++; @@ -3610,10 +3552,11 @@ check_match (const char *file, int line, if (expected_str == NULL || strcmp (expected_str, matched_name) != 0) mismatch (expected_str, matched_name); return true; - }, per_objfile); + }, + per_objfile); const char *expected_str - = expected_it == expected_end ? NULL : *expected_it++; + = expected_it == expected_end ? NULL : *expected_it++; if (expected_str != NULL) mismatch (expected_str, NULL); @@ -3622,32 +3565,22 @@ check_match (const char *file, int line, /* The symbols added to the mock mapped_index for testing (in canonical form). */ -static const char *test_symbols[] = { - "function", - "std::bar", - "std::zfunction", - "std::zfunction2", - "w1::w2", - "ns::foo<char*>", - "ns::foo<int>", - "ns::foo<long>", - "ns2::tmpl<int>::foo2", - "(anonymous namespace)::A::B::C", - - /* These are used to check that the increment-last-char in the +static const char *test_symbols[] + = { "function", "std::bar", "std::zfunction", "std::zfunction2", "w1::w2", + "ns::foo<char*>", "ns::foo<int>", "ns::foo<long>", + "ns2::tmpl<int>::foo2", "(anonymous namespace)::A::B::C", + + /* These are used to check that the increment-last-char in the matching algorithm for completion doesn't match "t1_fund" when completing "t1_func". */ - "t1_func", - "t1_func1", - "t1_fund", - "t1_fund1", + "t1_func", "t1_func1", "t1_fund", "t1_fund1", - /* A UTF-8 name with multi-byte sequences to make sure that + /* A UTF-8 name with multi-byte sequences to make sure that cp-name-parser understands this as a single identifier ("função" is "function" in PT). */ - u8"u8função", + u8"u8função", - /* Test a symbol name that ends with a 0xff character, which is a + /* Test a symbol name that ends with a 0xff character, which is a valid character in non-UTF-8 source character sets (e.g. Latin1 'ÿ'), and we can't rule out compilers allowing it in identifiers. We test this because the completion algorithm finds the upper @@ -3655,37 +3588,34 @@ static const char *test_symbols[] = { "func"-with-last-character-incremented, i.e. "fund", and adding 1 to 0xff should wraparound and carry to the previous character. See comments in make_sort_after_prefix_name. */ - "yfunc\377", + "yfunc\377", - /* Some more symbols with \377 (0xff). See above. */ - "\377", - "\377\377123", + /* Some more symbols with \377 (0xff). See above. */ + "\377", "\377\377123", - /* A name with all sorts of complications. Starts with "z" to make +/* A name with all sorts of complications. Starts with "z" to make it easier for the completion tests below. */ -#define Z_SYM_NAME \ - "z::std::tuple<(anonymous namespace)::ui*, std::bar<(anonymous namespace)::ui> >" \ - "::tuple<(anonymous namespace)::ui*, " \ - "std::default_delete<(anonymous namespace)::ui>, void>" +#define Z_SYM_NAME \ + "z::std::tuple<(anonymous namespace)::ui*, std::bar<(anonymous " \ + "namespace)::ui> >" \ + "::tuple<(anonymous namespace)::ui*, " \ + "std::default_delete<(anonymous namespace)::ui>, void>" - Z_SYM_NAME -}; + Z_SYM_NAME }; /* Returns true if the mapped_index_base::find_name_component_bounds method finds EXPECTED_SYMS in INDEX when looking for SEARCH_NAME, in completion mode. */ static bool -check_find_bounds_finds (mapped_index_base &index, - const char *search_name, +check_find_bounds_finds (mapped_index_base &index, const char *search_name, gdb::array_view<const char *> expected_syms, dwarf2_per_objfile *per_objfile) { - lookup_name_info lookup_name (search_name, - symbol_name_match_type::FULL, true); + lookup_name_info lookup_name (search_name, symbol_name_match_type::FULL, + true); - auto bounds = index.find_name_components_bounds (lookup_name, - language_cplus, + auto bounds = index.find_name_components_bounds (lookup_name, language_cplus, per_objfile); size_t distance = std::distance (bounds.first, bounds.second); @@ -3721,9 +3651,8 @@ test_mapped_index_find_name_component_bounds () "t1_func1", }; - SELF_CHECK (check_find_bounds_finds - (mock_index, "t1_func", expected_syms, - NULL /* per_objfile */)); + SELF_CHECK (check_find_bounds_finds (mock_index, "t1_func", expected_syms, + NULL /* per_objfile */)); } /* Check that the increment-last-char in the name matching algorithm @@ -3734,15 +3663,15 @@ test_mapped_index_find_name_component_bounds () "\377", "\377\377123", }; - SELF_CHECK (check_find_bounds_finds - (mock_index, "\377", expected_syms1, NULL /* per_objfile */)); + SELF_CHECK (check_find_bounds_finds (mock_index, "\377", expected_syms1, + NULL /* per_objfile */)); static const char *expected_syms2[] = { "\377\377123", }; - SELF_CHECK (check_find_bounds_finds - (mock_index, "\377\377", expected_syms2, - NULL /* per_objfile */)); + SELF_CHECK (check_find_bounds_finds (mock_index, "\377\377", + expected_syms2, + NULL /* per_objfile */)); } } @@ -3760,22 +3689,23 @@ test_dw2_expand_symtabs_matching_symbol () /* Create the expected symbols list (an initializer_list). Needed because lists have commas, and we need to pass them to CHECK, which is a macro. */ -#define EXPECT(...) { __VA_ARGS__ } +#define EXPECT(...) \ + { \ + __VA_ARGS__ \ + } /* Wrapper for check_match that passes down the current __FILE__/__LINE__. */ -#define CHECK_MATCH(NAME, MATCH_TYPE, COMPLETION_MODE, EXPECTED_LIST) \ - any_mismatch |= !check_match (__FILE__, __LINE__, \ - mock_index, \ - NAME, MATCH_TYPE, COMPLETION_MODE, \ - EXPECTED_LIST, NULL) +#define CHECK_MATCH(NAME, MATCH_TYPE, COMPLETION_MODE, EXPECTED_LIST) \ + any_mismatch \ + |= !check_match (__FILE__, __LINE__, mock_index, NAME, MATCH_TYPE, \ + COMPLETION_MODE, EXPECTED_LIST, NULL) /* Identity checks. */ for (const char *sym : test_symbols) { /* Should be able to match all existing symbols. */ - CHECK_MATCH (sym, symbol_name_match_type::FULL, false, - EXPECT (sym)); + CHECK_MATCH (sym, symbol_name_match_type::FULL, false, EXPECT (sym)); /* Should be able to match all existing symbols with parameters. */ @@ -3831,10 +3761,8 @@ test_dw2_expand_symtabs_matching_symbol () /* While "w" is a prefix of both components, the match function should still only be called once. */ { - CHECK_MATCH ("w", symbol_name_match_type::FULL, true, - EXPECT ("w1::w2")); - CHECK_MATCH ("w", symbol_name_match_type::WILD, true, - EXPECT ("w1::w2")); + CHECK_MATCH ("w", symbol_name_match_type::FULL, true, EXPECT ("w1::w2")); + CHECK_MATCH ("w", symbol_name_match_type::WILD, true, EXPECT ("w1::w2")); } /* Same, with a "complicated" symbol. */ @@ -3883,7 +3811,7 @@ test_dw2_expand_symtabs_matching_symbol () { static const char expected[] = "ns::foo<char*>"; /* Try both completion and non-completion modes. */ - static const bool completion_mode[2] = {false, true}; + static const bool completion_mode[2] = { false, true }; for (size_t i = 0; i < 2; i++) { CHECK_MATCH ("ns :: foo < char * >", symbol_name_match_type::FULL, @@ -3891,8 +3819,9 @@ test_dw2_expand_symtabs_matching_symbol () CHECK_MATCH ("foo < char * >", symbol_name_match_type::WILD, completion_mode[i], EXPECT (expected)); - CHECK_MATCH ("ns :: foo < char * > (int)", symbol_name_match_type::FULL, - completion_mode[i], EXPECT (expected)); + CHECK_MATCH ("ns :: foo < char * > (int)", + symbol_name_match_type::FULL, completion_mode[i], + EXPECT (expected)); CHECK_MATCH ("foo < char * > (int)", symbol_name_match_type::WILD, completion_mode[i], EXPECT (expected)); } @@ -3905,31 +3834,25 @@ test_dw2_expand_symtabs_matching_symbol () symbol_name_match_type::FULL, true, EXPECT (expected)); CHECK_MATCH ("ns :: foo < char * > ( int ) &&", symbol_name_match_type::FULL, true, EXPECT (expected)); - CHECK_MATCH ("foo < char * > ( int ) const", - symbol_name_match_type::WILD, true, EXPECT (expected)); - CHECK_MATCH ("foo < char * > ( int ) &&", - symbol_name_match_type::WILD, true, EXPECT (expected)); + CHECK_MATCH ("foo < char * > ( int ) const", symbol_name_match_type::WILD, + true, EXPECT (expected)); + CHECK_MATCH ("foo < char * > ( int ) &&", symbol_name_match_type::WILD, + true, EXPECT (expected)); } /* Test lookup names that don't match anything. */ { - CHECK_MATCH ("bar2", symbol_name_match_type::WILD, false, - {}); + CHECK_MATCH ("bar2", symbol_name_match_type::WILD, false, {}); - CHECK_MATCH ("doesntexist", symbol_name_match_type::FULL, false, - {}); + CHECK_MATCH ("doesntexist", symbol_name_match_type::FULL, false, {}); } /* Some wild matching tests, exercising "(anonymous namespace)", which should not be confused with a parameter list. */ { static const char *syms[] = { - "A::B::C", - "B::C", - "C", - "A :: B :: C ( int )", - "B :: C ( int )", - "C ( int )", + "A::B::C", "B::C", "C", "A :: B :: C ( int )", + "B :: C ( int )", "C ( int )", }; for (const char *s : syms) @@ -3941,8 +3864,7 @@ test_dw2_expand_symtabs_matching_symbol () { static const char expected[] = "ns2::tmpl<int>::foo2"; - CHECK_MATCH ("tmp", symbol_name_match_type::WILD, true, - EXPECT (expected)); + CHECK_MATCH ("tmp", symbol_name_match_type::WILD, true, EXPECT (expected)); CHECK_MATCH ("tmpl<", symbol_name_match_type::WILD, true, EXPECT (expected)); } @@ -3960,7 +3882,8 @@ run_test () test_dw2_expand_symtabs_matching_symbol (); } -}} // namespace selftests::dw2_expand_symtabs_matching +} // namespace dw2_expand_symtabs_matching +} // namespace selftests #endif /* GDB_SELF_TEST */ @@ -3970,11 +3893,10 @@ run_test () EXPANSION_NOTIFY on it. */ static bool -dw2_expand_symtabs_matching_one - (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify) +dw2_expand_symtabs_matching_one ( + dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify) { if (file_matcher == NULL || per_cu->mark) { @@ -3995,18 +3917,16 @@ dw2_expand_symtabs_matching_one index of the symbol name that matched. */ static bool -dw2_expand_marked_cus - (dwarf2_per_objfile *per_objfile, offset_type idx, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - search_domain kind) +dw2_expand_marked_cus ( + dwarf2_per_objfile *per_objfile, offset_type idx, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, search_domain kind) { offset_type vec_len, vec_idx; bool global_seen = false; - mapped_index &index - = *(gdb::checked_static_cast<mapped_index *> - (per_objfile->per_bfd->index_table.get ())); + mapped_index &index = *(gdb::checked_static_cast<mapped_index *> ( + per_objfile->per_bfd->index_table.get ())); offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx))); vec_len = vec[0]; @@ -4015,20 +3935,18 @@ dw2_expand_marked_cus offset_type cu_index_and_attrs = vec[vec_idx + 1]; /* This value is only valid for index versions >= 7. */ int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs); - gdb_index_symbol_kind symbol_kind = - GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); + gdb_index_symbol_kind symbol_kind + = GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs); /* Only check the symbol attributes if they're present. Indices prior to version 7 don't record them, and indices >= 7 may elide them for certain symbols (gold does this). */ - int attrs_valid = - (index.version >= 7 - && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); + int attrs_valid + = (index.version >= 7 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); /* Work around gold/15646. */ - if (attrs_valid - && !is_static + if (attrs_valid && !is_static && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE) { if (global_seen) @@ -4077,8 +3995,9 @@ dw2_expand_marked_cus /* Don't crash on bad data. */ if (cu_index >= per_objfile->per_bfd->all_units.size ()) { - complaint (_(".gdb_index entry has bad CU index" - " [in module %s]"), objfile_name (per_objfile->objfile)); + complaint (_ (".gdb_index entry has bad CU index" + " [in module %s]"), + objfile_name (per_objfile->objfile)); continue; } @@ -4096,19 +4015,19 @@ dw2_expand_marked_cus that match FILE_MATCHER. */ static void -dw_expand_symtabs_matching_file_matcher - (dwarf2_per_objfile *per_objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher) +dw_expand_symtabs_matching_file_matcher ( + dwarf2_per_objfile *per_objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher) { if (file_matcher == NULL) return; htab_up visited_found (htab_create_alloc (10, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + htab_eq_pointer, NULL, xcalloc, + xfree)); htab_up visited_not_found (htab_create_alloc (10, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + htab_eq_pointer, NULL, xcalloc, + xfree)); /* The rule is CUs specify all the files, including those used by any TU, so there's no need to scan TUs here. */ @@ -4146,8 +4065,8 @@ dw_expand_symtabs_matching_file_matcher } } - quick_file_names *file_data = dw2_get_file_names (per_cu.get (), - per_objfile); + quick_file_names *file_data + = dw2_get_file_names (per_cu.get (), per_objfile); if (file_data == NULL) continue; @@ -4172,8 +4091,7 @@ dw_expand_symtabs_matching_file_matcher /* Before we invoke realpath, which can get expensive when many files are involved, do a quick comparison of the basenames. */ if (!basenames_may_differ - && !file_matcher (lbasename (file_data->file_names[j]), - true)) + && !file_matcher (lbasename (file_data->file_names[j]), true)) continue; this_real_name = dw2_get_real_path (per_objfile, file_data, j); @@ -4184,24 +4102,21 @@ dw_expand_symtabs_matching_file_matcher } } - void **slot = htab_find_slot (per_cu->mark - ? visited_found.get () - : visited_not_found.get (), + void **slot = htab_find_slot (per_cu->mark ? visited_found.get () + : visited_not_found.get (), file_data, INSERT); *slot = file_data; } } bool -dwarf2_gdb_index::expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) +dwarf2_gdb_index::expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, enum search_domain kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -4211,8 +4126,7 @@ dwarf2_gdb_index::expand_symtabs_matching gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); if (lookup_name == nullptr) { - for (dwarf2_per_cu_data *per_cu - : all_units_range (per_objfile->per_bfd)) + for (dwarf2_per_cu_data *per_cu : all_units_range (per_objfile->per_bfd)) { QUIT; @@ -4224,20 +4138,18 @@ dwarf2_gdb_index::expand_symtabs_matching return true; } - mapped_index &index - = *(gdb::checked_static_cast<mapped_index *> - (per_objfile->per_bfd->index_table.get ())); + mapped_index &index = *(gdb::checked_static_cast<mapped_index *> ( + per_objfile->per_bfd->index_table.get ())); - bool result - = dw2_expand_symtabs_matching_symbol (index, *lookup_name, - symbol_matcher, - [&] (offset_type idx) - { - if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher, - expansion_notify, search_flags, kind)) - return false; - return true; - }, per_objfile); + bool result = dw2_expand_symtabs_matching_symbol ( + index, *lookup_name, symbol_matcher, + [&] (offset_type idx) { + if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher, + expansion_notify, search_flags, kind)) + return false; + return true; + }, + per_objfile); return result; } @@ -4282,42 +4194,38 @@ dwarf2_base_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, } struct compunit_symtab * -dwarf2_base_index_functions::find_pc_sect_compunit_symtab - (struct objfile *objfile, - struct bound_minimal_symbol msymbol, - CORE_ADDR pc, - struct obj_section *section, - int warn_if_readin) +dwarf2_base_index_functions::find_pc_sect_compunit_symtab ( + struct objfile *objfile, struct bound_minimal_symbol msymbol, CORE_ADDR pc, + struct obj_section *section, int warn_if_readin) { struct compunit_symtab *result; dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); CORE_ADDR baseaddr = objfile->text_section_offset (); - struct dwarf2_per_cu_data *data = find_per_cu (per_objfile->per_bfd, - pc - baseaddr); + struct dwarf2_per_cu_data *data + = find_per_cu (per_objfile->per_bfd, pc - baseaddr); if (data == nullptr) return nullptr; if (warn_if_readin && per_objfile->symtab_set_p (data)) - warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), + warning (_ ("(Internal error: pc %s in read in CU, but not in symtab.)"), paddress (objfile->arch (), pc)); - result = recursively_find_pc_sect_compunit_symtab - (dw2_instantiate_symtab (data, per_objfile, false), pc); + result = recursively_find_pc_sect_compunit_symtab ( + dw2_instantiate_symtab (data, per_objfile, false), pc); if (warn_if_readin && result == nullptr) - warning (_("(Error: pc %s in address map, but not in symtab.)"), + warning (_ ("(Error: pc %s in address map, but not in symtab.)"), paddress (objfile->arch (), pc)); return result; } void -dwarf2_base_index_functions::map_symbol_filenames - (struct objfile *objfile, - gdb::function_view<symbol_filename_ftype> fun, - bool need_fullname) +dwarf2_base_index_functions::map_symbol_filenames ( + struct objfile *objfile, gdb::function_view<symbol_filename_ftype> fun, + bool need_fullname) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -4333,16 +4241,14 @@ dwarf2_base_index_functions::map_symbol_filenames for (const auto &per_cu : per_objfile->per_bfd->all_units) { - if (!per_cu->is_debug_types - && per_objfile->symtab_set_p (per_cu.get ())) + if (!per_cu->is_debug_types && per_objfile->symtab_set_p (per_cu.get ())) { if (per_cu->file_names != nullptr) qfn_cache.insert (per_cu->file_names); } } - for (dwarf2_per_cu_data *per_cu - : all_units_range (per_objfile->per_bfd)) + for (dwarf2_per_cu_data *per_cu : all_units_range (per_objfile->per_bfd)) { /* We only need to look at symtabs not already expanded. */ if (per_cu->is_debug_types || per_objfile->symtab_set_p (per_cu)) @@ -4427,8 +4333,7 @@ static const gdb_byte dwarf5_augmentation[] = { 'G', 'D', 'B', 0 }; Returns true if all went well, false otherwise. */ static bool -read_debug_names_from_section (struct objfile *objfile, - const char *filename, +read_debug_names_from_section (struct objfile *objfile, const char *filename, struct dwarf2_section_info *section, mapped_debug_names &map) { @@ -4457,8 +4362,8 @@ read_debug_names_from_section (struct objfile *objfile, if (bytes_read + length != section->size) { /* There may be multiple per-CU indices. */ - warning (_("Section .debug_names in %s length %s does not match " - "section length %s, ignoring .debug_names."), + warning (_ ("Section .debug_names in %s length %s does not match " + "section length %s, ignoring .debug_names."), filename, plongest (bytes_read + length), pulongest (section->size)); return false; @@ -4469,8 +4374,8 @@ read_debug_names_from_section (struct objfile *objfile, addr += 2; if (version != 5) { - warning (_("Section .debug_names in %s has unsupported version %d, " - "ignoring .debug_names."), + warning (_ ("Section .debug_names in %s has unsupported version %d, " + "ignoring .debug_names."), filename, version); return false; } @@ -4480,8 +4385,8 @@ read_debug_names_from_section (struct objfile *objfile, addr += 2; if (padding != 0) { - warning (_("Section .debug_names in %s has unsupported padding %d, " - "ignoring .debug_names."), + warning (_ ("Section .debug_names in %s has unsupported padding %d, " + "ignoring .debug_names."), filename, padding); return false; } @@ -4501,9 +4406,10 @@ read_debug_names_from_section (struct objfile *objfile, addr += 4; if (foreign_tu_count != 0) { - warning (_("Section .debug_names in %s has unsupported %lu foreign TUs, " - "ignoring .debug_names."), - filename, static_cast<unsigned long> (foreign_tu_count)); + warning ( + _ ("Section .debug_names in %s has unsupported %lu foreign TUs, " + "ignoring .debug_names."), + filename, static_cast<unsigned long> (foreign_tu_count)); return false; } @@ -4525,10 +4431,10 @@ read_debug_names_from_section (struct objfile *objfile, string. This value is rounded up to a multiple of 4. */ uint32_t augmentation_string_size = read_4_bytes (abfd, addr); addr += 4; - map.augmentation_is_gdb = ((augmentation_string_size - == sizeof (dwarf5_augmentation)) - && memcmp (addr, dwarf5_augmentation, - sizeof (dwarf5_augmentation)) == 0); + map.augmentation_is_gdb + = ((augmentation_string_size == sizeof (dwarf5_augmentation)) + && memcmp (addr, dwarf5_augmentation, sizeof (dwarf5_augmentation)) + == 0); augmentation_string_size += (-augmentation_string_size) & 3; addr += augmentation_string_size; @@ -4555,7 +4461,8 @@ read_debug_names_from_section (struct objfile *objfile, const gdb_byte *abbrev_table_start = addr; for (;;) { - const ULONGEST index_num = read_unsigned_leb128 (abfd, addr, &bytes_read); + const ULONGEST index_num + = read_unsigned_leb128 (abfd, addr, &bytes_read); addr += bytes_read; if (index_num == 0) break; @@ -4564,8 +4471,8 @@ read_debug_names_from_section (struct objfile *objfile, = map.abbrev_map.emplace (index_num, mapped_debug_names::index_val ()); if (!insertpair.second) { - warning (_("Section .debug_names in %s has duplicate index %s, " - "ignoring .debug_names."), + warning (_ ("Section .debug_names in %s has duplicate index %s, " + "ignoring .debug_names."), filename, pulongest (index_num)); return false; } @@ -4582,8 +4489,8 @@ read_debug_names_from_section (struct objfile *objfile, addr += bytes_read; if (attr.form == DW_FORM_implicit_const) { - attr.implicit_const = read_signed_leb128 (abfd, addr, - &bytes_read); + attr.implicit_const + = read_signed_leb128 (abfd, addr, &bytes_read); addr += bytes_read; } if (attr.dw_idx == 0 && attr.form == 0) @@ -4593,8 +4500,8 @@ read_debug_names_from_section (struct objfile *objfile, } if (addr != abbrev_table_start + abbrev_table_size) { - warning (_("Section .debug_names in %s has abbreviation_table " - "of size %s vs. written as %u, ignoring .debug_names."), + warning (_ ("Section .debug_names in %s has abbreviation_table " + "of size %s vs. written as %u, ignoring .debug_names."), filename, plongest (addr - abbrev_table_start), abbrev_table_size); return false; @@ -4610,26 +4517,23 @@ read_debug_names_from_section (struct objfile *objfile, static bool create_cus_from_debug_names_list (dwarf2_per_bfd *per_bfd, const mapped_debug_names &map, - dwarf2_section_info §ion, - bool is_dwz) + dwarf2_section_info §ion, bool is_dwz) { if (!map.augmentation_is_gdb) { for (uint32_t i = 0; i < map.cu_count; ++i) { - sect_offset sect_off - = (sect_offset) (extract_unsigned_integer - (map.cu_table_reordered + i * map.offset_size, - map.offset_size, - map.dwarf5_byte_order)); + sect_offset sect_off = (sect_offset) (extract_unsigned_integer ( + map.cu_table_reordered + i * map.offset_size, map.offset_size, + map.dwarf5_byte_order)); /* We don't know the length of the CU, because the CU list in a .debug_names index can be incomplete, so we can't use the start of the next CU as end of this CU. We create the CUs here with length 0, and in cutu_reader::cutu_reader we'll fill in the actual length. */ dwarf2_per_cu_data_up per_cu - = create_cu_from_index_list (per_bfd, §ion, is_dwz, - sect_off, 0); + = create_cu_from_index_list (per_bfd, §ion, is_dwz, sect_off, + 0); per_bfd->all_units.push_back (std::move (per_cu)); } return true; @@ -4641,11 +4545,9 @@ create_cus_from_debug_names_list (dwarf2_per_bfd *per_bfd, sect_offset sect_off_next; if (i < map.cu_count) { - sect_off_next - = (sect_offset) (extract_unsigned_integer - (map.cu_table_reordered + i * map.offset_size, - map.offset_size, - map.dwarf5_byte_order)); + sect_off_next = (sect_offset) (extract_unsigned_integer ( + map.cu_table_reordered + i * map.offset_size, map.offset_size, + map.dwarf5_byte_order)); } else sect_off_next = (sect_offset) section.size; @@ -4653,14 +4555,15 @@ create_cus_from_debug_names_list (dwarf2_per_bfd *per_bfd, { if (sect_off_next == sect_off_prev) { - warning (_("Section .debug_names has duplicate entry in CU table," - " ignoring .debug_names.")); + warning ( + _ ("Section .debug_names has duplicate entry in CU table," + " ignoring .debug_names.")); return false; } if (sect_off_next < sect_off_prev) { - warning (_("Section .debug_names has non-ascending CU table," - " ignoring .debug_names.")); + warning (_ ("Section .debug_names has non-ascending CU table," + " ignoring .debug_names.")); return false; } /* Note: we're not using length = sect_off_next - sect_off_prev, @@ -4724,12 +4627,13 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) dwz_file *dwz = dwarf2_get_dwz_file (per_bfd); if (dwz != NULL) { - if (!read_debug_names_from_section (objfile, - bfd_get_filename (dwz->dwz_bfd.get ()), - &dwz->debug_names, dwz_map)) + if (!read_debug_names_from_section ( + objfile, bfd_get_filename (dwz->dwz_bfd.get ()), &dwz->debug_names, + dwz_map)) { - warning (_("could not read '.debug_names' section from %s; skipping"), - bfd_get_filename (dwz->dwz_bfd.get ())); + warning ( + _ ("could not read '.debug_names' section from %s; skipping"), + bfd_get_filename (dwz->dwz_bfd.get ())); return false; } } @@ -4751,12 +4655,11 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) } dwarf2_section_info *section - = (per_bfd->types.size () == 1 - ? &per_bfd->types[0] - : &per_bfd->info); + = (per_bfd->types.size () == 1 ? &per_bfd->types[0] : &per_bfd->info); - create_signatured_type_table_from_debug_names - (per_objfile, *map, section, &per_bfd->abbrev); + create_signatured_type_table_from_debug_names (per_objfile, *map, + section, + &per_bfd->abbrev); } finalize_all_units (per_bfd); @@ -4764,8 +4667,8 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges); per_bfd->index_table = std::move (map); - per_bfd->quick_file_names_table = - create_quick_file_names_table (per_bfd->all_units.size ()); + per_bfd->quick_file_names_table + = create_quick_file_names_table (per_bfd->all_units.size ()); return true; } @@ -4776,14 +4679,17 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) class dw2_debug_names_iterator { public: + dw2_debug_names_iterator (const mapped_debug_names &map, - block_search_flags block_index, - domain_enum domain, + block_search_flags block_index, domain_enum domain, const char *name, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), + m_block_index (block_index), + m_domain (domain), m_addr (find_vec_in_debug_names (map, name, per_objfile)), m_per_objfile (per_objfile) - {} + { + } dw2_debug_names_iterator (const mapped_debug_names &map, search_domain search, uint32_t namei, @@ -4794,33 +4700,38 @@ public: m_search (search), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) - {} + { + } dw2_debug_names_iterator (const mapped_debug_names &map, block_search_flags block_index, domain_enum domain, uint32_t namei, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), + m_block_index (block_index), + m_domain (domain), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) - {} + { + } /* Return the next matching CU or NULL if there are no more. */ dwarf2_per_cu_data *next (); private: - static const gdb_byte *find_vec_in_debug_names (const mapped_debug_names &map, - const char *name, - dwarf2_per_objfile *per_objfile); - static const gdb_byte *find_vec_in_debug_names (const mapped_debug_names &map, - uint32_t namei, - dwarf2_per_objfile *per_objfile); + + static const gdb_byte * + find_vec_in_debug_names (const mapped_debug_names &map, const char *name, + dwarf2_per_objfile *per_objfile); + static const gdb_byte * + find_vec_in_debug_names (const mapped_debug_names &map, uint32_t namei, + dwarf2_per_objfile *per_objfile); /* The internalized form of .debug_names. */ const mapped_debug_names &m_map; /* Restrict the search to these blocks. */ - block_search_flags m_block_index = (SEARCH_GLOBAL_BLOCK - | SEARCH_STATIC_BLOCK); + block_search_flags m_block_index + = (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK); /* The kind of symbol we're looking for. */ const domain_enum m_domain = UNDEF_DOMAIN; @@ -4834,14 +4745,13 @@ private: }; const char * -mapped_debug_names::namei_to_name - (uint32_t namei, dwarf2_per_objfile *per_objfile) const +mapped_debug_names::namei_to_name (uint32_t namei, + dwarf2_per_objfile *per_objfile) const { const ULONGEST namei_string_offs = extract_unsigned_integer ((name_table_string_offs_reordered + namei * offset_size), - offset_size, - dwarf5_byte_order); + offset_size, dwarf5_byte_order); return read_indirect_string_at_offset (per_objfile, namei_string_offs); } @@ -4850,9 +4760,9 @@ mapped_debug_names::namei_to_name return NULL. */ const gdb_byte * -dw2_debug_names_iterator::find_vec_in_debug_names - (const mapped_debug_names &map, const char *name, - dwarf2_per_objfile *per_objfile) +dw2_debug_names_iterator::find_vec_in_debug_names ( + const mapped_debug_names &map, const char *name, + dwarf2_per_objfile *per_objfile) { int (*cmp) (const char *, const char *); @@ -4875,35 +4785,33 @@ dw2_debug_names_iterator::find_vec_in_debug_names cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp); const uint32_t full_hash = dwarf5_djb_hash (name); - uint32_t namei - = extract_unsigned_integer (reinterpret_cast<const gdb_byte *> - (map.bucket_table_reordered - + (full_hash % map.bucket_count)), 4, - map.dwarf5_byte_order); + uint32_t namei = extract_unsigned_integer ( + reinterpret_cast<const gdb_byte *> (map.bucket_table_reordered + + (full_hash % map.bucket_count)), + 4, map.dwarf5_byte_order); if (namei == 0) return NULL; --namei; if (namei >= map.name_count) { - complaint (_("Wrong .debug_names with name index %u but name_count=%u " - "[in module %s]"), - namei, map.name_count, - objfile_name (per_objfile->objfile)); + complaint (_ ("Wrong .debug_names with name index %u but name_count=%u " + "[in module %s]"), + namei, map.name_count, objfile_name (per_objfile->objfile)); return NULL; } for (;;) { - const uint32_t namei_full_hash - = extract_unsigned_integer (reinterpret_cast<const gdb_byte *> - (map.hash_table_reordered + namei), 4, - map.dwarf5_byte_order); + const uint32_t namei_full_hash = extract_unsigned_integer ( + reinterpret_cast<const gdb_byte *> (map.hash_table_reordered + namei), + 4, map.dwarf5_byte_order); if (full_hash % map.bucket_count != namei_full_hash % map.bucket_count) return NULL; if (full_hash == namei_full_hash) { - const char *const namei_string = map.namei_to_name (namei, per_objfile); + const char *const namei_string + = map.namei_to_name (namei, per_objfile); #if 0 /* An expensive sanity check. */ if (namei_full_hash != dwarf5_djb_hash (namei_string)) @@ -4917,10 +4825,10 @@ dw2_debug_names_iterator::find_vec_in_debug_names if (cmp (namei_string, name) == 0) { - const ULONGEST namei_entry_offs - = extract_unsigned_integer ((map.name_table_entry_offs_reordered - + namei * map.offset_size), - map.offset_size, map.dwarf5_byte_order); + const ULONGEST namei_entry_offs = extract_unsigned_integer ( + (map.name_table_entry_offs_reordered + + namei * map.offset_size), + map.offset_size, map.dwarf5_byte_order); return map.entry_pool + namei_entry_offs; } } @@ -4932,15 +4840,15 @@ dw2_debug_names_iterator::find_vec_in_debug_names } const gdb_byte * -dw2_debug_names_iterator::find_vec_in_debug_names - (const mapped_debug_names &map, uint32_t namei, dwarf2_per_objfile *per_objfile) +dw2_debug_names_iterator::find_vec_in_debug_names ( + const mapped_debug_names &map, uint32_t namei, + dwarf2_per_objfile *per_objfile) { if (namei >= map.name_count) { - complaint (_("Wrong .debug_names with name index %u but name_count=%u " - "[in module %s]"), - namei, map.name_count, - objfile_name (per_objfile->objfile)); + complaint (_ ("Wrong .debug_names with name index %u but name_count=%u " + "[in module %s]"), + namei, map.name_count, objfile_name (per_objfile->objfile)); return NULL; } @@ -4963,7 +4871,7 @@ dw2_debug_names_iterator::next () struct objfile *objfile = m_per_objfile->objfile; bfd *const abfd = objfile->obfd.get (); - again: +again: unsigned int bytes_read; const ULONGEST abbrev = read_unsigned_leb128 (abfd, m_addr, &bytes_read); @@ -4974,17 +4882,19 @@ dw2_debug_names_iterator::next () const auto indexval_it = m_map.abbrev_map.find (abbrev); if (indexval_it == m_map.abbrev_map.cend ()) { - complaint (_("Wrong .debug_names undefined abbrev code %s " - "[in module %s]"), + complaint (_ ("Wrong .debug_names undefined abbrev code %s " + "[in module %s]"), pulongest (abbrev), objfile_name (objfile)); return NULL; } const mapped_debug_names::index_val &indexval = indexval_it->second; - enum class symbol_linkage { + enum class symbol_linkage + { unknown, static_, extern_, - } symbol_linkage_ = symbol_linkage::unknown; + } symbol_linkage_ + = symbol_linkage::unknown; dwarf2_per_cu_data *per_cu = NULL; for (const mapped_debug_names::index_val::attr &attr : indexval.attr_vec) { @@ -5014,9 +4924,8 @@ dw2_debug_names_iterator::next () m_addr += 8; break; default: - complaint (_("Unsupported .debug_names form %s [in module %s]"), - dwarf_form_name (attr.form), - objfile_name (objfile)); + complaint (_ ("Unsupported .debug_names form %s [in module %s]"), + dwarf_form_name (attr.form), objfile_name (objfile)); return NULL; } switch (attr.dw_idx) @@ -5026,10 +4935,9 @@ dw2_debug_names_iterator::next () /* Don't crash on bad data. */ if (ull >= per_bfd->all_comp_units.size ()) { - complaint (_(".debug_names entry has bad CU index %s" - " [in module %s]"), - pulongest (ull), - objfile_name (objfile)); + complaint (_ (".debug_names entry has bad CU index %s" + " [in module %s]"), + pulongest (ull), objfile_name (objfile)); continue; } } @@ -5039,10 +4947,9 @@ dw2_debug_names_iterator::next () /* Don't crash on bad data. */ if (ull >= per_bfd->all_type_units.size ()) { - complaint (_(".debug_names entry has bad TU index %s" - " [in module %s]"), - pulongest (ull), - objfile_name (objfile)); + complaint (_ (".debug_names entry has bad TU index %s" + " [in module %s]"), + pulongest (ull), objfile_name (objfile)); continue; } { @@ -5200,54 +5107,48 @@ dwarf2_debug_names_index::dump (struct objfile *objfile) } void -dwarf2_debug_names_index::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) +dwarf2_debug_names_index::expand_matching_symbols ( + struct objfile *objfile, const lookup_name_info &name, domain_enum domain, + int global, symbol_compare_ftype *ordered_compare) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - mapped_debug_names &map - = *(gdb::checked_static_cast<mapped_debug_names *> - (per_objfile->per_bfd->index_table.get ())); + mapped_debug_names &map = *(gdb::checked_static_cast<mapped_debug_names *> ( + per_objfile->per_bfd->index_table.get ())); const block_search_flags block_flags = global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK; const char *match_name = name.ada ().lookup_name ().c_str (); - auto matcher = [&] (const char *symname) - { - if (ordered_compare == nullptr) - return true; - return ordered_compare (symname, match_name) == 0; - }; + auto matcher = [&] (const char *symname) { + if (ordered_compare == nullptr) + return true; + return ordered_compare (symname, match_name) == 0; + }; - dw2_expand_symtabs_matching_symbol (map, name, matcher, - [&] (offset_type namei) - { - /* The name was matched, now expand corresponding CUs that were + dw2_expand_symtabs_matching_symbol ( + map, name, matcher, + [&] (offset_type namei) { + /* The name was matched, now expand corresponding CUs that were marked. */ - dw2_debug_names_iterator iter (map, block_flags, domain, namei, - per_objfile); + dw2_debug_names_iterator iter (map, block_flags, domain, namei, + per_objfile); - struct dwarf2_per_cu_data *per_cu; - while ((per_cu = iter.next ()) != NULL) - dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, - nullptr); - return true; - }, per_objfile); + struct dwarf2_per_cu_data *per_cu; + while ((per_cu = iter.next ()) != NULL) + dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, nullptr); + return true; + }, + per_objfile); } bool -dwarf2_debug_names_index::expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) +dwarf2_debug_names_index::expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, enum search_domain kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -5257,8 +5158,7 @@ dwarf2_debug_names_index::expand_symtabs_matching gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); if (lookup_name == nullptr) { - for (dwarf2_per_cu_data *per_cu - : all_units_range (per_objfile->per_bfd)) + for (dwarf2_per_cu_data *per_cu : all_units_range (per_objfile->per_bfd)) { QUIT; @@ -5270,27 +5170,24 @@ dwarf2_debug_names_index::expand_symtabs_matching return true; } - mapped_debug_names &map - = *(gdb::checked_static_cast<mapped_debug_names *> - (per_objfile->per_bfd->index_table.get ())); + mapped_debug_names &map = *(gdb::checked_static_cast<mapped_debug_names *> ( + per_objfile->per_bfd->index_table.get ())); - bool result - = dw2_expand_symtabs_matching_symbol (map, *lookup_name, - symbol_matcher, - [&] (offset_type namei) - { - /* The name was matched, now expand corresponding CUs that were + bool result = dw2_expand_symtabs_matching_symbol ( + map, *lookup_name, symbol_matcher, + [&] (offset_type namei) { + /* The name was matched, now expand corresponding CUs that were marked. */ - dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain); + dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain); - struct dwarf2_per_cu_data *per_cu; - while ((per_cu = iter.next ()) != NULL) - if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, - file_matcher, - expansion_notify)) - return false; - return true; - }, per_objfile); + struct dwarf2_per_cu_data *per_cu; + while ((per_cu = iter.next ()) != NULL) + if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, file_matcher, + expansion_notify)) + return false; + return true; + }, + per_objfile); return result; } @@ -5298,7 +5195,7 @@ dwarf2_debug_names_index::expand_symtabs_matching /* Get the content of the .gdb_index section of OBJ. SECTION_OWNER should point to either a dwarf2_per_bfd or dwz_file object. */ -template <typename T> +template<typename T> static gdb::array_view<const gdb_byte> get_gdb_index_contents_from_section (objfile *obj, T *section_owner) { @@ -5327,14 +5224,15 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) DWARF2_OBJ. */ static gdb::array_view<const gdb_byte> -get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) +get_gdb_index_contents_from_cache (objfile *obj, + dwarf2_per_bfd *dwarf2_per_bfd) { const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ()); if (build_id == nullptr) return {}; - return global_index_cache.lookup_gdb_index (build_id, - &dwarf2_per_bfd->index_cache_res); + return global_index_cache.lookup_gdb_index ( + build_id, &dwarf2_per_bfd->index_cache_res); } /* Same as the above, but for DWZ. */ @@ -5389,14 +5287,14 @@ dwarf2_initialize_objfile (struct objfile *objfile) if (dwarf2_read_debug_names (per_objfile)) { dwarf_read_debug_printf ("found debug names"); - objfile->qf.push_front - (per_bfd->index_table->make_quick_functions ()); + objfile->qf.push_front (per_bfd->index_table->make_quick_functions ()); return; } - if (dwarf2_read_gdb_index (per_objfile, - get_gdb_index_contents_from_section<struct dwarf2_per_bfd>, - get_gdb_index_contents_from_section<dwz_file>)) + if (dwarf2_read_gdb_index ( + per_objfile, + get_gdb_index_contents_from_section<struct dwarf2_per_bfd>, + get_gdb_index_contents_from_section<dwz_file>)) { dwarf_read_debug_printf ("found gdb index from file"); objfile->qf.push_front (per_bfd->index_table->make_quick_functions ()); @@ -5404,8 +5302,7 @@ dwarf2_initialize_objfile (struct objfile *objfile) } /* ... otherwise, try to find the index in the index cache. */ - if (dwarf2_read_gdb_index (per_objfile, - get_gdb_index_contents_from_cache, + if (dwarf2_read_gdb_index (per_objfile, get_gdb_index_contents_from_cache, get_gdb_index_contents_from_cache_dwz)) { dwarf_read_debug_printf ("found gdb index from cache"); @@ -5418,8 +5315,6 @@ dwarf2_initialize_objfile (struct objfile *objfile) objfile->qf.push_front (make_cooked_index_funcs ()); } - - /* Build a partial symbol table. */ static void @@ -5488,8 +5383,7 @@ get_abbrev_section_for_cu (struct dwarf2_per_cu_data *this_cu) static sect_offset read_abbrev_offset (dwarf2_per_objfile *per_objfile, - struct dwarf2_section_info *section, - sect_offset sect_off) + struct dwarf2_section_info *section, sect_offset sect_off) { bfd *abfd = section->get_bfd_owner (); const gdb_byte *info_ptr; @@ -5526,8 +5420,10 @@ hash_signatured_type (const void *item) static int eq_signatured_type (const void *item_lhs, const void *item_rhs) { - const struct signatured_type *lhs = (const struct signatured_type *) item_lhs; - const struct signatured_type *rhs = (const struct signatured_type *) item_rhs; + const struct signatured_type *lhs + = (const struct signatured_type *) item_lhs; + const struct signatured_type *rhs + = (const struct signatured_type *) item_rhs; return lhs->signature == rhs->signature; } @@ -5537,10 +5433,9 @@ eq_signatured_type (const void *item_lhs, const void *item_rhs) static htab_up allocate_signatured_type_table () { - return htab_up (htab_create_alloc (41, - hash_signatured_type, - eq_signatured_type, - NULL, xcalloc, xfree)); + return htab_up (htab_create_alloc (41, hash_signatured_type, + eq_signatured_type, NULL, xcalloc, + xfree)); } /* A helper for create_debug_types_hash_table. Read types from SECTION @@ -5550,8 +5445,8 @@ allocate_signatured_type_table () static void create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, struct dwo_file *dwo_file, - dwarf2_section_info *section, htab_up &types_htab, - rcuh_kind section_kind) + dwarf2_section_info *section, + htab_up &types_htab, rcuh_kind section_kind) { struct objfile *objfile = per_objfile->objfile; struct dwarf2_section_info *abbrev_section; @@ -5560,8 +5455,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, abbrev_section = &dwo_file->sections.abbrev; - dwarf_read_debug_printf ("Reading %s for %s", - section->get_name (), + dwarf_read_debug_printf ("Reading %s for %s", section->get_name (), abbrev_section->get_file_name ()); section->read (objfile); @@ -5602,8 +5496,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, length = header.get_length_with_initial (); /* Skip dummy type units. */ - if (ptr >= info_ptr + length - || peek_abbrev_code (abfd, ptr) == 0 + if (ptr >= info_ptr + length || peek_abbrev_code (abfd, ptr) == 0 || (header.unit_type != DW_UT_type && header.unit_type != DW_UT_split_type)) { @@ -5625,8 +5518,8 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, slot = htab_find_slot (types_htab.get (), dwo_tu, INSERT); gdb_assert (slot != NULL); if (*slot != NULL) - complaint (_("debug type entry at offset %s is duplicate to" - " the entry at offset %s, signature %s"), + complaint (_ ("debug type entry at offset %s is duplicate to" + " the entry at offset %s, signature %s"), sect_offset_str (sect_off), sect_offset_str (dwo_tu->sect_off), hex_string (header.signature)); @@ -5649,10 +5542,9 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, Note: This function processes DWO files only, not DWP files. */ static void -create_debug_types_hash_table (dwarf2_per_objfile *per_objfile, - struct dwo_file *dwo_file, - gdb::array_view<dwarf2_section_info> type_sections, - htab_up &types_htab) +create_debug_types_hash_table ( + dwarf2_per_objfile *per_objfile, struct dwo_file *dwo_file, + gdb::array_view<dwarf2_section_info> type_sections, htab_up &types_htab) { for (dwarf2_section_info §ion : type_sections) create_debug_type_hash_table (per_objfile, dwo_file, §ion, types_htab, @@ -5674,8 +5566,7 @@ add_type_unit (dwarf2_per_objfile *per_objfile, ULONGEST sig, void **slot) = per_objfile->per_bfd->allocate_signatured_type (sig); signatured_type *sig_type = sig_type_holder.get (); - per_objfile->per_bfd->all_units.emplace_back - (sig_type_holder.release ()); + per_objfile->per_bfd->all_units.emplace_back (sig_type_holder.release ()); if (slot == NULL) { @@ -5699,7 +5590,7 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile, dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; /* Make sure we're not clobbering something we don't expect to. */ - gdb_assert (! sig_entry->queued); + gdb_assert (!sig_entry->queued); gdb_assert (per_objfile->get_cu (sig_entry) == NULL); gdb_assert (!per_objfile->symtab_set_p (sig_entry)); gdb_assert (sig_entry->signature == dwo_entry->signature); @@ -5707,8 +5598,7 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile, || (to_underlying (sig_entry->type_offset_in_section) == to_underlying (dwo_entry->type_offset_in_tu))); gdb_assert (sig_entry->type_unit_group == NULL); - gdb_assert (sig_entry->dwo_unit == NULL - || sig_entry->dwo_unit == dwo_entry); + gdb_assert (sig_entry->dwo_unit == NULL || sig_entry->dwo_unit == dwo_entry); sig_entry->section = dwo_entry->section; sig_entry->sect_off = dwo_entry->sect_off; @@ -5777,8 +5667,8 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) if (dwo_file->tus == NULL) return NULL; find_dwo_entry.signature = sig; - dwo_entry = (struct dwo_unit *) htab_find (dwo_file->tus.get (), - &find_dwo_entry); + dwo_entry + = (struct dwo_unit *) htab_find (dwo_file->tus.get (), &find_dwo_entry); if (dwo_entry == NULL) return NULL; @@ -5860,9 +5750,8 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) if (per_objfile->per_bfd->signatured_types == NULL) return NULL; signatured_type find_entry (sig); - return ((struct signatured_type *) - htab_find (per_objfile->per_bfd->signatured_types.get (), - &find_entry)); + return ((struct signatured_type *) htab_find ( + per_objfile->per_bfd->signatured_types.get (), &find_entry)); } } @@ -5871,8 +5760,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) /* Initialize a die_reader_specs struct from a dwarf2_cu struct. */ static void -init_cu_die_reader (struct die_reader_specs *reader, - struct dwarf2_cu *cu, +init_cu_die_reader (struct die_reader_specs *reader, struct dwarf2_cu *cu, struct dwarf2_section_info *section, struct dwo_file *dwo_file, struct abbrev_table *abbrev_table) @@ -5907,8 +5795,7 @@ init_cu_die_reader (struct die_reader_specs *reader, The result is non-zero if a valid (non-dummy) DIE was found. */ static int -read_cutu_die_from_dwo (dwarf2_cu *cu, - struct dwo_unit *dwo_unit, +read_cutu_die_from_dwo (dwarf2_cu *cu, struct dwo_unit *dwo_unit, struct die_info *stub_comp_unit_die, const char *stub_comp_dir, struct die_reader_specs *result_reader, @@ -5922,7 +5809,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, bfd *abfd; const gdb_byte *begin_info_ptr, *info_ptr; struct attribute *comp_dir, *stmt_list, *low_pc, *high_pc, *ranges; - int i,num_extra_attrs; + int i, num_extra_attrs; struct dwarf2_section_info *dwo_abbrev_section; struct die_info *comp_unit_die; @@ -5982,8 +5869,8 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, dwarf2_section_info *section = dwo_unit->section; section->read (objfile); abfd = section->get_bfd_owner (); - begin_info_ptr = info_ptr = (section->buffer - + to_underlying (dwo_unit->sect_off)); + begin_info_ptr = info_ptr + = (section->buffer + to_underlying (dwo_unit->sect_off)); dwo_abbrev_section = &dwo_unit->dwo_file->sections.abbrev; if (per_cu->is_debug_types) @@ -5996,8 +5883,8 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, /* This is not an assert because it can be caused by bad debug info. */ if (sig_type->signature != cu->header.signature) { - error (_("Dwarf Error: signature mismatch %s vs %s while reading" - " TU at offset %s [in module %s]"), + error (_ ("Dwarf Error: signature mismatch %s vs %s while reading" + " TU at offset %s [in module %s]"), hex_string (sig_type->signature), hex_string (cu->header.signature), sect_offset_str (dwo_unit->sect_off), @@ -6035,11 +5922,8 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, from the stub. This has the benefit of simplifying the rest of the code - all the work to maintain the illusion of a single DW_TAG_{compile,type}_unit DIE is done here. */ - num_extra_attrs = ((stmt_list != NULL) - + (low_pc != NULL) - + (high_pc != NULL) - + (ranges != NULL) - + (comp_dir != NULL)); + num_extra_attrs = ((stmt_list != NULL) + (low_pc != NULL) + (high_pc != NULL) + + (ranges != NULL) + (comp_dir != NULL)); info_ptr = read_full_die_1 (result_reader, result_comp_unit_die, info_ptr, num_extra_attrs); @@ -6060,8 +5944,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, if (dwarf_die_debug) { - gdb_printf (gdb_stdlog, - "Read die from %s@0x%x of %s:\n", + gdb_printf (gdb_stdlog, "Read die from %s@0x%x of %s:\n", section->get_name (), (unsigned) (begin_info_ptr - section->buffer), bfd_get_filename (abfd)); @@ -6081,7 +5964,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the signature is part of the header. */ static gdb::optional<ULONGEST> -lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die) +lookup_dwo_id (struct dwarf2_cu *cu, struct die_info *comp_unit_die) { if (cu->header.version >= 5) return cu->header.signature; @@ -6124,8 +6007,8 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name) gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) - error (_("Dwarf Error: missing dwo_id for dwo_name %s" - " [in module %s]"), + error (_ ("Dwarf Error: missing dwo_id for dwo_name %s" + " [in module %s]"), dwo_name, bfd_get_filename (per_cu->per_bfd->obfd)); dwo_unit = lookup_dwo_comp_unit (cu, dwo_name, comp_dir, *signature); @@ -6175,10 +6058,9 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu, if (read_cutu_die_from_dwo (cu, sig_type->dwo_unit, NULL /* stub_comp_unit_die */, - sig_type->dwo_unit->dwo_file->comp_dir, - this, &info_ptr, - &comp_unit_die, - &m_dwo_abbrev_table) == 0) + sig_type->dwo_unit->dwo_file->comp_dir, this, + &info_ptr, &comp_unit_die, &m_dwo_abbrev_table) + == 0) { /* Dummy die. */ dummy_p = true; @@ -6198,8 +6080,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu, cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, struct abbrev_table *abbrev_table, - dwarf2_cu *existing_cu, - bool skip_partial, + dwarf2_cu *existing_cu, bool skip_partial, abbrev_cache *cache) : die_reader_specs {}, m_this_cu (this_cu) @@ -6234,7 +6115,8 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, /* This is cheap if the section is already read in. */ section->read (objfile); - begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off); + begin_info_ptr = info_ptr + = section->buffer + to_underlying (this_cu->sect_off); abbrev_section = get_abbrev_section_for_cu (this_cu); @@ -6293,17 +6175,17 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, this_cu->set_length (cu->header.get_length_with_initial ()); /* Establish the type offset that can be used to lookup the type. */ - sig_type->type_offset_in_section = - this_cu->sect_off + to_underlying (sig_type->type_offset_in_tu); + sig_type->type_offset_in_section + = this_cu->sect_off + to_underlying (sig_type->type_offset_in_tu); this_cu->set_version (cu->header.version); } else { - info_ptr = read_and_check_comp_unit_head (per_objfile, &cu->header, - section, abbrev_section, - info_ptr, - rcuh_kind::COMPILE); + info_ptr + = read_and_check_comp_unit_head (per_objfile, &cu->header, section, + abbrev_section, info_ptr, + rcuh_kind::COMPILE); gdb_assert (this_cu->sect_off == cu->header.sect_off); this_cu->set_length (cu->header.get_length_with_initial ()); @@ -6327,8 +6209,8 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, else { if (cache != nullptr) - abbrev_table = cache->find (abbrev_section, - cu->header.abbrev_sect_off); + abbrev_table + = cache->find (abbrev_section, cu->header.abbrev_sect_off); if (abbrev_table == nullptr) { abbrev_section->read (objfile); @@ -6364,19 +6246,18 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, if (comp_unit_die->has_children) { - complaint (_("compilation unit with DW_AT_GNU_dwo_name" - " has children (offset %s) [in module %s]"), + complaint (_ ("compilation unit with DW_AT_GNU_dwo_name" + " has children (offset %s) [in module %s]"), sect_offset_str (this_cu->sect_off), bfd_get_filename (abfd)); } dwo_unit = lookup_dwo_unit (cu, comp_unit_die, dwo_name); if (dwo_unit != NULL) { - if (read_cutu_die_from_dwo (cu, dwo_unit, - comp_unit_die, NULL, - this, &info_ptr, - &dwo_comp_unit_die, - &m_dwo_abbrev_table) == 0) + if (read_cutu_die_from_dwo (cu, dwo_unit, comp_unit_die, NULL, this, + &info_ptr, &dwo_comp_unit_die, + &m_dwo_abbrev_table) + == 0) { /* Dummy die. */ dummy_p = true; @@ -6445,21 +6326,19 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, gdb_assert (per_objfile->get_cu (this_cu) == nullptr); - abbrev_section = (dwo_file != NULL - ? &dwo_file->sections.abbrev - : get_abbrev_section_for_cu (this_cu)); + abbrev_section = (dwo_file != NULL ? &dwo_file->sections.abbrev + : get_abbrev_section_for_cu (this_cu)); /* This is cheap if the section is already read in. */ section->read (objfile); m_new_cu.reset (new dwarf2_cu (this_cu, per_objfile)); - begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off); - info_ptr = read_and_check_comp_unit_head (per_objfile, &m_new_cu->header, - section, abbrev_section, info_ptr, - (this_cu->is_debug_types - ? rcuh_kind::TYPE - : rcuh_kind::COMPILE)); + begin_info_ptr = info_ptr + = section->buffer + to_underlying (this_cu->sect_off); + info_ptr = read_and_check_comp_unit_head ( + per_objfile, &m_new_cu->header, section, abbrev_section, info_ptr, + (this_cu->is_debug_types ? rcuh_kind::TYPE : rcuh_kind::COMPILE)); if (parent_cu != nullptr) { @@ -6485,7 +6364,6 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, info_ptr = read_full_die (this, &comp_unit_die, info_ptr); } - /* Type Unit Groups. Type Unit Groups are a way to collapse the set of all TUs (type units) into @@ -6506,8 +6384,10 @@ hash_type_unit_group (const void *item) static int eq_type_unit_group (const void *item_lhs, const void *item_rhs) { - const struct type_unit_group *lhs = (const struct type_unit_group *) item_lhs; - const struct type_unit_group *rhs = (const struct type_unit_group *) item_rhs; + const struct type_unit_group *lhs + = (const struct type_unit_group *) item_lhs; + const struct type_unit_group *rhs + = (const struct type_unit_group *) item_rhs; return eq_stmt_list_entry (&lhs->hash, &rhs->hash); } @@ -6517,8 +6397,7 @@ eq_type_unit_group (const void *item_lhs, const void *item_rhs) static htab_up allocate_type_unit_groups_table () { - return htab_up (htab_create_alloc (3, - hash_type_unit_group, + return htab_up (htab_create_alloc (3, hash_type_unit_group, eq_type_unit_group, htab_delete_entry<type_unit_group>, xcalloc, xfree)); @@ -6558,7 +6437,8 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list) struct type_unit_group type_unit_group_for_lookup; if (per_objfile->per_bfd->type_unit_groups == NULL) - per_objfile->per_bfd->type_unit_groups = allocate_type_unit_groups_table (); + per_objfile->per_bfd->type_unit_groups + = allocate_type_unit_groups_table (); /* Do we need to create a new group, or can we use an existing one? */ @@ -6597,7 +6477,6 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list) gdb_assert (tu_group != nullptr); return tu_group; } - /* An instance of this is created when scanning DWARF to create a cooked index. */ @@ -6607,8 +6486,7 @@ class cooked_index_storage public: cooked_index_storage () - : m_reader_hash (htab_create_alloc (10, hash_cutu_reader, - eq_cutu_reader, + : m_reader_hash (htab_create_alloc (10, hash_cutu_reader, eq_cutu_reader, htab_delete_entry<cutu_reader>, xcalloc, xfree)), m_index (new cooked_index_shard) @@ -6618,18 +6496,15 @@ public: DISABLE_COPY_AND_ASSIGN (cooked_index_storage); /* Return the current abbrev cache. */ - abbrev_cache *get_abbrev_cache () - { - return &m_abbrev_cache; - } + abbrev_cache *get_abbrev_cache () { return &m_abbrev_cache; } /* Return the DIE reader corresponding to PER_CU. If no such reader has been registered, return NULL. */ cutu_reader *get_reader (dwarf2_per_cu_data *per_cu) { int index = per_cu->index; - return (cutu_reader *) htab_find_with_hash (m_reader_hash.get (), - &index, index); + return (cutu_reader *) htab_find_with_hash (m_reader_hash.get (), &index, + index); } /* Preserve READER by storing it in the local hash table. */ @@ -6638,8 +6513,8 @@ public: m_abbrev_cache.add (reader->release_abbrev_table ()); int index = reader->cu->per_cu->index; - void **slot = htab_find_slot_with_hash (m_reader_hash.get (), &index, - index, INSERT); + void **slot + = htab_find_slot_with_hash (m_reader_hash.get (), &index, index, INSERT); gdb_assert (*slot == nullptr); cutu_reader *result = reader.get (); *slot = reader.release (); @@ -6649,8 +6524,7 @@ public: /* Add an entry to the index. The arguments describe the entry; see cooked-index.h. The new entry is returned. */ const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, + cooked_index_flag flags, const char *name, const cooked_index_entry *parent_entry, dwarf2_per_cu_data *per_cu) { @@ -6666,10 +6540,7 @@ public: } /* Return the mutable addrmap that is currently being created. */ - addrmap_mutable *get_addrmap () - { - return &m_addrmap; - } + addrmap_mutable *get_addrmap () { return &m_addrmap; } private: @@ -6705,8 +6576,7 @@ class cooked_indexer { public: - cooked_indexer (cooked_index_storage *storage, - dwarf2_per_cu_data *per_cu, + cooked_indexer (cooked_index_storage *storage, dwarf2_per_cu_data *per_cu, enum language language) : m_index_storage (storage), m_per_cu (per_cu), @@ -6741,8 +6611,7 @@ private: up just a single DIE. */ cutu_reader *ensure_cu_exists (cutu_reader *reader, dwarf2_per_objfile *per_objfile, - sect_offset sect_off, - bool is_dwz, + sect_offset sect_off, bool is_dwz, bool for_scanning); /* Index DIEs in the READER starting at INFO_PTR. PARENT_ENTRY is @@ -6751,25 +6620,20 @@ private: function scopes must be fully explored in order to find nested functions. This returns a pointer to just after the spot where reading stopped. */ - const gdb_byte *index_dies (cutu_reader *reader, - const gdb_byte *info_ptr, + const gdb_byte *index_dies (cutu_reader *reader, const gdb_byte *info_ptr, const cooked_index_entry *parent_entry, bool fully); /* Scan the attributes for a given DIE and update the out parameters. Returns a pointer to the byte after the DIE. */ - const gdb_byte *scan_attributes (dwarf2_per_cu_data *scanning_per_cu, - cutu_reader *reader, - const gdb_byte *watermark_ptr, - const gdb_byte *info_ptr, - const abbrev_info *abbrev, - const char **name, - const char **linkage_name, - cooked_index_flag *flags, - sect_offset *sibling_offset, - const cooked_index_entry **parent_entry, - CORE_ADDR *maybe_defer, - bool for_specification); + const gdb_byte * + scan_attributes (dwarf2_per_cu_data *scanning_per_cu, cutu_reader *reader, + const gdb_byte *watermark_ptr, const gdb_byte *info_ptr, + const abbrev_info *abbrev, const char **name, + const char **linkage_name, cooked_index_flag *flags, + sect_offset *sibling_offset, + const cooked_index_entry **parent_entry, + CORE_ADDR *maybe_defer, bool for_specification); /* Handle DW_TAG_imported_unit, by scanning the DIE to find DW_AT_import, and then scanning the referenced CU. Returns a @@ -6780,10 +6644,8 @@ private: /* Recursively read DIEs, recording the section offsets in m_die_range_map and then calling index_dies. */ - const gdb_byte *recurse (cutu_reader *reader, - const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, - bool fully); + const gdb_byte *recurse (cutu_reader *reader, const gdb_byte *info_ptr, + const cooked_index_entry *parent_entry, bool fully); /* The storage object, where the results are kept. */ cooked_index_storage *m_index_storage; @@ -6857,8 +6719,7 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu, /* Reader function for build_type_psymtabs. */ static void -build_type_psymtabs_reader (cutu_reader *reader, - cooked_index_storage *storage) +build_type_psymtabs_reader (cutu_reader *reader, cooked_index_storage *storage) { struct dwarf2_cu *cu = reader->cu; struct dwarf2_per_cu_data *per_cu = cu->per_cu; @@ -6866,7 +6727,7 @@ build_type_psymtabs_reader (cutu_reader *reader, gdb_assert (per_cu->is_debug_types); - if (! type_unit_die->has_children) + if (!type_unit_die->has_children) return; prepare_one_comp_unit (cu, type_unit_die, language_minimal); @@ -6881,11 +6742,13 @@ build_type_psymtabs_reader (cutu_reader *reader, struct tu_abbrev_offset { tu_abbrev_offset (signatured_type *sig_type_, sect_offset abbrev_offset_) - : sig_type (sig_type_), abbrev_offset (abbrev_offset_) - {} + : sig_type (sig_type_), + abbrev_offset (abbrev_offset_) + { + } /* This is used when sorting. */ - bool operator< (const tu_abbrev_offset &other) const + bool operator<(const tu_abbrev_offset &other) const { return abbrev_offset < other.abbrev_offset; } @@ -6956,9 +6819,9 @@ build_type_psymtabs (dwarf2_per_objfile *per_objfile, if (cu->is_debug_types) { auto sig_type = static_cast<signatured_type *> (cu.get ()); - sorted_by_abbrev.emplace_back - (sig_type, read_abbrev_offset (per_objfile, sig_type->section, - sig_type->sect_off)); + sorted_by_abbrev.emplace_back ( + sig_type, read_abbrev_offset (per_objfile, sig_type->section, + sig_type->sect_off)); } } @@ -6969,18 +6832,17 @@ build_type_psymtabs (dwarf2_per_objfile *per_objfile, for (const tu_abbrev_offset &tu : sorted_by_abbrev) { /* Switch to the next abbrev table if necessary. */ - if (abbrev_table == NULL - || tu.abbrev_offset != abbrev_offset) + if (abbrev_table == NULL || tu.abbrev_offset != abbrev_offset) { abbrev_offset = tu.abbrev_offset; per_objfile->per_bfd->abbrev.read (per_objfile->objfile); - abbrev_table = - abbrev_table::read (&per_objfile->per_bfd->abbrev, abbrev_offset); + abbrev_table = abbrev_table::read (&per_objfile->per_bfd->abbrev, + abbrev_offset); ++tu_stats->nr_uniq_abbrev_tables; } - cutu_reader reader (tu.sig_type, per_objfile, - abbrev_table.get (), nullptr, false); + cutu_reader reader (tu.sig_type, per_objfile, abbrev_table.get (), + nullptr, false); if (!reader.dummy_p) build_type_psymtabs_reader (&reader, storage); } @@ -6999,8 +6861,7 @@ print_tu_stats (dwarf2_per_objfile *per_objfile) tu_stats->nr_uniq_abbrev_tables); dwarf_read_debug_printf (" %d symtabs from stmt_list entries", tu_stats->nr_symtabs); - dwarf_read_debug_printf (" %d symtab sharers", - tu_stats->nr_symtab_sharers); + dwarf_read_debug_printf (" %d symtab sharers", tu_stats->nr_symtab_sharers); dwarf_read_debug_printf (" %d type units without a stmt_list", tu_stats->nr_stmt_less_type_units); dwarf_read_debug_printf (" %d all_type_units reallocs", @@ -7116,11 +6977,10 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile) using iter_type = decltype (per_bfd->all_units.begin ()); - auto task_size_ = [] (iter_type iter) - { - dwarf2_per_cu_data *per_cu = iter->get (); - return (size_t)per_cu->length (); - }; + auto task_size_ = [] (iter_type iter) { + dwarf2_per_cu_data *per_cu = iter->get (); + return (size_t) per_cu->length (); + }; auto task_size = gdb::make_function_view (task_size_); /* Each thread returns a pair holding a cooked index, and a vector @@ -7130,28 +6990,26 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile) prompt, which looks weird. */ using result_type = std::pair<std::unique_ptr<cooked_index_shard>, std::vector<gdb_exception>>; - std::vector<result_type> results - = gdb::parallel_for_each (1, per_bfd->all_units.begin (), - per_bfd->all_units.end (), - [=] (iter_type iter, iter_type end) - { - std::vector<gdb_exception> errors; - cooked_index_storage thread_storage; - for (; iter != end; ++iter) - { - dwarf2_per_cu_data *per_cu = iter->get (); - try - { - process_psymtab_comp_unit (per_cu, per_objfile, - &thread_storage); - } - catch (gdb_exception &except) - { - errors.push_back (std::move (except)); - } - } - return result_type (thread_storage.release (), std::move (errors)); - }, task_size); + std::vector<result_type> results = gdb::parallel_for_each ( + 1, per_bfd->all_units.begin (), per_bfd->all_units.end (), + [=] (iter_type iter, iter_type end) { + std::vector<gdb_exception> errors; + cooked_index_storage thread_storage; + for (; iter != end; ++iter) + { + dwarf2_per_cu_data *per_cu = iter->get (); + try + { + process_psymtab_comp_unit (per_cu, per_objfile, &thread_storage); + } + catch (gdb_exception &except) + { + errors.push_back (std::move (except)); + } + } + return result_type (thread_storage.release (), std::move (errors)); + }, + task_size); /* Only show a given exception a single time. */ std::unordered_set<gdb_exception> seen_exceptions; @@ -7189,15 +7047,13 @@ static void read_comp_units_from_section (dwarf2_per_objfile *per_objfile, struct dwarf2_section_info *section, struct dwarf2_section_info *abbrev_section, - unsigned int is_dwz, - htab_up &types_htab, + unsigned int is_dwz, htab_up &types_htab, rcuh_kind section_kind) { const gdb_byte *info_ptr; struct objfile *objfile = per_objfile->objfile; - dwarf_read_debug_printf ("Reading %s for %s", - section->get_name (), + dwarf_read_debug_printf ("Reading %s for %s", section->get_name (), section->get_file_name ()); section->read (objfile); @@ -7212,8 +7068,7 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, comp_unit_head cu_header; read_and_check_comp_unit_head (per_objfile, &cu_header, section, - abbrev_section, info_ptr, - section_kind); + abbrev_section, info_ptr, section_kind); /* Save the compilation unit for later lookup. */ if (cu_header.unit_type != DW_UT_type) @@ -7223,8 +7078,8 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, if (types_htab == nullptr) types_htab = allocate_signatured_type_table (); - auto sig_type = per_objfile->per_bfd->allocate_signatured_type - (cu_header.signature); + auto sig_type = per_objfile->per_bfd->allocate_signatured_type ( + cu_header.signature); signatured_type *sig_ptr = sig_type.get (); sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu; this_cu.reset (sig_type.release ()); @@ -7232,8 +7087,8 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, void **slot = htab_find_slot (types_htab.get (), sig_ptr, INSERT); gdb_assert (slot != nullptr); if (*slot != nullptr) - complaint (_("debug type entry at offset %s is duplicate to" - " the entry at offset %s, signature %s"), + complaint (_ ("debug type entry at offset %s is duplicate to" + " the entry at offset %s, signature %s"), sect_offset_str (sect_off), sect_offset_str (sig_ptr->sect_off), hex_string (sig_ptr->signature)); @@ -7275,12 +7130,12 @@ create_all_units (dwarf2_per_objfile *per_objfile) gdb_assert (per_objfile->per_bfd->all_units.empty ()); read_comp_units_from_section (per_objfile, &per_objfile->per_bfd->info, - &per_objfile->per_bfd->abbrev, 0, - types_htab, rcuh_kind::COMPILE); + &per_objfile->per_bfd->abbrev, 0, types_htab, + rcuh_kind::COMPILE); for (dwarf2_section_info §ion : per_objfile->per_bfd->types) read_comp_units_from_section (per_objfile, §ion, - &per_objfile->per_bfd->abbrev, 0, - types_htab, rcuh_kind::TYPE); + &per_objfile->per_bfd->abbrev, 0, types_htab, + rcuh_kind::TYPE); dwz_file *dwz; try @@ -7327,8 +7182,8 @@ peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr) the initial number. */ static const struct abbrev_info * -peek_die_abbrev (const die_reader_specs &reader, - const gdb_byte *info_ptr, unsigned int *bytes_read) +peek_die_abbrev (const die_reader_specs &reader, const gdb_byte *info_ptr, + unsigned int *bytes_read) { dwarf2_cu *cu = reader.cu; bfd *abfd = reader.abfd; @@ -7342,8 +7197,8 @@ peek_die_abbrev (const die_reader_specs &reader, = reader.abbrev_table->lookup_abbrev (abbrev_number); if (!abbrev) { - error (_("Dwarf Error: Could not find abbrev number %d in %s" - " at offset %s [in module %s]"), + error (_ ("Dwarf Error: Could not find abbrev number %d in %s" + " at offset %s [in module %s]"), abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU", sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd)); } @@ -7361,8 +7216,8 @@ skip_children (const struct die_reader_specs *reader, const gdb_byte *info_ptr) while (1) { unsigned int bytes_read; - const abbrev_info *abbrev = peek_die_abbrev (*reader, info_ptr, - &bytes_read); + const abbrev_info *abbrev + = peek_die_abbrev (*reader, info_ptr, &bytes_read); if (abbrev == NULL) return info_ptr + bytes_read; @@ -7418,14 +7273,14 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, { read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); if (attr.form == DW_FORM_ref_addr) - complaint (_("ignoring absolute DW_AT_sibling")); + complaint (_ ("ignoring absolute DW_AT_sibling")); else { sect_offset off = attr.get_ref_die_offset (); const gdb_byte *sibling_ptr = buffer + to_underlying (off); if (sibling_ptr < info_ptr) - complaint (_("DW_AT_sibling points backwards")); + complaint (_ ("DW_AT_sibling points backwards")); else if (sibling_ptr > reader->buffer_end) reader->die_section->overflow_complaint (); else @@ -7524,10 +7379,9 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, goto skip_attribute; default: - error (_("Dwarf Error: Cannot handle %s " - "in DWARF reader [in module %s]"), - dwarf_form_name (form), - bfd_get_filename (abfd)); + error (_ ("Dwarf Error: Cannot handle %s " + "in DWARF reader [in module %s]"), + dwarf_form_name (form), bfd_get_filename (abfd)); } } @@ -7536,14 +7390,13 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, else return info_ptr; } - + /* Reading in full CUs. */ /* Add PER_CU to the queue. */ static void -queue_comp_unit (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, +queue_comp_unit (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, enum language pretend_language) { per_cu->queued = 1; @@ -7607,7 +7460,7 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu, if (!per_objfile->symtab_set_p (per_cu)) { /* Add it to the queue. */ - queue_comp_unit (per_cu, per_objfile, pretend_language); + queue_comp_unit (per_cu, per_objfile, pretend_language); queued = true; } @@ -7649,8 +7502,8 @@ process_queue (dwarf2_per_objfile *per_objfile) if (per_cu->is_debug_types) { - struct signatured_type *sig_type = - (struct signatured_type *) per_cu; + struct signatured_type *sig_type + = (struct signatured_type *) per_cu; sprintf (buf, "TU %s at offset %s", hex_string (sig_type->signature), @@ -7719,12 +7572,10 @@ die_eq (const void *item_lhs, const void *item_rhs) static void load_full_comp_unit (dwarf2_per_cu_data *this_cu, - dwarf2_per_objfile *per_objfile, - dwarf2_cu *existing_cu, - bool skip_partial, - enum language pretend_language) + dwarf2_per_objfile *per_objfile, dwarf2_cu *existing_cu, + bool skip_partial, enum language pretend_language) { - gdb_assert (! this_cu->is_debug_types); + gdb_assert (!this_cu->is_debug_types); cutu_reader reader (this_cu, per_objfile, NULL, existing_cu, skip_partial); if (reader.dummy_p) @@ -7734,19 +7585,16 @@ load_full_comp_unit (dwarf2_per_cu_data *this_cu, const gdb_byte *info_ptr = reader.info_ptr; gdb_assert (cu->die_hash == NULL); - cu->die_hash = - htab_create_alloc_ex (cu->header.get_length_without_initial () / 12, - die_hash, - die_eq, - NULL, - &cu->comp_unit_obstack, - hashtab_obstack_allocate, - dummy_obstack_deallocate); + cu->die_hash + = htab_create_alloc_ex (cu->header.get_length_without_initial () / 12, + die_hash, die_eq, NULL, &cu->comp_unit_obstack, + hashtab_obstack_allocate, + dummy_obstack_deallocate); if (reader.comp_unit_die->has_children) reader.comp_unit_die->child - = read_die_and_siblings (&reader, reader.info_ptr, - &info_ptr, reader.comp_unit_die); + = read_die_and_siblings (&reader, reader.info_ptr, &info_ptr, + reader.comp_unit_die); cu->dies = reader.comp_unit_die; /* comp_unit_die is not stored in die_hash, no need. */ @@ -7860,19 +7708,17 @@ fixup_go_packaging (struct dwarf2_cu *cu) struct pending *list; int i; - for (list = *cu->get_builder ()->get_global_symbols (); - list != NULL; + for (list = *cu->get_builder ()->get_global_symbols (); list != NULL; list = list->next) { for (i = 0; i < list->nsyms; ++i) { struct symbol *sym = list->symbol[i]; - if (sym->language () == language_go - && sym->aclass () == LOC_BLOCK) + if (sym->language () == language_go && sym->aclass () == LOC_BLOCK) { - gdb::unique_xmalloc_ptr<char> this_package_name - (go_symbol_package_name (sym)); + gdb::unique_xmalloc_ptr<char> this_package_name ( + go_symbol_package_name (sym)); if (this_package_name == NULL) continue; @@ -7881,13 +7727,15 @@ fixup_go_packaging (struct dwarf2_cu *cu) else { struct objfile *objfile = cu->per_objfile->objfile; - if (strcmp (package_name.get (), this_package_name.get ()) != 0) - complaint (_("Symtab %s has objects from two different Go packages: %s and %s"), - (sym->symtab () != NULL - ? symtab_to_filename_for_display - (sym->symtab ()) - : objfile_name (objfile)), - this_package_name.get (), package_name.get ()); + if (strcmp (package_name.get (), this_package_name.get ()) + != 0) + complaint ( + _ ("Symtab %s has objects from two different Go " + "packages: %s and %s"), + (sym->symtab () != NULL + ? symtab_to_filename_for_display (sym->symtab ()) + : objfile_name (objfile)), + this_package_name.get (), package_name.get ()); } } } @@ -7897,8 +7745,8 @@ fixup_go_packaging (struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_objfile->objfile; const char *saved_package_name = objfile->intern (package_name.get ()); - struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0, - saved_package_name); + struct type *type + = init_type (objfile, TYPE_CODE_MODULE, 0, saved_package_name); struct symbol *sym; sym = new (&objfile->objfile_obstack) symbol; @@ -7983,11 +7831,12 @@ alloc_rust_variant (struct obstack *obstack, struct type *type, consequence. */ part->is_unsigned = (discriminant_index == -1 - ? false - : type->field (discriminant_index).type ()->is_unsigned ()); + ? false + : type->field (discriminant_index).type ()->is_unsigned ()); part->variants = gdb::array_view<variant> (variants, n_variants); - void *storage = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>)); + void *storage + = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>)); gdb::array_view<variant_part> *prop_value = new (storage) gdb::array_view<variant_part> (part, 1); @@ -8041,15 +7890,13 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) char *tail; unsigned long index = strtoul (name, &tail, 10); name = tail; - if (*name != '$' - || index >= field_type->num_fields () + if (*name != '$' || index >= field_type->num_fields () || (field_type->field (index).loc_kind () != FIELD_LOC_KIND_BITPOS)) { - complaint (_("Could not parse Rust enum encoding string \"%s\"" - "[in module %s]"), - type->field (0).name (), - objfile_name (objfile)); + complaint (_ ("Could not parse Rust enum encoding string \"%s\"" + "[in module %s]"), + type->field (0).name (), objfile_name (objfile)); return; } ++name; @@ -8064,8 +7911,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) type->set_num_fields (3); /* Save the field we care about. */ struct field saved_field = type->field (0); - type->set_fields - ((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field))); + type->set_fields ((struct field *) + TYPE_ZALLOC (type, 3 * sizeof (struct field))); /* Put the discriminant at index 0. */ type->field (0).set_type (field_type); @@ -8076,17 +7923,15 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* The order of fields doesn't really matter, so put the real field at index 1 and the data-less field at index 2. */ type->field (1) = saved_field; - type->field (1).set_name - (rust_last_path_segment (type->field (1).type ()->name ())); - type->field (1).type ()->set_name - (rust_fully_qualify (&objfile->objfile_obstack, type->name (), - type->field (1).name ())); + type->field (1).set_name ( + rust_last_path_segment (type->field (1).type ()->name ())); + type->field (1).type ()->set_name (rust_fully_qualify ( + &objfile->objfile_obstack, type->name (), type->field (1).name ())); const char *dataless_name - = rust_fully_qualify (&objfile->objfile_obstack, type->name (), - name); - struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0, - dataless_name); + = rust_fully_qualify (&objfile->objfile_obstack, type->name (), name); + struct type *dataless_type + = init_type (objfile, TYPE_CODE_VOID, 0, dataless_name); type->field (2).set_type (dataless_type); /* NAME points into the original discriminant name, which already has the correct lifetime. */ @@ -8106,12 +7951,10 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) type->set_code (TYPE_CODE_STRUCT); struct type *field_type = type->field (0).type (); - const char *variant_name - = rust_last_path_segment (field_type->name ()); + const char *variant_name = rust_last_path_segment (field_type->name ()); type->field (0).set_name (variant_name); - field_type->set_name - (rust_fully_qualify (&objfile->objfile_obstack, - type->name (), variant_name)); + field_type->set_name (rust_fully_qualify (&objfile->objfile_obstack, + type->name (), variant_name)); alloc_rust_variant (&objfile->objfile_obstack, type, -1, 0, {}); } @@ -8132,8 +7975,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Could be data-less variant, so keep going. */ disr_type = nullptr; } - else if (strcmp (disr_type->field (0).name (), - "RUST$ENUM$DISR") != 0) + else if (strcmp (disr_type->field (0).name (), "RUST$ENUM$DISR") + != 0) { /* Not a Rust enum. */ return; @@ -8187,9 +8030,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* We don't need a range entry for the discriminant, but we do need one for every other field, as there is no default variant. */ - discriminant_range *ranges = XOBNEWVEC (&objfile->objfile_obstack, - discriminant_range, - n_fields - 1); + discriminant_range *ranges + = XOBNEWVEC (&objfile->objfile_obstack, discriminant_range, + n_fields - 1); /* Skip the discriminant here. */ for (int i = 1; i < n_fields; ++i) { @@ -8218,9 +8061,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) sub_type->set_fields (sub_type->fields () + 1); } type->field (i).set_name (variant_name); - sub_type->set_name - (rust_fully_qualify (&objfile->objfile_obstack, - type->name (), variant_name)); + sub_type->set_name (rust_fully_qualify (&objfile->objfile_obstack, + type->name (), + variant_name)); } /* Indicate that this is a variant type. */ @@ -8258,8 +8101,8 @@ dwarf2_per_objfile::get_type_unit_group_unshareable (type_unit_group *tu_group) } struct type * -dwarf2_per_objfile::get_type_for_signatured_type - (signatured_type *sig_type) const +dwarf2_per_objfile::get_type_for_signatured_type ( + signatured_type *sig_type) const { auto iter = this->m_type_map.find (sig_type); if (iter == this->m_type_map.end ()) @@ -8268,8 +8111,9 @@ dwarf2_per_objfile::get_type_for_signatured_type return iter->second; } -void dwarf2_per_objfile::set_type_for_signatured_type - (signatured_type *sig_type, struct type *type) +void +dwarf2_per_objfile::set_type_for_signatured_type (signatured_type *sig_type, + struct type *type) { gdb_assert (this->m_type_map.find (sig_type) == this->m_type_map.end ()); @@ -8323,9 +8167,8 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result, if (!per_cu->imported_symtabs_empty ()) for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs) { - recursively_compute_inclusions (result, all_children, - all_type_symtabs, ptr, per_objfile, - cust); + recursively_compute_inclusions (result, all_children, all_type_symtabs, + ptr, per_objfile, cust); } } @@ -8336,7 +8179,7 @@ static void compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { - gdb_assert (! per_cu->is_debug_types); + gdb_assert (!per_cu->is_debug_types); if (!per_cu->imported_symtabs_empty ()) { @@ -8349,11 +8192,11 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu, return; htab_up all_children (htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + htab_eq_pointer, NULL, xcalloc, + xfree)); htab_up all_type_symtabs (htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + htab_eq_pointer, NULL, + xcalloc, xfree)); for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs) { @@ -8364,9 +8207,8 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu, /* Now we have a transitive closure of all the included symtabs. */ len = result_symtabs.size (); - cust->includes - = XOBNEWVEC (&per_objfile->objfile->objfile_obstack, - struct compunit_symtab *, len + 1); + cust->includes = XOBNEWVEC (&per_objfile->objfile->objfile_obstack, + struct compunit_symtab *, len + 1); memcpy (cust->includes, result_symtabs.data (), len * sizeof (compunit_symtab *)); cust->includes[len] = NULL; @@ -8381,7 +8223,7 @@ process_cu_includes (dwarf2_per_objfile *per_objfile) { for (dwarf2_per_cu_data *iter : per_objfile->per_bfd->just_read_cus) { - if (! iter->is_debug_types) + if (!iter->is_debug_types) compute_compunit_symtab_includes (iter, per_objfile); } @@ -8419,10 +8261,10 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) case DW_TAG_type_unit: break; default: - error (_("Dwarf Error: unexpected tag '%s' at offset %s [in module %s]"), - dwarf_tag_name (cu->dies->tag), - sect_offset_str (cu->per_cu->sect_off), - objfile_name (per_objfile->objfile)); + error ( + _ ("Dwarf Error: unexpected tag '%s' at offset %s [in module %s]"), + dwarf_tag_name (cu->dies->tag), sect_offset_str (cu->per_cu->sect_off), + objfile_name (per_objfile->objfile)); } /* Do line number decoding in read_file_scope () */ @@ -8456,8 +8298,9 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) this comp unit. */ dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu); - cust = cu->get_builder ()->end_compunit_symtab_from_static_block - (static_block, 0); + cust + = cu->get_builder ()->end_compunit_symtab_from_static_block (static_block, + 0); if (cust != NULL) { @@ -8504,8 +8347,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) already been loaded into memory. */ static void -process_full_type_unit (dwarf2_cu *cu, - enum language pretend_language) +process_full_type_unit (dwarf2_cu *cu, enum language pretend_language) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct compunit_symtab *cust; @@ -8536,8 +8378,8 @@ process_full_type_unit (dwarf2_cu *cu, If this is the first TU to use this symtab, complete the construction of it with end_expandable_symtab. Otherwise, complete the addition of this TU's symbols to the existing symtab. */ - type_unit_group_unshareable *tug_unshare = - per_objfile->get_type_unit_group_unshareable (sig_type->type_unit_group); + type_unit_group_unshareable *tug_unshare + = per_objfile->get_type_unit_group_unshareable (sig_type->type_unit_group); if (tug_unshare->compunit_symtab == NULL) { buildsym_compunit *builder = cu->get_builder (); @@ -8577,8 +8419,8 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) /* For now we don't handle imported units in type units. */ if (cu->per_cu->is_debug_types) { - error (_("Dwarf Error: DW_TAG_imported_unit is not" - " supported in type units [in module %s]"), + error (_ ("Dwarf Error: DW_TAG_imported_unit is not" + " supported in type units [in module %s]"), objfile_name (cu->per_objfile->objfile)); } @@ -8602,8 +8444,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) return; /* If necessary, add it to the queue and load its DIEs. */ - if (maybe_queue_comp_unit (cu, per_cu, per_objfile, - cu->lang ())) + if (maybe_queue_comp_unit (cu, per_cu, per_objfile, cu->lang ())) load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu), false, cu->lang ()); @@ -8616,8 +8457,10 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) class process_die_scope { public: + process_die_scope (die_info *die, dwarf2_cu *cu) - : m_die (die), m_cu (cu) + : m_die (die), + m_cu (cu) { /* We should only be processing DIEs not already in process. */ gdb_assert (!m_die->in_process); @@ -8639,6 +8482,7 @@ public: } private: + die_info *m_die; dwarf2_cu *m_cu; }; @@ -8663,8 +8507,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) break; case DW_TAG_subprogram: /* Nested subprograms in Fortran get a prefix. */ - if (cu->lang () == language_fortran - && die->parent != NULL + if (cu->lang () == language_fortran && die->parent != NULL && die->parent->tag == DW_TAG_subprogram) cu->processing_has_namespace_info = true; /* Fall through. */ @@ -8740,9 +8583,10 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) /* Fall through. */ case DW_TAG_imported_module: cu->processing_has_namespace_info = true; - if (die->child != NULL && (die->tag == DW_TAG_imported_declaration - || cu->lang () != language_fortran)) - complaint (_("Tag '%s' has unexpected children"), + if (die->child != NULL + && (die->tag == DW_TAG_imported_declaration + || cu->lang () != language_fortran)) + complaint (_ ("Tag '%s' has unexpected children"), dwarf_tag_name (die->tag)); read_import_statement (die, cu); break; @@ -8760,7 +8604,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) break; } } - + /* DWARF name computation. */ /* A helper function for dwarf2_compute_name which determines whether DIE @@ -8810,9 +8654,9 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu) /* A variable in a lexical block of some kind does not need a namespace, even though in C++ such variables may be external and have a mangled name. */ - if (die->parent->tag == DW_TAG_lexical_block - || die->parent->tag == DW_TAG_try_block - || die->parent->tag == DW_TAG_catch_block + if (die->parent->tag == DW_TAG_lexical_block + || die->parent->tag == DW_TAG_try_block + || die->parent->tag == DW_TAG_catch_block || die->parent->tag == DW_TAG_subprogram) return 0; return 1; @@ -8876,9 +8720,8 @@ dw2_linkage_name (struct die_info *die, struct dwarf2_cu *cu) canonicalized. */ static const char * -dwarf2_compute_name (const char *name, - struct die_info *die, struct dwarf2_cu *cu, - int physname) +dwarf2_compute_name (const char *name, struct die_info *die, + struct dwarf2_cu *cu, int physname) { struct objfile *objfile = cu->per_objfile->objfile; @@ -8894,8 +8737,7 @@ dwarf2_compute_name (const char *name, Fortran names because there is no mangling standard. So new_symbol will set the demangled name to the result of dwarf2_full_name, and it is the demangled name that GDB uses if it exists. */ - if (lang == language_ada - || (lang == language_fortran && physname)) + if (lang == language_ada || (lang == language_fortran && physname)) { /* For Ada unit, we prefer the linkage name over the name, as the former contains the exported name, which the user expects @@ -8910,9 +8752,8 @@ dwarf2_compute_name (const char *name, /* These are the only languages we know how to qualify names in. */ if (name != NULL - && (lang == language_cplus - || lang == language_fortran || lang == language_d - || lang == language_rust)) + && (lang == language_cplus || lang == language_fortran + || lang == language_d || lang == language_rust)) { if (die_needs_namespace (die, cu)) { @@ -8923,8 +8764,8 @@ dwarf2_compute_name (const char *name, prefix = determine_prefix (die, cu); if (*prefix != '\0') { - gdb::unique_xmalloc_ptr<char> prefixed_name - (typename_concat (NULL, prefix, name, physname, cu)); + gdb::unique_xmalloc_ptr<char> prefixed_name ( + typename_concat (NULL, prefix, name, physname, cu)); buf.puts (prefixed_name.get ()); } @@ -8983,7 +8824,7 @@ dwarf2_compute_name (const char *name, attr = dwarf2_attr (child, DW_AT_type, cu); if (attr == NULL) { - complaint (_("template parameter missing DW_AT_type")); + complaint (_ ("template parameter missing DW_AT_type")); buf.puts ("UNKNOWN_TYPE"); continue; } @@ -8999,15 +8840,15 @@ dwarf2_compute_name (const char *name, attr = dwarf2_attr (child, DW_AT_const_value, cu); if (attr == NULL) { - complaint (_("template parameter missing " - "DW_AT_const_value")); + complaint (_ ("template parameter missing " + "DW_AT_const_value")); buf.puts ("UNKNOWN_VALUE"); continue; } dwarf2_const_value_attr (attr, type, name, - &cu->comp_unit_obstack, cu, - &value, &bytes, &baton); + &cu->comp_unit_obstack, cu, &value, + &bytes, &baton); if (type->has_no_signedness ()) /* GDB prints characters as NUMBER 'CHAR'. If that's @@ -9018,8 +8859,7 @@ dwarf2_compute_name (const char *name, struct value_print_options opts; if (baton != NULL) - v = dwarf2_evaluate_loc_desc (type, NULL, - baton->data, + v = dwarf2_evaluate_loc_desc (type, NULL, baton->data, baton->size, baton->per_cu, baton->per_objfile); @@ -9062,8 +8902,7 @@ dwarf2_compute_name (const char *name, { struct type *type = read_type_die (die, cu); - c_type_print_args (type, &buf, 1, lang, - &type_print_raw_options); + c_type_print_args (type, &buf, 1, lang, &type_print_raw_options); if (lang == language_cplus) { @@ -9089,7 +8928,8 @@ dwarf2_compute_name (const char *name, /* If we only computed INTERMEDIATE_NAME, or if INTERMEDIATE_NAME is already canonical, then we need to intern it. */ - if (canonical_name == NULL || canonical_name == intermediate_name.c_str ()) + if (canonical_name == NULL + || canonical_name == intermediate_name.c_str ()) name = objfile->intern (intermediate_name); else name = canonical_name; @@ -9154,8 +8994,8 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) to look up their definition from their declaration so the only disadvantage remains the minimal symbol variant `long name(params)' does not have the proper inferior type. */ - demangled = gdb_demangle (mangled, (DMGL_PARAMS | DMGL_ANSI - | DMGL_RET_DROP)); + demangled = gdb_demangle (mangled, + (DMGL_PARAMS | DMGL_ANSI | DMGL_RET_DROP)); } if (demangled) canon = demangled.get (); @@ -9176,8 +9016,8 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) compute DW_AT_linkage_name incorrectly. But in such case GDB would need to be bug-to-bug compatible. */ - complaint (_("Computed physname <%s> does not match demangled <%s> " - "(from linkage <%s>) - DIE at %s [in module %s]"), + complaint (_ ("Computed physname <%s> does not match demangled <%s> " + "(from linkage <%s>) - DIE at %s [in module %s]"), physname, canon, mangled, sect_offset_str (die->sect_off), objfile_name (objfile)); @@ -9224,7 +9064,7 @@ read_alias (struct die_info *die, struct dwarf2_cu *cu) /* If the compiler has nested DW_AT_imported_declaration DIEs, keep inspecting DIEs until we hit the underlying import. */ #define MAX_NESTED_IMPORTED_DECLARATIONS 100 - for (num = 0; num < MAX_NESTED_IMPORTED_DECLARATIONS; ++num) + for (num = 0; num < MAX_NESTED_IMPORTED_DECLARATIONS; ++num) { attr = dwarf2_attr (d, DW_AT_import, cu); if (attr == NULL) @@ -9237,8 +9077,9 @@ read_alias (struct die_info *die, struct dwarf2_cu *cu) if (num == MAX_NESTED_IMPORTED_DECLARATIONS) { - complaint (_("DIE at %s has too many recursively imported " - "declarations"), sect_offset_str (d->sect_off)); + complaint (_ ("DIE at %s has too many recursively imported " + "declarations"), + sect_offset_str (d->sect_off)); return false; } @@ -9312,11 +9153,11 @@ read_decl_line (struct die_info *die, struct dwarf2_cu *cu) if (0 <= val && val <= UINT_MAX) return (unsigned int) val; - complaint (_("Declared line for using directive is too large")); + complaint (_ ("Declared line for using directive is too large")); return 0; } - complaint (_("Declared line for using directive is of incorrect format")); + complaint (_ ("Declared line for using directive is of incorrect format")); return 0; } @@ -9340,7 +9181,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) import_attr = dwarf2_attr (die, DW_AT_import, cu); if (import_attr == NULL) { - complaint (_("Tag '%s' has no DW_AT_import"), + complaint (_ ("Tag '%s' has no DW_AT_import"), dwarf_tag_name (die->tag)); return; } @@ -9402,17 +9243,13 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) canonical_name = imported_name_prefix; } else if (strlen (imported_name_prefix) > 0) - canonical_name = obconcat (&objfile->objfile_obstack, - imported_name_prefix, - (cu->lang () == language_d - ? "." - : "::"), + canonical_name = obconcat (&objfile->objfile_obstack, imported_name_prefix, + (cu->lang () == language_d ? "." : "::"), imported_name, (char *) NULL); else canonical_name = imported_name; - if (die->tag == DW_TAG_imported_module - && cu->lang () == language_fortran) + if (die->tag == DW_TAG_imported_module && cu->lang () == language_fortran) for (child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) { @@ -9423,8 +9260,8 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) if (child_die->tag != DW_TAG_imported_declaration) { - complaint (_("child DW_TAG_imported_declaration expected " - "- DIE at %s [in module %s]"), + complaint (_ ("child DW_TAG_imported_declaration expected " + "- DIE at %s [in module %s]"), sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; @@ -9433,19 +9270,19 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) import_attr = dwarf2_attr (child_die, DW_AT_import, cu); if (import_attr == NULL) { - complaint (_("Tag '%s' has no DW_AT_import"), + complaint (_ ("Tag '%s' has no DW_AT_import"), dwarf_tag_name (child_die->tag)); continue; } imported_cu = cu; - imported_die = follow_die_ref_or_sig (child_die, import_attr, - &imported_cu); + imported_die + = follow_die_ref_or_sig (child_die, import_attr, &imported_cu); imported_name = dwarf2_name (imported_die, imported_cu); if (imported_name == NULL) { - complaint (_("child DW_TAG_imported_declaration has unknown " - "imported name - DIE at %s [in module %s]"), + complaint (_ ("child DW_TAG_imported_declaration has unknown " + "imported name - DIE at %s [in module %s]"), sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; @@ -9456,15 +9293,9 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) process_die (child_die, cu); } - add_using_directive (using_directives (cu), - import_prefix, - canonical_name, - import_alias, - imported_declaration, - excludes, - read_decl_line (die, cu), - 0, - &objfile->objfile_obstack); + add_using_directive (using_directives (cu), import_prefix, canonical_name, + import_alias, imported_declaration, excludes, + read_decl_line (die, cu), 0, &objfile->objfile_obstack); } /* ICC<14 does not output the required DW_AT_declaration on incomplete @@ -9527,10 +9358,8 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) file_and_directory res (dwarf2_string_attr (die, DW_AT_name, cu), dwarf2_string_attr (die, DW_AT_comp_dir, cu)); - if (res.get_comp_dir () == nullptr - && producer_is_gcc_lt_4_3 (cu) - && res.get_name () != nullptr - && IS_ABSOLUTE_PATH (res.get_name ())) + if (res.get_comp_dir () == nullptr && producer_is_gcc_lt_4_3 (cu) + && res.get_name () != nullptr && IS_ABSOLUTE_PATH (res.get_name ())) { res.set_comp_dir (ldirname (res.get_name ())); res.set_name (make_unique_xstrdup (lbasename (res.get_name ()))); @@ -9556,7 +9385,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, void **slot; int decode_mapping; - gdb_assert (! cu->per_cu->is_debug_types); + gdb_assert (!cu->per_cu->is_debug_types); attr = dwarf2_attr (die, DW_AT_stmt_list, cu); if (attr == NULL || !attr->form_is_unsigned ()) @@ -9570,14 +9399,11 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, compile_unit, then use the line header hash table if it's already created, but don't create one just yet. */ - if (per_objfile->line_header_hash == NULL - && die->tag == DW_TAG_partial_unit) + if (per_objfile->line_header_hash == NULL && die->tag == DW_TAG_partial_unit) { - per_objfile->line_header_hash - .reset (htab_create_alloc (127, line_header_hash_voidp, - line_header_eq_voidp, - htab_delete_entry<line_header>, - xcalloc, xfree)); + per_objfile->line_header_hash.reset ( + htab_create_alloc (127, line_header_hash_voidp, line_header_eq_voidp, + htab_delete_entry<line_header>, xcalloc, xfree)); } line_header line_header_local (line_offset, cu->per_cu->is_dwz); @@ -9601,8 +9427,8 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, /* dwarf_decode_line_header does not yet provide sufficient information. We always have to call also dwarf_decode_lines for it. */ - line_header_up lh = dwarf_decode_line_header (line_offset, cu, - fnd.get_comp_dir ()); + line_header_up lh + = dwarf_decode_line_header (line_offset, cu, fnd.get_comp_dir ()); if (lh == NULL) return; @@ -9704,7 +9530,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) if (attr != nullptr && attr->form_is_unsigned () && cu->line_header) { if (dwarf2_attr (die, DW_AT_macro_info, cu)) - complaint (_("CU refers to both DW_AT_macros and DW_AT_macro_info")); + complaint (_ ("CU refers to both DW_AT_macros and DW_AT_macro_info")); dwarf_decode_macros (cu, attr->as_unsigned (), 1); } @@ -9765,11 +9591,10 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) gdb_assert (tug_unshare->symtabs == NULL); gdb_assert (m_builder == nullptr); struct compunit_symtab *cust = tug_unshare->compunit_symtab; - m_builder.reset (new struct buildsym_compunit - (cust->objfile (), "", - cust->dirname (), - cust->language (), - 0, cust)); + m_builder.reset (new struct buildsym_compunit (cust->objfile (), "", + cust->dirname (), + cust->language (), 0, + cust)); list_in_scope = get_builder ()->get_file_symbols (); } return; @@ -9788,8 +9613,8 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) time. */ tug_unshare->symtabs - = XOBNEWVEC (&cust->objfile ()->objfile_obstack, - struct symtab *, line_header->file_names_size ()); + = XOBNEWVEC (&cust->objfile ()->objfile_obstack, struct symtab *, + line_header->file_names_size ()); auto &file_names = line_header->file_names (); for (i = 0; i < file_names.size (); ++i) @@ -9819,11 +9644,8 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) { gdb_assert (m_builder == nullptr); struct compunit_symtab *cust = tug_unshare->compunit_symtab; - m_builder.reset (new struct buildsym_compunit - (cust->objfile (), "", - cust->dirname (), - cust->language (), - 0, cust)); + m_builder.reset (new struct buildsym_compunit ( + cust->objfile (), "", cust->dirname (), cust->language (), 0, cust)); list_in_scope = get_builder ()->get_file_symbols (); auto &file_names = line_header->file_names (); @@ -9868,7 +9690,7 @@ read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu) } } } - + /* DWO/DWP files. http://gcc.gnu.org/wiki/DebugFission @@ -9908,18 +9730,15 @@ eq_dwo_file (const void *item_lhs, const void *item_rhs) static htab_up allocate_dwo_file_hash_table () { - return htab_up (htab_create_alloc (41, - hash_dwo_file, - eq_dwo_file, - htab_delete_entry<dwo_file>, - xcalloc, xfree)); + return htab_up (htab_create_alloc (41, hash_dwo_file, eq_dwo_file, + htab_delete_entry<dwo_file>, xcalloc, + xfree)); } /* Lookup DWO file DWO_NAME. */ static void ** -lookup_dwo_file_slot (dwarf2_per_objfile *per_objfile, - const char *dwo_name, +lookup_dwo_file_slot (dwarf2_per_objfile *per_objfile, const char *dwo_name, const char *comp_dir) { struct dwo_file find_entry; @@ -9966,20 +9785,16 @@ allocate_dwo_unit_table () { /* Start out with a pretty small number. Generally DWO files contain only one CU and maybe some TUs. */ - return htab_up (htab_create_alloc (3, - hash_dwo_unit, - eq_dwo_unit, - NULL, xcalloc, xfree)); + return htab_up (htab_create_alloc (3, hash_dwo_unit, eq_dwo_unit, NULL, + xcalloc, xfree)); } /* die_reader_func for create_dwo_cu. */ static void create_dwo_cu_reader (const struct die_reader_specs *reader, - const gdb_byte *info_ptr, - struct die_info *comp_unit_die, - struct dwo_file *dwo_file, - struct dwo_unit *dwo_unit) + const gdb_byte *info_ptr, struct die_info *comp_unit_die, + struct dwo_file *dwo_file, struct dwo_unit *dwo_unit) { struct dwarf2_cu *cu = reader->cu; sect_offset sect_off = cu->per_cu->sect_off; @@ -9988,8 +9803,8 @@ create_dwo_cu_reader (const struct die_reader_specs *reader, gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) { - complaint (_("Dwarf Error: debug entry at offset %s is missing" - " its dwo_id [in module %s]"), + complaint (_ ("Dwarf Error: debug entry at offset %s is missing" + " its dwo_id [in module %s]"), sect_offset_str (sect_off), dwo_file->dwo_name); return; } @@ -10009,9 +9824,9 @@ create_dwo_cu_reader (const struct die_reader_specs *reader, Note: This function processes DWO files only, not DWP files. */ static void -create_cus_hash_table (dwarf2_per_objfile *per_objfile, - dwarf2_cu *cu, struct dwo_file &dwo_file, - dwarf2_section_info §ion, htab_up &cus_htab) +create_cus_hash_table (dwarf2_per_objfile *per_objfile, dwarf2_cu *cu, + struct dwo_file &dwo_file, dwarf2_section_info §ion, + htab_up &cus_htab) { struct objfile *objfile = per_objfile->objfile; dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; @@ -10023,15 +9838,17 @@ create_cus_hash_table (dwarf2_per_objfile *per_objfile, if (info_ptr == NULL) return; - dwarf_read_debug_printf ("Reading %s for %s:", - section.get_name (), + dwarf_read_debug_printf ("Reading %s for %s:", section.get_name (), section.get_file_name ()); end_ptr = info_ptr + section.size; while (info_ptr < end_ptr) { struct dwarf2_per_cu_data per_cu; - struct dwo_unit read_unit {}; + + struct dwo_unit read_unit + { + }; struct dwo_unit *dwo_unit; void **slot; sect_offset sect_off = (sect_offset) (info_ptr - section.buffer); @@ -10054,22 +9871,22 @@ create_cus_hash_table (dwarf2_per_objfile *per_objfile, if (cus_htab == NULL) cus_htab = allocate_dwo_unit_table (); - dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack, - struct dwo_unit); + dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwo_unit); *dwo_unit = read_unit; slot = htab_find_slot (cus_htab.get (), dwo_unit, INSERT); gdb_assert (slot != NULL); if (*slot != NULL) { - const struct dwo_unit *dup_cu = (const struct dwo_unit *)*slot; + const struct dwo_unit *dup_cu = (const struct dwo_unit *) *slot; sect_offset dup_sect_off = dup_cu->sect_off; - complaint (_("debug cu entry at offset %s is duplicate to" - " the entry at offset %s, signature %s"), - sect_offset_str (sect_off), sect_offset_str (dup_sect_off), + complaint (_ ("debug cu entry at offset %s is duplicate to" + " the entry at offset %s, signature %s"), + sect_offset_str (sect_off), + sect_offset_str (dup_sect_off), hex_string (dwo_unit->signature)); } - *slot = (void *)dwo_unit; + *slot = (void *) dwo_unit; } } @@ -10266,18 +10083,19 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (version != 1 && version != 2 && version != 5) { - error (_("Dwarf Error: unsupported DWP file version (%s)" - " [in module %s]"), + error (_ ("Dwarf Error: unsupported DWP file version (%s)" + " [in module %s]"), pulongest (version), dwp_file->name); } if (nr_slots != (nr_slots & -nr_slots)) { - error (_("Dwarf Error: number of slots in DWP hash table (%s)" - " is not power of 2 [in module %s]"), + error (_ ("Dwarf Error: number of slots in DWP hash table (%s)" + " is not power of 2 [in module %s]"), pulongest (nr_slots), dwp_file->name); } - htab = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, struct dwp_hash_table); + htab + = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, struct dwp_hash_table); htab->version = version; htab->nr_columns = nr_columns; htab->nr_units = nr_units; @@ -10286,17 +10104,15 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, htab->unit_table = htab->hash_table + sizeof (uint64_t) * nr_slots; /* Exit early if the table is empty. */ - if (nr_slots == 0 || nr_units == 0 - || (version == 2 && nr_columns == 0) + if (nr_slots == 0 || nr_units == 0 || (version == 2 && nr_columns == 0) || (version == 5 && nr_columns == 0)) { /* All must be zero. */ - if (nr_slots != 0 || nr_units != 0 - || (version == 2 && nr_columns != 0) + if (nr_slots != 0 || nr_units != 0 || (version == 2 && nr_columns != 0) || (version == 5 && nr_columns != 0)) { - complaint (_("Empty DWP but nr_slots,nr_units,nr_columns not" - " all zero [in modules %s]"), + complaint (_ ("Empty DWP but nr_slots,nr_units,nr_columns not" + " all zero [in modules %s]"), dwp_file->name); } return htab; @@ -10304,14 +10120,15 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (version == 1) { - htab->section_pool.v1.indices = - htab->unit_table + sizeof (uint32_t) * nr_slots; + htab->section_pool.v1.indices + = htab->unit_table + sizeof (uint32_t) * nr_slots; /* It's harder to decide whether the section is too small in v1. V1 is deprecated anyway so we punt. */ } else if (version == 2) { - const gdb_byte *ids_ptr = htab->unit_table + sizeof (uint32_t) * nr_slots; + const gdb_byte *ids_ptr + = htab->unit_table + sizeof (uint32_t) * nr_slots; int *ids = htab->section_pool.v2.section_ids; size_t sizeof_ids = sizeof (htab->section_pool.v2.section_ids); /* Reverse map for error checking. */ @@ -10320,14 +10137,14 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (nr_columns < 2) { - error (_("Dwarf Error: bad DWP hash table, too few columns" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, too few columns" + " in section table [in module %s]"), dwp_file->name); } if (nr_columns > MAX_NR_V2_DWO_SECTIONS) { - error (_("Dwarf Error: bad DWP hash table, too many columns" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, too many columns" + " in section table [in module %s]"), dwp_file->name); } memset (ids, 255, sizeof_ids); @@ -10338,51 +10155,51 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (id < DW_SECT_MIN || id > DW_SECT_MAX) { - error (_("Dwarf Error: bad DWP hash table, bad section id %d" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, bad section id %d" + " in section table [in module %s]"), id, dwp_file->name); } if (ids_seen[id] != -1) { - error (_("Dwarf Error: bad DWP hash table, duplicate section" - " id %d in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, duplicate section" + " id %d in section table [in module %s]"), id, dwp_file->name); } ids_seen[id] = i; ids[i] = id; } /* Must have exactly one info or types section. */ - if (((ids_seen[DW_SECT_INFO] != -1) - + (ids_seen[DW_SECT_TYPES] != -1)) + if (((ids_seen[DW_SECT_INFO] != -1) + (ids_seen[DW_SECT_TYPES] != -1)) != 1) { - error (_("Dwarf Error: bad DWP hash table, missing/duplicate" - " DWO info/types section [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, missing/duplicate" + " DWO info/types section [in module %s]"), dwp_file->name); } /* Must have an abbrev section. */ if (ids_seen[DW_SECT_ABBREV] == -1) { - error (_("Dwarf Error: bad DWP hash table, missing DWO abbrev" - " section [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, missing DWO abbrev" + " section [in module %s]"), dwp_file->name); } htab->section_pool.v2.offsets = ids_ptr + sizeof (uint32_t) * nr_columns; - htab->section_pool.v2.sizes = - htab->section_pool.v2.offsets + (sizeof (uint32_t) - * nr_units * nr_columns); - if ((htab->section_pool.v2.sizes + (sizeof (uint32_t) - * nr_units * nr_columns)) + htab->section_pool.v2.sizes + = htab->section_pool.v2.offsets + + (sizeof (uint32_t) * nr_units * nr_columns); + if ((htab->section_pool.v2.sizes + + (sizeof (uint32_t) * nr_units * nr_columns)) > index_end) { - error (_("Dwarf Error: DWP index section is corrupt (too small)" - " [in module %s]"), + error (_ ("Dwarf Error: DWP index section is corrupt (too small)" + " [in module %s]"), dwp_file->name); } } else /* version == 5 */ { - const gdb_byte *ids_ptr = htab->unit_table + sizeof (uint32_t) * nr_slots; + const gdb_byte *ids_ptr + = htab->unit_table + sizeof (uint32_t) * nr_slots; int *ids = htab->section_pool.v5.section_ids; size_t sizeof_ids = sizeof (htab->section_pool.v5.section_ids); /* Reverse map for error checking. */ @@ -10390,14 +10207,14 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (nr_columns < 2) { - error (_("Dwarf Error: bad DWP hash table, too few columns" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, too few columns" + " in section table [in module %s]"), dwp_file->name); } if (nr_columns > MAX_NR_V5_DWO_SECTIONS) { - error (_("Dwarf Error: bad DWP hash table, too many columns" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, too many columns" + " in section table [in module %s]"), dwp_file->name); } memset (ids, 255, sizeof_ids); @@ -10408,14 +10225,14 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, if (id < DW_SECT_MIN || id > DW_SECT_MAX_V5) { - error (_("Dwarf Error: bad DWP hash table, bad section id %d" - " in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, bad section id %d" + " in section table [in module %s]"), id, dwp_file->name); } if (ids_seen[id] != -1) { - error (_("Dwarf Error: bad DWP hash table, duplicate section" - " id %d in section table [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, duplicate section" + " id %d in section table [in module %s]"), id, dwp_file->name); } ids_seen[id] = i; @@ -10424,27 +10241,27 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, /* Must have seen an info section. */ if (ids_seen[DW_SECT_INFO_V5] == -1) { - error (_("Dwarf Error: bad DWP hash table, missing/duplicate" - " DWO info/types section [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, missing/duplicate" + " DWO info/types section [in module %s]"), dwp_file->name); } /* Must have an abbrev section. */ if (ids_seen[DW_SECT_ABBREV_V5] == -1) { - error (_("Dwarf Error: bad DWP hash table, missing DWO abbrev" - " section [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, missing DWO abbrev" + " section [in module %s]"), dwp_file->name); } htab->section_pool.v5.offsets = ids_ptr + sizeof (uint32_t) * nr_columns; htab->section_pool.v5.sizes - = htab->section_pool.v5.offsets + (sizeof (uint32_t) - * nr_units * nr_columns); - if ((htab->section_pool.v5.sizes + (sizeof (uint32_t) - * nr_units * nr_columns)) + = htab->section_pool.v5.offsets + + (sizeof (uint32_t) * nr_units * nr_columns); + if ((htab->section_pool.v5.sizes + + (sizeof (uint32_t) * nr_units * nr_columns)) > index_end) { - error (_("Dwarf Error: DWP index section is corrupt (too small)" - " [in module %s]"), + error (_ ("Dwarf Error: DWP index section is corrupt (too small)" + " [in module %s]"), dwp_file->name); } } @@ -10539,13 +10356,12 @@ locate_v1_virtual_dwo_sections (asection *sectp, static struct dwo_unit * create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile *per_objfile, - struct dwp_file *dwp_file, - uint32_t unit_index, - const char *comp_dir, - ULONGEST signature, int is_debug_types) + struct dwp_file *dwp_file, uint32_t unit_index, + const char *comp_dir, ULONGEST signature, + int is_debug_types) { - const struct dwp_hash_table *dwp_htab = - is_debug_types ? dwp_file->tus : dwp_file->cus; + const struct dwp_hash_table *dwp_htab + = is_debug_types ? dwp_file->tus : dwp_file->cus; bfd *dbfd = dwp_file->dbfd.get (); const char *kind = is_debug_types ? "TU" : "CU"; struct dwo_file *dwo_file; @@ -10556,20 +10372,20 @@ create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile *per_objfile, gdb_assert (dwp_file->version == 1); - dwarf_read_debug_printf ("Reading %s %s/%s in DWP V1 file: %s", - kind, pulongest (unit_index), hex_string (signature), + dwarf_read_debug_printf ("Reading %s %s/%s in DWP V1 file: %s", kind, + pulongest (unit_index), hex_string (signature), dwp_file->name); /* Fetch the sections of this DWO unit. Put a limit on the number of sections we look for so that bad data doesn't cause us to loop forever. */ -#define MAX_NR_V1_DWO_SECTIONS \ - (1 /* .debug_info or .debug_types */ \ - + 1 /* .debug_abbrev */ \ - + 1 /* .debug_line */ \ - + 1 /* .debug_loc */ \ - + 1 /* .debug_str_offsets */ \ +#define MAX_NR_V1_DWO_SECTIONS \ + (1 /* .debug_info or .debug_types */ \ + + 1 /* .debug_abbrev */ \ + + 1 /* .debug_line */ \ + + 1 /* .debug_loc */ \ + + 1 /* .debug_str_offsets */ \ + 1 /* .debug_macro or .debug_macinfo */ \ + 1 /* trailing zero */) @@ -10578,41 +10394,38 @@ create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile *per_objfile, for (i = 0; i < MAX_NR_V1_DWO_SECTIONS; ++i) { asection *sectp; - uint32_t section_nr = - read_4_bytes (dbfd, - dwp_htab->section_pool.v1.indices - + (unit_index + i) * sizeof (uint32_t)); + uint32_t section_nr + = read_4_bytes (dbfd, dwp_htab->section_pool.v1.indices + + (unit_index + i) * sizeof (uint32_t)); if (section_nr == 0) break; if (section_nr >= dwp_file->num_sections) { - error (_("Dwarf Error: bad DWP hash table, section number too large" - " [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, section number too large" + " [in module %s]"), dwp_file->name); } sectp = dwp_file->elf_sections[section_nr]; - if (! locate_v1_virtual_dwo_sections (sectp, §ions)) + if (!locate_v1_virtual_dwo_sections (sectp, §ions)) { - error (_("Dwarf Error: bad DWP hash table, invalid section found" - " [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, invalid section found" + " [in module %s]"), dwp_file->name); } } - if (i < 2 - || sections.info_or_types.empty () - || sections.abbrev.empty ()) + if (i < 2 || sections.info_or_types.empty () || sections.abbrev.empty ()) { - error (_("Dwarf Error: bad DWP hash table, missing DWO sections" - " [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, missing DWO sections" + " [in module %s]"), dwp_file->name); } if (i == MAX_NR_V1_DWO_SECTIONS) { - error (_("Dwarf Error: bad DWP hash table, too many DWO sections" - " [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, too many DWO sections" + " [in module %s]"), dwp_file->name); } @@ -10625,15 +10438,13 @@ create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile *per_objfile, (fewer struct dwo_file objects to allocate). Remember that for really large apps there can be on the order of 8K CUs and 200K TUs, or more. */ - std::string virtual_dwo_name = - string_printf ("virtual-dwo/%d-%d-%d-%d", - sections.abbrev.get_id (), - sections.line.get_id (), - sections.loc.get_id (), - sections.str_offsets.get_id ()); + std::string virtual_dwo_name + = string_printf ("virtual-dwo/%d-%d-%d-%d", sections.abbrev.get_id (), + sections.line.get_id (), sections.loc.get_id (), + sections.str_offsets.get_id ()); /* Can we use an existing virtual DWO file? */ - dwo_file_slot = lookup_dwo_file_slot (per_objfile, virtual_dwo_name.c_str (), - comp_dir); + dwo_file_slot + = lookup_dwo_file_slot (per_objfile, virtual_dwo_name.c_str (), comp_dir); /* Create one if necessary. */ if (*dwo_file_slot == NULL) { @@ -10671,8 +10482,8 @@ create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile *per_objfile, dwo_unit = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, struct dwo_unit); dwo_unit->dwo_file = dwo_file; dwo_unit->signature = signature; - dwo_unit->section = - XOBNEW (&per_objfile->per_bfd->obstack, struct dwarf2_section_info); + dwo_unit->section + = XOBNEW (&per_objfile->per_bfd->obstack, struct dwarf2_section_info); *dwo_unit->section = sections.info_or_types; /* dwo_unit->{offset,length,type_offset_in_tu} are set later. */ @@ -10707,11 +10518,10 @@ create_dwp_v2_or_v5_section (dwarf2_per_objfile *per_objfile, /* Flag an error if the piece denoted by OFFSET,SIZE is outside the bounds of the real section. This is a pretty-rare event, so just flag an error (easier) instead of a warning and trying to cope. */ - if (sectp == NULL - || offset + size > bfd_section_size (sectp)) + if (sectp == NULL || offset + size > bfd_section_size (sectp)) { - error (_("Dwarf Error: Bad DWP V2 or V5 section info, doesn't fit" - " in section %s [in module %s]"), + error (_ ("Dwarf Error: Bad DWP V2 or V5 section info, doesn't fit" + " in section %s [in module %s]"), sectp ? bfd_section_name (sectp) : "<unknown>", objfile_name (per_objfile->objfile)); } @@ -10728,13 +10538,12 @@ create_dwp_v2_or_v5_section (dwarf2_per_objfile *per_objfile, static struct dwo_unit * create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, - struct dwp_file *dwp_file, - uint32_t unit_index, - const char *comp_dir, - ULONGEST signature, int is_debug_types) + struct dwp_file *dwp_file, uint32_t unit_index, + const char *comp_dir, ULONGEST signature, + int is_debug_types) { - const struct dwp_hash_table *dwp_htab = - is_debug_types ? dwp_file->tus : dwp_file->cus; + const struct dwp_hash_table *dwp_htab + = is_debug_types ? dwp_file->tus : dwp_file->cus; bfd *dbfd = dwp_file->dbfd.get (); const char *kind = is_debug_types ? "TU" : "CU"; struct dwo_file *dwo_file; @@ -10745,8 +10554,8 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, gdb_assert (dwp_file->version == 2); - dwarf_read_debug_printf ("Reading %s %s/%s in DWP V2 file: %s", - kind, pulongest (unit_index), hex_string (signature), + dwarf_read_debug_printf ("Reading %s %s/%s in DWP V2 file: %s", kind, + pulongest (unit_index), hex_string (signature), dwp_file->name); /* Fetch the section offsets of this DWO unit. */ @@ -10755,16 +10564,16 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, for (i = 0; i < dwp_htab->nr_columns; ++i) { - uint32_t offset = read_4_bytes (dbfd, - dwp_htab->section_pool.v2.offsets - + (((unit_index - 1) * dwp_htab->nr_columns - + i) - * sizeof (uint32_t))); - uint32_t size = read_4_bytes (dbfd, - dwp_htab->section_pool.v2.sizes - + (((unit_index - 1) * dwp_htab->nr_columns - + i) - * sizeof (uint32_t))); + uint32_t offset + = read_4_bytes (dbfd, + dwp_htab->section_pool.v2.offsets + + (((unit_index - 1) * dwp_htab->nr_columns + i) + * sizeof (uint32_t))); + uint32_t size + = read_4_bytes (dbfd, + dwp_htab->section_pool.v2.sizes + + (((unit_index - 1) * dwp_htab->nr_columns + i) + * sizeof (uint32_t))); switch (dwp_htab->section_pool.v2.section_ids[i]) { @@ -10809,16 +10618,15 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, (fewer struct dwo_file objects to allocate). Remember that for really large apps there can be on the order of 8K CUs and 200K TUs, or more. */ - std::string virtual_dwo_name = - string_printf ("virtual-dwo/%ld-%ld-%ld-%ld", - (long) (sections.abbrev_size ? sections.abbrev_offset : 0), - (long) (sections.line_size ? sections.line_offset : 0), - (long) (sections.loc_size ? sections.loc_offset : 0), - (long) (sections.str_offsets_size - ? sections.str_offsets_offset : 0)); + std::string virtual_dwo_name = string_printf ( + "virtual-dwo/%ld-%ld-%ld-%ld", + (long) (sections.abbrev_size ? sections.abbrev_offset : 0), + (long) (sections.line_size ? sections.line_offset : 0), + (long) (sections.loc_size ? sections.loc_offset : 0), + (long) (sections.str_offsets_size ? sections.str_offsets_offset : 0)); /* Can we use an existing virtual DWO file? */ - dwo_file_slot = lookup_dwo_file_slot (per_objfile, virtual_dwo_name.c_str (), - comp_dir); + dwo_file_slot + = lookup_dwo_file_slot (per_objfile, virtual_dwo_name.c_str (), comp_dir); /* Create one if necessary. */ if (*dwo_file_slot == NULL) { @@ -10828,30 +10636,31 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, dwo_file = new struct dwo_file; dwo_file->dwo_name = per_objfile->objfile->intern (virtual_dwo_name); dwo_file->comp_dir = comp_dir; - dwo_file->sections.abbrev = - create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.abbrev, - sections.abbrev_offset, - sections.abbrev_size); - dwo_file->sections.line = - create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.line, - sections.line_offset, - sections.line_size); - dwo_file->sections.loc = - create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.loc, - sections.loc_offset, sections.loc_size); - dwo_file->sections.macinfo = - create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.macinfo, - sections.macinfo_offset, - sections.macinfo_size); - dwo_file->sections.macro = - create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.macro, - sections.macro_offset, - sections.macro_size); - dwo_file->sections.str_offsets = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.str_offsets, - sections.str_offsets_offset, - sections.str_offsets_size); + dwo_file->sections.abbrev + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.abbrev, + sections.abbrev_offset, + sections.abbrev_size); + dwo_file->sections.line + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.line, + sections.line_offset, + sections.line_size); + dwo_file->sections.loc + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.loc, + sections.loc_offset, sections.loc_size); + dwo_file->sections.macinfo + = create_dwp_v2_or_v5_section (per_objfile, + &dwp_file->sections.macinfo, + sections.macinfo_offset, + sections.macinfo_size); + dwo_file->sections.macro + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.macro, + sections.macro_offset, + sections.macro_size); + dwo_file->sections.str_offsets + = create_dwp_v2_or_v5_section (per_objfile, + &dwp_file->sections.str_offsets, + sections.str_offsets_offset, + sections.str_offsets_size); /* The "str" section is global to the entire DWP file. */ dwo_file->sections.str = dwp_file->sections.str; /* The info or types section is assigned below to dwo_unit, @@ -10874,15 +10683,14 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, dwo_unit = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, struct dwo_unit); dwo_unit->dwo_file = dwo_file; dwo_unit->signature = signature; - dwo_unit->section = - XOBNEW (&per_objfile->per_bfd->obstack, struct dwarf2_section_info); - *dwo_unit->section = create_dwp_v2_or_v5_section - (per_objfile, - is_debug_types - ? &dwp_file->sections.types - : &dwp_file->sections.info, - sections.info_or_types_offset, - sections.info_or_types_size); + dwo_unit->section + = XOBNEW (&per_objfile->per_bfd->obstack, struct dwarf2_section_info); + *dwo_unit->section + = create_dwp_v2_or_v5_section (per_objfile, + is_debug_types ? &dwp_file->sections.types + : &dwp_file->sections.info, + sections.info_or_types_offset, + sections.info_or_types_size); /* dwo_unit->{offset,length,type_offset_in_tu} are set later. */ return dwo_unit; @@ -10895,10 +10703,9 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile *per_objfile, static struct dwo_unit * create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, - struct dwp_file *dwp_file, - uint32_t unit_index, - const char *comp_dir, - ULONGEST signature, int is_debug_types) + struct dwp_file *dwp_file, uint32_t unit_index, + const char *comp_dir, ULONGEST signature, + int is_debug_types) { const struct dwp_hash_table *dwp_htab = is_debug_types ? dwp_file->tus : dwp_file->cus; @@ -10906,13 +10713,17 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, const char *kind = is_debug_types ? "TU" : "CU"; struct dwo_file *dwo_file; struct dwo_unit *dwo_unit; - struct virtual_v2_or_v5_dwo_sections sections {}; + + struct virtual_v2_or_v5_dwo_sections sections + { + }; + void **dwo_file_slot; gdb_assert (dwp_file->version == 5); - dwarf_read_debug_printf ("Reading %s %s/%s in DWP V5 file: %s", - kind, pulongest (unit_index), hex_string (signature), + dwarf_read_debug_printf ("Reading %s %s/%s in DWP V5 file: %s", kind, + pulongest (unit_index), hex_string (signature), dwp_file->name); /* Fetch the section offsets of this DWO unit. */ @@ -10921,51 +10732,50 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, for (int i = 0; i < dwp_htab->nr_columns; ++i) { - uint32_t offset = read_4_bytes (dbfd, - dwp_htab->section_pool.v5.offsets - + (((unit_index - 1) - * dwp_htab->nr_columns - + i) - * sizeof (uint32_t))); - uint32_t size = read_4_bytes (dbfd, - dwp_htab->section_pool.v5.sizes - + (((unit_index - 1) * dwp_htab->nr_columns - + i) - * sizeof (uint32_t))); + uint32_t offset + = read_4_bytes (dbfd, + dwp_htab->section_pool.v5.offsets + + (((unit_index - 1) * dwp_htab->nr_columns + i) + * sizeof (uint32_t))); + uint32_t size + = read_4_bytes (dbfd, + dwp_htab->section_pool.v5.sizes + + (((unit_index - 1) * dwp_htab->nr_columns + i) + * sizeof (uint32_t))); switch (dwp_htab->section_pool.v5.section_ids[i]) { - case DW_SECT_ABBREV_V5: - sections.abbrev_offset = offset; - sections.abbrev_size = size; - break; - case DW_SECT_INFO_V5: - sections.info_or_types_offset = offset; - sections.info_or_types_size = size; - break; - case DW_SECT_LINE_V5: - sections.line_offset = offset; - sections.line_size = size; - break; - case DW_SECT_LOCLISTS_V5: - sections.loclists_offset = offset; - sections.loclists_size = size; - break; - case DW_SECT_MACRO_V5: - sections.macro_offset = offset; - sections.macro_size = size; - break; - case DW_SECT_RNGLISTS_V5: - sections.rnglists_offset = offset; - sections.rnglists_size = size; - break; - case DW_SECT_STR_OFFSETS_V5: - sections.str_offsets_offset = offset; - sections.str_offsets_size = size; - break; - case DW_SECT_RESERVED_V5: - default: - break; + case DW_SECT_ABBREV_V5: + sections.abbrev_offset = offset; + sections.abbrev_size = size; + break; + case DW_SECT_INFO_V5: + sections.info_or_types_offset = offset; + sections.info_or_types_size = size; + break; + case DW_SECT_LINE_V5: + sections.line_offset = offset; + sections.line_size = size; + break; + case DW_SECT_LOCLISTS_V5: + sections.loclists_offset = offset; + sections.loclists_size = size; + break; + case DW_SECT_MACRO_V5: + sections.macro_offset = offset; + sections.macro_size = size; + break; + case DW_SECT_RNGLISTS_V5: + sections.rnglists_offset = offset; + sections.rnglists_size = size; + break; + case DW_SECT_STR_OFFSETS_V5: + sections.str_offsets_offset = offset; + sections.str_offsets_size = size; + break; + case DW_SECT_RESERVED_V5: + default: + break; } } @@ -10978,19 +10788,17 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, (fewer struct dwo_file objects to allocate). Remember that for really large apps there can be on the order of 8K CUs and 200K TUs, or more. */ - std::string virtual_dwo_name = - string_printf ("virtual-dwo/%ld-%ld-%ld-%ld-%ld-%ld", - (long) (sections.abbrev_size ? sections.abbrev_offset : 0), - (long) (sections.line_size ? sections.line_offset : 0), - (long) (sections.loclists_size ? sections.loclists_offset : 0), - (long) (sections.str_offsets_size - ? sections.str_offsets_offset : 0), - (long) (sections.macro_size ? sections.macro_offset : 0), - (long) (sections.rnglists_size ? sections.rnglists_offset: 0)); + std::string virtual_dwo_name = string_printf ( + "virtual-dwo/%ld-%ld-%ld-%ld-%ld-%ld", + (long) (sections.abbrev_size ? sections.abbrev_offset : 0), + (long) (sections.line_size ? sections.line_offset : 0), + (long) (sections.loclists_size ? sections.loclists_offset : 0), + (long) (sections.str_offsets_size ? sections.str_offsets_offset : 0), + (long) (sections.macro_size ? sections.macro_offset : 0), + (long) (sections.rnglists_size ? sections.rnglists_offset : 0)); /* Can we use an existing virtual DWO file? */ - dwo_file_slot = lookup_dwo_file_slot (per_objfile, - virtual_dwo_name.c_str (), - comp_dir); + dwo_file_slot + = lookup_dwo_file_slot (per_objfile, virtual_dwo_name.c_str (), comp_dir); /* Create one if necessary. */ if (*dwo_file_slot == NULL) { @@ -11000,35 +10808,33 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, dwo_file = new struct dwo_file; dwo_file->dwo_name = per_objfile->objfile->intern (virtual_dwo_name); dwo_file->comp_dir = comp_dir; - dwo_file->sections.abbrev = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.abbrev, - sections.abbrev_offset, - sections.abbrev_size); - dwo_file->sections.line = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.line, - sections.line_offset, sections.line_size); - dwo_file->sections.macro = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.macro, - sections.macro_offset, - sections.macro_size); - dwo_file->sections.loclists = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.loclists, - sections.loclists_offset, - sections.loclists_size); - dwo_file->sections.rnglists = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.rnglists, - sections.rnglists_offset, - sections.rnglists_size); - dwo_file->sections.str_offsets = - create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.str_offsets, - sections.str_offsets_offset, - sections.str_offsets_size); + dwo_file->sections.abbrev + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.abbrev, + sections.abbrev_offset, + sections.abbrev_size); + dwo_file->sections.line + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.line, + sections.line_offset, + sections.line_size); + dwo_file->sections.macro + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.macro, + sections.macro_offset, + sections.macro_size); + dwo_file->sections.loclists + = create_dwp_v2_or_v5_section (per_objfile, + &dwp_file->sections.loclists, + sections.loclists_offset, + sections.loclists_size); + dwo_file->sections.rnglists + = create_dwp_v2_or_v5_section (per_objfile, + &dwp_file->sections.rnglists, + sections.rnglists_offset, + sections.rnglists_size); + dwo_file->sections.str_offsets + = create_dwp_v2_or_v5_section (per_objfile, + &dwp_file->sections.str_offsets, + sections.str_offsets_offset, + sections.str_offsets_size); /* The "str" section is global to the entire DWP file. */ dwo_file->sections.str = dwp_file->sections.str; /* The info or types section is assigned below to dwo_unit, @@ -11053,10 +10859,10 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_objfile *per_objfile, dwo_unit->signature = signature; dwo_unit->section = XOBNEW (&per_objfile->per_bfd->obstack, struct dwarf2_section_info); - *dwo_unit->section = create_dwp_v2_or_v5_section (per_objfile, - &dwp_file->sections.info, - sections.info_or_types_offset, - sections.info_or_types_size); + *dwo_unit->section + = create_dwp_v2_or_v5_section (per_objfile, &dwp_file->sections.info, + sections.info_or_types_offset, + sections.info_or_types_size); /* dwo_unit->{offset,length,type_offset_in_tu} are set later. */ return dwo_unit; @@ -11070,8 +10876,8 @@ lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, struct dwp_file *dwp_file, const char *comp_dir, ULONGEST signature, int is_debug_types) { - const struct dwp_hash_table *dwp_htab = - is_debug_types ? dwp_file->tus : dwp_file->cus; + const struct dwp_hash_table *dwp_htab + = is_debug_types ? dwp_file->tus : dwp_file->cus; bfd *dbfd = dwp_file->dbfd.get (); uint32_t mask = dwp_htab->nr_slots - 1; uint32_t hash = signature & mask; @@ -11082,9 +10888,8 @@ lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, memset (&find_dwo_cu, 0, sizeof (find_dwo_cu)); find_dwo_cu.signature = signature; - slot = htab_find_slot (is_debug_types - ? dwp_file->loaded_tus.get () - : dwp_file->loaded_cus.get (), + slot = htab_find_slot (is_debug_types ? dwp_file->loaded_tus.get () + : dwp_file->loaded_cus.get (), &find_dwo_cu, INSERT); if (*slot != NULL) @@ -11095,13 +10900,13 @@ lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, { ULONGEST signature_in_table; - signature_in_table = - read_8_bytes (dbfd, dwp_htab->hash_table + hash * sizeof (uint64_t)); + signature_in_table + = read_8_bytes (dbfd, dwp_htab->hash_table + hash * sizeof (uint64_t)); if (signature_in_table == signature) { - uint32_t unit_index = - read_4_bytes (dbfd, - dwp_htab->unit_table + hash * sizeof (uint32_t)); + uint32_t unit_index + = read_4_bytes (dbfd, + dwp_htab->unit_table + hash * sizeof (uint32_t)); if (dwp_file->version == 1) { @@ -11128,8 +10933,8 @@ lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, hash = (hash + hash2) & mask; } - error (_("Dwarf Error: bad DWP hash table, lookup didn't terminate" - " [in module %s]"), + error (_ ("Dwarf Error: bad DWP hash table, lookup didn't terminate" + " [in module %s]"), dwp_file->name); } @@ -11146,8 +10951,8 @@ lookup_dwo_unit_in_dwp (dwarf2_per_objfile *per_objfile, NOTE: This function is derived from symfile_bfd_open. */ static gdb_bfd_ref_ptr -try_open_dwop_file (dwarf2_per_objfile *per_objfile, - const char *file_name, int is_dwp, int search_cwd) +try_open_dwop_file (dwarf2_per_objfile *per_objfile, const char *file_name, + int is_dwp, int search_cwd) { int desc; /* Blech. OPF_TRY_CWD_FIRST also disables searching the path list if @@ -11175,8 +10980,8 @@ try_open_dwop_file (dwarf2_per_objfile *per_objfile, /* Add the path for the executable binary to the list of search paths. */ std::string objfile_dir = ldirname (objfile_name (per_objfile->objfile)); search_path_holder.reset (concat (objfile_dir.c_str (), - dirname_separator_string, - search_path, nullptr)); + dirname_separator_string, search_path, + nullptr)); search_path = search_path_holder.get (); openp_flags flags = OPF_RETURN_REALPATH; @@ -11184,13 +10989,13 @@ try_open_dwop_file (dwarf2_per_objfile *per_objfile, flags |= OPF_SEARCH_IN_PATH; gdb::unique_xmalloc_ptr<char> absolute_name; - desc = openp (search_path, flags, file_name, - O_RDONLY | O_BINARY, &absolute_name); + desc = openp (search_path, flags, file_name, O_RDONLY | O_BINARY, + &absolute_name); if (desc < 0) return NULL; - gdb_bfd_ref_ptr sym_bfd (gdb_bfd_open (absolute_name.get (), - gnutarget, desc)); + gdb_bfd_ref_ptr sym_bfd (gdb_bfd_open (absolute_name.get (), gnutarget, + desc)); if (sym_bfd == NULL) return NULL; bfd_set_cacheable (sym_bfd.get (), 1); @@ -11215,12 +11020,12 @@ try_open_dwop_file (dwarf2_per_objfile *per_objfile, same as symfile_bfd_open. */ static gdb_bfd_ref_ptr -open_dwo_file (dwarf2_per_objfile *per_objfile, - const char *file_name, const char *comp_dir) +open_dwo_file (dwarf2_per_objfile *per_objfile, const char *file_name, + const char *comp_dir) { if (IS_ABSOLUTE_PATH (file_name)) - return try_open_dwop_file (per_objfile, file_name, - 0 /*is_dwp*/, 0 /*search_cwd*/); + return try_open_dwop_file (per_objfile, file_name, 0 /*is_dwp*/, + 0 /*search_cwd*/); /* Before trying the search path, try DWO_NAME in COMP_DIR. */ @@ -11230,8 +11035,8 @@ open_dwo_file (dwarf2_per_objfile *per_objfile, /* NOTE: If comp_dir is a relative path, this will also try the search path, which seems useful. */ - gdb_bfd_ref_ptr abfd (try_open_dwop_file - (per_objfile, path_to_try.c_str (), 0 /*is_dwp*/, 1 /*search_cwd*/)); + gdb_bfd_ref_ptr abfd (try_open_dwop_file ( + per_objfile, path_to_try.c_str (), 0 /*is_dwp*/, 1 /*search_cwd*/)); if (abfd != NULL) return abfd; @@ -11243,8 +11048,8 @@ open_dwo_file (dwarf2_per_objfile *per_objfile, if (debug_file_directory.empty ()) return NULL; - return try_open_dwop_file (per_objfile, file_name, - 0 /*is_dwp*/, 1 /*search_cwd*/); + return try_open_dwop_file (per_objfile, file_name, 0 /*is_dwp*/, + 1 /*search_cwd*/); } /* This function is mapped across the sections and remembers the offset and @@ -11490,10 +11295,9 @@ eq_dwp_loaded_cutus (const void *a, const void *b) static htab_up allocate_dwp_loaded_cutus_table () { - return htab_up (htab_create_alloc (3, - hash_dwp_loaded_cutus, - eq_dwp_loaded_cutus, - NULL, xcalloc, xfree)); + return htab_up (htab_create_alloc (3, hash_dwp_loaded_cutus, + eq_dwp_loaded_cutus, NULL, xcalloc, + xfree)); } /* Try to open DWP file FILE_NAME. @@ -11506,8 +11310,7 @@ static gdb_bfd_ref_ptr open_dwp_file (dwarf2_per_objfile *per_objfile, const char *file_name) { gdb_bfd_ref_ptr abfd (try_open_dwop_file (per_objfile, file_name, - 1 /*is_dwp*/, - 1 /*search_cwd*/)); + 1 /*is_dwp*/, 1 /*search_cwd*/)); if (abfd != NULL) return abfd; @@ -11525,8 +11328,7 @@ open_dwp_file (dwarf2_per_objfile *per_objfile, const char *file_name) If the user wants to search "." to handle this case, it must be added to debug-file-directory. */ return try_open_dwop_file (per_objfile, lbasename (file_name), - 1 /*is_dwp*/, - 0 /*search_cwd*/); + 1 /*is_dwp*/, 0 /*search_cwd*/); } return NULL; @@ -11552,7 +11354,8 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) struct objfile *backlink = objfile->separate_debug_objfile_backlink; const char *backlink_basename = lbasename (backlink->original_name); - dwp_name = ldirname (objfile->original_name) + SLASH_STRING + backlink_basename; + dwp_name + = ldirname (objfile->original_name) + SLASH_STRING + backlink_basename; } else dwp_name = objfile->original_name; @@ -11577,13 +11380,12 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) } const char *name = bfd_get_filename (dbfd.get ()); - std::unique_ptr<struct dwp_file> dwp_file - (new struct dwp_file (name, std::move (dbfd))); + std::unique_ptr<struct dwp_file> dwp_file ( + new struct dwp_file (name, std::move (dbfd))); dwp_file->num_sections = elf_numsections (dwp_file->dbfd); - dwp_file->elf_sections = - OBSTACK_CALLOC (&per_objfile->per_bfd->obstack, - dwp_file->num_sections, asection *); + dwp_file->elf_sections = OBSTACK_CALLOC (&per_objfile->per_bfd->obstack, + dwp_file->num_sections, asection *); for (asection *sec : gdb_bfd_sections (dwp_file->dbfd)) dwarf2_locate_common_dwp_sections (objfile, dwp_file->dbfd.get (), sec, @@ -11600,8 +11402,8 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) /* Technically speaking, we should try to limp along, but this is pretty bizarre. We use pulongest here because that's the established portability solution (e.g, we cannot use %u for uint32_t). */ - error (_("Dwarf Error: DWP file CU version %s doesn't match" - " TU version %s [in DWP file %s]"), + error (_ ("Dwarf Error: DWP file CU version %s doesn't match" + " TU version %s [in DWP file %s]"), pulongest (dwp_file->cus->version), pulongest (dwp_file->tus->version), dwp_name.c_str ()); } @@ -11627,9 +11429,10 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) dwp_file->loaded_tus = allocate_dwp_loaded_cutus_table (); dwarf_read_debug_printf ("DWP file found: %s", dwp_file->name); - dwarf_read_debug_printf (" %s CUs, %s TUs", - pulongest (dwp_file->cus ? dwp_file->cus->nr_units : 0), - pulongest (dwp_file->tus ? dwp_file->tus->nr_units : 0)); + dwarf_read_debug_printf ( + " %s CUs, %s TUs", + pulongest (dwp_file->cus ? dwp_file->cus->nr_units : 0), + pulongest (dwp_file->tus ? dwp_file->tus->nr_units : 0)); return dwp_file; } @@ -11682,19 +11485,19 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, dwp_file = get_dwp_file (per_objfile); if (dwp_file != NULL) { - const struct dwp_hash_table *dwp_htab = - is_debug_types ? dwp_file->tus : dwp_file->cus; + const struct dwp_hash_table *dwp_htab + = is_debug_types ? dwp_file->tus : dwp_file->cus; if (dwp_htab != NULL) { - struct dwo_unit *dwo_cutu = - lookup_dwo_unit_in_dwp (per_objfile, dwp_file, comp_dir, signature, - is_debug_types); + struct dwo_unit *dwo_cutu + = lookup_dwo_unit_in_dwp (per_objfile, dwp_file, comp_dir, + signature, is_debug_types); if (dwo_cutu != NULL) { - dwarf_read_debug_printf ("Virtual DWO %s %s found: @%s", - kind, hex_string (signature), + dwarf_read_debug_printf ("Virtual DWO %s %s found: @%s", kind, + hex_string (signature), host_address_to_string (dwo_cutu)); return dwo_cutu; @@ -11724,9 +11527,8 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, memset (&find_dwo_cutu, 0, sizeof (find_dwo_cutu)); find_dwo_cutu.signature = signature; - dwo_cutu - = (struct dwo_unit *) htab_find (dwo_file->tus.get (), - &find_dwo_cutu); + dwo_cutu = (struct dwo_unit *) htab_find (dwo_file->tus.get (), + &find_dwo_cutu); } else if (!is_debug_types && dwo_file->cus) { @@ -11734,14 +11536,14 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, memset (&find_dwo_cutu, 0, sizeof (find_dwo_cutu)); find_dwo_cutu.signature = signature; - dwo_cutu = (struct dwo_unit *)htab_find (dwo_file->cus.get (), - &find_dwo_cutu); + dwo_cutu = (struct dwo_unit *) htab_find (dwo_file->cus.get (), + &find_dwo_cutu); } if (dwo_cutu != NULL) { - dwarf_read_debug_printf ("DWO %s %s(%s) found: @%s", - kind, dwo_name, hex_string (signature), + dwarf_read_debug_printf ("DWO %s %s(%s) found: @%s", kind, + dwo_name, hex_string (signature), host_address_to_string (dwo_cutu)); return dwo_cutu; @@ -11753,8 +11555,8 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, someone deleted the DWO/DWP file, or the search path isn't set up correctly to find the file. */ - dwarf_read_debug_printf ("DWO %s %s(%s) not found", - kind, dwo_name, hex_string (signature)); + dwarf_read_debug_printf ("DWO %s %s(%s) not found", kind, dwo_name, + hex_string (signature)); /* This is a warning and not a complaint because it can be caused by pilot error (e.g., user accidentally deleting the DWO). */ @@ -11764,11 +11566,11 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, std::string dwp_text; if (dwp_file != NULL) - dwp_text = string_printf (" [in DWP file %s]", - lbasename (dwp_file->name)); + dwp_text + = string_printf (" [in DWP file %s]", lbasename (dwp_file->name)); - warning (_("Could not find DWO %s %s(%s)%s referenced by %s at offset %s" - " [in module %s]"), + warning (_ ("Could not find DWO %s %s(%s)%s referenced by %s at offset %s" + " [in module %s]"), kind, dwo_name, hex_string (signature), dwp_text.c_str (), kind, sect_offset_str (cu->per_cu->sect_off), objfile_name (objfile)); } @@ -11779,8 +11581,8 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, See lookup_dwo_cutu_unit for details. */ static struct dwo_unit * -lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, - ULONGEST signature) +lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, + const char *comp_dir, ULONGEST signature) { gdb_assert (!cu->per_cu->is_debug_types); @@ -11791,7 +11593,8 @@ lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, See lookup_dwo_cutu_unit for details. */ static struct dwo_unit * -lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir) +lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name, + const char *comp_dir) { gdb_assert (cu->per_cu->is_debug_types); @@ -11815,8 +11618,7 @@ queue_and_load_dwo_tu (void **slot, void *info) /* We pass NULL for DEPENDENT_CU because we don't yet know if there's a real dependency of PER_CU on SIG_TYPE. That is detected later while processing PER_CU. */ - if (maybe_queue_comp_unit (NULL, sig_type, cu->per_objfile, - cu->lang ())) + if (maybe_queue_comp_unit (NULL, sig_type, cu->per_objfile, cu->lang ())) load_full_type_unit (sig_type, cu->per_objfile); cu->per_cu->imported_symtabs_push (sig_type); } @@ -11876,7 +11678,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) if (die->tag != origin_die->tag && !(die->tag == DW_TAG_inlined_subroutine && origin_die->tag == DW_TAG_subprogram)) - complaint (_("DIE %s and its abstract origin %s have different tags"), + complaint (_ ("DIE %s and its abstract origin %s have different tags"), sect_offset_str (die->sect_off), sect_offset_str (origin_die->sect_off)); @@ -11891,8 +11693,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) die_info *abstract_child = origin_die->child; while (concrete_child != nullptr || abstract_child != nullptr) { - if (concrete_child == nullptr - || abstract_child == nullptr + if (concrete_child == nullptr || abstract_child == nullptr || concrete_child->tag != abstract_child->tag) { are_isomorphic = false; @@ -11913,8 +11714,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) std::vector<sect_offset> offsets; - for (die_info *child_die = die->child; - child_die && child_die->tag; + for (die_info *child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) { /* We are trying to process concrete instance entries: @@ -11945,16 +11745,15 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) if (attr == nullptr) break; - child_origin_die = follow_die_ref (child_origin_die, attr, - &child_origin_cu); + child_origin_die + = follow_die_ref (child_origin_die, attr, &child_origin_cu); } /* If missing DW_AT_abstract_origin, try the corresponding child of the origin. Clang emits such lexical scopes. */ if (child_origin_die == child_die && dwarf2_attr (child_die, DW_AT_abstract_origin, cu) == nullptr - && are_isomorphic - && child_die->tag == DW_TAG_lexical_block) + && are_isomorphic && child_die->tag == DW_TAG_lexical_block) child_origin_die = corresponding_abstract_child; /* According to DWARF3 3.3.8.2 #3 new entries without their abstract @@ -11964,13 +11763,13 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) if (child_die->tag != child_origin_die->tag && !(child_die->tag == DW_TAG_inlined_subroutine && child_origin_die->tag == DW_TAG_subprogram)) - complaint (_("Child DIE %s and its abstract origin %s have " - "different tags"), + complaint (_ ("Child DIE %s and its abstract origin %s have " + "different tags"), sect_offset_str (child_die->sect_off), sect_offset_str (child_origin_die->sect_off)); if (child_origin_die->parent != origin_die) - complaint (_("Child DIE %s and its abstract origin %s have " - "different parents"), + complaint (_ ("Child DIE %s and its abstract origin %s have " + "different parents"), sect_offset_str (child_die->sect_off), sect_offset_str (child_origin_die->sect_off)); else @@ -11985,12 +11784,11 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) { std::sort (offsets.begin (), offsets.end ()); - for (auto offsets_it = offsets.begin () + 1; - offsets_it < offsets.end (); + for (auto offsets_it = offsets.begin () + 1; offsets_it < offsets.end (); ++offsets_it) if (*(offsets_it - 1) == *offsets_it) - complaint (_("Multiple children of DIE %s refer " - "to DIE %s as their abstract origin"), + complaint (_ ("Multiple children of DIE %s refer " + "to DIE %s as their abstract origin"), sect_offset_str (die->sect_off), sect_offset_str (*offsets_it)); } @@ -12065,7 +11863,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) illegal according to the DWARF standard. */ if (name == NULL) { - complaint (_("missing name for subprogram DIE at %s"), + complaint (_ ("missing name for subprogram DIE at %s"), sect_offset_str (die->sect_off)); return; } @@ -12080,15 +11878,14 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) bool external_p = attr != nullptr && attr->as_boolean (); attr = dwarf2_attr (die, DW_AT_inline, cu); bool inlined_p - = (attr != nullptr - && attr->is_nonnegative () + = (attr != nullptr && attr->is_nonnegative () && (attr->as_nonnegative () == DW_INL_inlined || attr->as_nonnegative () == DW_INL_declared_inlined)); attr = dwarf2_attr (die, DW_AT_declaration, cu); bool decl_p = attr != nullptr && attr->as_boolean (); if (!external_p && !inlined_p && !decl_p) - complaint (_("cannot get low and high bounds " - "for subprogram DIE at %s"), + complaint (_ ("cannot get low and high bounds " + "for subprogram DIE at %s"), sect_offset_str (die->sect_off)); } return; @@ -12187,13 +11984,11 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) struct context_stack cstk = cu->get_builder ()->pop_context (); /* Make a block for the local symbols within. */ block = cu->get_builder ()->finish_block (cstk.name, cstk.old_blocks, - cstk.static_link, lowpc, highpc); + cstk.static_link, lowpc, highpc); /* For C++, set the block's scope. */ - if ((cu->lang () == language_cplus - || cu->lang () == language_fortran - || cu->lang () == language_d - || cu->lang () == language_rust) + if ((cu->lang () == language_cplus || cu->lang () == language_fortran + || cu->lang () == language_d || cu->lang () == language_rust) && cu->processing_has_namespace_info) block_set_scope (block, determine_prefix (die, cu), &objfile->objfile_obstack); @@ -12212,8 +12007,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) templ_func->template_arguments = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, templ_func->n_template_arguments); - memcpy (templ_func->template_arguments, - template_args.data (), + memcpy (templ_func->template_arguments, template_args.data (), (templ_func->n_template_arguments * sizeof (struct symbol *))); /* Make sure that the symtab is set on the new symbols. Even @@ -12262,8 +12056,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) /* DW_TAG_lexical_block has no attributes, process its children as if there was no wrapping by that DW_TAG_lexical_block. GCC does no longer produces such DWARF since GCC r224161. */ - for (child_die = die->child; - child_die != NULL && child_die->tag; + for (child_die = die->child; child_die != NULL && child_die->tag; child_die = child_die->sibling) { /* We might already be processing this DIE. This can happen @@ -12300,7 +12093,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) { struct block *block = cu->get_builder ()->finish_block (0, cstk.old_blocks, NULL, - cstk.start_addr, highpc); + cstk.start_addr, highpc); /* Note that recording ranges after traversing children, as we do here, means that recording a parent's ranges entails @@ -12319,8 +12112,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) } static void dwarf2_ranges_read_low_addrs (unsigned offset, - struct dwarf2_cu *cu, - dwarf_tag tag, + struct dwarf2_cu *cu, dwarf_tag tag, std::vector<CORE_ADDR> &result); /* Read in DW_TAG_call_site and insert it to CU->call_site_htab. */ @@ -12348,8 +12140,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) } if (!attr) { - complaint (_("missing DW_AT_call_return_pc for DW_TAG_call_site " - "DIE %s [in module %s]"), + complaint (_ ("missing DW_AT_call_return_pc for DW_TAG_call_site " + "DIE %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (objfile)); return; } @@ -12358,16 +12150,16 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) pc -= baseaddr; if (cu->call_site_htab == NULL) - cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash, - call_site::eq, NULL, - &objfile->objfile_obstack, - hashtab_obstack_allocate, NULL); + cu->call_site_htab + = htab_create_alloc_ex (16, call_site::hash, call_site::eq, NULL, + &objfile->objfile_obstack, + hashtab_obstack_allocate, NULL); struct call_site call_site_local (pc, nullptr, nullptr); slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); if (*slot != NULL) { - complaint (_("Duplicate PC %s for DW_TAG_call_site " - "DIE %s [in module %s]"), + complaint (_ ("Duplicate PC %s for DW_TAG_call_site " + "DIE %s [in module %s]"), paddress (gdbarch, pc), sect_offset_str (die->sect_off), objfile_name (objfile)); return; @@ -12382,8 +12174,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) if (child_die->tag != DW_TAG_call_site_parameter && child_die->tag != DW_TAG_GNU_call_site_parameter) { - complaint (_("Tag %d is not DW_TAG_call_site_parameter in " - "DW_TAG_call_site child DIE %s [in module %s]"), + complaint (_ ("Tag %d is not DW_TAG_call_site_parameter in " + "DW_TAG_call_site child DIE %s [in module %s]"), child_die->tag, sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; @@ -12393,15 +12185,16 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) } struct call_site *call_site - = new (XOBNEWVAR (&objfile->objfile_obstack, - struct call_site, - sizeof (*call_site) + sizeof (call_site->parameter[0]) * nparams)) - struct call_site (pc, cu->per_cu, per_objfile); + = new (XOBNEWVAR (&objfile->objfile_obstack, struct call_site, + sizeof (*call_site) + + sizeof (call_site->parameter[0]) + * nparams)) struct call_site (pc, cu->per_cu, + per_objfile); *slot = call_site; /* We never call the destructor of call_site, so we must ensure it is trivially destructible. */ - gdb_static_assert(std::is_trivially_destructible<struct call_site>::value); + gdb_static_assert (std::is_trivially_destructible<struct call_site>::value); if (dwarf2_flag_true_p (die, DW_AT_call_tail_call, cu) || dwarf2_flag_true_p (die, DW_AT_GNU_tail_call, cu)) @@ -12412,12 +12205,12 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) for (func_die = die->parent; func_die && func_die->tag != DW_TAG_subprogram && func_die->tag != DW_TAG_subroutine_type; - func_die = func_die->parent); + func_die = func_die->parent) + ; /* DW_AT_call_all_calls is a superset of DW_AT_call_all_tail_calls. */ - if (func_die - && !dwarf2_flag_true_p (func_die, DW_AT_call_all_calls, cu) + if (func_die && !dwarf2_flag_true_p (func_die, DW_AT_call_all_calls, cu) && !dwarf2_flag_true_p (func_die, DW_AT_GNU_all_call_sites, cu) && !dwarf2_flag_true_p (func_die, DW_AT_call_all_tail_calls, cu) && !dwarf2_flag_true_p (func_die, DW_AT_GNU_all_tail_call_sites, cu)) @@ -12446,9 +12239,10 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) TYPE_TAIL_CALL_LIST (func_type) = call_site; } else - complaint (_("Cannot find function owning DW_TAG_call_site " - "DIE %s [in module %s]"), - sect_offset_str (die->sect_off), objfile_name (objfile)); + complaint (_ ("Cannot find function owning DW_TAG_call_site " + "DIE %s [in module %s]"), + sect_offset_str (die->sect_off), + objfile_name (objfile)); } } @@ -12471,7 +12265,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) struct dwarf2_locexpr_baton *dlbaton; struct dwarf_block *block = attr->as_block (); - dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); + dlbaton + = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); dlbaton->data = block->data; dlbaton->size = block->size; dlbaton->per_objfile = per_objfile; @@ -12499,16 +12294,17 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) if (target_physname == NULL) target_physname = dwarf2_physname (NULL, target_die, target_cu); if (target_physname == NULL) - complaint (_("DW_AT_call_target target DIE has invalid " - "physname, for referencing DIE %s [in module %s]"), - sect_offset_str (die->sect_off), objfile_name (objfile)); + complaint (_ ("DW_AT_call_target target DIE has invalid " + "physname, for referencing DIE %s [in module %s]"), + sect_offset_str (die->sect_off), + objfile_name (objfile)); else call_site->target.set_loc_physname (target_physname); } else if (ranges_attr != nullptr && ranges_attr->form_is_unsigned ()) { - ULONGEST ranges_offset = (ranges_attr->as_unsigned () - + target_cu->gnu_ranges_base); + ULONGEST ranges_offset + = (ranges_attr->as_unsigned () + target_cu->gnu_ranges_base); std::vector<CORE_ADDR> addresses; dwarf2_ranges_read_low_addrs (ranges_offset, target_cu, target_die->tag, addresses); @@ -12525,9 +12321,10 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) if (dwarf2_get_pc_bounds (target_die, &lowpc, NULL, target_cu, nullptr, nullptr) <= PC_BOUNDS_INVALID) - complaint (_("DW_AT_call_target target DIE has invalid " - "low pc, for referencing DIE %s [in module %s]"), - sect_offset_str (die->sect_off), objfile_name (objfile)); + complaint (_ ("DW_AT_call_target target DIE has invalid " + "low pc, for referencing DIE %s [in module %s]"), + sect_offset_str (die->sect_off), + objfile_name (objfile)); else { lowpc = (gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr) @@ -12537,12 +12334,11 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) } } else - complaint (_("DW_TAG_call_site DW_AT_call_target is neither " - "block nor reference, for DIE %s [in module %s]"), + complaint (_ ("DW_TAG_call_site DW_AT_call_target is neither " + "block nor reference, for DIE %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (objfile)); - for (child_die = die->child; - child_die && child_die->tag; + for (child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) { struct call_site_parameter *parameter; @@ -12580,8 +12376,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) /* As DW_OP_GNU_parameter_ref uses CU-relative offset this binding can be done only inside one CU. Such referenced DIE therefore cannot be even moved to DW_TAG_partial_unit. */ - complaint (_("DW_AT_call_parameter offset is not in CU for " - "DW_TAG_call_site child DIE %s [in module %s]"), + complaint (_ ("DW_AT_call_parameter offset is not in CU for " + "DW_TAG_call_site child DIE %s [in module %s]"), sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; @@ -12591,31 +12387,33 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) } else if (loc == NULL || origin != NULL || !loc->form_is_block ()) { - complaint (_("No DW_FORM_block* DW_AT_location for " - "DW_TAG_call_site child DIE %s [in module %s]"), - sect_offset_str (child_die->sect_off), objfile_name (objfile)); + complaint (_ ("No DW_FORM_block* DW_AT_location for " + "DW_TAG_call_site child DIE %s [in module %s]"), + sect_offset_str (child_die->sect_off), + objfile_name (objfile)); continue; } else { struct dwarf_block *block = loc->as_block (); - parameter->u.dwarf_reg = dwarf_block_to_dwarf_reg - (block->data, &block->data[block->size]); + parameter->u.dwarf_reg + = dwarf_block_to_dwarf_reg (block->data, + &block->data[block->size]); if (parameter->u.dwarf_reg != -1) parameter->kind = CALL_SITE_PARAMETER_DWARF_REG; else if (dwarf_block_to_sp_offset (gdbarch, block->data, - &block->data[block->size], + &block->data[block->size], ¶meter->u.fb_offset)) parameter->kind = CALL_SITE_PARAMETER_FB_OFFSET; else { - complaint (_("Only single DW_OP_reg or DW_OP_fbreg is supported " - "for DW_FORM_block* DW_AT_location is supported for " - "DW_TAG_call_site child DIE %s " - "[in module %s]"), - sect_offset_str (child_die->sect_off), - objfile_name (objfile)); + complaint ( + _ ("Only single DW_OP_reg or DW_OP_fbreg is supported " + "for DW_FORM_block* DW_AT_location is supported for " + "DW_TAG_call_site child DIE %s " + "[in module %s]"), + sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; } } @@ -12625,8 +12423,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_value, cu); if (attr == NULL || !attr->form_is_block ()) { - complaint (_("No DW_FORM_block* DW_AT_call_value for " - "DW_TAG_call_site child DIE %s [in module %s]"), + complaint (_ ("No DW_FORM_block* DW_AT_call_value for " + "DW_TAG_call_site child DIE %s [in module %s]"), sect_offset_str (child_die->sect_off), objfile_name (objfile)); continue; @@ -12647,8 +12445,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) if (attr != nullptr) { if (!attr->form_is_block ()) - complaint (_("No DW_FORM_block* DW_AT_call_data_value for " - "DW_TAG_call_site child DIE %s [in module %s]"), + complaint (_ ("No DW_FORM_block* DW_AT_call_data_value for " + "DW_TAG_call_site child DIE %s [in module %s]"), sect_offset_str (child_die->sect_off), objfile_name (objfile)); else @@ -12721,8 +12519,8 @@ read_variable (struct die_info *die, struct dwarf2_cu *cu) struct die_info *origin_die = follow_die_ref (die, abstract_origin, &origin_cu); dwarf2_per_objfile *per_objfile = cu->per_objfile; - per_objfile->per_bfd->abstract_to_concrete - [origin_die->sect_off].push_back (die->sect_off); + per_objfile->per_bfd->abstract_to_concrete[origin_die->sect_off] + .push_back (die->sect_off); } } @@ -12733,10 +12531,10 @@ read_variable (struct die_info *die, struct dwarf2_cu *cu) Return true if the attributes are present and valid, otherwise, return false. */ -template <typename Callback> +template<typename Callback> static bool -dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, - dwarf_tag tag, Callback &&callback) +dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, + Callback &&callback) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct objfile *objfile = per_objfile->objfile; @@ -12754,7 +12552,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (offset >= rnglists_section->size) { - complaint (_("Offset %d out of bounds for DW_AT_ranges attribute"), + complaint (_ ("Offset %d out of bounds for DW_AT_ranges attribute"), offset); return false; } @@ -12764,8 +12562,8 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, { /* Initialize it due to a false compiler warning. */ CORE_ADDR range_beginning = 0, range_end = 0; - const gdb_byte *buf_end = (rnglists_section->buffer - + rnglists_section->size); + const gdb_byte *buf_end + = (rnglists_section->buffer + rnglists_section->size); unsigned int bytes_read; if (buffer == buf_end) @@ -12773,7 +12571,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, overflow = true; break; } - const auto rlet = static_cast<enum dwarf_range_list_entry>(*buffer++); + const auto rlet = static_cast<enum dwarf_range_list_entry> (*buffer++); switch (rlet) { case DW_RLE_end_of_list: @@ -12798,8 +12596,8 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, overflow = true; break; } - range_beginning = cu->header.read_address (obfd, buffer, - &bytes_read); + range_beginning + = cu->header.read_address (obfd, buffer, &bytes_read); buffer += bytes_read; range_end = (range_beginning + read_unsigned_leb128 (obfd, buffer, &bytes_read)); @@ -12845,8 +12643,8 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, overflow = true; break; } - range_beginning = cu->header.read_address (obfd, buffer, - &bytes_read); + range_beginning + = cu->header.read_address (obfd, buffer, &bytes_read); buffer += bytes_read; range_end = cu->header.read_address (obfd, buffer, &bytes_read); buffer += bytes_read; @@ -12865,7 +12663,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, range_end = read_addr_index (cu, addr_index); break; default: - complaint (_("Invalid .debug_rnglists data (no base address)")); + complaint (_ ("Invalid .debug_rnglists data (no base address)")); return false; } if (rlet == DW_RLE_end_of_list || overflow) @@ -12876,7 +12674,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (range_beginning > range_end) { /* Inverted range entries are invalid. */ - complaint (_("Invalid .debug_rnglists data (inverted range)")); + complaint (_ ("Invalid .debug_rnglists data (inverted range)")); return false; } @@ -12890,8 +12688,9 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (!base.has_value ()) { /* We have no valid base address for the DW_RLE_offset_pair. */ - complaint (_("Invalid .debug_rnglists data (no base address for " - "DW_RLE_offset_pair)")); + complaint ( + _ ("Invalid .debug_rnglists data (no base address for " + "DW_RLE_offset_pair)")); return false; } @@ -12901,11 +12700,11 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, /* A not-uncommon case of bad debug info. Don't pollute the addrmap with bad data. */ - if (range_beginning == 0 - && !per_objfile->per_bfd->has_section_at_zero) + if (range_beginning == 0 && !per_objfile->per_bfd->has_section_at_zero) { - complaint (_(".debug_rnglists entry has start address of zero" - " [in module %s]"), objfile_name (objfile)); + complaint (_ (".debug_rnglists entry has start address of zero" + " [in module %s]"), + objfile_name (objfile)); continue; } @@ -12914,8 +12713,8 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (overflow) { - complaint (_("Offset %d is not terminated " - "for DW_AT_ranges attribute"), + complaint (_ ("Offset %d is not terminated " + "for DW_AT_ranges attribute"), offset); return false; } @@ -12928,7 +12727,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, void (CORE_ADDR range_beginning, CORE_ADDR range_end) Return 1 if the attributes are present and valid, otherwise, return 0. */ -template <typename Callback> +template<typename Callback> static int dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, Callback &&callback) @@ -12938,7 +12737,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, struct comp_unit_head *cu_header = &cu->header; bfd *obfd = objfile->obfd.get (); unsigned int addr_size = cu_header->addr_size; - CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); + CORE_ADDR mask = ~(~(CORE_ADDR) 1 << (addr_size * 8 - 1)); /* Base address selection entry. */ gdb::optional<CORE_ADDR> base; unsigned int dummy; @@ -12952,7 +12751,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, per_objfile->per_bfd->ranges.read (objfile); if (offset >= per_objfile->per_bfd->ranges.size) { - complaint (_("Offset %d out of bounds for DW_AT_ranges attribute"), + complaint (_ ("Offset %d out of bounds for DW_AT_ranges attribute"), offset); return 0; } @@ -12988,14 +12787,14 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, { /* We have no valid base address for the ranges data. */ - complaint (_("Invalid .debug_ranges data (no base address)")); + complaint (_ ("Invalid .debug_ranges data (no base address)")); return 0; } if (range_beginning > range_end) { /* Inverted range entries are invalid. */ - complaint (_("Invalid .debug_ranges data (inverted range)")); + complaint (_ ("Invalid .debug_ranges data (inverted range)")); return 0; } @@ -13008,11 +12807,11 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, /* A not-uncommon case of bad debug info. Don't pollute the addrmap with bad data. */ - if (range_beginning == 0 - && !per_objfile->per_bfd->has_section_at_zero) + if (range_beginning == 0 && !per_objfile->per_bfd->has_section_at_zero) { - complaint (_(".debug_ranges entry has start address of zero" - " [in module %s]"), objfile_name (objfile)); + complaint (_ (".debug_ranges entry has start address of zero" + " [in module %s]"), + objfile_name (objfile)); continue; } @@ -13029,8 +12828,8 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, static int dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, - CORE_ADDR *high_return, struct dwarf2_cu *cu, - addrmap *map, void *datum, dwarf_tag tag) + CORE_ADDR *high_return, struct dwarf2_cu *cu, addrmap *map, + void *datum, dwarf_tag tag) { struct objfile *objfile = cu->per_objfile->objfile; struct gdbarch *gdbarch = objfile->arch (); @@ -13041,44 +12840,43 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, int retval; retval = dwarf2_ranges_process (offset, cu, tag, - [&] (CORE_ADDR range_beginning, CORE_ADDR range_end) - { - if (map != nullptr) - { - CORE_ADDR lowpc; - CORE_ADDR highpc; - - lowpc = (gdbarch_adjust_dwarf2_addr (gdbarch, - range_beginning + baseaddr) - - baseaddr); - highpc = (gdbarch_adjust_dwarf2_addr (gdbarch, - range_end + baseaddr) - - baseaddr); - map->set_empty (lowpc, highpc - 1, datum); - } + [&] (CORE_ADDR range_beginning, + CORE_ADDR range_end) { + if (map != nullptr) + { + CORE_ADDR lowpc; + CORE_ADDR highpc; + + lowpc + = (gdbarch_adjust_dwarf2_addr (gdbarch, range_beginning + baseaddr) + - baseaddr); + highpc = (gdbarch_adjust_dwarf2_addr (gdbarch, range_end + baseaddr) + - baseaddr); + map->set_empty (lowpc, highpc - 1, datum); + } - /* FIXME: This is recording everything as a low-high + /* FIXME: This is recording everything as a low-high segment of consecutive addresses. We should have a data structure for discontiguous block ranges instead. */ - if (! low_set) - { + if (!low_set) + { + low = range_beginning; + high = range_end; + low_set = 1; + } + else + { + if (range_beginning < low) low = range_beginning; + if (range_end > high) high = range_end; - low_set = 1; - } - else - { - if (range_beginning < low) - low = range_beginning; - if (range_end > high) - high = range_end; - } - }); + } + }); if (!retval) return 0; - if (! low_set) + if (!low_set) /* If the first entry is an end-of-list marker, the range describes an empty scope, i.e. no instructions. */ return 0; @@ -13094,14 +12892,12 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, static void dwarf2_ranges_read_low_addrs (unsigned offset, struct dwarf2_cu *cu, - dwarf_tag tag, - std::vector<CORE_ADDR> &result) + dwarf_tag tag, std::vector<CORE_ADDR> &result) { dwarf2_ranges_process (offset, cu, tag, - [&] (CORE_ADDR start, CORE_ADDR end) - { - result.push_back (start); - }); + [&] (CORE_ADDR start, CORE_ADDR end) { + result.push_back (start); + }); } /* Get low and high pc attributes from a die. See enum pc_bounds_kind @@ -13110,8 +12906,8 @@ dwarf2_ranges_read_low_addrs (unsigned offset, struct dwarf2_cu *cu, static enum pc_bounds_kind dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, - CORE_ADDR *highpc, struct dwarf2_cu *cu, - addrmap *map, void *datum) + CORE_ADDR *highpc, struct dwarf2_cu *cu, addrmap *map, + void *datum) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct attribute *attr; @@ -13154,8 +12950,8 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, /* Value of the DW_AT_ranges attribute is the offset in the .debug_ranges section. */ - if (!dwarf2_ranges_read (ranges_offset, &low, &high, cu, - map, datum, die->tag)) + if (!dwarf2_ranges_read (ranges_offset, &low, &high, cu, map, datum, + die->tag)) return PC_BOUNDS_INVALID; /* Found discontinuous range of addresses. */ ret = PC_BOUNDS_RANGES; @@ -13191,9 +12987,8 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, and HIGHPC to the high address if greater than HIGHPC. */ static void -dwarf2_get_subprogram_pc_bounds (struct die_info *die, - CORE_ADDR *lowpc, CORE_ADDR *highpc, - struct dwarf2_cu *cu) +dwarf2_get_subprogram_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, + CORE_ADDR *highpc, struct dwarf2_cu *cu) { CORE_ADDR low, high; struct die_info *child = die->child; @@ -13228,16 +13023,15 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die, determined, set *LOWPC to -1 and *HIGHPC to 0. */ static void -get_scope_pc_bounds (struct die_info *die, - CORE_ADDR *lowpc, CORE_ADDR *highpc, +get_scope_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, CORE_ADDR *highpc, struct dwarf2_cu *cu) { CORE_ADDR best_low = (CORE_ADDR) -1; CORE_ADDR best_high = (CORE_ADDR) 0; CORE_ADDR current_low, current_high; - if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu, - nullptr, nullptr) + if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu, nullptr, + nullptr) >= PC_BOUNDS_RANGES) { best_low = current_low; @@ -13249,13 +13043,15 @@ get_scope_pc_bounds (struct die_info *die, while (child && child->tag) { - switch (child->tag) { - case DW_TAG_subprogram: - dwarf2_get_subprogram_pc_bounds (child, &best_low, &best_high, cu); - break; - case DW_TAG_namespace: - case DW_TAG_module: - /* FIXME: carlton/2004-01-16: Should we do this for + switch (child->tag) + { + case DW_TAG_subprogram: + dwarf2_get_subprogram_pc_bounds (child, &best_low, &best_high, + cu); + break; + case DW_TAG_namespace: + case DW_TAG_module: + /* FIXME: carlton/2004-01-16: Should we do this for DW_TAG_class_type/DW_TAG_structure_type, too? I think that current GCC's always emit the DIEs corresponding to definitions of methods of classes as children of a @@ -13263,18 +13059,18 @@ get_scope_pc_bounds (struct die_info *die, the DIEs giving the declarations, which could be anywhere). But I don't see any reason why the standards says that they have to be there. */ - get_scope_pc_bounds (child, ¤t_low, ¤t_high, cu); + get_scope_pc_bounds (child, ¤t_low, ¤t_high, cu); - if (current_low != ((CORE_ADDR) -1)) - { - best_low = std::min (best_low, current_low); - best_high = std::max (best_high, current_high); - } - break; - default: - /* Ignore. */ - break; - } + if (current_low != ((CORE_ADDR) -1)) + { + best_low = std::min (best_low, current_low); + best_high = std::max (best_high, current_high); + } + break; + default: + /* Ignore. */ + break; + } child = child->sibling; } @@ -13328,15 +13124,14 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, std::vector<blockrange> blockvec; dwarf2_ranges_process (ranges_offset, cu, die->tag, - [&] (CORE_ADDR start, CORE_ADDR end) - { - start += baseaddr; - end += baseaddr; - start = gdbarch_adjust_dwarf2_addr (gdbarch, start); - end = gdbarch_adjust_dwarf2_addr (gdbarch, end); - cu->get_builder ()->record_block_range (block, start, end - 1); - blockvec.emplace_back (start, end); - }); + [&] (CORE_ADDR start, CORE_ADDR end) { + start += baseaddr; + end += baseaddr; + start = gdbarch_adjust_dwarf2_addr (gdbarch, start); + end = gdbarch_adjust_dwarf2_addr (gdbarch, end); + cu->get_builder ()->record_block_range (block, start, end - 1); + blockvec.emplace_back (start, end); + }); block->set_ranges (make_blockranges (objfile, blockvec)); } @@ -13398,7 +13193,6 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) return cu->producer_is_gxx_lt_4_6; } - /* Codewarrior (at least as of version 5.0.40) generates dwarf line information with incorrect is_stmt attributes. */ @@ -13422,11 +13216,10 @@ dwarf2_access_attribute (struct die_info *die, struct dwarf2_cu *cu) if (attr != nullptr) { LONGEST value = attr->constant_value (-1); - if (value == DW_ACCESS_public - || value == DW_ACCESS_protected + if (value == DW_ACCESS_public || value == DW_ACCESS_protected || value == DW_ACCESS_private) return (dwarf_access_attribute) value; - complaint (_("Unhandled DW_AT_accessibility value (%s)"), + complaint (_ ("Unhandled DW_AT_accessibility value (%s)"), plongest (value)); } @@ -13521,7 +13314,8 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu, */ if (offset == -1 && cu->producer_is_gcc_11) { - complaint (_("DW_AT_data_member_location value of -1, assuming 0")); + complaint ( + _ ("DW_AT_data_member_location value of -1, assuming 0")); offset = 0; } @@ -13607,17 +13401,17 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, && !die_is_declaration (die, cu)) { if (die->tag == DW_TAG_namelist_item) - { + { /* Typically, DW_TAG_namelist_item are references to namelist items. If so, follow that reference. */ struct attribute *attr1 = dwarf2_attr (die, DW_AT_namelist_item, cu); struct die_info *item_die = nullptr; struct dwarf2_cu *item_cu = cu; - if (attr1->form_is_ref ()) + if (attr1->form_is_ref ()) item_die = follow_die_ref (die, attr1, &item_cu); if (item_die != nullptr) die = item_die; - } + } /* Data member other than a C++ static data member. */ /* Get type of field. */ @@ -13648,7 +13442,8 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, anonymous object to the MSB of the field. We don't have to do anything special since we don't need to know the size of the anonymous object. */ - fp->set_loc_bitpos (fp->loc_bitpos () + attr->constant_value (0)); + fp->set_loc_bitpos (fp->loc_bitpos () + + attr->constant_value (0)); } else { @@ -13678,8 +13473,8 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, anonymous_size = fp->type ()->length (); } fp->set_loc_bitpos (fp->loc_bitpos () - + anonymous_size * bits_per_byte - - bit_offset - FIELD_BITSIZE (*fp)); + + anonymous_size * bits_per_byte - bit_offset + - FIELD_BITSIZE (*fp)); } } @@ -13828,7 +13623,7 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, if (variant.discr_list_data == nullptr) { discriminant_range r - = {variant.discriminant_value, variant.discriminant_value}; + = { variant.discriminant_value, variant.discriminant_value }; ranges.push_back (r); } else @@ -13839,7 +13634,7 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, { if (data[0] != DW_DSC_range && data[0] != DW_DSC_label) { - complaint (_("invalid discriminant marker: %d"), data[0]); + complaint (_ ("invalid discriminant marker: %d"), data[0]); break; } bool is_range = data[0] == DW_DSC_range; @@ -13850,7 +13645,7 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, if (data.empty ()) { - complaint (_("DW_AT_discr_list missing low value")); + complaint (_ ("DW_AT_discr_list missing low value")); break; } if (is_unsigned) @@ -13864,12 +13659,12 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, { if (data.empty ()) { - complaint (_("DW_AT_discr_list missing high value")); + complaint (_ ("DW_AT_discr_list missing high value")); break; } if (is_unsigned) - high = read_unsigned_leb128 (nullptr, data.data (), - &bytes_read); + high + = read_unsigned_leb128 (nullptr, data.data (), &bytes_read); else high = (LONGEST) read_signed_leb128 (nullptr, data.data (), &bytes_read); @@ -13882,17 +13677,16 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, } } - discriminant_range *result = XOBNEWVEC (obstack, discriminant_range, - ranges.size ()); + discriminant_range *result + = XOBNEWVEC (obstack, discriminant_range, ranges.size ()); std::copy (ranges.begin (), ranges.end (), result); return gdb::array_view<discriminant_range> (result, ranges.size ()); } -static const gdb::array_view<variant_part> create_variant_parts - (struct obstack *obstack, - const offset_map_type &offset_map, - struct field_info *fi, - const std::vector<variant_part_builder> &variant_parts); +static const gdb::array_view<variant_part> +create_variant_parts (struct obstack *obstack, + const offset_map_type &offset_map, struct field_info *fi, + const std::vector<variant_part_builder> &variant_parts); /* Fill in a "struct variant" for a given variant field. RESULT is the variant to fill in. OBSTACK is where any needed allocations @@ -13902,14 +13696,14 @@ static const gdb::array_view<variant_part> create_variant_parts static void create_one_variant (variant &result, struct obstack *obstack, - const offset_map_type &offset_map, - struct field_info *fi, const variant_field &field) + const offset_map_type &offset_map, struct field_info *fi, + const variant_field &field) { result.discriminants = convert_variant_range (obstack, field, false); result.first_field = field.first_field + fi->baseclasses.size (); result.last_field = field.last_field + fi->baseclasses.size (); - result.parts = create_variant_parts (obstack, offset_map, fi, - field.variant_parts); + result.parts + = create_variant_parts (obstack, offset_map, fi, field.variant_parts); } /* Fill in a "struct variant_part" for a given variant part. RESULT @@ -13920,8 +13714,7 @@ create_one_variant (variant &result, struct obstack *obstack, converted. */ static void -create_one_variant_part (variant_part &result, - struct obstack *obstack, +create_one_variant_part (variant_part &result, struct obstack *obstack, const offset_map_type &offset_map, struct field_info *fi, const variant_part_builder &builder) @@ -13957,8 +13750,7 @@ create_one_variant_part (variant_part &result, static const gdb::array_view<variant_part> create_variant_parts (struct obstack *obstack, - const offset_map_type &offset_map, - struct field_info *fi, + const offset_map_type &offset_map, struct field_info *fi, const std::vector<variant_part_builder> &variant_parts) { if (variant_parts.empty ()) @@ -13993,9 +13785,8 @@ add_variant_property (struct field_info *fip, struct type *type, fip->variant_parts); struct dynamic_prop prop; - prop.set_variant_parts ((gdb::array_view<variant_part> *) - obstack_copy (&objfile->objfile_obstack, &parts, - sizeof (parts))); + prop.set_variant_parts ((gdb::array_view<variant_part> *) obstack_copy ( + &objfile->objfile_obstack, &parts, sizeof (parts))); type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop); } @@ -14011,23 +13802,23 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, /* Record the field count, allocate space for the array of fields, and create blank accessibility bitfields if necessary. */ type->set_num_fields (nfields); - type->set_fields - ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields)); + type->set_fields ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) + * nfields)); if (fip->non_public_fields && cu->lang () != language_ada) { ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_FIELD_PRIVATE_BITS (type) = - (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); + TYPE_FIELD_PRIVATE_BITS (type) + = (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields); - TYPE_FIELD_PROTECTED_BITS (type) = - (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); + TYPE_FIELD_PROTECTED_BITS (type) + = (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields); - TYPE_FIELD_IGNORE_BITS (type) = - (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); + TYPE_FIELD_IGNORE_BITS (type) + = (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields); } @@ -14052,8 +13843,9 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, for (int i = 0; i < nfields; ++i) { struct nextfield &field - = ((i < fip->baseclasses.size ()) ? fip->baseclasses[i] - : fip->fields[i - fip->baseclasses.size ()]); + = ((i < fip->baseclasses.size ()) + ? fip->baseclasses[i] + : fip->fields[i - fip->baseclasses.size ()]); type->field (i) = field.field; switch (field.accessibility) @@ -14074,7 +13866,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, default: /* Unknown accessibility. Complain and treat it as public. */ { - complaint (_("unsupported accessibility %d"), + complaint (_ ("unsupported accessibility %d"), field.accessibility); } break; @@ -14086,7 +13878,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, case DW_VIRTUALITY_virtual: case DW_VIRTUALITY_pure_virtual: if (cu->lang () == language_ada) - error (_("unexpected virtuality in component of Ada type")); + error (_ ("unexpected virtuality in component of Ada type")); SET_TYPE_FIELD_VIRTUAL (type, i); break; } @@ -14137,7 +13929,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, struct type *this_type; if (cu->lang () == language_ada) - error (_("unexpected member function in Ada type")); + error (_ ("unexpected member function in Ada type")); /* Get name of member function. */ fieldname = dwarf2_name (die, cu); @@ -14170,8 +13962,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* Delay processing of the physname until later. */ if (cu->lang () == language_cplus) - add_to_method_list (type, i, flp->fnfields.size () - 1, fieldname, - die, cu); + add_to_method_list (type, i, flp->fnfields.size () - 1, fieldname, die, + cu); else { const char *physname = dwarf2_physname (fieldname, die, cu); @@ -14186,10 +13978,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* TYPE is the domain of this method, and THIS_TYPE is the type of the method itself (TYPE_CODE_METHOD). */ - smash_to_method_type (fnp->type, type, - this_type->target_type (), - this_type->fields (), - this_type->num_fields (), + smash_to_method_type (fnp->type, type, this_type->target_type (), + this_type->fields (), this_type->num_fields (), this_type->has_varargs ()); /* Handle static member functions. @@ -14202,7 +13992,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, fnp->voffset = VOFFSET_STATIC; } else - complaint (_("member function type missing for '%s'"), + complaint (_ ("member function type missing for '%s'"), dwarf2_full_name (fieldname, die, cu)); /* Get fcontext from DW_AT_containing_type if present. */ @@ -14260,8 +14050,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, fnp->voffset = decode_locdesc (block, cu) + 2; } else if (block->data[0] == DW_OP_deref - || (block->size > 1 - && block->data[0] == DW_OP_deref_size + || (block->size > 1 && block->data[0] == DW_OP_deref_size && block->data[1] == cu->header.addr_size)) { fnp->voffset = decode_locdesc (block, cu); @@ -14282,8 +14071,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (this_type->num_fields () == 0 || !TYPE_FIELD_ARTIFICIAL (this_type, 0)) { - complaint (_("cannot determine context for virtual member " - "function \"%s\" (offset %s)"), + complaint (_ ("cannot determine context for virtual member " + "function \"%s\" (offset %s)"), fieldname, sect_offset_str (die->sect_off)); } else @@ -14308,8 +14097,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (attr != nullptr && attr->as_virtuality () != DW_VIRTUALITY_none) { /* GCC does this, as of 2008-08-25; PR debug/37237. */ - complaint (_("Member function \"%s\" (offset %s) is virtual " - "but the vtable offset is not specified"), + complaint (_ ("Member function \"%s\" (offset %s) is virtual " + "but the vtable offset is not specified"), fieldname, sect_offset_str (die->sect_off)); ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_CPLUS_DYNAMIC (type) = 1; @@ -14324,12 +14113,12 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, struct dwarf2_cu *cu) { if (cu->lang () == language_ada) - error (_("unexpected member functions in Ada type")); + error (_ ("unexpected member functions in Ada type")); ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *) - TYPE_ALLOC (type, - sizeof (struct fn_fieldlist) * fip->fnfieldlists.size ()); + TYPE_FN_FIELDLISTS (type) + = (struct fn_fieldlist *) TYPE_ALLOC (type, sizeof (struct fn_fieldlist) + * fip->fnfieldlists.size ()); for (int i = 0; i < fip->fnfieldlists.size (); i++) { @@ -14338,8 +14127,9 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, TYPE_FN_FIELDLIST_NAME (type, i) = nf.name; TYPE_FN_FIELDLIST_LENGTH (type, i) = nf.fnfields.size (); - fn_flp->fn_fields = (struct fn_field *) - TYPE_ALLOC (type, sizeof (struct fn_field) * nf.fnfields.size ()); + fn_flp->fn_fields + = (struct fn_field *) TYPE_ALLOC (type, sizeof (struct fn_field) + * nf.fnfields.size ()); for (int k = 0; k < nf.fnfields.size (); ++k) fn_flp->fn_fields[k] = nf.fnfields[k]; @@ -14387,8 +14177,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) /* Find the type of the method. */ pfn_type = type->field (0).type (); - if (pfn_type == NULL - || pfn_type->code () != TYPE_CODE_PTR + if (pfn_type == NULL || pfn_type->code () != TYPE_CODE_PTR || pfn_type->target_type ()->code () != TYPE_CODE_FUNC) return; @@ -14436,8 +14225,7 @@ rewrite_array_type (struct type *type) struct type *copy = copy_type (type); int nfields = copy->num_fields (); field *new_fields - = ((struct field *) TYPE_ZALLOC (copy, - nfields * sizeof (struct field))); + = ((struct field *) TYPE_ZALLOC (copy, nfields * sizeof (struct field))); memcpy (new_fields, copy->fields (), nfields * sizeof (struct field)); copy->set_fields (new_fields); if (new_target != nullptr) @@ -14445,8 +14233,7 @@ rewrite_array_type (struct type *type) struct type *index_copy = copy_type (index_type); range_bounds *bounds - = (struct range_bounds *) TYPE_ZALLOC (index_copy, - sizeof (range_bounds)); + = (struct range_bounds *) TYPE_ZALLOC (index_copy, sizeof (range_bounds)); *bounds = *current_bounds; bounds->low.set_const_val (1); bounds->high.set_const_val (0); @@ -14508,8 +14295,8 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die) if (!attr->form_is_constant ()) { - complaint (_("DW_AT_alignment must have constant form" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_alignment must have constant form" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return 0; @@ -14518,8 +14305,8 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die) LONGEST val = attr->constant_value (0); if (val < 0) { - complaint (_("DW_AT_alignment value must not be negative" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_alignment value must not be negative" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return 0; @@ -14528,16 +14315,16 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die) if (align == 0) { - complaint (_("DW_AT_alignment value must not be zero" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_alignment value must not be zero" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return 0; } if ((align & (align - 1)) != 0) { - complaint (_("DW_AT_alignment value must be a power of 2" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_alignment value must be a power of 2" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return 0; @@ -14554,8 +14341,8 @@ maybe_set_alignment (struct dwarf2_cu *cu, struct die_info *die, struct type *type) { if (!set_type_align (type, get_alignment (cu, die))) - complaint (_("DW_AT_alignment value too large" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_alignment value too large" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); } @@ -14574,8 +14361,9 @@ is_valid_DW_AT_calling_convention_for_type (ULONGEST value) return true; default: - complaint (_("unrecognized DW_AT_calling_convention value " - "(%s) for a type"), pulongest (value)); + complaint (_ ("unrecognized DW_AT_calling_convention value " + "(%s) for a type"), + pulongest (value)); return false; } } @@ -14600,8 +14388,9 @@ is_valid_DW_AT_calling_convention_for_subroutine (ULONGEST value) return true; default: - complaint (_("unrecognized DW_AT_calling_convention value " - "(%s) for a subroutine"), pulongest (value)); + complaint (_ ("unrecognized DW_AT_calling_convention value " + "(%s) for a subroutine"), + pulongest (value)); return false; } } @@ -14645,8 +14434,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) name = dwarf2_name (die, cu); if (name != NULL) { - if (cu->lang () == language_cplus - || cu->lang () == language_d + if (cu->lang () == language_cplus || cu->lang () == language_d || cu->lang () == language_rust) { const char *full_name = dwarf2_full_name (name, die, cu); @@ -14745,12 +14533,9 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) return type; } -static void handle_struct_member_die - (struct die_info *child_die, - struct type *type, - struct field_info *fi, - std::vector<struct symbol *> *template_args, - struct dwarf2_cu *cu); +static void handle_struct_member_die ( + struct die_info *child_die, struct type *type, struct field_info *fi, + std::vector<struct symbol *> *template_args, struct dwarf2_cu *cu); /* A helper for handle_struct_member_die that handles DW_TAG_variant_part. */ @@ -14769,8 +14554,8 @@ handle_variant_part (struct die_info *die, struct type *type, } else if (!fi->current_variant_part->processing_variant) { - complaint (_("nested DW_TAG_variant_part seen " - "- DIE at %s [in module %s]"), + complaint (_ ("nested DW_TAG_variant_part seen " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return; @@ -14801,14 +14586,13 @@ handle_variant_part (struct die_info *die, struct type *type, } else { - complaint (_("DW_AT_discr does not have DIE reference form" - " - DIE at %s [in module %s]"), + complaint (_ ("DW_AT_discr does not have DIE reference form" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); } - for (die_info *child_die = die->child; - child_die != NULL; + for (die_info *child_die = die->child; child_die != NULL; child_die = child_die->sibling) handle_struct_member_die (child_die, type, fi, template_args, cu); } @@ -14817,23 +14601,22 @@ handle_variant_part (struct die_info *die, struct type *type, DW_TAG_variant. */ static void -handle_variant (struct die_info *die, struct type *type, - struct field_info *fi, +handle_variant (struct die_info *die, struct type *type, struct field_info *fi, std::vector<struct symbol *> *template_args, struct dwarf2_cu *cu) { if (fi->current_variant_part == nullptr) { - complaint (_("saw DW_TAG_variant outside DW_TAG_variant_part " - "- DIE at %s [in module %s]"), + complaint (_ ("saw DW_TAG_variant outside DW_TAG_variant_part " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return; } if (fi->current_variant_part->processing_variant) { - complaint (_("nested DW_TAG_variant seen " - "- DIE at %s [in module %s]"), + complaint (_ ("nested DW_TAG_variant seen " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return; @@ -14861,8 +14644,7 @@ handle_variant (struct die_info *die, struct type *type, else variant.discriminant_value = discr->constant_value (0); - for (die_info *variant_child = die->child; - variant_child != NULL; + for (die_info *variant_child = die->child; variant_child != NULL; variant_child = variant_child->sibling) handle_struct_member_die (variant_child, type, fi, template_args, cu); @@ -14878,8 +14660,7 @@ handle_struct_member_die (struct die_info *child_die, struct type *type, std::vector<struct symbol *> *template_args, struct dwarf2_cu *cu) { - if (child_die->tag == DW_TAG_member - || child_die->tag == DW_TAG_variable + if (child_die->tag == DW_TAG_member || child_die->tag == DW_TAG_variable || child_die->tag == DW_TAG_namelist_item) { /* NOTE: carlton/2002-11-05: A C++ static data member @@ -14940,7 +14721,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) type = read_structure_type (die, cu); bool has_template_parameters = false; - if (die->child != NULL && ! die_is_declaration (die, cu)) + if (die->child != NULL && !die_is_declaration (die, cu)) { struct field_info fi; std::vector<struct symbol *> template_args; @@ -14960,11 +14741,9 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_N_TEMPLATE_ARGUMENTS (type) = template_args.size (); TYPE_TEMPLATE_ARGUMENTS (type) - = XOBNEWVEC (&objfile->objfile_obstack, - struct symbol *, + = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, TYPE_N_TEMPLATE_ARGUMENTS (type)); - memcpy (TYPE_TEMPLATE_ARGUMENTS (type), - template_args.data (), + memcpy (TYPE_TEMPLATE_ARGUMENTS (type), template_args.data (), (TYPE_N_TEMPLATE_ARGUMENTS (type) * sizeof (struct symbol *))); } @@ -14991,8 +14770,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int i; /* Our own class provides vtbl ptr. */ - for (i = t->num_fields () - 1; - i >= TYPE_N_BASECLASSES (t); + for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); --i) { const char *fieldname = t->field (i).name (); @@ -15006,8 +14784,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) /* Complain if virtual function table field not found. */ if (i < TYPE_N_BASECLASSES (t)) - complaint (_("virtual function table pointer " - "not found when defining class '%s'"), + complaint (_ ("virtual function table pointer " + "not found when defining class '%s'"), type->name () ? type->name () : ""); } else @@ -15016,7 +14794,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) } } else if (cu->producer - && startswith (cu->producer, "IBM(R) XL C/C++ Advanced Edition")) + && startswith (cu->producer, + "IBM(R) XL C/C++ Advanced Edition")) { /* The IBM XLC compiler does not provide direct indication of the containing type, but the vtable pointer is @@ -15024,8 +14803,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int i; - for (i = type->num_fields () - 1; - i >= TYPE_N_BASECLASSES (type); + for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); --i) { if (strcmp (type->field (i).name (), "__vfp") == 0) @@ -15045,10 +14823,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int count = fi.typedef_field_list.size (); ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_TYPEDEF_FIELD_ARRAY (type) - = ((struct decl_field *) - TYPE_ALLOC (type, - sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * count)); + TYPE_TYPEDEF_FIELD_ARRAY (type) = ((struct decl_field *) TYPE_ALLOC ( + type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * count)); TYPE_TYPEDEF_FIELD_COUNT (type) = count; for (int i = 0; i < fi.typedef_field_list.size (); ++i) @@ -15057,15 +14833,13 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) /* Copy fi.nested_types_list linked list elements content into the allocated array TYPE_NESTED_TYPES_ARRAY (type). */ - if (!fi.nested_types_list.empty () - && cu->lang () != language_ada) + if (!fi.nested_types_list.empty () && cu->lang () != language_ada) { int count = fi.nested_types_list.size (); ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_NESTED_TYPES_ARRAY (type) - = ((struct decl_field *) - TYPE_ALLOC (type, sizeof (struct decl_field) * count)); + TYPE_NESTED_TYPES_ARRAY (type) = ((struct decl_field *) TYPE_ALLOC ( + type, sizeof (struct decl_field) * count)); TYPE_NESTED_TYPES_COUNT (type) = count; for (int i = 0; i < fi.nested_types_list.size (); ++i) @@ -15090,8 +14864,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) while (child_die != NULL && child_die->tag) { - if (child_die->tag == DW_TAG_member - || child_die->tag == DW_TAG_variable + if (child_die->tag == DW_TAG_member || child_die->tag == DW_TAG_variable || child_die->tag == DW_TAG_inheritance || child_die->tag == DW_TAG_template_value_param || child_die->tag == DW_TAG_template_type_param) @@ -15121,15 +14894,14 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) else if (cu->line_header != nullptr) { /* Any related symtab will do. */ - symtab - = cu->line_header->file_names ()[0].symtab; + symtab = cu->line_header->file_names ()[0].symtab; } else { symtab = nullptr; - complaint (_("could not find suitable " - "symtab for template parameter" - " - DIE at %s [in module %s]"), + complaint (_ ("could not find suitable " + "symtab for template parameter" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (objfile)); } @@ -15152,8 +14924,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) children. In particular, the fields are computed. */ static void -update_enumeration_type_from_children (struct die_info *die, - struct type *type, +update_enumeration_type_from_children (struct die_info *die, struct type *type, struct dwarf2_cu *cu) { struct die_info *child_die; @@ -15163,8 +14934,7 @@ update_enumeration_type_from_children (struct die_info *die, auto_obstack obstack; std::vector<struct field> fields; - for (child_die = die->child; - child_die != NULL && child_die->tag; + for (child_die = die->child; child_die != NULL && child_die->tag; child_die = child_die->sibling) { struct attribute *attr; @@ -15184,8 +14954,8 @@ update_enumeration_type_from_children (struct die_info *die, if (name == NULL) name = "<anonymous enumerator>"; - dwarf2_const_value_attr (attr, type, name, &obstack, cu, - &value, &bytes, &baton); + dwarf2_const_value_attr (attr, type, name, &obstack, cu, &value, &bytes, + &baton); if (value < 0) { unsigned_enum = 0; @@ -15206,9 +14976,9 @@ update_enumeration_type_from_children (struct die_info *die, if (!fields.empty ()) { type->set_num_fields (fields.size ()); - type->set_fields - ((struct field *) - TYPE_ALLOC (type, sizeof (struct field) * fields.size ())); + type->set_fields ((struct field *) TYPE_ALLOC (type, + sizeof (struct field) + * fields.size ())); memcpy (type->fields (), fields.data (), sizeof (struct field) * fields.size ()); } @@ -15292,8 +15062,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) if (type->length () == 0) type->set_length (underlying_type->length ()); - if (TYPE_RAW_ALIGN (type) == 0 - && TYPE_RAW_ALIGN (underlying_type) != 0) + if (TYPE_RAW_ALIGN (type) == 0 && TYPE_RAW_ALIGN (underlying_type) != 0) set_type_align (type, TYPE_RAW_ALIGN (underlying_type)); } @@ -15356,8 +15125,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) actually available. Note that we do not want to do this for all enums which are just declarations, because C++0x allows forward enum declarations. */ - if (cu->per_cu->is_debug_types - && die_is_declaration (die, cu)) + if (cu->per_cu->is_debug_types && die_is_declaration (die, cu)) { struct signatured_type *sig_type; @@ -15432,7 +15200,7 @@ recognize_bound_expression (struct die_info *die, enum dwarf_attribute name, return false; int offset = 0; - if (start ==end) + if (start == end) return false; else if (*start == DW_OP_deref_size || *start == DW_OP_deref) { @@ -15517,16 +15285,14 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, other layout, because we don't know what expression the compiler might choose to emit should this happen. */ struct dwarf_block *blk = attr->as_block (); - if (blk->size != 2 - || blk->data[0] != DW_OP_push_object_address + if (blk->size != 2 || blk->data[0] != DW_OP_push_object_address || blk->data[1] != DW_OP_deref) return nullptr; int bounds_offset = -1; int max_align = -1; std::vector<struct field> range_fields; - for (struct die_info *child_die = die->child; - child_die; + for (struct die_info *child_die = die->child; child_die; child_die = child_die->sibling) { if (child_die->tag == DW_TAG_subrange_type) @@ -15578,9 +15344,8 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, bounds->set_code (TYPE_CODE_STRUCT); bounds->set_num_fields (range_fields.size ()); - bounds->set_fields - ((struct field *) TYPE_ALLOC (bounds, (bounds->num_fields () - * sizeof (struct field)))); + bounds->set_fields ((struct field *) TYPE_ALLOC ( + bounds, (bounds->num_fields () * sizeof (struct field)))); memcpy (bounds->fields (), range_fields.data (), bounds->num_fields () * sizeof (struct field)); @@ -15597,8 +15362,8 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, { gdb_assert (iter->code () == TYPE_CODE_ARRAY); iter->main_type->dyn_prop_list = nullptr; - iter->set_index_type - (create_static_range_type (NULL, bounds->field (i).type (), 1, 0)); + iter->set_index_type ( + create_static_range_type (NULL, bounds->field (i).type (), 1, 0)); iter = iter->target_type (); } @@ -15606,9 +15371,8 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, result->set_code (TYPE_CODE_STRUCT); result->set_num_fields (2); - result->set_fields - ((struct field *) TYPE_ZALLOC (result, (result->num_fields () - * sizeof (struct field)))); + result->set_fields ((struct field *) TYPE_ZALLOC ( + result, (result->num_fields () * sizeof (struct field)))); /* The names are chosen to coincide with what the compiler does with -fgnat-encodings=all, which the Ada code in gdb already @@ -15658,12 +15422,12 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) byte_stride_prop = (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop)); - stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, - prop_type); + stride_ok + = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, prop_type); if (!stride_ok) { - complaint (_("unable to read array DW_AT_byte_stride " - " - DIE at %s [in module %s]"), + complaint (_ ("unable to read array DW_AT_byte_stride " + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); /* Ignore this attribute. We will likely not be able to print @@ -15709,7 +15473,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) if (range_types.empty ()) { - complaint (_("unable to find array range - DIE at %s [in module %s]"), + complaint (_ ("unable to find array range - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); return NULL; @@ -15769,8 +15533,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) if (attr->as_unsigned () >= type->length ()) type->set_length (attr->as_unsigned ()); else - complaint (_("DW_AT_byte_size for array type smaller " - "than the total size of elements")); + complaint (_ ("DW_AT_byte_size for array type smaller " + "than the total size of elements")); } name = dwarf2_name (die, cu); @@ -15817,8 +15581,8 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu) FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need version checking. */ - if (cu->lang () == language_fortran - && cu->producer && strstr (cu->producer, "GNU F77")) + if (cu->lang () == language_fortran && cu->producer + && strstr (cu->producer, "GNU F77")) { return DW_ORD_row_major; } @@ -15886,8 +15650,7 @@ mark_common_block_symbol_computed (struct symbol *sym, gdb_assert (common_loc && member_loc); gdb_assert (common_loc->form_is_block ()); - gdb_assert (member_loc->form_is_block () - || member_loc->form_is_constant ()); + gdb_assert (member_loc->form_is_block () || member_loc->form_is_constant ()); baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); baton->per_objfile = per_objfile; @@ -15974,8 +15737,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) struct common_block *common_block; struct symbol *sym; - for (child_die = die->child; - child_die && child_die->tag; + for (child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) ++n_entries; @@ -15987,8 +15749,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) memset (common_block->contents, 0, n_entries * sizeof (struct symbol *)); common_block->n_entries = 0; - for (child_die = die->child; - child_die && child_die->tag; + for (child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) { /* Create the symbol in the DW_TAG_common_block block in the current @@ -16000,18 +15761,18 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) common_block->contents[common_block->n_entries++] = sym; - member_loc = dwarf2_attr (child_die, DW_AT_data_member_location, - cu); + member_loc + = dwarf2_attr (child_die, DW_AT_data_member_location, cu); if (member_loc) { /* GDB has handled this for a long time, but it is not specified by DWARF. It seems to have been emitted by gfortran at least as recently as: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23057. */ - complaint (_("Variable in common block has " - "DW_AT_data_member_location " - "- DIE at %s [in module %s]"), - sect_offset_str (child_die->sect_off), + complaint (_ ("Variable in common block has " + "DW_AT_data_member_location " + "- DIE at %s [in module %s]"), + sect_offset_str (child_die->sect_off), objfile_name (objfile)); if (member_loc->form_is_section_offset ()) @@ -16064,8 +15825,8 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu) previous_prefix = determine_prefix (die, cu); if (previous_prefix[0] != '\0') - name = typename_concat (&objfile->objfile_obstack, - previous_prefix, name, 0, cu); + name = typename_concat (&objfile->objfile_obstack, previous_prefix, name, + 0, cu); /* Create the type. */ type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name); @@ -16098,11 +15859,10 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) const char *previous_prefix = determine_prefix (die, cu); std::vector<const char *> excludes; - add_using_directive (using_directives (cu), - previous_prefix, type->name (), NULL, - NULL, excludes, - read_decl_line (die, cu), - 0, &objfile->objfile_obstack); + add_using_directive (using_directives (cu), previous_prefix, + type->name (), NULL, NULL, excludes, + read_decl_line (die, cu), 0, + &objfile->objfile_obstack); } } @@ -16165,8 +15925,7 @@ namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *cu) /* Loop through the extensions until we find a name. */ - for (current_die = die; - current_die != NULL; + for (current_die = die; current_die != NULL; current_die = dwarf2_extension (die, &cu)) { /* We don't use dwarf2_name here so that we can detect the absence @@ -16242,12 +16001,12 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu) } else if (type->length () != byte_size) { - complaint (_("invalid pointer size %d"), byte_size); + complaint (_ ("invalid pointer size %d"), byte_size); } else if (TYPE_RAW_ALIGN (type) != alignment) { - complaint (_("Invalid DW_AT_alignment" - " - DIE at %s [in module %s]"), + complaint (_ ("Invalid DW_AT_alignment" + " - DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); } @@ -16302,7 +16061,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu) static struct type * read_tag_reference_type (struct die_info *die, struct dwarf2_cu *cu, - enum type_code refcode) + enum type_code refcode) { struct comp_unit_head *cu_header = &cu->header; struct type *type, *target_type; @@ -16465,8 +16224,8 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) static bool warning_printed = false; if (!warning_printed) { - warning (_("DW_AT_bit_size and DW_AT_string_length_bit_size not " - "currently supported on DW_TAG_string_type.")); + warning (_ ("DW_AT_bit_size and DW_AT_string_length_bit_size not " + "currently supported on DW_TAG_string_type.")); warning_printed = true; } } @@ -16554,8 +16313,7 @@ prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu) languages that allow unprototyped functions (Eg: Objective C). For all other languages, assume that functions are always prototyped. */ - if (cu->lang () != language_c - && cu->lang () != language_objc + if (cu->lang () != language_c && cu->lang () != language_objc && cu->lang () != language_opencl) return 1; @@ -16583,8 +16341,8 @@ static struct type * read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_objfile->objfile; - struct type *type; /* Type that this function returns. */ - struct type *ftype; /* Function that returns above type. */ + struct type *type; /* Type that this function returns. */ + struct type *ftype; /* Function that returns above type. */ struct attribute *attr; type = die_type (die, cu); @@ -16604,7 +16362,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) the default value DW_CC_normal. */ attr = dwarf2_attr (die, DW_AT_calling_convention, cu); if (attr != nullptr - && is_valid_DW_AT_calling_convention_for_subroutine (attr->constant_value (0))) + && is_valid_DW_AT_calling_convention_for_subroutine ( + attr->constant_value (0))) TYPE_CALLING_CONVENTION (ftype) = (enum dwarf_calling_convention) attr->constant_value (0); else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL")) @@ -16646,8 +16405,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) /* Allocate storage for parameters and fill them in. */ ftype->set_num_fields (nparams); - ftype->set_fields - ((struct field *) TYPE_ZALLOC (ftype, nparams * sizeof (struct field))); + ftype->set_fields ( + (struct field *) TYPE_ZALLOC (ftype, nparams * sizeof (struct field))); /* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it even if we error out during the parameters reading below. */ @@ -16681,8 +16440,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) /* RealView does not mark THIS as const, which the testsuite expects. GCC marks THIS as const in method definitions, but not in the class specifications (GCC PR 43053). */ - if (cu->lang () == language_cplus - && !TYPE_CONST (arg_type) + if (cu->lang () == language_cplus && !TYPE_CONST (arg_type) && TYPE_FIELD_ARTIFICIAL (ftype, iparams)) { int is_this = 0; @@ -16738,8 +16496,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu) { /* Self-referential typedefs are, it seems, not allowed by the DWARF spec and cause infinite loops in GDB. */ - complaint (_("Self-referential DW_TAG_typedef " - "- DIE at %s [in module %s]"), + complaint (_ ("Self-referential DW_TAG_typedef " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (objfile)); this_type->set_target_type (nullptr); } @@ -16770,15 +16528,15 @@ get_mpz (struct dwarf2_cu *cu, gdb_mpz *value, struct attribute *attr) if (blk->size > 0 && blk->data[0] == DW_OP_implicit_value) { uint64_t len; - const gdb_byte *ptr = safe_read_uleb128 (blk->data + 1, - blk->data + blk->size, - &len); + const gdb_byte *ptr + = safe_read_uleb128 (blk->data + 1, blk->data + blk->size, &len); if (ptr - blk->data + len <= blk->size) { - mpz_import (value->val, len, - bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) - ? 1 : -1, - 1, 0, 0, ptr); + mpz_import ( + value->val, len, + bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) ? 1 + : -1, + 1, 0, 0, ptr); return; } } @@ -16790,8 +16548,8 @@ get_mpz (struct dwarf2_cu *cu, gdb_mpz *value, struct attribute *attr) { dwarf_block *blk = attr->as_block (); mpz_import (value->val, blk->size, - bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) - ? 1 : -1, + bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) ? 1 + : -1, 1, 0, 0, blk->data); } else @@ -16813,12 +16571,12 @@ get_dwarf2_rational_constant (struct die_info *die, struct dwarf2_cu *cu, num_attr = dwarf2_attr (die, DW_AT_GNU_numerator, cu); if (num_attr == nullptr) - complaint (_("DW_AT_GNU_numerator missing in %s DIE at %s"), + complaint (_ ("DW_AT_GNU_numerator missing in %s DIE at %s"), dwarf_tag_name (die->tag), sect_offset_str (die->sect_off)); denom_attr = dwarf2_attr (die, DW_AT_GNU_denominator, cu); if (denom_attr == nullptr) - complaint (_("DW_AT_GNU_denominator missing in %s DIE at %s"), + complaint (_ ("DW_AT_GNU_denominator missing in %s DIE at %s"), dwarf_tag_name (die->tag), sect_offset_str (die->sect_off)); if (num_attr == nullptr || denom_attr == nullptr) @@ -16851,15 +16609,15 @@ get_dwarf2_unsigned_rational_constant (struct die_info *die, } else if (mpz_sgn (num.val) == -1) { - complaint (_("unexpected negative value for DW_AT_GNU_numerator" - " in DIE at %s"), + complaint (_ ("unexpected negative value for DW_AT_GNU_numerator" + " in DIE at %s"), sect_offset_str (die->sect_off)); return; } else if (mpz_sgn (denom.val) == -1) { - complaint (_("unexpected negative value for DW_AT_GNU_denominator" - " in DIE at %s"), + complaint (_ ("unexpected negative value for DW_AT_GNU_denominator" + " in DIE at %s"), sect_offset_str (die->sect_off)); return; } @@ -16907,8 +16665,8 @@ ada_get_gnat_encoded_number (const char *encoding, int &k, gdb_mpz *result) failure. */ static bool -ada_get_gnat_encoded_ratio (const char *encoding, int &offset, - gdb_mpz *num, gdb_mpz *denom) +ada_get_gnat_encoded_ratio (const char *encoding, int &offset, gdb_mpz *num, + gdb_mpz *denom) { if (!ada_get_gnat_encoded_number (encoding, offset, num)) return false; @@ -16971,7 +16729,7 @@ finish_fixed_point_type (struct type *type, const char *suffix, see the encoded value. */ scale_num = 1; scale_denom = 1; - complaint (_("no scale found for fixed-point type (DIE at %s)"), + complaint (_ ("no scale found for fixed-point type (DIE at %s)"), sect_offset_str (die->sect_off)); } } @@ -16980,7 +16738,8 @@ finish_fixed_point_type (struct type *type, const char *suffix, LONGEST scale_exp = attr->constant_value (0); gdb_mpz *num_or_denom = scale_exp > 0 ? &scale_num : &scale_denom; - mpz_mul_2exp (num_or_denom->val, num_or_denom->val, std::abs (scale_exp)); + mpz_mul_2exp (num_or_denom->val, num_or_denom->val, + std::abs (scale_exp)); } else if (attr->name == DW_AT_decimal_scale) { @@ -16996,17 +16755,17 @@ finish_fixed_point_type (struct type *type, const char *suffix, scale_die = follow_die_ref (die, attr, &scale_cu); if (scale_die->tag == DW_TAG_constant) - get_dwarf2_unsigned_rational_constant (scale_die, scale_cu, - &scale_num, &scale_denom); + get_dwarf2_unsigned_rational_constant (scale_die, scale_cu, &scale_num, + &scale_denom); else - complaint (_("%s DIE not supported as target of DW_AT_small attribute" - " (DIE at %s)"), + complaint (_ ("%s DIE not supported as target of DW_AT_small attribute" + " (DIE at %s)"), dwarf_tag_name (die->tag), sect_offset_str (die->sect_off)); } else { - complaint (_("unsupported scale attribute %s for fixed-point type" - " (DIE at %s)"), + complaint (_ ("unsupported scale attribute %s for fixed-point type" + " (DIE at %s)"), dwarf_attr_name (attr->name), sect_offset_str (die->sect_off)); } @@ -17079,16 +16838,14 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile, CU is the DIE's Compilation Unit. */ static bool -has_zero_over_zero_small_attribute (struct die_info *die, - struct dwarf2_cu *cu) +has_zero_over_zero_small_attribute (struct die_info *die, struct dwarf2_cu *cu) { struct attribute *attr = dwarf2_attr (die, DW_AT_small, cu); if (attr == nullptr) return false; struct dwarf2_cu *scale_cu = cu; - struct die_info *scale_die - = follow_die_ref (die, attr, &scale_cu); + struct die_info *scale_die = follow_die_ref (die, attr, &scale_cu); if (scale_die->tag != DW_TAG_constant) return false; @@ -17108,8 +16865,7 @@ has_zero_over_zero_small_attribute (struct die_info *die, named, we try to select a suitable name based on the size of the component. */ static struct type * -dwarf2_init_complex_target_type (struct dwarf2_cu *cu, - struct objfile *objfile, +dwarf2_init_complex_target_type (struct dwarf2_cu *cu, struct objfile *objfile, int bits, const char *name_hint, enum bfd_endian byte_order) { @@ -17130,7 +16886,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu, case 64: tt = builtin_f_type (gdbarch)->builtin_real_s8; break; - case 96: /* The x86-32 ABI specifies 96-bit long double. */ + case 96: /* The x86-32 ABI specifies 96-bit long double. */ case 128: tt = builtin_f_type (gdbarch)->builtin_real_s16; break; @@ -17145,7 +16901,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu, case 64: tt = builtin_type (gdbarch)->builtin_double; break; - case 96: /* The x86-32 ABI specifies 96-bit long double. */ + case 96: /* The x86-32 ABI specifies 96-bit long double. */ case 128: tt = builtin_type (gdbarch)->builtin_long_double; break; @@ -17184,7 +16940,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) bits = attr->constant_value (0) * TARGET_CHAR_BIT; name = dwarf2_name (die, cu); if (!name) - complaint (_("DW_AT_name missing from DW_TAG_base_type")); + complaint (_ ("DW_AT_name missing from DW_TAG_base_type")); arch = objfile->arch (); enum bfd_endian byte_order = gdbarch_byte_order (arch); @@ -17203,7 +16959,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) byte_order = BFD_ENDIAN_LITTLE; break; default: - complaint (_("DW_AT_endianity has unrecognized value %d"), endianity); + complaint (_ ("DW_AT_endianity has unrecognized value %d"), + endianity); break; } } @@ -17220,9 +16977,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) the scaling factor via the standard DWARF mechanisms, and for which the info is provided via the GNAT encodings instead. This is likely what this DIE is about. */ - encoding = (encoding == DW_ATE_signed_fixed - ? DW_ATE_signed - : DW_ATE_unsigned); + encoding + = (encoding == DW_ATE_signed_fixed ? DW_ATE_signed : DW_ATE_unsigned); } /* With GNAT encodings, fixed-point information will be encoded in @@ -17231,8 +16987,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) than an "else if". */ const char *gnat_encoding_suffix = nullptr; if ((encoding == DW_ATE_signed || encoding == DW_ATE_unsigned) - && cu->lang () == language_ada - && name != nullptr) + && cu->lang () == language_ada && name != nullptr) { gnat_encoding_suffix = gnat_encoded_fixed_point_type_info (name); if (gnat_encoding_suffix != nullptr) @@ -17245,99 +17000,91 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) "XF". */ gnat_encoding_suffix += strlen (GNAT_FIXED_POINT_SUFFIX) - 1; - encoding = (encoding == DW_ATE_signed - ? DW_ATE_signed_fixed - : DW_ATE_unsigned_fixed); + encoding = (encoding == DW_ATE_signed ? DW_ATE_signed_fixed + : DW_ATE_unsigned_fixed); } } switch (encoding) { - case DW_ATE_address: - /* Turn DW_ATE_address into a void * pointer. */ - type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); - type = init_pointer_type (objfile, bits, name, type); - break; - case DW_ATE_boolean: - type = init_boolean_type (objfile, bits, 1, name); - break; - case DW_ATE_complex_float: - type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name, - byte_order); - if (type->code () == TYPE_CODE_ERROR) - { - if (name == nullptr) - { - struct obstack *obstack - = &cu->per_objfile->objfile->objfile_obstack; - name = obconcat (obstack, "_Complex ", type->name (), - nullptr); - } - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); - } - else - type = init_complex_type (name, type); - break; - case DW_ATE_decimal_float: - type = init_decfloat_type (objfile, bits, name); - break; - case DW_ATE_float: - type = dwarf2_init_float_type (objfile, bits, name, name, byte_order); - break; - case DW_ATE_signed: - type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); - break; - case DW_ATE_unsigned: - if (cu->lang () == language_fortran - && name - && startswith (name, "character(")) - type = init_character_type (objfile, bits, 1, name); - else - type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); - break; - case DW_ATE_signed_char: - if (cu->lang () == language_ada - || cu->lang () == language_m2 - || cu->lang () == language_pascal - || cu->lang () == language_fortran) - type = init_character_type (objfile, bits, 0, name); - else - type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); - break; - case DW_ATE_unsigned_char: - if (cu->lang () == language_ada - || cu->lang () == language_m2 - || cu->lang () == language_pascal - || cu->lang () == language_fortran - || cu->lang () == language_rust) - type = init_character_type (objfile, bits, 1, name); - else - type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); - break; - case DW_ATE_UTF: + case DW_ATE_address: + /* Turn DW_ATE_address into a void * pointer. */ + type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); + type = init_pointer_type (objfile, bits, name, type); + break; + case DW_ATE_boolean: + type = init_boolean_type (objfile, bits, 1, name); + break; + case DW_ATE_complex_float: + type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name, + byte_order); + if (type->code () == TYPE_CODE_ERROR) { - type = init_character_type (objfile, bits, 1, name); - return set_die_type (die, type, cu); + if (name == nullptr) + { + struct obstack *obstack + = &cu->per_objfile->objfile->objfile_obstack; + name = obconcat (obstack, "_Complex ", type->name (), nullptr); + } + type = init_type (objfile, TYPE_CODE_ERROR, bits, name); } - break; - case DW_ATE_signed_fixed: - type = init_fixed_point_type (objfile, bits, 0, name); - finish_fixed_point_type (type, gnat_encoding_suffix, die, cu); - break; - case DW_ATE_unsigned_fixed: - type = init_fixed_point_type (objfile, bits, 1, name); - finish_fixed_point_type (type, gnat_encoding_suffix, die, cu); - break; + else + type = init_complex_type (name, type); + break; + case DW_ATE_decimal_float: + type = init_decfloat_type (objfile, bits, name); + break; + case DW_ATE_float: + type = dwarf2_init_float_type (objfile, bits, name, name, byte_order); + break; + case DW_ATE_signed: + type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); + break; + case DW_ATE_unsigned: + if (cu->lang () == language_fortran && name + && startswith (name, "character(")) + type = init_character_type (objfile, bits, 1, name); + else + type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); + break; + case DW_ATE_signed_char: + if (cu->lang () == language_ada || cu->lang () == language_m2 + || cu->lang () == language_pascal || cu->lang () == language_fortran) + type = init_character_type (objfile, bits, 0, name); + else + type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); + break; + case DW_ATE_unsigned_char: + if (cu->lang () == language_ada || cu->lang () == language_m2 + || cu->lang () == language_pascal || cu->lang () == language_fortran + || cu->lang () == language_rust) + type = init_character_type (objfile, bits, 1, name); + else + type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); + break; + case DW_ATE_UTF: + { + type = init_character_type (objfile, bits, 1, name); + return set_die_type (die, type, cu); + } + break; + case DW_ATE_signed_fixed: + type = init_fixed_point_type (objfile, bits, 0, name); + finish_fixed_point_type (type, gnat_encoding_suffix, die, cu); + break; + case DW_ATE_unsigned_fixed: + type = init_fixed_point_type (objfile, bits, 1, name); + finish_fixed_point_type (type, gnat_encoding_suffix, die, cu); + break; - default: - complaint (_("unsupported DW_AT_encoding: '%s'"), - dwarf_type_encoding_name (encoding)); - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); - break; + default: + complaint (_ ("unsupported DW_AT_encoding: '%s'"), + dwarf_type_encoding_name (encoding)); + type = init_type (objfile, TYPE_CODE_ERROR, bits, name); + break; } - if (type->code () == TYPE_CODE_INT - && name != nullptr + if (type->code () == TYPE_CODE_INT && name != nullptr && strcmp (name, "char") == 0) type->set_has_no_signedness (true); @@ -17354,8 +17101,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu); /* Only use the attributes if they make sense together. */ if (attr == nullptr - || (attr->as_unsigned () + real_bit_size - <= 8 * type->length ())) + || (attr->as_unsigned () + real_bit_size <= 8 * type->length ())) { TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_size = real_bit_size; @@ -17419,8 +17165,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, { size_t data_size = 16; block = XOBNEW (obstack, struct dwarf_block); - block->size = (data_size - + 2 /* Extra bytes for DW_OP and arg. */); + block->size = (data_size + 2 /* Extra bytes for DW_OP and arg. */); gdb_byte *data = XOBNEWVEC (obstack, gdb_byte, block->size); data[0] = DW_OP_implicit_value; data[1] = data_size; @@ -17454,11 +17199,11 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, target_die = follow_die_ref (die, attr, &target_cu); target_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); if (target_attr == NULL) - target_attr = dwarf2_attr (target_die, DW_AT_data_member_location, - target_cu); + target_attr + = dwarf2_attr (target_die, DW_AT_data_member_location, target_cu); if (target_attr == nullptr) - target_attr = dwarf2_attr (target_die, DW_AT_data_bit_offset, - target_cu); + target_attr + = dwarf2_attr (target_die, DW_AT_data_bit_offset, target_cu); if (target_attr == NULL) { const char *name = var_decl_name (target_die, target_cu); @@ -17472,51 +17217,51 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, switch (target_attr->name) { - case DW_AT_location: - if (target_attr->form_is_section_offset ()) - { - baton = XOBNEW (obstack, struct dwarf2_property_baton); - baton->property_type = die_type (target_die, target_cu); - fill_in_loclist_baton (cu, &baton->loclist, target_attr); - prop->set_loclist (baton); - gdb_assert (prop->baton () != NULL); - } - else if (target_attr->form_is_block ()) - { - baton = XOBNEW (obstack, struct dwarf2_property_baton); - baton->property_type = die_type (target_die, target_cu); - baton->locexpr.per_cu = cu->per_cu; - baton->locexpr.per_objfile = per_objfile; - struct dwarf_block *block = target_attr->as_block (); - baton->locexpr.size = block->size; - baton->locexpr.data = block->data; - baton->locexpr.is_reference = true; - prop->set_locexpr (baton); - gdb_assert (prop->baton () != NULL); - } - else - { - dwarf2_invalid_attrib_class_complaint ("DW_AT_location", - "dynamic property"); - return 0; - } - break; - case DW_AT_data_member_location: - case DW_AT_data_bit_offset: + case DW_AT_location: + if (target_attr->form_is_section_offset ()) { - LONGEST offset; - - if (!handle_member_location (target_die, target_cu, &offset)) - return 0; - baton = XOBNEW (obstack, struct dwarf2_property_baton); - baton->property_type = read_type_die (target_die->parent, - target_cu); - baton->offset_info.offset = offset; - baton->offset_info.type = die_type (target_die, target_cu); - prop->set_addr_offset (baton); - break; + baton->property_type = die_type (target_die, target_cu); + fill_in_loclist_baton (cu, &baton->loclist, target_attr); + prop->set_loclist (baton); + gdb_assert (prop->baton () != NULL); + } + else if (target_attr->form_is_block ()) + { + baton = XOBNEW (obstack, struct dwarf2_property_baton); + baton->property_type = die_type (target_die, target_cu); + baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.per_objfile = per_objfile; + struct dwarf_block *block = target_attr->as_block (); + baton->locexpr.size = block->size; + baton->locexpr.data = block->data; + baton->locexpr.is_reference = true; + prop->set_locexpr (baton); + gdb_assert (prop->baton () != NULL); } + else + { + dwarf2_invalid_attrib_class_complaint ("DW_AT_location", + "dynamic property"); + return 0; + } + break; + case DW_AT_data_member_location: + case DW_AT_data_bit_offset: + { + LONGEST offset; + + if (!handle_member_location (target_die, target_cu, &offset)) + return 0; + + baton = XOBNEW (obstack, struct dwarf2_property_baton); + baton->property_type + = read_type_die (target_die->parent, target_cu); + baton->offset_info.offset = offset; + baton->offset_info.type = die_type (target_die, target_cu); + prop->set_addr_offset (baton); + break; + } } } else if (attr->form_is_constant ()) @@ -17541,7 +17286,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, return 1; - invalid: +invalid: dwarf2_invalid_attrib_class_complaint (dwarf_form_name (attr->form), dwarf2_name (die, cu)); return 0; @@ -17639,8 +17384,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) if (attr != nullptr) attr_to_dynamic_prop (attr, die, cu, &low, base_type); else if (!low_default_is_valid) - complaint (_("Missing DW_AT_lower_bound " - "- DIE at %s [in module %s]"), + complaint (_ ("Missing DW_AT_lower_bound " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); @@ -17660,13 +17405,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) else { if (attr_ub != NULL) - complaint (_("Unresolved DW_AT_upper_bound " - "- DIE at %s [in module %s]"), + complaint (_ ("Unresolved DW_AT_upper_bound " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); if (attr_count != NULL) - complaint (_("Unresolved DW_AT_count " - "- DIE at %s [in module %s]"), + complaint (_ ("Unresolved DW_AT_count " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); } @@ -17694,12 +17439,12 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) ULONGEST negative_mask = -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1)); - if (low.kind () == PROP_CONST - && !base_type->is_unsigned () && (low.const_val () & negative_mask)) + if (low.kind () == PROP_CONST && !base_type->is_unsigned () + && (low.const_val () & negative_mask)) low.set_const_val (low.const_val () | negative_mask); - if (high.kind () == PROP_CONST - && !base_type->is_unsigned () && (high.const_val () & negative_mask)) + if (high.kind () == PROP_CONST && !base_type->is_unsigned () + && (high.const_val () & negative_mask)) high.set_const_val (high.const_val () | negative_mask); } @@ -17720,8 +17465,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) /* It only makes sense to have either a bit or byte stride. */ if (attr_byte_stride != nullptr) { - complaint (_("Found DW_AT_bit_stride and DW_AT_byte_stride " - "- DIE at %s [in module %s]"), + complaint (_ ("Found DW_AT_bit_stride and DW_AT_byte_stride " + "- DIE at %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); attr_bit_stride = nullptr; @@ -17734,16 +17479,15 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) } } - if (attr_byte_stride != nullptr - || attr_bit_stride != nullptr) + if (attr_byte_stride != nullptr || attr_bit_stride != nullptr) { bool byte_stride_p = (attr_byte_stride != nullptr); struct dynamic_prop *stride = byte_stride_p ? &byte_stride_prop : &bit_stride_prop; range_type - = create_range_type_with_stride (NULL, orig_base_type, &low, - &high, bias, stride, byte_stride_p); + = create_range_type_with_stride (NULL, orig_base_type, &low, &high, + bias, stride, byte_stride_p); } else range_type = create_range_type (NULL, orig_base_type, &low, &high, bias); @@ -17799,8 +17543,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu) static struct die_info * read_die_and_children (const struct die_reader_specs *reader, - const gdb_byte *info_ptr, - const gdb_byte **new_info_ptr, + const gdb_byte *info_ptr, const gdb_byte **new_info_ptr, struct die_info *parent) { struct die_info *die; @@ -17870,17 +17613,15 @@ read_die_and_siblings_1 (const struct die_reader_specs *reader, static struct die_info * read_die_and_siblings (const struct die_reader_specs *reader, - const gdb_byte *info_ptr, - const gdb_byte **new_info_ptr, + const gdb_byte *info_ptr, const gdb_byte **new_info_ptr, struct die_info *parent) { - struct die_info *die = read_die_and_siblings_1 (reader, info_ptr, - new_info_ptr, parent); + struct die_info *die + = read_die_and_siblings_1 (reader, info_ptr, new_info_ptr, parent); if (dwarf_die_debug) { - gdb_printf (gdb_stdlog, - "Read die from %s@0x%x of %s:\n", + gdb_printf (gdb_stdlog, "Read die from %s@0x%x of %s:\n", reader->die_section->get_name (), (unsigned) (info_ptr - reader->die_section->buffer), bfd_get_filename (reader->abfd)); @@ -17898,9 +17639,8 @@ read_die_and_siblings (const struct die_reader_specs *reader, except for its child, sibling, and parent fields. */ static const gdb_byte * -read_full_die_1 (const struct die_reader_specs *reader, - struct die_info **diep, const gdb_byte *info_ptr, - int num_extra_attrs) +read_full_die_1 (const struct die_reader_specs *reader, struct die_info **diep, + const gdb_byte *info_ptr, int num_extra_attrs) { unsigned int abbrev_number, bytes_read, i; const struct abbrev_info *abbrev; @@ -17919,9 +17659,8 @@ read_full_die_1 (const struct die_reader_specs *reader, abbrev = reader->abbrev_table->lookup_abbrev (abbrev_number); if (!abbrev) - error (_("Dwarf Error: could not find abbrev number %d [in module %s]"), - abbrev_number, - bfd_get_filename (abfd)); + error (_ ("Dwarf Error: could not find abbrev number %d [in module %s]"), + abbrev_number, bfd_get_filename (abfd)); die = dwarf_alloc_die (cu, abbrev->num_attrs + num_extra_attrs); die->sect_off = sect_off; @@ -17937,8 +17676,8 @@ read_full_die_1 (const struct die_reader_specs *reader, bool any_need_reprocess = false; for (i = 0; i < abbrev->num_attrs; ++i) { - info_ptr = read_attribute (reader, &die->attrs[i], &abbrev->attrs[i], - info_ptr); + info_ptr + = read_attribute (reader, &die->attrs[i], &abbrev->attrs[i], info_ptr); if (die->attrs[i].requires_reprocessing_p ()) any_need_reprocess = true; } @@ -17976,8 +17715,8 @@ read_full_die_1 (const struct die_reader_specs *reader, except for its child, sibling, and parent fields. */ static const gdb_byte * -read_full_die (const struct die_reader_specs *reader, - struct die_info **diep, const gdb_byte *info_ptr) +read_full_die (const struct die_reader_specs *reader, struct die_info **diep, + const gdb_byte *info_ptr) { const gdb_byte *result; @@ -17985,8 +17724,7 @@ read_full_die (const struct die_reader_specs *reader, if (dwarf_die_debug) { - gdb_printf (gdb_stdlog, - "Read die from %s@0x%x of %s:\n", + gdb_printf (gdb_stdlog, "Read die from %s@0x%x of %s:\n", reader->die_section->get_name (), (unsigned) (info_ptr - reader->die_section->buffer), bfd_get_filename (reader->abfd)); @@ -17995,7 +17733,6 @@ read_full_die (const struct die_reader_specs *reader, return result; } - void cooked_indexer::check_bounds (cutu_reader *reader) @@ -18083,8 +17820,8 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader, prepare_one_comp_unit (new_reader.cu, new_reader.comp_unit_die, language_minimal); - std::unique_ptr<cutu_reader> copy - (new cutu_reader (std::move (new_reader))); + std::unique_ptr<cutu_reader> copy ( + new cutu_reader (std::move (new_reader))); result = m_index_storage->preserve (std::move (copy)); } @@ -18098,18 +17835,13 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader, } const gdb_byte * -cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, - cutu_reader *reader, - const gdb_byte *watermark_ptr, - const gdb_byte *info_ptr, - const abbrev_info *abbrev, - const char **name, - const char **linkage_name, - cooked_index_flag *flags, - sect_offset *sibling_offset, - const cooked_index_entry **parent_entry, - CORE_ADDR *maybe_defer, - bool for_specification) +cooked_indexer::scan_attributes ( + dwarf2_per_cu_data *scanning_per_cu, cutu_reader *reader, + const gdb_byte *watermark_ptr, const gdb_byte *info_ptr, + const abbrev_info *abbrev, const char **name, const char **linkage_name, + cooked_index_flag *flags, sect_offset *sibling_offset, + const cooked_index_entry **parent_entry, CORE_ADDR *maybe_defer, + bool for_specification) { bool origin_is_dwz = false; bool is_declaration = false; @@ -18266,39 +17998,35 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, origin_is_dwz, false); if (new_reader != nullptr) { - const gdb_byte *new_info_ptr = (new_reader->buffer - + to_underlying (origin_offset)); + const gdb_byte *new_info_ptr + = (new_reader->buffer + to_underlying (origin_offset)); - if (new_reader->cu == reader->cu - && new_info_ptr > watermark_ptr + if (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr && *parent_entry == nullptr) *maybe_defer = form_addr (origin_offset, origin_is_dwz); else if (*parent_entry == nullptr) { CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz); void *obj = m_die_range_map.find (lookup); - *parent_entry = static_cast <cooked_index_entry *> (obj); + *parent_entry = static_cast<cooked_index_entry *> (obj); } unsigned int bytes_read; - const abbrev_info *new_abbrev = peek_die_abbrev (*new_reader, - new_info_ptr, - &bytes_read); + const abbrev_info *new_abbrev + = peek_die_abbrev (*new_reader, new_info_ptr, &bytes_read); new_info_ptr += bytes_read; - scan_attributes (scanning_per_cu, new_reader, new_info_ptr, new_info_ptr, - new_abbrev, name, linkage_name, flags, nullptr, - parent_entry, maybe_defer, true); + scan_attributes (scanning_per_cu, new_reader, new_info_ptr, + new_info_ptr, new_abbrev, name, linkage_name, flags, + nullptr, parent_entry, maybe_defer, true); } } if (!for_specification) { - if (m_language == language_ada - && *linkage_name == nullptr) + if (m_language == language_ada && *linkage_name == nullptr) *linkage_name = *name; - if (!scanning_per_cu->addresses_seen - && low_pc.has_value () + if (!scanning_per_cu->addresses_seen && low_pc.has_value () && (reader->cu->per_objfile->per_bfd->has_section_at_zero || *low_pc != 0) && high_pc.has_value ()) @@ -18358,8 +18086,8 @@ cooked_indexer::index_imported_unit (cutu_reader *reader, if (attr.name == DW_AT_import) { sect_off = attr.get_ref_die_offset (); - is_dwz = (attr.form == DW_FORM_GNU_ref_alt - || reader->cu->per_cu->is_dwz); + is_dwz + = (attr.form == DW_FORM_GNU_ref_alt || reader->cu->per_cu->is_dwz); } } @@ -18368,8 +18096,8 @@ cooked_indexer::index_imported_unit (cutu_reader *reader, return info_ptr; dwarf2_per_objfile *per_objfile = reader->cu->per_objfile; - cutu_reader *new_reader = ensure_cu_exists (reader, per_objfile, sect_off, - is_dwz, true); + cutu_reader *new_reader + = ensure_cu_exists (reader, per_objfile, sect_off, is_dwz, true); if (new_reader != nullptr) { index_dies (new_reader, new_reader->info_ptr, nullptr, false); @@ -18381,17 +18109,15 @@ cooked_indexer::index_imported_unit (cutu_reader *reader, } const gdb_byte * -cooked_indexer::recurse (cutu_reader *reader, - const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, - bool fully) +cooked_indexer::recurse (cutu_reader *reader, const gdb_byte *info_ptr, + const cooked_index_entry *parent_entry, bool fully) { info_ptr = index_dies (reader, info_ptr, parent_entry, fully); if (parent_entry != nullptr) { - CORE_ADDR start = form_addr (parent_entry->die_offset, - reader->cu->per_cu->is_dwz); + CORE_ADDR start + = form_addr (parent_entry->die_offset, reader->cu->per_cu->is_dwz); CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer), reader->cu->per_cu->is_dwz); m_die_range_map.set_empty (start, end, (void *) parent_entry); @@ -18401,21 +18127,19 @@ cooked_indexer::recurse (cutu_reader *reader, } const gdb_byte * -cooked_indexer::index_dies (cutu_reader *reader, - const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, - bool fully) +cooked_indexer::index_dies (cutu_reader *reader, const gdb_byte *info_ptr, + const cooked_index_entry *parent_entry, bool fully) { - const gdb_byte *end_ptr = (reader->buffer - + to_underlying (reader->cu->header.sect_off) - + reader->cu->header.get_length_with_initial ()); + const gdb_byte *end_ptr + = (reader->buffer + to_underlying (reader->cu->header.sect_off) + + reader->cu->header.get_length_with_initial ()); while (info_ptr < end_ptr) { sect_offset this_die = (sect_offset) (info_ptr - reader->buffer); unsigned int bytes_read; - const abbrev_info *abbrev = peek_die_abbrev (*reader, info_ptr, - &bytes_read); + const abbrev_info *abbrev + = peek_die_abbrev (*reader, info_ptr, &bytes_read); info_ptr += bytes_read; if (abbrev == nullptr) break; @@ -18440,13 +18164,12 @@ cooked_indexer::index_dies (cutu_reader *reader, cooked_index_flag flags = IS_STATIC; sect_offset sibling {}; const cooked_index_entry *this_parent_entry = parent_entry; - info_ptr = scan_attributes (reader->cu->per_cu, reader, info_ptr, - info_ptr, abbrev, &name, &linkage_name, - &flags, &sibling, &this_parent_entry, - &defer, false); + info_ptr + = scan_attributes (reader->cu->per_cu, reader, info_ptr, info_ptr, + abbrev, &name, &linkage_name, &flags, &sibling, + &this_parent_entry, &defer, false); - if (abbrev->tag == DW_TAG_namespace - && m_language == language_cplus + if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus && strcmp (name, "::") == 0) { /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they @@ -18460,13 +18183,12 @@ cooked_indexer::index_dies (cutu_reader *reader, if (name != nullptr) { if (defer != 0) - m_deferred_entries.push_back ({ - this_die, name, defer, abbrev->tag, flags - }); + m_deferred_entries.push_back ({ this_die, name, defer, abbrev->tag, + flags }); else - this_entry = m_index_storage->add (this_die, abbrev->tag, flags, - name, this_parent_entry, - m_per_cu); + this_entry + = m_index_storage->add (this_die, abbrev->tag, flags, name, + this_parent_entry, m_per_cu); } if (linkage_name != nullptr) @@ -18479,11 +18201,11 @@ cooked_indexer::index_dies (cutu_reader *reader, have linkage name present but name is absent. */ if (name != nullptr || (abbrev->tag != DW_TAG_subprogram - && abbrev->tag != DW_TAG_inlined_subroutine - && abbrev->tag != DW_TAG_entry_point)) + && abbrev->tag != DW_TAG_inlined_subroutine + && abbrev->tag != DW_TAG_entry_point)) flags = flags | IS_LINKAGE; - m_index_storage->add (this_die, abbrev->tag, flags, - linkage_name, nullptr, m_per_cu); + m_index_storage->add (this_die, abbrev->tag, flags, linkage_name, + nullptr, m_per_cu); } if (abbrev->has_children) @@ -18509,9 +18231,8 @@ cooked_indexer::index_dies (cutu_reader *reader, "enum_class::enumerator"; otherwise we inject the names into our own parent scope. */ info_ptr = recurse (reader, info_ptr, - ((flags & IS_ENUM_CLASS) == 0) - ? parent_entry - : this_entry, + ((flags & IS_ENUM_CLASS) == 0) ? parent_entry + : this_entry, fully); continue; @@ -18542,7 +18263,7 @@ cooked_indexer::index_dies (cutu_reader *reader, = reader->buffer + to_underlying (sibling); if (sibling_ptr < info_ptr) - complaint (_("DW_AT_sibling points backwards")); + complaint (_ ("DW_AT_sibling points backwards")); else if (sibling_ptr > reader->buffer_end) reader->die_section->overflow_complaint (); else @@ -18569,7 +18290,7 @@ cooked_indexer::make_index (cutu_reader *reader) { CORE_ADDR key = form_addr (entry.die_offset, m_per_cu->is_dwz); void *obj = m_die_range_map.find (key); - cooked_index_entry *parent = static_cast <cooked_index_entry *> (obj); + cooked_index_entry *parent = static_cast<cooked_index_entry *> (obj); m_index_storage->add (entry.die_offset, entry.tag, entry.flags, entry.name, parent, m_per_cu); } @@ -18583,15 +18304,15 @@ struct cooked_index_functions : public dwarf2_base_index_functions dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, CORE_ADDR adjusted_pc) override; - struct compunit_symtab *find_compunit_symtab_by_address - (struct objfile *objfile, CORE_ADDR address) override; + struct compunit_symtab * + find_compunit_symtab_by_address (struct objfile *objfile, + CORE_ADDR address) override; void dump (struct objfile *objfile) override { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - cooked_index *index - = (gdb::checked_static_cast<cooked_index *> - (per_objfile->per_bfd->index_table.get ())); + cooked_index *index = (gdb::checked_static_cast<cooked_index *> ( + per_objfile->per_bfd->index_table.get ())); if (index == nullptr) return; @@ -18600,27 +18321,20 @@ struct cooked_index_functions : public dwarf2_base_index_functions index->dump (objfile->arch ()); } - void expand_matching_symbols - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) override; - - bool expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) override; - - bool can_lazily_read_symbols () override - { - return true; - } + void expand_matching_symbols ( + struct objfile *, const lookup_name_info &lookup_name, domain_enum domain, + int global, symbol_compare_ftype *ordered_compare) override; + + bool expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, + enum search_domain kind) override; + + bool can_lazily_read_symbols () override { return true; } void read_partial_symbols (struct objfile *objfile) override { @@ -18634,24 +18348,22 @@ cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, CORE_ADDR adjusted_pc) { cooked_index *table - = (gdb::checked_static_cast<cooked_index *> - (per_bfd->index_table.get ())); + = (gdb::checked_static_cast<cooked_index *> (per_bfd->index_table.get ())); if (table == nullptr) return nullptr; return table->lookup (adjusted_pc); } struct compunit_symtab * -cooked_index_functions::find_compunit_symtab_by_address - (struct objfile *objfile, CORE_ADDR address) +cooked_index_functions::find_compunit_symtab_by_address ( + struct objfile *objfile, CORE_ADDR address) { if (objfile->sect_index_data == -1) return nullptr; dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - cooked_index *table - = (gdb::checked_static_cast<cooked_index *> - (per_objfile->per_bfd->index_table.get ())); + cooked_index *table = (gdb::checked_static_cast<cooked_index *> ( + per_objfile->per_bfd->index_table.get ())); if (table == nullptr) return nullptr; @@ -18664,23 +18376,18 @@ cooked_index_functions::find_compunit_symtab_by_address } void -cooked_index_functions::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) +cooked_index_functions::expand_matching_symbols ( + struct objfile *objfile, const lookup_name_info &lookup_name, + domain_enum domain, int global, symbol_compare_ftype *ordered_compare) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - cooked_index *table - = (gdb::checked_static_cast<cooked_index *> - (per_objfile->per_bfd->index_table.get ())); + cooked_index *table = (gdb::checked_static_cast<cooked_index *> ( + per_objfile->per_bfd->index_table.get ())); if (table == nullptr) return; - const block_search_flags search_flags = (global - ? SEARCH_GLOBAL_BLOCK - : SEARCH_STATIC_BLOCK); + const block_search_flags search_flags + = (global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK); const language_defn *lang = language_def (language_ada); symbol_name_matcher_ftype *name_match = lang->get_symbol_name_matcher (lookup_name); @@ -18692,8 +18399,7 @@ cooked_index_functions::expand_matching_symbols if (entry->parent_entry != nullptr) continue; - if (!entry->matches (search_flags) - || !entry->matches (domain)) + if (!entry->matches (search_flags) || !entry->matches (domain)) continue; if (name_match (entry->canonical, lookup_name, nullptr)) @@ -18702,21 +18408,18 @@ cooked_index_functions::expand_matching_symbols } bool -cooked_index_functions::expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, - gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_domain kind) +cooked_index_functions::expand_symtabs_matching ( + struct objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, + gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, + block_search_flags search_flags, domain_enum domain, enum search_domain kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - cooked_index *table - = (gdb::checked_static_cast<cooked_index *> - (per_objfile->per_bfd->index_table.get ())); + cooked_index *table = (gdb::checked_static_cast<cooked_index *> ( + per_objfile->per_bfd->index_table.get ())); if (table == nullptr) return true; @@ -18728,8 +18431,7 @@ cooked_index_functions::expand_symtabs_matching gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); if (lookup_name == nullptr) { - for (dwarf2_per_cu_data *per_cu - : all_units_range (per_objfile->per_bfd)) + for (dwarf2_per_cu_data *per_cu : all_units_range (per_objfile->per_bfd)) { QUIT; @@ -18746,16 +18448,14 @@ cooked_index_functions::expand_symtabs_matching bool completing = lookup_name->completion_mode (); /* Unique styles of language splitting. */ - static const enum language unique_styles[] = - { - /* No splitting is also a style. */ - language_c, - /* This includes Rust. */ - language_cplus, - /* This includes Go. */ - language_d, - language_ada - }; + static const enum language unique_styles[] + = { /* No splitting is also a style. */ + language_c, + /* This includes Rust. */ + language_cplus, + /* This includes Go. */ + language_d, language_ada + }; for (enum language lang : unique_styles) { @@ -18763,8 +18463,8 @@ cooked_index_functions::expand_symtabs_matching = lookup_name_without_params.split_name (lang); std::string last_name = gdb::to_string (name_vec.back ()); - for (const cooked_index_entry *entry : table->find (last_name, - completing)) + for (const cooked_index_entry *entry : + table->find (last_name, completing)) { QUIT; @@ -18778,8 +18478,7 @@ cooked_index_functions::expand_symtabs_matching continue; /* See if the symbol matches the type filter. */ - if (!entry->matches (search_flags) - || !entry->matches (domain) + if (!entry->matches (search_flags) || !entry->matches (domain) || !entry->matches (kind)) continue; @@ -18795,7 +18494,8 @@ cooked_index_functions::expand_symtabs_matching match, this did not match. */ if (parent == nullptr || strncmp (parent->name, name_vec[i - 1].data (), - name_vec[i - 1].length ()) != 0) + name_vec[i - 1].length ()) + != 0) { found = false; break; @@ -18851,8 +18551,6 @@ cooked_index::make_quick_functions () const return make_cooked_index_funcs (); } - - /* Read the .debug_loclists or .debug_rnglists header (they are the same format) contents from the given SECTION in the HEADER. @@ -18897,7 +18595,7 @@ lookup_loclist_base (struct dwarf2_cu *cu) if (cu->dwo_unit != nullptr) { if (cu->header.initial_length_size == 4) - return LOCLIST_HEADER_SIZE32; + return LOCLIST_HEADER_SIZE32; return LOCLIST_HEADER_SIZE64; } return cu->loclist_base; @@ -18912,14 +18610,14 @@ read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) dwarf2_per_objfile *per_objfile = cu->per_objfile; struct objfile *objfile = per_objfile->objfile; bfd *abfd = objfile->obfd.get (); - ULONGEST loclist_header_size = - (cu->header.initial_length_size == 4 ? LOCLIST_HEADER_SIZE32 - : LOCLIST_HEADER_SIZE64); + ULONGEST loclist_header_size + = (cu->header.initial_length_size == 4 ? LOCLIST_HEADER_SIZE32 + : LOCLIST_HEADER_SIZE64); ULONGEST loclist_base = lookup_loclist_base (cu); /* Offset in .debug_loclists of the offset for LOCLIST_INDEX. */ - ULONGEST start_offset = - loclist_base + loclist_index * cu->header.offset_size; + ULONGEST start_offset + = loclist_base + loclist_index * cu->header.offset_size; /* Get loclists section. */ struct dwarf2_section_info *section = cu_debug_loc_section (cu); @@ -18927,30 +18625,33 @@ read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) /* Read the loclists section content. */ section->read (objfile); if (section->buffer == NULL) - error (_("DW_FORM_loclistx used without .debug_loclists " - "section [in module %s]"), objfile_name (objfile)); + error (_ ("DW_FORM_loclistx used without .debug_loclists " + "section [in module %s]"), + objfile_name (objfile)); /* DW_AT_loclists_base points after the .debug_loclists contribution header, so if loclist_base is smaller than the header size, we have a problem. */ if (loclist_base < loclist_header_size) - error (_("DW_AT_loclists_base is smaller than header size [in module %s]"), - objfile_name (objfile)); + error ( + _ ("DW_AT_loclists_base is smaller than header size [in module %s]"), + objfile_name (objfile)); /* Read the header of the loclists contribution. */ struct loclists_rnglists_header header; read_loclists_rnglists_header (&header, section, - (sect_offset) (loclist_base - loclist_header_size)); + (sect_offset) (loclist_base + - loclist_header_size)); /* Verify the loclist index is valid. */ if (loclist_index >= header.offset_entry_count) - error (_("DW_FORM_loclistx pointing outside of " - ".debug_loclists offset array [in module %s]"), + error (_ ("DW_FORM_loclistx pointing outside of " + ".debug_loclists offset array [in module %s]"), objfile_name (objfile)); /* Validate that reading won't go beyond the end of the section. */ if (start_offset + cu->header.offset_size > section->size) - error (_("Reading DW_FORM_loclistx index beyond end of" - ".debug_loclists section [in module %s]"), + error (_ ("Reading DW_FORM_loclistx index beyond end of" + ".debug_loclists section [in module %s]"), objfile_name (objfile)); const gdb_byte *info_ptr = section->buffer + start_offset; @@ -18971,19 +18672,19 @@ read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile; struct objfile *objfile = dwarf2_per_objfile->objfile; bfd *abfd = objfile->obfd.get (); - ULONGEST rnglist_header_size = - (cu->header.initial_length_size == 4 ? RNGLIST_HEADER_SIZE32 - : RNGLIST_HEADER_SIZE64); + ULONGEST rnglist_header_size + = (cu->header.initial_length_size == 4 ? RNGLIST_HEADER_SIZE32 + : RNGLIST_HEADER_SIZE64); /* When reading a DW_FORM_rnglistx from a DWO, we read from the DWO's .debug_rnglists.dwo section. The rnglists base given in the skeleton doesn't apply. */ - ULONGEST rnglist_base = - (cu->dwo_unit != nullptr) ? rnglist_header_size : cu->rnglists_base; + ULONGEST rnglist_base + = (cu->dwo_unit != nullptr) ? rnglist_header_size : cu->rnglists_base; /* Offset in .debug_rnglists of the offset for RNGLIST_INDEX. */ - ULONGEST start_offset = - rnglist_base + rnglist_index * cu->header.offset_size; + ULONGEST start_offset + = rnglist_base + rnglist_index * cu->header.offset_size; /* Get rnglists section. */ struct dwarf2_section_info *section = cu_debug_rnglists_section (cu, tag); @@ -18991,31 +18692,33 @@ read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, /* Read the rnglists section content. */ section->read (objfile); if (section->buffer == nullptr) - error (_("DW_FORM_rnglistx used without .debug_rnglists section " - "[in module %s]"), + error (_ ("DW_FORM_rnglistx used without .debug_rnglists section " + "[in module %s]"), objfile_name (objfile)); /* DW_AT_rnglists_base points after the .debug_rnglists contribution header, so if rnglist_base is smaller than the header size, we have a problem. */ if (rnglist_base < rnglist_header_size) - error (_("DW_AT_rnglists_base is smaller than header size [in module %s]"), - objfile_name (objfile)); + error ( + _ ("DW_AT_rnglists_base is smaller than header size [in module %s]"), + objfile_name (objfile)); /* Read the header of the rnglists contribution. */ struct loclists_rnglists_header header; read_loclists_rnglists_header (&header, section, - (sect_offset) (rnglist_base - rnglist_header_size)); + (sect_offset) (rnglist_base + - rnglist_header_size)); /* Verify the rnglist index is valid. */ if (rnglist_index >= header.offset_entry_count) - error (_("DW_FORM_rnglistx index pointing outside of " - ".debug_rnglists offset array [in module %s]"), + error (_ ("DW_FORM_rnglistx index pointing outside of " + ".debug_rnglists offset array [in module %s]"), objfile_name (objfile)); /* Validate that reading won't go beyond the end of the section. */ if (start_offset + cu->header.offset_size > section->size) - error (_("Reading DW_FORM_rnglistx index beyond end of" - ".debug_rnglists section [in module %s]"), + error (_ ("Reading DW_FORM_rnglistx index beyond end of" + ".debug_rnglists section [in module %s]"), objfile_name (objfile)); const gdb_byte *info_ptr = section->buffer + start_offset; @@ -19037,46 +18740,44 @@ read_attribute_reprocess (const struct die_reader_specs *reader, struct dwarf2_cu *cu = reader->cu; switch (attr->form) { - case DW_FORM_addrx: - case DW_FORM_GNU_addr_index: - attr->set_address (read_addr_index (cu, - attr->as_unsigned_reprocess ())); - break; - case DW_FORM_loclistx: - { - sect_offset loclists_sect_off - = read_loclist_index (cu, attr->as_unsigned_reprocess ()); + case DW_FORM_addrx: + case DW_FORM_GNU_addr_index: + attr->set_address (read_addr_index (cu, attr->as_unsigned_reprocess ())); + break; + case DW_FORM_loclistx: + { + sect_offset loclists_sect_off + = read_loclist_index (cu, attr->as_unsigned_reprocess ()); - attr->set_unsigned (to_underlying (loclists_sect_off)); - } - break; - case DW_FORM_rnglistx: - { - sect_offset rnglists_sect_off - = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag); + attr->set_unsigned (to_underlying (loclists_sect_off)); + } + break; + case DW_FORM_rnglistx: + { + sect_offset rnglists_sect_off + = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag); - attr->set_unsigned (to_underlying (rnglists_sect_off)); - } + attr->set_unsigned (to_underlying (rnglists_sect_off)); + } + break; + case DW_FORM_strx: + case DW_FORM_strx1: + case DW_FORM_strx2: + case DW_FORM_strx3: + case DW_FORM_strx4: + case DW_FORM_GNU_str_index: + { + unsigned int str_index = attr->as_unsigned_reprocess (); + gdb_assert (!attr->canonical_string_p ()); + if (reader->dwo_file != NULL) + attr->set_string_noncanonical (read_dwo_str_index (reader, + str_index)); + else + attr->set_string_noncanonical (read_stub_str_index (cu, str_index)); break; - case DW_FORM_strx: - case DW_FORM_strx1: - case DW_FORM_strx2: - case DW_FORM_strx3: - case DW_FORM_strx4: - case DW_FORM_GNU_str_index: - { - unsigned int str_index = attr->as_unsigned_reprocess (); - gdb_assert (!attr->canonical_string_p ()); - if (reader->dwo_file != NULL) - attr->set_string_noncanonical (read_dwo_str_index (reader, - str_index)); - else - attr->set_string_noncanonical (read_stub_str_index (cu, - str_index)); - break; - } - default: - gdb_assert_not_reached ("Unexpected DWARF form."); + } + default: + gdb_assert_not_reached ("Unexpected DWARF form."); } } @@ -19176,10 +18877,8 @@ read_attribute_value (const struct die_reader_specs *reader, case DW_FORM_strp: if (!cu->per_cu->is_dwz) { - attr->set_string_noncanonical - (read_indirect_string (per_objfile, - abfd, info_ptr, cu_header, - &bytes_read)); + attr->set_string_noncanonical (read_indirect_string ( + per_objfile, abfd, info_ptr, cu_header, &bytes_read)); info_ptr += bytes_read; break; } @@ -19187,9 +18886,8 @@ read_attribute_value (const struct die_reader_specs *reader, case DW_FORM_line_strp: if (!cu->per_cu->is_dwz) { - attr->set_string_noncanonical - (per_objfile->read_line_string (info_ptr, cu_header, - &bytes_read)); + attr->set_string_noncanonical ( + per_objfile->read_line_string (info_ptr, cu_header, &bytes_read)); info_ptr += bytes_read; break; } @@ -19197,11 +18895,10 @@ read_attribute_value (const struct die_reader_specs *reader, case DW_FORM_GNU_strp_alt: { dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd, true); - LONGEST str_offset = cu_header->read_offset (abfd, info_ptr, - &bytes_read); + LONGEST str_offset + = cu_header->read_offset (abfd, info_ptr, &bytes_read); - attr->set_string_noncanonical - (dwz->read_string (objfile, str_offset)); + attr->set_string_noncanonical (dwz->read_string (objfile, str_offset)); info_ptr += bytes_read; } break; @@ -19283,8 +18980,8 @@ read_attribute_value (const struct die_reader_specs *reader, implicit_const = read_signed_leb128 (abfd, info_ptr, &bytes_read); info_ptr += bytes_read; } - info_ptr = read_attribute_value (reader, attr, form, implicit_const, - info_ptr); + info_ptr + = read_attribute_value (reader, attr, form, implicit_const, info_ptr); break; case DW_FORM_implicit_const: attr->set_signed (implicit_const); @@ -19332,9 +19029,9 @@ read_attribute_value (const struct die_reader_specs *reader, } break; default: - error (_("Dwarf Error: Cannot handle %s in DWARF reader [in module %s]"), - dwarf_form_name (form), - bfd_get_filename (abfd)); + error ( + _ ("Dwarf Error: Cannot handle %s in DWARF reader [in module %s]"), + dwarf_form_name (form), bfd_get_filename (abfd)); } /* Super hack. */ @@ -19347,13 +19044,12 @@ read_attribute_value (const struct die_reader_specs *reader, an object of this size seems pretty unlikely so we can relatively safely treat these cases as if the size attribute was invalid and treat them as zero by default. */ - if (attr->name == DW_AT_byte_size - && form == DW_FORM_data4 + if (attr->name == DW_AT_byte_size && form == DW_FORM_data4 && attr->as_unsigned () >= 0xffffffff) { - complaint - (_("Suspicious DW_AT_byte_size value treated as zero instead of %s"), - hex_string (attr->as_unsigned ())); + complaint ( + _ ("Suspicious DW_AT_byte_size value treated as zero instead of %s"), + hex_string (attr->as_unsigned ())); attr->set_unsigned (0); } @@ -19363,9 +19059,8 @@ read_attribute_value (const struct die_reader_specs *reader, /* Read an attribute described by an abbreviated attribute. */ static const gdb_byte * -read_attribute (const struct die_reader_specs *reader, - struct attribute *attr, const struct attr_abbrev *abbrev, - const gdb_byte *info_ptr) +read_attribute (const struct die_reader_specs *reader, struct attribute *attr, + const struct attr_abbrev *abbrev, const gdb_byte *info_ptr) { attr->name = abbrev->name; attr->string_is_canonical = 0; @@ -19408,7 +19103,8 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf, bfd *abfd = objfile->obfd.get (); ULONGEST str_offset = read_offset (abfd, buf, offset_size); - return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line_strp"); + return per_bfd->line_str.read_string (objfile, str_offset, + "DW_FORM_line_strp"); } /* See read.h. */ @@ -19421,7 +19117,8 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf, bfd *abfd = objfile->obfd.get (); LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr); - return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line_strp"); + return per_bfd->line_str.read_string (objfile, str_offset, + "DW_FORM_line_strp"); } /* Given index ADDR_INDEX in .debug_addr, fetch the value. @@ -19439,12 +19136,13 @@ read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index, per_objfile->per_bfd->addr.read (objfile); if (per_objfile->per_bfd->addr.buffer == NULL) - error (_("DW_FORM_addr_index used without .debug_addr section [in module %s]"), - objfile_name (objfile)); + error ( + _ ("DW_FORM_addr_index used without .debug_addr section [in module %s]"), + objfile_name (objfile)); if (addr_base_or_zero + addr_index * addr_size >= per_objfile->per_bfd->addr.size) - error (_("DW_FORM_addr_index pointing outside of " - ".debug_addr section [in module %s]"), + error (_ ("DW_FORM_addr_index pointing outside of " + ".debug_addr section [in module %s]"), objfile_name (objfile)); info_ptr = (per_objfile->per_bfd->addr.buffer + addr_base_or_zero + addr_index * addr_size); @@ -19459,8 +19157,8 @@ read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index, static CORE_ADDR read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index) { - return read_addr_index_1 (cu->per_objfile, addr_index, - cu->addr_base, cu->header.addr_size); + return read_addr_index_1 (cu->per_objfile, addr_index, cu->addr_base, + cu->header.addr_size); } /* Given a pointer to an leb128 value, fetch the value from .debug_addr. */ @@ -19522,8 +19220,7 @@ dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu, DWO file. */ static const char * -read_str_index (struct dwarf2_cu *cu, - struct dwarf2_section_info *str_section, +read_str_index (struct dwarf2_cu *cu, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, ULONGEST str_offsets_base, ULONGEST str_index, unsigned offset_size) @@ -19539,25 +19236,24 @@ read_str_index (struct dwarf2_cu *cu, str_section->read (objfile); str_offsets_section->read (objfile); if (str_section->buffer == NULL) - error (_("%s used without %s section" - " in CU at offset %s [in module %s]"), + error (_ ("%s used without %s section" + " in CU at offset %s [in module %s]"), form_name, str_section->get_name (), sect_offset_str (cu->header.sect_off), objf_name); if (str_offsets_section->buffer == NULL) - error (_("%s used without %s section" - " in CU at offset %s [in module %s]"), + error (_ ("%s used without %s section" + " in CU at offset %s [in module %s]"), form_name, str_section->get_name (), sect_offset_str (cu->header.sect_off), objf_name); - info_ptr = (str_offsets_section->buffer - + str_offsets_base + info_ptr = (str_offsets_section->buffer + str_offsets_base + str_index * offset_size); if (offset_size == 4) str_offset = bfd_get_32 (abfd, info_ptr); else str_offset = bfd_get_64 (abfd, info_ptr); if (str_offset >= str_section->size) - error (_("Offset from %s pointing outside of" - " .debug_str.dwo section in CU at offset %s [in module %s]"), + error (_ ("Offset from %s pointing outside of" + " .debug_str.dwo section in CU at offset %s [in module %s]"), form_name, sect_offset_str (cu->header.sect_off), objf_name); return (const char *) (str_section->buffer + str_offset); } @@ -19595,9 +19291,9 @@ read_dwo_str_index (const struct die_reader_specs *reader, ULONGEST str_index) because we parse the header more than once (see FIXME above) we'd have many warnings, so use a complaint instead, which at least has a limit. */ - complaint (_("Section .debug_str_offsets in %s has unsupported" - " version %d, use empty string."), - reader->dwo_file->dwo_name, version); + complaint (_ ("Section .debug_str_offsets in %s has unsupported" + " version %d, use empty string."), + reader->dwo_file->dwo_name, version); return ""; } @@ -19615,10 +19311,9 @@ read_dwo_str_index (const struct die_reader_specs *reader, ULONGEST str_index) /* Determine offset_size based on the .debug_info header. */ offset_size = reader->cu->header.offset_size; - } + } - return read_str_index (reader->cu, - &reader->dwo_file->sections.str, + return read_str_index (reader->cu, &reader->dwo_file->sections.str, &reader->dwo_file->sections.str_offsets, str_offsets_base, str_index, offset_size); } @@ -19634,13 +19329,12 @@ read_stub_str_index (struct dwarf2_cu *cu, ULONGEST str_index) static const char str_offsets_attr_name[] = "DW_AT_str_offsets"; if (!cu->str_offsets_base.has_value ()) - error (_("%s used in Fission stub without %s" - " in CU at offset 0x%lx [in module %s]"), - form_name, str_offsets_attr_name, - (long) cu->header.offset_size, objf_name); + error (_ ("%s used in Fission stub without %s" + " in CU at offset 0x%lx [in module %s]"), + form_name, str_offsets_attr_name, (long) cu->header.offset_size, + objf_name); - return read_str_index (cu, - &cu->per_objfile->per_bfd->str, + return read_str_index (cu, &cu->per_objfile->per_bfd->str, &cu->per_objfile->per_bfd->str_offsets, *cu->str_offsets_base, str_index, cu->header.offset_size); @@ -19760,7 +19454,8 @@ dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu) is either not found or is of an incorrect type. */ static const char * -dwarf2_string_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu) +dwarf2_string_attr (struct die_info *die, unsigned int name, + struct dwarf2_cu *cu) { struct attribute *attr; const char *str = NULL; @@ -19771,8 +19466,8 @@ dwarf2_string_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *c { str = attr->as_string (); if (str == nullptr) - complaint (_("string type expected for attribute %s for " - "DIE at %s in module %s"), + complaint (_ ("string type expected for attribute %s for " + "DIE at %s in module %s"), dwarf_attr_name (name), sect_offset_str (die->sect_off), objfile_name (cu->per_objfile->objfile)); } @@ -19826,8 +19521,8 @@ die_is_declaration (struct die_info *die, struct dwarf2_cu *cu) static struct die_info * die_specification (struct die_info *die, struct dwarf2_cu **spec_cu) { - struct attribute *spec_attr = dwarf2_attr (die, DW_AT_specification, - *spec_cu); + struct attribute *spec_attr + = dwarf2_attr (die, DW_AT_specification, *spec_cu); if (spec_attr == NULL) spec_attr = dwarf2_attr (die, DW_AT_abstract_origin, *spec_cu); @@ -19884,15 +19579,14 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu, if (section->buffer == NULL) { if (cu->dwo_unit && cu->per_cu->is_debug_types) - complaint (_("missing .debug_line.dwo section")); + complaint (_ ("missing .debug_line.dwo section")); else - complaint (_("missing .debug_line section")); + complaint (_ ("missing .debug_line section")); return 0; } - return dwarf_decode_line_header (sect_off, cu->per_cu->is_dwz, - per_objfile, section, &cu->header, - comp_dir); + return dwarf_decode_line_header (sect_off, cu->per_cu->is_dwz, per_objfile, + section, &cu->header, comp_dir); } /* Subroutine of dwarf_decode_lines to simplify it. @@ -19969,6 +19663,7 @@ compute_include_file_name (const struct line_header *lh, const file_entry &fe, class lnp_state_machine { public: + /* Initialize a machine state for the start of a line number program. */ lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, line_header *lh); @@ -19986,8 +19681,7 @@ public: /* Check ADDRESS is -1, or zero and less than UNRELOCATED_LOWPC, and if true nop-out rest of the lines in this sequence. */ - void check_line_address (struct dwarf2_cu *cu, - const gdb_byte *line_ptr, + void check_line_address (struct dwarf2_cu *cu, const gdb_byte *line_ptr, CORE_ADDR unrelocated_lowpc, CORE_ADDR address); void handle_set_discriminator (unsigned int discriminator) @@ -20011,19 +19705,13 @@ public: void handle_special_opcode (unsigned char op_code); /* Handle DW_LNS_advance_line. */ - void handle_advance_line (int line_delta) - { - advance_line (line_delta); - } + void handle_advance_line (int line_delta) { advance_line (line_delta); } /* Handle DW_LNS_set_file. */ void handle_set_file (file_name_index file); /* Handle DW_LNS_negate_stmt. */ - void handle_negate_stmt () - { - m_flags ^= LEF_IS_STMT; - } + void handle_negate_stmt () { m_flags ^= LEF_IS_STMT; } /* Handle DW_LNS_const_add_pc. */ void handle_const_add_pc (); @@ -20044,18 +19732,13 @@ public: } /* Handle DW_LNE_end_sequence. */ - void handle_end_sequence () - { - m_currently_recording_lines = true; - } + void handle_end_sequence () { m_currently_recording_lines = true; } /* Handle DW_LNS_set_prologue_end. */ - void handle_set_prologue_end () - { - m_flags |= LEF_PROLOGUE_END; - } + void handle_set_prologue_end () { m_flags |= LEF_PROLOGUE_END; } private: + /* Advance the line by LINE_DELTA. */ void advance_line (int line_delta) { @@ -20116,12 +19799,12 @@ private: void lnp_state_machine::handle_advance_pc (CORE_ADDR adjust) { - CORE_ADDR addr_adj = (((m_op_index + adjust) - / m_line_header->maximum_ops_per_instruction) - * m_line_header->minimum_instruction_length); + CORE_ADDR addr_adj + = (((m_op_index + adjust) / m_line_header->maximum_ops_per_instruction) + * m_line_header->minimum_instruction_length); m_address += gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true); - m_op_index = ((m_op_index + adjust) - % m_line_header->maximum_ops_per_instruction); + m_op_index + = ((m_op_index + adjust) % m_line_header->maximum_ops_per_instruction); } void @@ -20167,13 +19850,12 @@ lnp_state_machine::handle_const_add_pc () = (255 - m_line_header->opcode_base) / m_line_header->line_range; CORE_ADDR addr_adj - = (((m_op_index + adjust) - / m_line_header->maximum_ops_per_instruction) + = (((m_op_index + adjust) / m_line_header->maximum_ops_per_instruction) * m_line_header->minimum_instruction_length); m_address += gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true); - m_op_index = ((m_op_index + adjust) - % m_line_header->maximum_ops_per_instruction); + m_op_index + = ((m_op_index + adjust) % m_line_header->maximum_ops_per_instruction); } /* Return non-zero if we should add LINE to the line number table. @@ -20207,8 +19889,8 @@ lnp_state_machine::handle_const_add_pc () within one sequence, thus this coalescing is ok. */ static int -dwarf_record_line_p (struct dwarf2_cu *cu, - unsigned int line, unsigned int last_line, +dwarf_record_line_p (struct dwarf2_cu *cu, unsigned int line, + unsigned int last_line, int line_has_non_zero_discriminator, struct subfile *last_subfile) { @@ -20230,16 +19912,14 @@ dwarf_record_line_p (struct dwarf2_cu *cu, static void dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile, unsigned int line, CORE_ADDR address, - linetable_entry_flags flags, - struct dwarf2_cu *cu) + linetable_entry_flags flags, struct dwarf2_cu *cu) { CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address); if (dwarf_line_debug) { - gdb_printf (gdb_stdlog, - "Recording line %u, file %s, address %s\n", - line, lbasename (subfile->name.c_str ()), + gdb_printf (gdb_stdlog, "Recording line %u, file %s, address %s\n", line, + lbasename (subfile->name.c_str ()), paddress (gdbarch, address)); } @@ -20261,8 +19941,7 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile, if (dwarf_line_debug) { - gdb_printf (gdb_stdlog, - "Finishing current line, file %s, address %s\n", + gdb_printf (gdb_stdlog, "Finishing current line, file %s, address %s\n", lbasename (subfile->name.c_str ()), paddress (gdbarch, address)); } @@ -20278,11 +19957,9 @@ lnp_state_machine::record_line (bool end_sequence) gdb_printf (gdb_stdlog, "Processing actual line %u: file %u," " address %s, is_stmt %u, prologue_end %u, discrim %u%s\n", - m_line, m_file, - paddress (m_gdbarch, m_address), + m_line, m_file, paddress (m_gdbarch, m_address), (m_flags & LEF_IS_STMT) != 0, - (m_flags & LEF_PROLOGUE_END) != 0, - m_discriminator, + (m_flags & LEF_PROLOGUE_END) != 0, m_discriminator, (end_sequence ? "\t(end sequence)" : "")); } @@ -20314,8 +19991,7 @@ lnp_state_machine::record_line (bool end_sequence) = m_last_subfile != m_cu->get_builder ()->get_current_subfile (); bool ignore_this_line = ((file_changed && !end_sequence && m_last_address == m_address - && ((m_flags & LEF_IS_STMT) == 0) - && m_stmt_at_address) + && ((m_flags & LEF_IS_STMT) == 0) && m_stmt_at_address) || (!end_sequence && m_line == 0)); if ((file_changed && !ignore_this_line) || end_sequence) @@ -20335,10 +20011,10 @@ lnp_state_machine::record_line (bool end_sequence) m_last_subfile)) { buildsym_compunit *builder = m_cu->get_builder (); - dwarf_record_line_1 (m_gdbarch, - builder->get_current_subfile (), + dwarf_record_line_1 (m_gdbarch, builder->get_current_subfile (), m_line, m_address, lte_flags, - m_currently_recording_lines ? m_cu : nullptr); + m_currently_recording_lines ? m_cu + : nullptr); } m_last_subfile = m_cu->get_builder ()->get_current_subfile (); m_last_line = m_line; @@ -20374,7 +20050,8 @@ lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, void lnp_state_machine::check_line_address (struct dwarf2_cu *cu, const gdb_byte *line_ptr, - CORE_ADDR unrelocated_lowpc, CORE_ADDR address) + CORE_ADDR unrelocated_lowpc, + CORE_ADDR address) { /* Linkers resolve a symbolic relocation referencing a GC'd function to 0 or -1. If ADDRESS is 0, ignoring the opcode will err if the text section is @@ -20390,7 +20067,7 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu, struct objfile *objfile = cu->per_objfile->objfile; long line_offset = line_ptr - get_debug_line_section (cu)->buffer; - complaint (_(".debug_line address at offset 0x%lx is 0 [in module %s]"), + complaint (_ (".debug_line address at offset 0x%lx is 0 [in module %s]"), line_offset, objfile_name (objfile)); m_currently_recording_lines = false; /* Note: m_currently_recording_lines is left as false until we see @@ -20445,159 +20122,164 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, /* Special opcode. */ state_machine.handle_special_opcode (op_code); } - else switch (op_code) - { - case DW_LNS_extended_op: - extended_len = read_unsigned_leb128 (abfd, line_ptr, - &bytes_read); - line_ptr += bytes_read; - extended_end = line_ptr + extended_len; - extended_op = read_1_byte (abfd, line_ptr); - line_ptr += 1; - if (DW_LNE_lo_user <= extended_op - && extended_op <= DW_LNE_hi_user) - { - /* Vendor extension, ignore. */ - line_ptr = extended_end; - break; - } - switch (extended_op) - { - case DW_LNE_end_sequence: - state_machine.handle_end_sequence (); - end_sequence = true; - break; - case DW_LNE_set_address: + else + switch (op_code) + { + case DW_LNS_extended_op: + extended_len + = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; + extended_end = line_ptr + extended_len; + extended_op = read_1_byte (abfd, line_ptr); + line_ptr += 1; + if (DW_LNE_lo_user <= extended_op + && extended_op <= DW_LNE_hi_user) { - CORE_ADDR address - = cu->header.read_address (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - - state_machine.check_line_address (cu, line_ptr, - lowpc - baseaddr, address); - state_machine.handle_set_address (baseaddr, address); + /* Vendor extension, ignore. */ + line_ptr = extended_end; + break; } - break; - case DW_LNE_define_file: + switch (extended_op) { - const char *cur_file; - unsigned int mod_time, length; - dir_index dindex; - - cur_file = read_direct_string (abfd, line_ptr, + case DW_LNE_end_sequence: + state_machine.handle_end_sequence (); + end_sequence = true; + break; + case DW_LNE_set_address: + { + CORE_ADDR address + = cu->header.read_address (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - dindex = (dir_index) - read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - mod_time = - read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - length = - read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - lh->add_file_name (cur_file, dindex, mod_time, length); - } - break; - case DW_LNE_set_discriminator: - { - /* The discriminator is not interesting to the + line_ptr += bytes_read; + + state_machine.check_line_address (cu, line_ptr, + lowpc - baseaddr, + address); + state_machine.handle_set_address (baseaddr, address); + } + break; + case DW_LNE_define_file: + { + const char *cur_file; + unsigned int mod_time, length; + dir_index dindex; + + cur_file + = read_direct_string (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; + dindex + = (dir_index) read_unsigned_leb128 (abfd, line_ptr, + &bytes_read); + line_ptr += bytes_read; + mod_time + = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; + length + = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; + lh->add_file_name (cur_file, dindex, mod_time, length); + } + break; + case DW_LNE_set_discriminator: + { + /* The discriminator is not interesting to the debugger; just ignore it. We still need to check its value though: if there are consecutive entries for the same (non-prologue) line we want to coalesce them. PR 17276. */ - unsigned int discr - = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; + unsigned int discr + = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; - state_machine.handle_set_discriminator (discr); + state_machine.handle_set_discriminator (discr); + } + break; + default: + complaint (_ ("mangled .debug_line section")); + return; } - break; - default: - complaint (_("mangled .debug_line section")); - return; - } - /* Make sure that we parsed the extended op correctly. If e.g. + /* Make sure that we parsed the extended op correctly. If e.g. we expected a different address size than the producer used, we may have read the wrong number of bytes. */ - if (line_ptr != extended_end) + if (line_ptr != extended_end) + { + complaint (_ ("mangled .debug_line section")); + return; + } + break; + case DW_LNS_copy: + state_machine.handle_copy (); + break; + case DW_LNS_advance_pc: { - complaint (_("mangled .debug_line section")); - return; + CORE_ADDR adjust + = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; + + state_machine.handle_advance_pc (adjust); } - break; - case DW_LNS_copy: - state_machine.handle_copy (); - break; - case DW_LNS_advance_pc: - { - CORE_ADDR adjust - = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; + break; + case DW_LNS_advance_line: + { + int line_delta + = read_signed_leb128 (abfd, line_ptr, &bytes_read); + line_ptr += bytes_read; - state_machine.handle_advance_pc (adjust); - } - break; - case DW_LNS_advance_line: - { - int line_delta - = read_signed_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; + state_machine.handle_advance_line (line_delta); + } + break; + case DW_LNS_set_file: + { + file_name_index file + = (file_name_index) read_unsigned_leb128 (abfd, line_ptr, + &bytes_read); + line_ptr += bytes_read; - state_machine.handle_advance_line (line_delta); - } - break; - case DW_LNS_set_file: - { - file_name_index file - = (file_name_index) read_unsigned_leb128 (abfd, line_ptr, - &bytes_read); + state_machine.handle_set_file (file); + } + break; + case DW_LNS_set_column: + (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); line_ptr += bytes_read; - - state_machine.handle_set_file (file); - } - break; - case DW_LNS_set_column: - (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - break; - case DW_LNS_negate_stmt: - state_machine.handle_negate_stmt (); - break; - case DW_LNS_set_basic_block: - break; - /* Add to the address register of the state machine the + break; + case DW_LNS_negate_stmt: + state_machine.handle_negate_stmt (); + break; + case DW_LNS_set_basic_block: + break; + /* Add to the address register of the state machine the address increment value corresponding to special opcode 255. I.e., this value is scaled by the minimum instruction length since special opcode 255 would have scaled the increment. */ - case DW_LNS_const_add_pc: - state_machine.handle_const_add_pc (); - break; - case DW_LNS_fixed_advance_pc: - { - CORE_ADDR addr_adj = read_2_bytes (abfd, line_ptr); - line_ptr += 2; + case DW_LNS_const_add_pc: + state_machine.handle_const_add_pc (); + break; + case DW_LNS_fixed_advance_pc: + { + CORE_ADDR addr_adj = read_2_bytes (abfd, line_ptr); + line_ptr += 2; - state_machine.handle_fixed_advance_pc (addr_adj); - } - break; - case DW_LNS_set_prologue_end: - state_machine.handle_set_prologue_end (); - break; - default: - { - /* Unknown standard opcode, ignore it. */ - int i; + state_machine.handle_fixed_advance_pc (addr_adj); + } + break; + case DW_LNS_set_prologue_end: + state_machine.handle_set_prologue_end (); + break; + default: + { + /* Unknown standard opcode, ignore it. */ + int i; - for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++) - { - (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); - line_ptr += bytes_read; - } + for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++) + { + (void) read_unsigned_leb128 (abfd, line_ptr, + &bytes_read); + line_ptr += bytes_read; + } + } } - } } if (!end_sequence) @@ -20741,23 +20423,21 @@ var_decode_location (struct attribute *attr, struct symbol *sym, && block->size == 1 + cu_header->addr_size) || ((block->data[0] == DW_OP_GNU_addr_index || block->data[0] == DW_OP_addrx) - && (block->size - == 1 + leb128_size (&block->data[1])))) + && (block->size == 1 + leb128_size (&block->data[1])))) { unsigned int dummy; if (block->data[0] == DW_OP_addr) - sym->set_value_address - (cu->header.read_address (objfile->obfd.get (), block->data + 1, - &dummy)); + sym->set_value_address (cu->header.read_address ( + objfile->obfd.get (), block->data + 1, &dummy)); else - sym->set_value_address - (read_addr_index_from_leb128 (cu, block->data + 1, &dummy)); + sym->set_value_address ( + read_addr_index_from_leb128 (cu, block->data + 1, &dummy)); sym->set_aclass_index (LOC_STATIC); fixup_symbol_section (sym, objfile); - sym->set_value_address - (sym->value_address () - + objfile->section_offsets[sym->section_index ()]); + sym->set_value_address ( + sym->value_address () + + objfile->section_offsets[sym->section_index ()]); return; } } @@ -20802,9 +20482,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, baseaddr = objfile->text_section_offset (); name = dwarf2_name (die, cu); - if (name == nullptr && (die->tag == DW_TAG_subprogram - || die->tag == DW_TAG_inlined_subroutine - || die->tag == DW_TAG_entry_point)) + if (name == nullptr + && (die->tag == DW_TAG_subprogram + || die->tag == DW_TAG_inlined_subroutine + || die->tag == DW_TAG_entry_point)) name = dw2_linkage_name (die, cu); if (name) @@ -20822,9 +20503,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* Fortran does not have mangling standard and the mangling does differ between gfortran, iFort etc. */ const char *physname - = (cu->lang () == language_fortran - ? dwarf2_full_name (name, die, cu) - : dwarf2_physname (name, die, cu)); + = (cu->lang () == language_fortran ? dwarf2_full_name (name, die, cu) + : dwarf2_physname (name, die, cu)); const char *linkagename = dw2_linkage_name (die, cu); if (linkagename == nullptr || cu->lang () == language_ada) @@ -20848,15 +20528,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_type (type); else sym->set_type (die_type (die, cu)); - attr = dwarf2_attr (die, - inlined_func ? DW_AT_call_line : DW_AT_decl_line, - cu); + attr + = dwarf2_attr (die, inlined_func ? DW_AT_call_line : DW_AT_decl_line, + cu); if (attr != nullptr) sym->set_line (attr->constant_value (0)); - attr = dwarf2_attr (die, - inlined_func ? DW_AT_call_file : DW_AT_decl_file, - cu); + attr + = dwarf2_attr (die, inlined_func ? DW_AT_call_file : DW_AT_decl_file, + cu); if (attr != nullptr && attr->is_nonnegative ()) { file_name_index file_index @@ -20869,7 +20549,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, fe = NULL; if (fe == NULL) - complaint (_("file index out of range")); + complaint (_ ("file index out of range")); else sym->set_symtab (fe->symtab); } @@ -20970,8 +20650,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, && die->parent->tag == DW_TAG_common_block) attr2 = NULL; - if (sym->aclass () == LOC_STATIC - && sym->value_address () == 0 + if (sym->aclass () == LOC_STATIC && sym->value_address () == 0 && !per_objfile->per_bfd->has_section_at_zero) { /* When a static variable is eliminated by the linker, @@ -20991,19 +20670,18 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, marked hidden, in which case this would not apply. */ bound_minimal_symbol found - = (lookup_minimal_symbol_linkage - (sym->linkage_name (), objfile)); + = (lookup_minimal_symbol_linkage (sym->linkage_name (), + objfile)); if (found.minsym != nullptr) sym->maybe_copied = 1; } /* A variable with DW_AT_external is never static, but it may be block-scoped. */ - list_to_add - = ((cu->list_in_scope - == cu->get_builder ()->get_file_symbols ()) - ? cu->get_builder ()->get_global_symbols () - : cu->list_in_scope); + list_to_add = ((cu->list_in_scope + == cu->get_builder ()->get_file_symbols ()) + ? cu->get_builder ()->get_global_symbols () + : cu->list_in_scope); } else list_to_add = cu->list_in_scope; @@ -21033,11 +20711,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, { /* A variable with DW_AT_external is never static, but it may be block-scoped. */ - list_to_add - = ((cu->list_in_scope - == cu->get_builder ()->get_file_symbols ()) - ? cu->get_builder ()->get_global_symbols () - : cu->list_in_scope); + list_to_add = ((cu->list_in_scope + == cu->get_builder ()->get_file_symbols ()) + ? cu->get_builder ()->get_global_symbols () + : cu->list_in_scope); sym->set_aclass_index (LOC_UNRESOLVED); } @@ -21114,15 +20791,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, buildsym_compunit *builder = cu->get_builder (); list_to_add = (cu->list_in_scope == builder->get_file_symbols () - && cu->lang () == language_cplus - ? builder->get_global_symbols () - : cu->list_in_scope); + && cu->lang () == language_cplus + ? builder->get_global_symbols () + : cu->list_in_scope); /* The semantics of C++ state that "struct foo { ... }" also defines a typedef for "foo". */ if (cu->lang () == language_cplus - || cu->lang () == language_ada - || cu->lang () == language_d + || cu->lang () == language_ada || cu->lang () == language_d || cu->lang () == language_rust) { /* The symbol's name is already allocated along @@ -21160,9 +20836,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, list_to_add = (cu->list_in_scope == cu->get_builder ()->get_file_symbols () - && cu->lang () == language_cplus - ? cu->get_builder ()->get_global_symbols () - : cu->list_in_scope); + && cu->lang () == language_cplus + ? cu->get_builder ()->get_global_symbols () + : cu->list_in_scope); } break; case DW_TAG_imported_declaration: @@ -21185,8 +20861,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, trash data, but since we must specifically ignore things we don't recognize, there is nothing else we should do at this point. */ - complaint (_("unsupported tag: '%s'"), - dwarf_tag_name (die->tag)); + complaint (_ ("unsupported tag: '%s'"), dwarf_tag_name (die->tag)); break; } @@ -21202,8 +20877,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* For the benefit of old versions of GCC, check for anonymous namespaces based on the demangled name. */ - if (!cu->processing_has_namespace_info - && cu->lang () == language_cplus) + if (!cu->processing_has_namespace_info && cu->lang () == language_cplus) cp_scan_for_anonymous_namespaces (cu->get_builder (), sym, objfile); } return (sym); @@ -21222,8 +20896,9 @@ dwarf2_const_value_data (const struct attribute *attr, struct obstack *obstack, struct dwarf2_cu *cu, LONGEST *value, int bits) { struct objfile *objfile = cu->per_objfile->objfile; - enum bfd_endian byte_order = bfd_big_endian (objfile->obfd.get ()) ? - BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; + enum bfd_endian byte_order = bfd_big_endian (objfile->obfd.get ()) + ? BFD_ENDIAN_BIG + : BFD_ENDIAN_LITTLE; LONGEST l = attr->constant_value (0); if (bits < sizeof (*value) * 8) @@ -21252,16 +20927,17 @@ dwarf2_const_value_data (const struct attribute *attr, struct obstack *obstack, static void dwarf2_const_value_attr (const struct attribute *attr, struct type *type, const char *name, struct obstack *obstack, - struct dwarf2_cu *cu, - LONGEST *value, const gdb_byte **bytes, + struct dwarf2_cu *cu, LONGEST *value, + const gdb_byte **bytes, struct dwarf2_locexpr_baton **baton) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct objfile *objfile = per_objfile->objfile; struct comp_unit_head *cu_header = &cu->header; struct dwarf_block *blk; - enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd.get ()) ? - BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE); + enum bfd_endian byte_order + = (bfd_big_endian (objfile->obfd.get ()) ? BFD_ENDIAN_BIG + : BFD_ENDIAN_LITTLE); *value = 0; *bytes = NULL; @@ -21292,8 +20968,8 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, (*baton)->data = data; data[0] = DW_OP_addr; - store_unsigned_integer (&data[1], cu_header->addr_size, - byte_order, attr->as_address ()); + store_unsigned_integer (&data[1], cu_header->addr_size, byte_order, + attr->as_address ()); data[cu_header->addr_size + 1] = DW_OP_stack_value; } break; @@ -21347,14 +21023,13 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, break; default: - complaint (_("unsupported const value attribute form: '%s'"), + complaint (_ ("unsupported const value attribute form: '%s'"), dwarf_form_name (attr->form)); *value = 0; break; } } - /* Copy constant value from an attribute to a symbol. */ static void @@ -21366,10 +21041,9 @@ dwarf2_const_value (const struct attribute *attr, struct symbol *sym, const gdb_byte *bytes; struct dwarf2_locexpr_baton *baton; - dwarf2_const_value_attr (attr, sym->type (), - sym->print_name (), - &objfile->objfile_obstack, cu, - &value, &bytes, &baton); + dwarf2_const_value_attr (attr, sym->type (), sym->print_name (), + &objfile->objfile_obstack, cu, &value, &bytes, + &baton); if (baton != NULL) { @@ -21461,8 +21135,9 @@ die_containing_type (struct die_info *die, struct dwarf2_cu *cu) type_attr = dwarf2_attr (die, DW_AT_containing_type, cu); if (!type_attr) - error (_("Dwarf Error: Problem turning containing type into gdb type " - "[in module %s]"), objfile_name (objfile)); + error (_ ("Dwarf Error: Problem turning containing type into gdb type " + "[in module %s]"), + objfile_name (objfile)); return lookup_die_type (die, type_attr, cu); } @@ -21477,7 +21152,7 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die) char *saved; std::string message - = string_printf (_("<unknown type in %s, CU %s, DIE %s>"), + = string_printf (_ ("<unknown type in %s, CU %s, DIE %s>"), objfile_name (objfile), sect_offset_str (cu->header.sect_off), sect_offset_str (die->sect_off)); @@ -21510,8 +21185,8 @@ lookup_die_type (struct die_info *die, const struct attribute *attr, struct dwarf2_per_cu_data *per_cu; sect_offset sect_off = attr->get_ref_die_offset (); - per_cu = dwarf2_find_containing_comp_unit (sect_off, 1, - per_objfile->per_bfd); + per_cu + = dwarf2_find_containing_comp_unit (sect_off, 1, per_objfile->per_bfd); this_type = get_die_type_at_offset (sect_off, per_cu, per_objfile); } else if (attr->form_is_ref ()) @@ -21528,8 +21203,8 @@ lookup_die_type (struct die_info *die, const struct attribute *attr, } else { - complaint (_("Dwarf Error: Bad type attribute %s in DIE" - " at %s [in module %s]"), + complaint (_ ("Dwarf Error: Bad type attribute %s in DIE" + " at %s [in module %s]"), dwarf_attr_name (attr->name), sect_offset_str (die->sect_off), objfile_name (objfile)); return build_error_marker_type (cu, die); @@ -21657,7 +21332,7 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) this_type = read_tag_atomic_type (die, cu); break; default: - complaint (_("unexpected tag in read_type_die: '%s'"), + complaint (_ ("unexpected tag in read_type_die: '%s'"), dwarf_tag_name (die->tag)); break; } @@ -21689,9 +21364,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) cu = spec_cu; } - for (child = die->child; - child != NULL; - child = child->sibling) + for (child = die->child; child != NULL; child = child->sibling) { if (child->tag == DW_TAG_subprogram) { @@ -21699,8 +21372,8 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) if (linkage_name != NULL) { - gdb::unique_xmalloc_ptr<char> actual_name - (cu->language_defn->class_name_from_physname (linkage_name)); + gdb::unique_xmalloc_ptr<char> actual_name ( + cu->language_defn->class_name_from_physname (linkage_name)); const char *name = NULL; if (actual_name != NULL) @@ -21720,8 +21393,8 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) if (actual_name_len > die_name_len + 2 && ptr[actual_name_len - die_name_len - 1] == ':') name = obstack_strndup ( - &objfile->per_bfd->storage_obstack, - ptr, actual_name_len - die_name_len - 2); + &objfile->per_bfd->storage_obstack, ptr, + actual_name_len - die_name_len - 2); } } return name; @@ -21763,8 +21436,7 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu) return ""; struct objfile *objfile = cu->per_objfile->objfile; - return obstack_strndup (&objfile->per_bfd->storage_obstack, - attr_name, + return obstack_strndup (&objfile->per_bfd->storage_obstack, attr_name, &base[-1] - attr_name); } @@ -21792,10 +21464,8 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) struct type *parent_type; const char *retval; - if (cu->lang () != language_cplus - && cu->lang () != language_fortran - && cu->lang () != language_d - && cu->lang () != language_rust) + if (cu->lang () != language_cplus && cu->lang () != language_fortran + && cu->lang () != language_d && cu->lang () != language_rust) return ""; retval = anonymous_struct_prefix (die, cu); @@ -21870,7 +21540,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) doesn't allow it), and break the loop here. */ name = dwarf2_name (die, cu); parent_name = dwarf2_name (parent, cu); - complaint (_("template param type '%s' defined within parent '%s'"), + complaint (_ ("template param type '%s' defined within parent '%s'"), name ? name : "<unknown>", parent_name ? parent_name : "<unknown>"); return ""; @@ -21905,8 +21575,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_partial_unit: /* gcc-4.5 -gdwarf-4 can drop the enclosing namespace. Cope. */ if (cu->lang () == language_cplus - && !per_objfile->per_bfd->types.empty () - && die->child != NULL + && !per_objfile->per_bfd->types.empty () && die->child != NULL && (die->tag == DW_TAG_class_type || die->tag == DW_TAG_structure_type || die->tag == DW_TAG_union_type)) @@ -21921,7 +21590,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) of the parent's subroutine. */ if (cu->lang () == language_fortran) { - if ((die->tag == DW_TAG_subprogram) + if ((die->tag == DW_TAG_subprogram) && (dwarf2_name (parent, cu) != NULL)) return dwarf2_name (parent, cu); } @@ -21946,7 +21615,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) an obconcat, otherwise allocate storage for the result. The CU argument is used to determine the language and hence, the appropriate separator. */ -#define MAX_SEP_LEN 7 /* strlen ("__") + strlen ("_MOD_") */ +#define MAX_SEP_LEN 7 /* strlen ("__") + strlen ("_MOD_") */ static char * typename_concat (struct obstack *obs, const char *prefix, const char *suffix, @@ -21955,8 +21624,8 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix, const char *lead = ""; const char *sep; - if (suffix == NULL || suffix[0] == '\0' - || prefix == NULL || prefix[0] == '\0') + if (suffix == NULL || suffix[0] == '\0' || prefix == NULL + || prefix[0] == '\0') sep = ""; else if (cu->lang () == language_d) { @@ -21988,9 +21657,8 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix, if (obs == NULL) { - char *retval - = ((char *) - xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1)); + char *retval = ((char *) xmalloc (strlen (prefix) + MAX_SEP_LEN + + strlen (suffix) + 1)); strcpy (retval, lead); strcat (retval, prefix); @@ -22025,16 +21693,16 @@ unnamed_template_tag_name (die_info *die, dwarf2_cu *cu) die_info *child = die->parent->child; while (child != die) - { - gdb_assert (child != nullptr); - if (child->tag == DW_TAG_template_type_param - || child->tag == DW_TAG_template_value_param) - { - if (dwarf2_attr (child, DW_AT_name, cu) == nullptr) - ++nth_unnamed; - } - child = child->sibling; - } + { + gdb_assert (child != nullptr); + if (child->tag == DW_TAG_template_type_param + || child->tag == DW_TAG_template_value_param) + { + if (dwarf2_attr (child, DW_AT_name, cu) == nullptr) + ++nth_unnamed; + } + child = child->sibling; + } const std::string name_str = "<unnamed" + std::to_string (nth_unnamed) + ">"; return cu->per_objfile->objfile->intern (name_str.c_str ()); @@ -22051,16 +21719,14 @@ dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu, if (cu->lang () == language_cplus) { - gdb::unique_xmalloc_ptr<char> canon_name - = cp_canonicalize_string (name); + gdb::unique_xmalloc_ptr<char> canon_name = cp_canonicalize_string (name); if (canon_name != nullptr) name = objfile->intern (canon_name.get ()); } else if (cu->lang () == language_c) { - gdb::unique_xmalloc_ptr<char> canon_name - = c_canonicalize_name (name); + gdb::unique_xmalloc_ptr<char> canon_name = c_canonicalize_name (name); if (canon_name != nullptr) name = objfile->intern (canon_name.get ()); @@ -22080,12 +21746,9 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_name, cu); const char *attr_name = attr == nullptr ? nullptr : attr->as_string (); - if (attr_name == nullptr - && die->tag != DW_TAG_namespace - && die->tag != DW_TAG_class_type - && die->tag != DW_TAG_interface_type - && die->tag != DW_TAG_structure_type - && die->tag != DW_TAG_namelist + if (attr_name == nullptr && die->tag != DW_TAG_namespace + && die->tag != DW_TAG_class_type && die->tag != DW_TAG_interface_type + && die->tag != DW_TAG_structure_type && die->tag != DW_TAG_namelist && die->tag != DW_TAG_union_type && die->tag != DW_TAG_template_type_param && die->tag != DW_TAG_template_value_param) @@ -22146,8 +21809,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) call for the same DIE. */ if (!attr->canonical_string_p ()) { - gdb::unique_xmalloc_ptr<char> demangled - (gdb_demangle (attr_name, DMGL_TYPES)); + gdb::unique_xmalloc_ptr<char> demangled ( + gdb_demangle (attr_name, DMGL_TYPES)); if (demangled == nullptr) return nullptr; @@ -22197,26 +21860,22 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) { unsigned int i; - gdb_printf (f, "%*sDie: %s (abbrev %d, offset %s)\n", - indent, "", + gdb_printf (f, "%*sDie: %s (abbrev %d, offset %s)\n", indent, "", dwarf_tag_name (die->tag), die->abbrev, sect_offset_str (die->sect_off)); if (die->parent != NULL) - gdb_printf (f, "%*s parent at offset: %s\n", - indent, "", + gdb_printf (f, "%*s parent at offset: %s\n", indent, "", sect_offset_str (die->parent->sect_off)); - gdb_printf (f, "%*s has children: %s\n", - indent, "", + gdb_printf (f, "%*s has children: %s\n", indent, "", dwarf_bool_name (die->child != NULL)); gdb_printf (f, "%*s attributes:\n", indent, ""); for (i = 0; i < die->num_attrs; ++i) { - gdb_printf (f, "%*s %s (%s) ", - indent, "", + gdb_printf (f, "%*s %s (%s) ", indent, "", dwarf_attr_name (die->attrs[i].name), dwarf_form_name (die->attrs[i].form)); @@ -22281,8 +21940,8 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) case DW_FORM_GNU_str_index: case DW_FORM_GNU_strp_alt: gdb_printf (f, "string: \"%s\" (%s canonicalized)", - die->attrs[i].as_string () - ? die->attrs[i].as_string () : "", + die->attrs[i].as_string () ? die->attrs[i].as_string () + : "", die->attrs[i].canonical_string_p () ? "is" : "not"); break; case DW_FORM_flag: @@ -22297,8 +21956,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) case DW_FORM_indirect: /* The reader will have reduced the indirect form to the "base form" so this form should not occur. */ - gdb_printf (f, - "unexpected attribute form: DW_FORM_indirect"); + gdb_printf (f, "unexpected attribute form: DW_FORM_indirect"); break; case DW_FORM_sdata: case DW_FORM_implicit_const: @@ -22342,8 +22000,7 @@ dump_die_1 (struct ui_file *f, int level, int max_level, struct die_info *die) } else { - gdb_printf (f, - " [not printed, max nesting level reached]\n"); + gdb_printf (f, " [not printed, max nesting level reached]\n"); } } @@ -22368,8 +22025,7 @@ store_in_ref_table (struct die_info *die, struct dwarf2_cu *cu) void **slot; slot = htab_find_slot_with_hash (cu->die_hash, die, - to_underlying (die->sect_off), - INSERT); + to_underlying (die->sect_off), INSERT); *slot = die; } @@ -22391,7 +22047,7 @@ follow_die_ref_or_sig (struct die_info *src_die, const struct attribute *attr, else { dump_die_for_error (src_die); - error (_("Dwarf Error: Expected reference attribute [in module %s]"), + error (_ ("Dwarf Error: Expected reference attribute [in module %s]"), objfile_name ((*ref_cu)->per_objfile->objfile)); } @@ -22487,8 +22143,8 @@ follow_die_ref (struct die_info *src_die, const struct attribute *attr, || cu->per_cu->is_dwz), ref_cu); if (!die) - error (_("Dwarf Error: Cannot find DIE at %s referenced from DIE " - "at %s [in module %s]"), + error (_ ("Dwarf Error: Cannot find DIE at %s referenced from DIE " + "at %s [in module %s]"), sect_offset_str (sect_off), sect_offset_str (src_die->sect_off), objfile_name (cu->per_objfile->objfile)); @@ -22517,13 +22173,13 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, { /* We shouldn't get here for a dummy CU, but don't crash on the user. Instead just throw an error, not much else we can do. */ - error (_("Dwarf Error: Dummy CU at %s referenced in module %s"), + error (_ ("Dwarf Error: Dummy CU at %s referenced in module %s"), sect_offset_str (sect_off), objfile_name (objfile)); } die = follow_die_offset (sect_off, per_cu->is_dwz, &cu); if (!die) - error (_("Dwarf Error: Cannot find DIE at %s referenced in module %s"), + error (_ ("Dwarf Error: Cannot find DIE at %s referenced in module %s"), sect_offset_str (sect_off), objfile_name (objfile)); attr = dwarf2_attr (die, DW_AT_location, cu); @@ -22535,15 +22191,13 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, CORE_ADDR baseaddr = objfile->text_section_offset (); struct gdbarch *gdbarch = objfile->arch (); - for (const auto &cand_off - : per_objfile->per_bfd->abstract_to_concrete[die->sect_off]) + for (const auto &cand_off : + per_objfile->per_bfd->abstract_to_concrete[die->sect_off]) { struct dwarf2_cu *cand_cu = cu; struct die_info *cand = follow_die_offset (cand_off, per_cu->is_dwz, &cand_cu); - if (!cand - || !cand->parent - || cand->parent->tag != DW_TAG_subprogram) + if (!cand || !cand->parent || cand->parent->tag != DW_TAG_subprogram) continue; CORE_ADDR pc_low, pc_high; @@ -22577,15 +22231,15 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, fill_in_loclist_baton (cu, &loclist_baton, attr); - retval.data = dwarf2_find_location_expression (&loclist_baton, - &size, pc); + retval.data + = dwarf2_find_location_expression (&loclist_baton, &size, pc); retval.size = size; } else { if (!attr->form_is_block ()) - error (_("Dwarf Error: DIE at %s referenced in module %s " - "is neither DW_FORM_block* nor DW_FORM_exprloc"), + error (_ ("Dwarf Error: DIE at %s referenced in module %s " + "is neither DW_FORM_block* nor DW_FORM_exprloc"), sect_offset_str (sect_off), objfile_name (objfile)); struct dwarf_block *block = attr->as_block (); @@ -22618,11 +22272,8 @@ dwarf2_fetch_die_loc_cu_off (cu_offset offset_in_cu, OBSTACK. */ static const gdb_byte * -write_constant_as_bytes (struct obstack *obstack, - enum bfd_endian byte_order, - struct type *type, - ULONGEST value, - LONGEST *len) +write_constant_as_bytes (struct obstack *obstack, enum bfd_endian byte_order, + struct type *type, ULONGEST value, LONGEST *len) { gdb_byte *result; @@ -22636,10 +22287,8 @@ write_constant_as_bytes (struct obstack *obstack, /* See read.h. */ const gdb_byte * -dwarf2_fetch_constant_bytes (sect_offset sect_off, - dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - obstack *obstack, +dwarf2_fetch_constant_bytes (sect_offset sect_off, dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, obstack *obstack, LONGEST *len) { struct die_info *die; @@ -22658,21 +22307,21 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, { /* We shouldn't get here for a dummy CU, but don't crash on the user. Instead just throw an error, not much else we can do. */ - error (_("Dwarf Error: Dummy CU at %s referenced in module %s"), + error (_ ("Dwarf Error: Dummy CU at %s referenced in module %s"), sect_offset_str (sect_off), objfile_name (objfile)); } die = follow_die_offset (sect_off, per_cu->is_dwz, &cu); if (!die) - error (_("Dwarf Error: Cannot find DIE at %s referenced in module %s"), + error (_ ("Dwarf Error: Cannot find DIE at %s referenced in module %s"), sect_offset_str (sect_off), objfile_name (objfile)); attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr == NULL) return NULL; - byte_order = (bfd_big_endian (objfile->obfd.get ()) - ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE); + byte_order = (bfd_big_endian (objfile->obfd.get ()) ? BFD_ENDIAN_BIG + : BFD_ENDIAN_LITTLE); switch (attr->form) { @@ -22723,46 +22372,46 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, type = die_type (die, cu); result = dwarf2_const_value_data (attr, obstack, cu, &value, 8); if (result == NULL) - result = write_constant_as_bytes (obstack, byte_order, - type, value, len); + result + = write_constant_as_bytes (obstack, byte_order, type, value, len); break; case DW_FORM_data2: type = die_type (die, cu); result = dwarf2_const_value_data (attr, obstack, cu, &value, 16); if (result == NULL) - result = write_constant_as_bytes (obstack, byte_order, - type, value, len); + result + = write_constant_as_bytes (obstack, byte_order, type, value, len); break; case DW_FORM_data4: type = die_type (die, cu); result = dwarf2_const_value_data (attr, obstack, cu, &value, 32); if (result == NULL) - result = write_constant_as_bytes (obstack, byte_order, - type, value, len); + result + = write_constant_as_bytes (obstack, byte_order, type, value, len); break; case DW_FORM_data8: type = die_type (die, cu); result = dwarf2_const_value_data (attr, obstack, cu, &value, 64); if (result == NULL) - result = write_constant_as_bytes (obstack, byte_order, - type, value, len); + result + = write_constant_as_bytes (obstack, byte_order, type, value, len); break; case DW_FORM_sdata: case DW_FORM_implicit_const: type = die_type (die, cu); - result = write_constant_as_bytes (obstack, byte_order, - type, attr->as_signed (), len); + result = write_constant_as_bytes (obstack, byte_order, type, + attr->as_signed (), len); break; case DW_FORM_udata: type = die_type (die, cu); - result = write_constant_as_bytes (obstack, byte_order, - type, attr->as_unsigned (), len); + result = write_constant_as_bytes (obstack, byte_order, type, + attr->as_unsigned (), len); break; default: - complaint (_("unsupported const value attribute form: '%s'"), + complaint (_ ("unsupported const value attribute form: '%s'"), dwarf_form_name (attr->form)); break; } @@ -22799,8 +22448,7 @@ dwarf2_fetch_die_type_sect_off (sect_offset sect_off, /* See read.h. */ struct type * -dwarf2_get_die_type (cu_offset die_offset, - dwarf2_per_cu_data *per_cu, +dwarf2_get_die_type (cu_offset die_offset, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { sect_offset die_offset_sect = per_cu->sect_off + to_underlying (die_offset); @@ -22821,7 +22469,6 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type, struct die_info *die; dwarf2_per_objfile *per_objfile = (*ref_cu)->per_objfile; - /* While it might be nice to assert sig_type->type == NULL here, we can get here for DW_AT_imported_declaration where we need the DIE not the type. */ @@ -22831,8 +22478,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type, Even if maybe_queue_comp_unit doesn't require us to load the CU's DIEs, it doesn't mean they are currently loaded. Since we require them to be loaded, we must check for ourselves. */ - if (maybe_queue_comp_unit (*ref_cu, sig_type, per_objfile, - language_minimal) + if (maybe_queue_comp_unit (*ref_cu, sig_type, per_objfile, language_minimal) || per_objfile->get_cu (sig_type) == nullptr) read_signatured_type (sig_type, per_objfile); @@ -22840,8 +22486,8 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type, gdb_assert (sig_cu != NULL); gdb_assert (to_underlying (sig_type->type_offset_in_section) != 0); temp_die.sect_off = sig_type->type_offset_in_section; - die = (struct die_info *) htab_find_with_hash (sig_cu->die_hash, &temp_die, - to_underlying (temp_die.sect_off)); + die = (struct die_info *) htab_find_with_hash ( + sig_cu->die_hash, &temp_die, to_underlying (temp_die.sect_off)); if (die) { /* For .gdb_index version 7 keep track of included TUs. @@ -22880,8 +22526,8 @@ follow_die_sig (struct die_info *src_die, const struct attribute *attr, the debug info. */ if (sig_type == NULL) { - error (_("Dwarf Error: Cannot find signatured DIE %s referenced" - " from DIE at %s [in module %s]"), + error (_ ("Dwarf Error: Cannot find signatured DIE %s referenced" + " from DIE at %s [in module %s]"), hex_string (signature), sect_offset_str (src_die->sect_off), objfile_name ((*ref_cu)->per_objfile->objfile)); } @@ -22890,8 +22536,8 @@ follow_die_sig (struct die_info *src_die, const struct attribute *attr, if (die == NULL) { dump_die_for_error (src_die); - error (_("Dwarf Error: Problem reading signatured DIE %s referenced" - " from DIE at %s [in module %s]"), + error (_ ("Dwarf Error: Problem reading signatured DIE %s referenced" + " from DIE at %s [in module %s]"), hex_string (signature), sect_offset_str (src_die->sect_off), objfile_name ((*ref_cu)->per_objfile->objfile)); } @@ -22917,8 +22563,8 @@ get_signatured_type (struct die_info *die, ULONGEST signature, the debug info. */ if (sig_type == NULL) { - complaint (_("Dwarf Error: Cannot find signatured DIE %s referenced" - " from DIE at %s [in module %s]"), + complaint (_ ("Dwarf Error: Cannot find signatured DIE %s referenced" + " from DIE at %s [in module %s]"), hex_string (signature), sect_offset_str (die->sect_off), objfile_name (per_objfile->objfile)); return build_error_marker_type (cu, die); @@ -22939,8 +22585,8 @@ get_signatured_type (struct die_info *die, ULONGEST signature, type = read_type_die (type_die, type_cu); if (type == NULL) { - complaint (_("Dwarf Error: Cannot build signatured type %s" - " referenced from DIE at %s [in module %s]"), + complaint (_ ("Dwarf Error: Cannot build signatured type %s" + " referenced from DIE at %s [in module %s]"), hex_string (signature), sect_offset_str (die->sect_off), objfile_name (per_objfile->objfile)); type = build_error_marker_type (cu, die); @@ -22948,8 +22594,8 @@ get_signatured_type (struct die_info *die, ULONGEST signature, } else { - complaint (_("Dwarf Error: Problem reading signatured DIE %s referenced" - " from DIE at %s [in module %s]"), + complaint (_ ("Dwarf Error: Problem reading signatured DIE %s referenced" + " from DIE at %s [in module %s]"), hex_string (signature), sect_offset_str (die->sect_off), objfile_name (per_objfile->objfile)); type = build_error_marker_type (cu, die); @@ -22983,8 +22629,8 @@ get_DW_AT_signature_type (struct die_info *die, const struct attribute *attr, { dwarf2_per_objfile *per_objfile = cu->per_objfile; - complaint (_("Dwarf Error: DW_AT_signature has bad form %s in DIE" - " at %s [in module %s]"), + complaint (_ ("Dwarf Error: DW_AT_signature has bad form %s in DIE" + " at %s [in module %s]"), dwarf_form_name (attr->form), sect_offset_str (die->sect_off), objfile_name (per_objfile->objfile)); return build_error_marker_type (cu, die); @@ -23030,14 +22676,11 @@ read_signatured_type (signatured_type *sig_type, const gdb_byte *info_ptr = reader.info_ptr; gdb_assert (cu->die_hash == NULL); - cu->die_hash = - htab_create_alloc_ex (cu->header.get_length_without_initial () / 12, - die_hash, - die_eq, - NULL, - &cu->comp_unit_obstack, - hashtab_obstack_allocate, - dummy_obstack_deallocate); + cu->die_hash + = htab_create_alloc_ex (cu->header.get_length_without_initial () / 12, + die_hash, die_eq, NULL, &cu->comp_unit_obstack, + hashtab_obstack_allocate, + dummy_obstack_deallocate); if (reader.comp_unit_die->has_children) reader.comp_unit_die->child @@ -23184,8 +22827,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) case DW_OP_addr: stack[++stacki] = cu->header.read_address (objfile->obfd.get (), - &data[i], - &bytes_read); + &data[i], &bytes_read); i += bytes_read; break; @@ -23195,7 +22837,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) break; case DW_OP_const1s: - stack[++stacki] = read_1_signed_byte (objfile->obfd.get (), &data[i]); + stack[++stacki] + = read_1_signed_byte (objfile->obfd.get (), &data[i]); i += 1; break; @@ -23205,7 +22848,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) break; case DW_OP_const2s: - stack[++stacki] = read_2_signed_bytes (objfile->obfd.get (), &data[i]); + stack[++stacki] + = read_2_signed_bytes (objfile->obfd.get (), &data[i]); i += 2; break; @@ -23215,7 +22859,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) break; case DW_OP_const4s: - stack[++stacki] = read_4_signed_bytes (objfile->obfd.get (), &data[i]); + stack[++stacki] + = read_4_signed_bytes (objfile->obfd.get (), &data[i]); i += 4; break; @@ -23225,8 +22870,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) break; case DW_OP_constu: - stack[++stacki] = read_unsigned_leb128 (NULL, (data + i), - &bytes_read); + stack[++stacki] + = read_unsigned_leb128 (NULL, (data + i), &bytes_read); i += bytes_read; break; @@ -23246,8 +22891,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) break; case DW_OP_plus_uconst: - stack[stacki] += read_unsigned_leb128 (NULL, (data + i), - &bytes_read); + stack[stacki] + += read_unsigned_leb128 (NULL, (data + i), &bytes_read); i += bytes_read; break; @@ -23298,8 +22943,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) case DW_OP_addrx: case DW_OP_GNU_addr_index: case DW_OP_GNU_const_index: - stack[++stacki] = read_addr_index_from_leb128 (cu, &data[i], - &bytes_read); + stack[++stacki] + = read_addr_index_from_leb128 (cu, &data[i], &bytes_read); i += bytes_read; break; @@ -23309,11 +22954,9 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) const char *name = get_DW_OP_name (op); if (name) - complaint (_("unsupported stack op: '%s'"), - name); + complaint (_ ("unsupported stack op: '%s'"), name); else - complaint (_("unsupported stack op: '%02x'"), - op); + complaint (_ ("unsupported stack op: '%02x'"), op); } return (stack[stacki]); @@ -23324,14 +22967,14 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, bool *computed) if (stacki >= ARRAY_SIZE (stack) - 1) { if (computed == nullptr) - complaint (_("location description stack overflow")); + complaint (_ ("location description stack overflow")); return 0; } if (stacki <= 0) { if (computed == nullptr) - complaint (_("location description stack underflow")); + complaint (_ ("location description stack underflow")); return 0; } } @@ -23363,8 +23006,6 @@ dwarf_alloc_die (struct dwarf2_cu *cu, int num_attrs) return (die); } - - /* Macro support. */ /* An overload of dwarf_decode_macros that finds the correct section @@ -23411,7 +23052,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, section->read (objfile); if (section->buffer == nullptr) { - complaint (_("missing %s section"), section_name); + complaint (_ ("missing %s section"), section_name); return; } @@ -23423,8 +23064,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, if (cu->dwo_unit != nullptr) { - str_offsets_section = &cu->dwo_unit->dwo_file - ->sections.str_offsets; + str_offsets_section = &cu->dwo_unit->dwo_file->sections.str_offsets; str_section = &cu->dwo_unit->dwo_file->sections.str; str_offsets_base = cu->header.addr_size; } @@ -23435,9 +23075,9 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, str_offsets_base = cu->str_offsets_base; } - dwarf_decode_macros (per_objfile, builder, section, lh, - offset_size, offset, str_section, str_offsets_section, - str_offsets_base, section_is_gnu, cu); + dwarf_decode_macros (per_objfile, builder, section, lh, offset_size, offset, + str_section, str_offsets_section, str_offsets_base, + section_is_gnu, cu); } /* Return the .debug_loc section to use for CU. @@ -23463,7 +23103,7 @@ static struct dwarf2_section_info * cu_debug_rnglists_section (struct dwarf2_cu *cu, dwarf_tag tag) { if (cu->header.version < 5) - error (_(".debug_rnglists section cannot be used in DWARF %d"), + error (_ (".debug_rnglists section cannot be used in DWARF %d"), cu->header.version); struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile; @@ -23472,8 +23112,7 @@ cu_debug_rnglists_section (struct dwarf2_cu *cu, dwarf_tag tag) would be the .dwo file, if there is one. However for DW_TAG_compile_unit or DW_TAG_skeleton unit, we always want to read from objfile/linked program. */ - if (cu->dwo_unit != nullptr - && tag != DW_TAG_compile_unit + if (cu->dwo_unit != nullptr && tag != DW_TAG_compile_unit && tag != DW_TAG_skeleton_unit) { struct dwo_sections *sections = &cu->dwo_unit->dwo_file->sections; @@ -23481,7 +23120,7 @@ cu_debug_rnglists_section (struct dwarf2_cu *cu, dwarf_tag tag) if (sections->rnglists.size > 0) return §ions->rnglists; else - error (_(".debug_rnglists section is missing from .dwo file.")); + error (_ (".debug_rnglists section is missing from .dwo file.")); } return &dwarf2_per_objfile->per_bfd->rnglists; } @@ -23533,12 +23172,11 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, fill_in_loclist_baton (cu, baton, attr); if (!cu->base_address.has_value ()) - complaint (_("Location list used without " - "specifying the CU base address.")); + complaint (_ ("Location list used without " + "specifying the CU base address.")); - sym->set_aclass_index ((is_block - ? dwarf2_loclist_block_index - : dwarf2_loclist_index)); + sym->set_aclass_index ((is_block ? dwarf2_loclist_block_index + : dwarf2_loclist_index)); SYMBOL_LOCATION_BATON (sym) = baton; } else @@ -23568,9 +23206,8 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, baton->size = 0; } - sym->set_aclass_index ((is_block - ? dwarf2_locexpr_block_index - : dwarf2_locexpr_index)); + sym->set_aclass_index ((is_block ? dwarf2_locexpr_block_index + : dwarf2_locexpr_index)); SYMBOL_LOCATION_BATON (sym) = baton; } } @@ -23630,10 +23267,9 @@ dwarf2_per_cu_data::ref_addr_size () const tested. */ static int -dwarf2_find_containing_comp_unit - (sect_offset sect_off, - unsigned int offset_in_dwz, - const std::vector<dwarf2_per_cu_data_up> &all_units) +dwarf2_find_containing_comp_unit ( + sect_offset sect_off, unsigned int offset_in_dwz, + const std::vector<dwarf2_per_cu_data_up> &all_units) { int low, high; @@ -23664,27 +23300,25 @@ dwarf2_find_containing_comp_unit (sect_offset sect_off, unsigned int offset_in_dwz, dwarf2_per_bfd *per_bfd) { - int low = dwarf2_find_containing_comp_unit - (sect_off, offset_in_dwz, per_bfd->all_units); + int low = dwarf2_find_containing_comp_unit (sect_off, offset_in_dwz, + per_bfd->all_units); dwarf2_per_cu_data *this_cu = per_bfd->all_units[low].get (); if (this_cu->is_dwz != offset_in_dwz || this_cu->sect_off > sect_off) { if (low == 0 || this_cu->is_dwz != offset_in_dwz) - error (_("Dwarf Error: could not find partial DIE containing " - "offset %s [in module %s]"), - sect_offset_str (sect_off), - bfd_get_filename (per_bfd->obfd)); + error (_ ("Dwarf Error: could not find partial DIE containing " + "offset %s [in module %s]"), + sect_offset_str (sect_off), bfd_get_filename (per_bfd->obfd)); - gdb_assert (per_bfd->all_units[low-1]->sect_off - <= sect_off); + gdb_assert (per_bfd->all_units[low - 1]->sect_off <= sect_off); return per_bfd->all_units[low - 1].get (); } else { if (low == per_bfd->all_units.size () - 1 && sect_off >= this_cu->sect_off + this_cu->length ()) - error (_("invalid dwarf2 offset %s"), sect_offset_str (sect_off)); + error (_ ("invalid dwarf2 offset %s"), sect_offset_str (sect_off)); gdb_assert (sect_off < this_cu->sect_off + this_cu->length ()); return this_cu; } @@ -23692,8 +23326,10 @@ dwarf2_find_containing_comp_unit (sect_offset sect_off, #if GDB_SELF_TEST -namespace selftests { -namespace find_containing_comp_unit { +namespace selftests +{ +namespace find_containing_comp_unit +{ static void run_test () @@ -23740,8 +23376,8 @@ run_test () SELF_CHECK (units[result].get () == four_ptr); } -} -} +} // namespace find_containing_comp_unit +} // namespace selftests #endif /* GDB_SELF_TEST */ @@ -23767,8 +23403,7 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, string. */ lang = language_opencl; } - else if (cu->producer != nullptr - && strstr (cu->producer, "GNU Go ") != NULL) + else if (cu->producer != nullptr && strstr (cu->producer, "GNU Go ") != NULL) { /* Similar hack for Go. */ lang = language_go; @@ -23792,7 +23427,7 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, cu->per_cu->set_unit_type (DW_UT_type); break; default: - error (_("Dwarf Error: unexpected tag '%s' at offset %s"), + error (_ ("Dwarf Error: unexpected tag '%s' at offset %s"), dwarf_tag_name (comp_unit_die->tag), sect_offset_str (cu->per_cu->sect_off)); } @@ -23966,14 +23601,11 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu, where the type-specific area is used to store the floatformat). But this is not a problem, because the gnat-specific information is actually not needed for these types. */ - if (need_gnat_info (cu) - && type->code () != TYPE_CODE_FUNC - && type->code () != TYPE_CODE_FLT - && type->code () != TYPE_CODE_METHODPTR + if (need_gnat_info (cu) && type->code () != TYPE_CODE_FUNC + && type->code () != TYPE_CODE_FLT && type->code () != TYPE_CODE_METHODPTR && type->code () != TYPE_CODE_MEMBERPTR && type->code () != TYPE_CODE_METHOD - && type->code () != TYPE_CODE_FIXED_POINT - && !HAVE_GNAT_AUX_INFO (type)) + && type->code () != TYPE_CODE_FIXED_POINT && !HAVE_GNAT_AUX_INFO (type)) INIT_GNAT_SPECIFIC (type); /* Read DW_AT_allocated and set in type. */ @@ -24013,10 +23645,9 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu, if (per_objfile->die_type_hash == NULL) per_objfile->die_type_hash - = htab_up (htab_create_alloc (127, - per_cu_offset_and_type_hash, - per_cu_offset_and_type_eq, - NULL, xcalloc, xfree)); + = htab_up (htab_create_alloc (127, per_cu_offset_and_type_hash, + per_cu_offset_and_type_eq, NULL, xcalloc, + xfree)); ofs.per_cu = cu->per_cu; ofs.sect_off = die->sect_off; @@ -24024,10 +23655,10 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu, slot = (struct dwarf2_per_cu_offset_and_type **) htab_find_slot (per_objfile->die_type_hash.get (), &ofs, INSERT); if (*slot) - complaint (_("A problem internal to GDB: DIE %s has type already set"), + complaint (_ ("A problem internal to GDB: DIE %s has type already set"), sect_offset_str (die->sect_off)); - *slot = XOBNEW (&objfile->objfile_obstack, - struct dwarf2_per_cu_offset_and_type); + *slot + = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_cu_offset_and_type); **slot = ofs; return type; } @@ -24036,8 +23667,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu, or return NULL if the die does not have a saved type. */ static struct type * -get_die_type_at_offset (sect_offset sect_off, - dwarf2_per_cu_data *per_cu, +get_die_type_at_offset (sect_offset sect_off, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { struct dwarf2_per_cu_offset_and_type *slot, ofs; @@ -24048,7 +23678,7 @@ get_die_type_at_offset (sect_offset sect_off, ofs.per_cu = per_cu; ofs.sect_off = sect_off; slot = ((struct dwarf2_per_cu_offset_and_type *) - htab_find (per_objfile->die_type_hash.get (), &ofs)); + htab_find (per_objfile->die_type_hash.get (), &ofs)); if (slot) return slot->type; else @@ -24071,95 +23701,97 @@ static void show_check_physname (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, - _("Whether to check \"physname\" is %s.\n"), - value); + gdb_printf (file, _ ("Whether to check \"physname\" is %s.\n"), value); } void _initialize_dwarf2_read (); + void _initialize_dwarf2_read () { - add_setshow_prefix_cmd ("dwarf", class_maintenance, - _("\ + add_setshow_prefix_cmd ("dwarf", class_maintenance, _ ("\ Set DWARF specific variables.\n\ Configure DWARF variables such as the cache size."), - _("\ + _ ("\ Show DWARF specific variables.\n\ Show DWARF variables such as the cache size."), &set_dwarf_cmdlist, &show_dwarf_cmdlist, &maintenance_set_cmdlist, &maintenance_show_cmdlist); add_setshow_zinteger_cmd ("max-cache-age", class_obscure, - &dwarf_max_cache_age, _("\ -Set the upper bound on the age of cached DWARF compilation units."), _("\ -Show the upper bound on the age of cached DWARF compilation units."), _("\ + &dwarf_max_cache_age, _ ("\ +Set the upper bound on the age of cached DWARF compilation units."), + _ ("\ +Show the upper bound on the age of cached DWARF compilation units."), + _ ("\ A higher limit means that cached compilation units will be stored\n\ in memory longer, and more total memory will be used. Zero disables\n\ caching, which can slow down startup."), - NULL, - show_dwarf_max_cache_age, - &set_dwarf_cmdlist, + NULL, show_dwarf_max_cache_age, &set_dwarf_cmdlist, &show_dwarf_cmdlist); - add_setshow_zuinteger_cmd ("dwarf-read", no_class, &dwarf_read_debug, _("\ -Set debugging of the DWARF reader."), _("\ -Show debugging of the DWARF reader."), _("\ + add_setshow_zuinteger_cmd ("dwarf-read", no_class, &dwarf_read_debug, _ ("\ +Set debugging of the DWARF reader."), + _ ("\ +Show debugging of the DWARF reader."), + _ ("\ When enabled (non-zero), debugging messages are printed during DWARF\n\ reading and symtab expansion. A value of 1 (one) provides basic\n\ information. A value greater than 1 provides more verbose information."), - NULL, - NULL, - &setdebuglist, &showdebuglist); + NULL, NULL, &setdebuglist, &showdebuglist); - add_setshow_zuinteger_cmd ("dwarf-die", no_class, &dwarf_die_debug, _("\ -Set debugging of the DWARF DIE reader."), _("\ -Show debugging of the DWARF DIE reader."), _("\ + add_setshow_zuinteger_cmd ("dwarf-die", no_class, &dwarf_die_debug, _ ("\ +Set debugging of the DWARF DIE reader."), + _ ("\ +Show debugging of the DWARF DIE reader."), + _ ("\ When enabled (non-zero), DIEs are dumped after they are read in.\n\ The value is the maximum depth to print."), - NULL, - NULL, - &setdebuglist, &showdebuglist); + NULL, NULL, &setdebuglist, &showdebuglist); - add_setshow_zuinteger_cmd ("dwarf-line", no_class, &dwarf_line_debug, _("\ -Set debugging of the dwarf line reader."), _("\ -Show debugging of the dwarf line reader."), _("\ + add_setshow_zuinteger_cmd ("dwarf-line", no_class, &dwarf_line_debug, _ ("\ +Set debugging of the dwarf line reader."), + _ ("\ +Show debugging of the dwarf line reader."), + _ ("\ When enabled (non-zero), line number entries are dumped as they are read in.\n\ A value of 1 (one) provides basic information.\n\ A value greater than 1 provides more verbose information."), - NULL, - NULL, - &setdebuglist, &showdebuglist); + NULL, NULL, &setdebuglist, &showdebuglist); - add_setshow_boolean_cmd ("check-physname", no_class, &check_physname, _("\ -Set cross-checking of \"physname\" code against demangler."), _("\ -Show cross-checking of \"physname\" code against demangler."), _("\ + add_setshow_boolean_cmd ("check-physname", no_class, &check_physname, _ ("\ +Set cross-checking of \"physname\" code against demangler."), + _ ("\ +Show cross-checking of \"physname\" code against demangler."), + _ ("\ When enabled, GDB's internal \"physname\" code is checked against\n\ the demangler."), - NULL, show_check_physname, - &setdebuglist, &showdebuglist); - - add_setshow_boolean_cmd ("use-deprecated-index-sections", - no_class, &use_deprecated_index_sections, _("\ -Set whether to use deprecated gdb_index sections."), _("\ -Show whether to use deprecated gdb_index sections."), _("\ + NULL, show_check_physname, &setdebuglist, + &showdebuglist); + + add_setshow_boolean_cmd ("use-deprecated-index-sections", no_class, + &use_deprecated_index_sections, _ ("\ +Set whether to use deprecated gdb_index sections."), + _ ("\ +Show whether to use deprecated gdb_index sections."), + _ ("\ When enabled, deprecated .gdb_index sections are used anyway.\n\ Normally they are ignored either because of a missing feature or\n\ performance issue.\n\ Warning: This option must be enabled before gdb reads the file."), - NULL, - NULL, - &setlist, &showlist); - - dwarf2_locexpr_index = register_symbol_computed_impl (LOC_COMPUTED, - &dwarf2_locexpr_funcs); - dwarf2_loclist_index = register_symbol_computed_impl (LOC_COMPUTED, - &dwarf2_loclist_funcs); - - dwarf2_locexpr_block_index = register_symbol_block_impl (LOC_BLOCK, - &dwarf2_block_frame_base_locexpr_funcs); - dwarf2_loclist_block_index = register_symbol_block_impl (LOC_BLOCK, - &dwarf2_block_frame_base_loclist_funcs); + NULL, NULL, &setlist, &showlist); + + dwarf2_locexpr_index + = register_symbol_computed_impl (LOC_COMPUTED, &dwarf2_locexpr_funcs); + dwarf2_loclist_index + = register_symbol_computed_impl (LOC_COMPUTED, &dwarf2_loclist_funcs); + + dwarf2_locexpr_block_index + = register_symbol_block_impl (LOC_BLOCK, + &dwarf2_block_frame_base_locexpr_funcs); + dwarf2_loclist_block_index + = register_symbol_block_impl (LOC_BLOCK, + &dwarf2_block_frame_base_loclist_funcs); #if GDB_SELF_TEST selftests::register_test ("dw2_expand_symtabs_matching", diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 8045a57..360e3eb 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -91,7 +91,7 @@ struct dwarf2_per_cu_data_deleter /* A specialization of unique_ptr for dwarf2_per_cu_data and subclasses. */ typedef std::unique_ptr<dwarf2_per_cu_data, dwarf2_per_cu_data_deleter> - dwarf2_per_cu_data_up; + dwarf2_per_cu_data_up; /* Persistent data held for a compilation unit, even when not processing it. We put a pointer to this structure in the @@ -120,12 +120,14 @@ struct dwarf2_per_cu_data sect_offset sect_off {}; private: + unsigned int m_length = 0; /* DWARF standard version this data has been read from (such as 4 or 5). */ unsigned char m_dwarf_version = 0; public: + /* Flag indicating this compilation unit will be read in before any of the current compilation units are processed. */ unsigned int queued : 1; @@ -177,13 +179,15 @@ public: packed<bool, 1> addresses_seen = false; private: + /* The unit type of this CU. */ - std::atomic<packed<dwarf_unit_type, 1>> m_unit_type {(dwarf_unit_type)0}; + std::atomic<packed<dwarf_unit_type, 1>> m_unit_type { (dwarf_unit_type) 0 }; /* The language of this CU. */ - std::atomic<packed<language, LANGUAGE_BYTES>> m_lang {language_unknown}; + std::atomic<packed<language, LANGUAGE_BYTES>> m_lang { language_unknown }; public: + /* True if this CU has been scanned by the indexer; false if not. */ std::atomic<bool> scanned; @@ -243,7 +247,7 @@ public: could be refactored to make this private. Until then please try to avoid direct access to this member, and instead use the helper functions above. */ - std::vector <dwarf2_per_cu_data *> *imported_symtabs = nullptr; + std::vector<dwarf2_per_cu_data *> *imported_symtabs = nullptr; /* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */ bool imported_symtabs_empty () const @@ -256,7 +260,7 @@ public: void imported_symtabs_push (dwarf2_per_cu_data *p) { if (imported_symtabs == nullptr) - imported_symtabs = new std::vector <dwarf2_per_cu_data *>; + imported_symtabs = new std::vector<dwarf2_per_cu_data *>; imported_symtabs->push_back (p); } @@ -338,7 +342,7 @@ public: void set_unit_type (dwarf_unit_type unit_type) { /* Set if not set already. */ - packed<dwarf_unit_type, 1> nope = (dwarf_unit_type)0; + packed<dwarf_unit_type, 1> nope = (dwarf_unit_type) 0; if (m_unit_type.compare_exchange_strong (nope, unit_type)) return; @@ -382,7 +386,8 @@ struct signatured_type : public dwarf2_per_cu_data { signatured_type (ULONGEST signature) : signature (signature) - {} + { + } /* The type's signature. */ ULONGEST signature; @@ -424,7 +429,8 @@ struct dwarf2_per_bfd used. CAN_COPY is true for formats where symbol interposition is possible and so symbol values must follow copy relocation rules. */ - dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy); + dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, + bool can_copy); ~dwarf2_per_bfd (); @@ -451,6 +457,7 @@ struct dwarf2_per_bfd void map_info_sections (struct objfile *objfile); private: + /* This function is mapped across the sections and remembers the offset and size of each of the debugging sections we are interested in. */ @@ -458,6 +465,7 @@ private: const dwarf2_debug_sections &names); public: + /* The corresponding BFD. */ bfd *obfd; @@ -506,7 +514,9 @@ public: /* Type unit statistics, to see how well the scaling improvements are doing. */ - struct tu_stats tu_stats {}; + struct tu_stats tu_stats + { + }; /* A table mapping DW_AT_dwo_name values to struct dwo_file objects. This is NULL if the table hasn't been allocated yet. */ @@ -591,8 +601,10 @@ struct type_unit_group_unshareable struct dwarf2_per_objfile { dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd) - : objfile (objfile), per_bfd (per_bfd) - {} + : objfile (objfile), + per_bfd (per_bfd) + { + } ~dwarf2_per_objfile (); @@ -605,8 +617,7 @@ struct dwarf2_per_objfile /* Return pointer to string at .debug_line_str offset as read from BUF. The offset_size is OFFSET_SIZE. */ - const char *read_line_string (const gdb_byte *buf, - unsigned int offset_size); + const char *read_line_string (const gdb_byte *buf, unsigned int offset_size); /* Return true if the symtab corresponding to PER_CU has been set, false otherwise. */ @@ -620,8 +631,8 @@ struct dwarf2_per_objfile /* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one does not exist, create it. */ - type_unit_group_unshareable *get_type_unit_group_unshareable - (type_unit_group *tu_group); + type_unit_group_unshareable * + get_type_unit_group_unshareable (type_unit_group *tu_group); struct type *get_type_for_signatured_type (signatured_type *sig_type) const; @@ -666,6 +677,7 @@ struct dwarf2_per_objfile gdb::optional<std::queue<dwarf2_queue_item>> queue; private: + /* Hold the corresponding compunit_symtab for each CU or TU. This is indexed by dwarf2_per_cu_data::index. A NULL value means that the CU/TU has not been expanded yet. */ @@ -684,8 +696,8 @@ private: /* Map from the objfile-independent dwarf2_per_cu_data instances to the corresponding objfile-dependent dwarf2_cu instances. */ - std::unordered_map<dwarf2_per_cu_data *, - std::unique_ptr<dwarf2_cu>> m_dwarf2_cus; + std::unordered_map<dwarf2_per_cu_data *, std::unique_ptr<dwarf2_cu>> + m_dwarf2_cus; }; /* Get the dwarf2_per_objfile associated to OBJFILE. */ @@ -713,53 +725,55 @@ CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu, dwarf2_locexpr_baton->data has lifetime of PER_CU->DWARF2_PER_OBJFILE->OBJFILE. */ -struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off - (sect_offset sect_off, dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - gdb::function_view<CORE_ADDR ()> get_frame_pc, - bool resolve_abstract_p = false); +struct dwarf2_locexpr_baton +dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, + gdb::function_view<CORE_ADDR ()> get_frame_pc, + bool resolve_abstract_p = false); /* Like dwarf2_fetch_die_loc_sect_off, but take a CU offset. */ -struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off - (cu_offset offset_in_cu, dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - gdb::function_view<CORE_ADDR ()> get_frame_pc); +struct dwarf2_locexpr_baton +dwarf2_fetch_die_loc_cu_off (cu_offset offset_in_cu, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, + gdb::function_view<CORE_ADDR ()> get_frame_pc); /* If the DIE at SECT_OFF in PER_CU has a DW_AT_const_value, return a pointer to the constant bytes and set LEN to the length of the data. If memory is needed, allocate it on OBSTACK. If the DIE does not have a DW_AT_const_value, return NULL. */ -extern const gdb_byte *dwarf2_fetch_constant_bytes - (sect_offset sect_off, dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, obstack *obstack, - LONGEST *len); +extern const gdb_byte * +dwarf2_fetch_constant_bytes (sect_offset sect_off, dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, obstack *obstack, + LONGEST *len); /* Return the type of the die at SECT_OFF in PER_CU. Return NULL if no valid type for this die is found. If VAR_NAME is non-null, and if the DIE in question is a variable declaration (definitions are excluded), then *VAR_NAME is set to the variable's name. */ -struct type *dwarf2_fetch_die_type_sect_off - (sect_offset sect_off, dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - const char **var_name = nullptr); +struct type *dwarf2_fetch_die_type_sect_off (sect_offset sect_off, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, + const char **var_name = nullptr); /* When non-zero, dump line number entries as they are read in. */ extern unsigned int dwarf_line_debug; /* Dwarf2 sections that can be accessed by dwarf2_get_section_info. */ -enum dwarf2_section_enum { +enum dwarf2_section_enum +{ DWARF2_DEBUG_FRAME, DWARF2_EH_FRAME }; extern void dwarf2_get_section_info (struct objfile *, - enum dwarf2_section_enum, - asection **, const gdb_byte **, - bfd_size_type *); + enum dwarf2_section_enum, asection **, + const gdb_byte **, bfd_size_type *); /* Return true if the producer of the inferior is clang. */ extern bool producer_is_clang (struct dwarf2_cu *cu); diff --git a/gdb/dwarf2/sect-names.h b/gdb/dwarf2/sect-names.h index c05d496..6a3dadf 100644 --- a/gdb/dwarf2/sect-names.h +++ b/gdb/dwarf2/sect-names.h @@ -28,7 +28,8 @@ It doesn't make sense to have a NULL NORMAL field but a non-NULL COMPRESSED field. */ -struct dwarf2_section_names { +struct dwarf2_section_names +{ const char *normal; const char *compressed; @@ -47,7 +48,8 @@ struct dwarf2_section_names { update all instances of dwarf2_debug_sections if you add a field to this structure. It is always safe to use { NULL, NULL } in this case. */ -struct dwarf2_debug_sections { +struct dwarf2_debug_sections +{ struct dwarf2_section_names info; struct dwarf2_section_names abbrev; struct dwarf2_section_names line; diff --git a/gdb/dwarf2/section.c b/gdb/dwarf2/section.c index c9ef418..ae2ee61 100644 --- a/gdb/dwarf2/section.c +++ b/gdb/dwarf2/section.c @@ -33,8 +33,8 @@ void dwarf2_section_info::overflow_complaint () const { - complaint (_("debug info runs off end of %s section" - " [in module %s]"), + complaint (_ ("debug info runs off end of %s section" + " [in module %s]"), get_name (), get_file_name ()); } @@ -135,14 +135,14 @@ dwarf2_section_info::read (struct objfile *objfile) /* If this is a virtual section we need to read in the real one first. */ if (is_virtual) { - struct dwarf2_section_info *containing_section = - get_containing_section (); + struct dwarf2_section_info *containing_section + = get_containing_section (); gdb_assert (sectp != NULL); if ((sectp->flags & SEC_RELOC) != 0) { - error (_("Dwarf Error: DWP format V2 with relocations is not" - " supported in section %s [in module %s]"), + error (_ ("Dwarf Error: DWP format V2 with relocations is not" + " supported in section %s [in module %s]"), get_name (), get_file_name ()); } containing_section->read (objfile); @@ -184,8 +184,8 @@ dwarf2_section_info::read (struct objfile *objfile) if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 || bfd_bread (buf, size, abfd) != size) { - error (_("Dwarf Error: Can't read DWARF data" - " in section %s [in module %s]"), + error (_ ("Dwarf Error: Can't read DWARF data" + " in section %s [in module %s]"), bfd_section_name (sectp), bfd_get_filename (abfd)); } } @@ -198,15 +198,14 @@ dwarf2_section_info::read_string (struct objfile *objfile, LONGEST str_offset, if (buffer == NULL) { if (get_bfd_section () == nullptr) - error (_("Dwarf Error: %s used without required section"), - form_name); + error (_ ("Dwarf Error: %s used without required section"), form_name); else - error (_("Dwarf Error: %s used without %s section [in module %s]"), + error (_ ("Dwarf Error: %s used without %s section [in module %s]"), form_name, get_name (), get_file_name ()); } if (str_offset >= size) - error (_("%s pointing outside of %s section [in module %s]"), - form_name, get_name (), get_file_name ()); + error (_ ("%s pointing outside of %s section [in module %s]"), form_name, + get_name (), get_file_name ()); gdb_assert (HOST_CHAR_BIT == 8); if (buffer[str_offset] == '\0') return NULL; diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h index fbeb974..5fb0ffe 100644 --- a/gdb/dwarf2/section.h +++ b/gdb/dwarf2/section.h @@ -111,6 +111,7 @@ struct dwarf2_section_info section. */ struct dwarf2_section_info *containing_section; } s; + /* Pointer to section data, only valid if readin. */ const gdb_byte *buffer; /* The size of the section, real or virtual. */ |