diff options
author | emaste <emaste@FreeBSD.org> | 2014-11-26 16:48:12 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-11-26 16:48:12 +0000 |
commit | 0147dda7de9580d13778ecb4c9e92b83b7a63911 (patch) | |
tree | b16dc95f693ed59342b6141cd3fd9f59a6cd7e7e /contrib/llvm/tools/lldb/source/Plugins/SymbolFile | |
parent | bfd4c39c61ae9b29542625bb12b6f7f4b1f8c727 (diff) | |
parent | 01ee1789d6aa7294e5966a97f8d29387f6f81699 (diff) | |
download | FreeBSD-src-0147dda7de9580d13778ecb4c9e92b83b7a63911.zip FreeBSD-src-0147dda7de9580d13778ecb4c9e92b83b7a63911.tar.gz |
Update LLDB snapshot to upstream r216948 (git 50f7fe44)
This is approximately "LLDB 3.5" although with a little bit of skew,
and will go along with the Clang 3.5 import.
Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Plugins/SymbolFile')
21 files changed, 501 insertions, 501 deletions
diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp index ff2e376..bc2e7a6 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp @@ -92,84 +92,6 @@ DWARFAbbreviationDeclaration::IsValid() } -void -DWARFAbbreviationDeclaration::CopyExcludingAddressAttributes(const DWARFAbbreviationDeclaration& abbr_decl, const uint32_t idx) -{ - m_code = abbr_decl.Code(); // Invalidate the code since that can't be copied safely. - m_tag = abbr_decl.Tag(); - m_has_children = abbr_decl.HasChildren(); - - const DWARFAttribute::collection& attributes = abbr_decl.Attributes(); - const uint32_t num_abbr_decl_attributes = attributes.size(); - - dw_attr_t attr; - dw_form_t form; - uint32_t i; - - for (i = 0; i < num_abbr_decl_attributes; ++i) - { - attributes[i].get(attr, form); - switch (attr) - { - case DW_AT_location: - case DW_AT_frame_base: - // Only add these if they are location expressions (have a single - // value) and not location lists (have a lists of location - // expressions which are only valid over specific address ranges) - if (DWARFFormValue::IsBlockForm(form)) - m_attributes.push_back(DWARFAttribute(attr, form)); - break; - - case DW_AT_low_pc: - case DW_AT_high_pc: - case DW_AT_ranges: - case DW_AT_entry_pc: - // Don't add these attributes - if (i >= idx) - break; - // Fall through and add attribute - default: - // Add anything that isn't address related - m_attributes.push_back(DWARFAttribute(attr, form)); - break; - } - } -} - -void -DWARFAbbreviationDeclaration::CopyChangingStringToStrp( - const DWARFAbbreviationDeclaration& abbr_decl, - const DWARFDataExtractor& debug_info_data, - dw_offset_t debug_info_offset, - const DWARFCompileUnit* cu, - const uint32_t strp_min_len -) -{ - m_code = InvalidCode; - m_tag = abbr_decl.Tag(); - m_has_children = abbr_decl.HasChildren(); - - const DWARFAttribute::collection& attributes = abbr_decl.Attributes(); - const uint32_t num_abbr_decl_attributes = attributes.size(); - - dw_attr_t attr; - dw_form_t form; - uint32_t i; - lldb::offset_t offset = debug_info_offset; - - for (i = 0; i < num_abbr_decl_attributes; ++i) - { - attributes[i].get(attr, form); - dw_offset_t attr_offset = offset; - DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu); - - if (form == DW_FORM_string && ((offset - attr_offset) >= strp_min_len)) - m_attributes.push_back(DWARFAttribute(attr, DW_FORM_strp)); - else - m_attributes.push_back(DWARFAttribute(attr, form)); - } -} - uint32_t DWARFAbbreviationDeclaration::FindAttributeIndex(dw_attr_t attr) const @@ -193,19 +115,3 @@ DWARFAbbreviationDeclaration::operator == (const DWARFAbbreviationDeclaration& r && Attributes() == rhs.Attributes(); } -#if 0 -DWARFAbbreviationDeclaration::Append(BinaryStreamBuf& out_buff) const -{ - out_buff.Append32_as_ULEB128(Code()); - out_buff.Append32_as_ULEB128(Tag()); - out_buff.Append8(HasChildren()); - const uint32_t kNumAttributes = m_attributes.size(); - for (uint32_t i = 0; i < kNumAttributes; ++i) - { - out_buff.Append32_as_ULEB128(m_attributes[i].attr()); - out_buff.Append32_as_ULEB128(m_attributes[i].form()); - } - out_buff.Append8(0); // Output a zero for attr (faster than using Append32_as_ULEB128) - out_buff.Append8(0); // Output a zero for attr (faster than using Append32_as_ULEB128) -} -#endif // 0 diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h index 48b9ebe..0ef153a 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h @@ -55,21 +55,12 @@ public: { return m_attributes[idx].get_form(); } - void CopyExcludingAddressAttributes(const DWARFAbbreviationDeclaration& abbr_decl, const uint32_t idx); - void CopyChangingStringToStrp( - const DWARFAbbreviationDeclaration& abbr_decl, - const lldb_private::DWARFDataExtractor& debug_info_data, - dw_offset_t debug_info_offset, - const DWARFCompileUnit* cu, - const uint32_t strp_min_len); uint32_t FindAttributeIndex(dw_attr_t attr) const; bool Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr); bool Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code); -// void Append(BinaryStreamBuf& out_buff) const; bool IsValid(); void Dump(lldb_private::Stream *s) const; bool operator == (const DWARFAbbreviationDeclaration& rhs) const; -// DWARFAttribute::collection& Attributes() { return m_attributes; } const DWARFAttribute::collection& Attributes() const { return m_attributes; } protected: dw_uleb128_t m_code; diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index cf664db..b2e64ad 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -265,12 +265,16 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end()); exact_size_die_array.swap (m_die_array); } - Log *log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE)); - if (log) + Log *verbose_log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE)); + if (verbose_log) { StreamString strm; - DWARFDebugInfoEntry::DumpDIECollection (strm, m_die_array); - log->PutCString (strm.GetString().c_str()); + Dump(&strm); + if (m_die_array.empty()) + strm.Printf("error: no DIE for compile unit"); + else + m_die_array[0].Dump(m_dwarf2Data, this, strm, UINT32_MAX); + verbose_log->PutCString (strm.GetString().c_str()); } return m_die_array.size(); @@ -357,18 +361,43 @@ DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size) void DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, - DWARFDebugAranges* debug_aranges, - bool clear_dies_if_already_not_parsed) + DWARFDebugAranges* debug_aranges) { // This function is usually called if there in no .debug_aranges section // in order to produce a compile unit level set of address ranges that - // is accurate. If the DIEs weren't parsed, then we don't want all dies for - // all compile units to stay loaded when they weren't needed. So we can end - // up parsing the DWARF and then throwing them all away to keep memory usage - // down. + // is accurate. + + // First get the compile unit DIE only and check if it has a DW_AT_ranges + const DWARFDebugInfoEntry* die = GetCompileUnitDIEOnly(); + + const dw_offset_t cu_offset = GetOffset(); + if (die) + { + DWARFDebugRanges::RangeList ranges; + const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false); + if (num_ranges > 0) + { + // This compile unit has DW_AT_ranges, assume this is correct if it + // is present since clang no longer makes .debug_aranges by default + // and it emits DW_AT_ranges for DW_TAG_compile_units. GCC also does + // this with recent GCC builds. + for (size_t i=0; i<num_ranges; ++i) + { + const DWARFDebugRanges::RangeList::Entry &range = ranges.GetEntryRef(i); + debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd()); + } + + return; // We got all of our ranges from the DW_AT_ranges attribute + } + } + // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF + + // If the DIEs weren't parsed, then we don't want all dies for all compile units + // to stay loaded when they weren't needed. So we can end up parsing the DWARF + // and then throwing them all away to keep memory usage down. const bool clear_dies = ExtractDIEsIfNeeded (false) > 1; - const DWARFDebugInfoEntry* die = DIE(); + die = DIE(); if (die) die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges); @@ -393,7 +422,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, for (uint32_t idx=0; idx<num_ranges; ++idx) { const LineTable::FileAddressRanges::Entry &range = file_ranges.GetEntryRef(idx); - debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(), range.GetRangeEnd()); + debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd()); printf ("0x%8.8x: [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n", GetOffset(), range.GetRangeBase(), range.GetRangeEnd()); } } diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index 35597f3..ed1894b 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -54,8 +54,7 @@ public: dw_addr_t GetBaseAddress() const { return m_base_addr; } void ClearDIEs(bool keep_compile_unit_die); void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, - DWARFDebugAranges* debug_aranges, - bool clear_dies_if_already_not_parsed); + DWARFDebugAranges* debug_aranges); void SetBaseAddress(dw_addr_t base_addr) diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp index d083f8a..b0b7136 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp @@ -188,38 +188,74 @@ DWARFDebugArangeSet::Extract(const DWARFDataExtractor &data, lldb::offset_t *off m_header.cu_offset = data.GetDWARFOffset(offset_ptr); m_header.addr_size = data.GetU8(offset_ptr); m_header.seg_size = data.GetU8(offset_ptr); - - - // The first tuple following the header in each set begins at an offset - // that is a multiple of the size of a single tuple (that is, twice the - // size of an address). The header is padded, if necessary, to the - // appropriate boundary. - const uint32_t header_size = *offset_ptr - m_offset; - const uint32_t tuple_size = m_header.addr_size << 1; - uint32_t first_tuple_offset = 0; - while (first_tuple_offset < header_size) - first_tuple_offset += tuple_size; - - *offset_ptr = m_offset + first_tuple_offset; - - Descriptor arangeDescriptor; - - assert(sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length)); - assert(sizeof(arangeDescriptor.address) >= m_header.addr_size); - - while (data.ValidOffset(*offset_ptr)) + + // Try to avoid reading invalid arange sets by making sure: + // 1 - the version looks good + // 2 - the address byte size looks plausible + // 3 - the length seems to make sense + // size looks plausible + if ((m_header.version >= 2 && m_header.version <= 5) && + (m_header.addr_size == 4 || m_header.addr_size == 8) && + (m_header.length > 0)) { - arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size); - arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size); - - // Each set of tuples is terminated by a 0 for the address and 0 - // for the length. - if (arangeDescriptor.address || arangeDescriptor.length) - m_arange_descriptors.push_back(arangeDescriptor); + if (data.ValidOffset(m_offset + sizeof(m_header.length) + m_header.length - 1)) + { + // The first tuple following the header in each set begins at an offset + // that is a multiple of the size of a single tuple (that is, twice the + // size of an address). The header is padded, if necessary, to the + // appropriate boundary. + const uint32_t header_size = *offset_ptr - m_offset; + const uint32_t tuple_size = m_header.addr_size << 1; + uint32_t first_tuple_offset = 0; + while (first_tuple_offset < header_size) + first_tuple_offset += tuple_size; + + *offset_ptr = m_offset + first_tuple_offset; + + Descriptor arangeDescriptor; + + static_assert(sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length), + "DWARFDebugArangeSet::Descriptor.address and DWARFDebugArangeSet::Descriptor.length must have same size"); + + while (data.ValidOffset(*offset_ptr)) + { + arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size); + arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size); + + // Each set of tuples is terminated by a 0 for the address and 0 + // for the length. + if (arangeDescriptor.address || arangeDescriptor.length) + m_arange_descriptors.push_back(arangeDescriptor); + else + break; // We are done if we get a zero address and length + } + } +#if defined (LLDB_CONFIGURATION_DEBUG) else - break; // We are done if we get a zero address and length + { + printf ("warning: .debug_arange set length is too large arange data at 0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, addr_size=%u, seg_size=%u\n", + m_offset, + m_header.length, + m_header.version, + m_header.cu_offset, + m_header.addr_size, + m_header.seg_size); + } +#endif } - +#if defined (LLDB_CONFIGURATION_DEBUG) + else + { + printf ("warning: .debug_arange set has bad header at 0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, addr_size=%u, seg_size=%u\n", + m_offset, + m_header.length, + m_header.version, + m_header.cu_offset, + m_header.addr_size, + m_header.seg_size); + } +#endif + return !m_arange_descriptors.empty(); } return false; diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index 4f77bff..60e5c6e 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -93,14 +93,13 @@ DWARFDebugAranges::Generate(SymbolFileDWARF* dwarf2Data) DWARFDebugInfo* debug_info = dwarf2Data->DebugInfo(); if (debug_info) { - const bool clear_dies_if_already_not_parsed = true; uint32_t cu_idx = 0; const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits(); for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) { DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx); if (cu) - cu->BuildAddressRangeTable(dwarf2Data, this, clear_dies_if_already_not_parsed); + cu->BuildAddressRangeTable(dwarf2Data, this); } } return !IsEmpty(); @@ -136,7 +135,7 @@ void DWARFDebugAranges::Sort (bool minimize) { Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", - __PRETTY_FUNCTION__, this); + __PRETTY_FUNCTION__, static_cast<void*>(this)); Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); size_t orig_arange_size = 0; diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index d4db12c..a8c553e 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -79,7 +79,6 @@ DWARFDebugInfo::GetCompileUnitAranges () // Manually build arange data for everything that wasn't in the .debug_aranges table. bool printed = false; const size_t num_compile_units = GetNumCompileUnits(); - const bool clear_dies_if_already_not_parsed = true; for (size_t idx = 0; idx < num_compile_units; ++idx) { DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx); @@ -94,7 +93,7 @@ DWARFDebugInfo::GetCompileUnitAranges () m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str()); printed = true; } - cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed); + cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get()); } } @@ -214,13 +213,6 @@ DWARFDebugInfo::ContainsCompileUnit (const DWARFCompileUnit *cu) const return false; } - -static bool CompileUnitOffsetLessThan (const DWARFCompileUnitSP& a, const DWARFCompileUnitSP& b) -{ - return a->GetOffset() < b->GetOffset(); -} - - static int CompareDWARFCompileUnitSPOffset (const void *key, const void *arrmem) { @@ -280,15 +272,6 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) } //---------------------------------------------------------------------- -// Compare function DWARFDebugAranges::Range structures -//---------------------------------------------------------------------- -static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2) -{ - return die1.GetOffset() < die2.GetOffset(); -} - - -//---------------------------------------------------------------------- // GetDIE() // // Get the DIE (Debug Information Entry) with the specified offset. @@ -341,40 +324,6 @@ DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUn } //---------------------------------------------------------------------- -// DWARFDebugInfo_ParseCallback -// -// A callback function for the static DWARFDebugInfo::Parse() function -// that gets parses all compile units and DIE's into an internate -// representation for further modification. -//---------------------------------------------------------------------- - -static dw_offset_t -DWARFDebugInfo_ParseCallback -( - SymbolFileDWARF* dwarf2Data, - DWARFCompileUnitSP& cu_sp, - DWARFDebugInfoEntry* die, - const dw_offset_t next_offset, - const uint32_t curr_depth, - void* userData -) -{ - DWARFDebugInfo* debug_info = (DWARFDebugInfo*)userData; - DWARFCompileUnit* cu = cu_sp.get(); - if (die) - { - cu->AddDIE(*die); - } - else if (cu) - { - debug_info->AddCompileUnit(cu_sp); - } - - // Just return the current offset to parse the next CU or DIE entry - return next_offset; -} - -//---------------------------------------------------------------------- // AddCompileUnit //---------------------------------------------------------------------- void @@ -563,7 +512,7 @@ static dw_offset_t DumpCallback // We have already found our DIE and are printing it's children. Obey // our recurse depth and return an invalid offset if we get done - // dumping all the the children + // dumping all of the children if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) die->Dump(dwarf2Data, cu, *s, 0); } diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 37741eb..856a7fa 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -1485,6 +1485,40 @@ DWARFDebugInfoEntry::GetAttributeAddressRange hi_pc = fail_value; return false; } + +size_t +DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data, + const DWARFCompileUnit* cu, + DWARFDebugRanges::RangeList &ranges, + bool check_hi_lo_pc) const +{ + ranges.Clear(); + + dw_offset_t ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET); + if (ranges_offset != DW_INVALID_OFFSET) + { + dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET); + if (debug_ranges_offset != DW_INVALID_OFFSET) + { + DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges(); + + debug_ranges->FindRanges(debug_ranges_offset, ranges); + ranges.Slide (cu->GetBaseAddress()); + } + } + else if (check_hi_lo_pc) + { + dw_addr_t lo_pc = LLDB_INVALID_ADDRESS; + dw_addr_t hi_pc = LLDB_INVALID_ADDRESS; + if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) + { + if (lo_pc < hi_pc) + ranges.Append(DWARFDebugRanges::RangeList::Entry(lo_pc, hi_pc - lo_pc)); + } + } + return ranges.GetSize(); +} + //---------------------------------------------------------------------- // GetAttributeValueAsLocation // diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index f740575..3949ad3 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -86,7 +86,7 @@ public: dw_form_t form; }; - typedef llvm::SmallVector<Info, 32> collection; + typedef llvm::SmallVector<Info, 8> collection; collection m_infos; }; @@ -209,7 +209,13 @@ public: dw_addr_t& lo_pc, dw_addr_t& hi_pc, uint64_t fail_value) const; - + + size_t GetAttributeAddressRanges ( + SymbolFileDWARF* dwarf2Data, + const DWARFCompileUnit* cu, + DWARFDebugRanges::RangeList &ranges, + bool check_hi_lo_pc) const; + dw_offset_t GetAttributeValueAsLocation( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp index 0a2f1f7..6a26494 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -256,7 +256,13 @@ DWARFDebugLine::DumpStatementOpcodes(Log *log, const DWARFDataExtractor& debug_l prologue.file_names.push_back(fileEntry); } break; - + + case DW_LNE_set_discriminator: + { + uint64_t discriminator = debug_line_data.GetULEB128(&offset); + log->Printf( "0x%8.8x: DW_LNE_set_discriminator (0x%" PRIx64 ")", op_offset, discriminator); + } + break; default: log->Printf( "0x%8.8x: DW_LNE_??? (%2.2x) - Skipping unknown upcode", op_offset, opcode); // Length doesn't include the zero opcode byte or the length itself, but @@ -412,7 +418,7 @@ DWARFDebugLine::ParsePrologue(const DWARFDataExtractor& debug_line_data, lldb::o const char * s; prologue->total_length = debug_line_data.GetDWARFInitialLength(offset_ptr); prologue->version = debug_line_data.GetU16(offset_ptr); - if (prologue->version != 2) + if (prologue->version < 2 || prologue->version > 3) return false; prologue->prologue_length = debug_line_data.GetDWARFOffset(offset_ptr); @@ -480,7 +486,7 @@ DWARFDebugLine::ParseSupportFiles (const lldb::ModuleSP &module_sp, (void)debug_line_data.GetDWARFInitialLength(&offset); const char * s; uint32_t version = debug_line_data.GetU16(&offset); - if (version != 2) + if (version < 2 || version > 3) return false; const dw_offset_t end_prologue_offset = debug_line_data.GetDWARFOffset(&offset) + offset; @@ -666,7 +672,7 @@ DWARFDebugLine::ParseStatementTable // The files are numbered, starting at 1, in the order in which they // appear; the names in the prologue come before names defined by // the DW_LNE_define_file instruction. These numbers are used in the - // the file register of the state machine. + // file register of the state machine. { FileNameEntry fileEntry; fileEntry.name = debug_line_data.GetCStr(offset_ptr); @@ -789,7 +795,7 @@ DWARFDebugLine::ParseStatementTable // as a multiple of LEB128 operands for each opcode. { uint8_t i; - assert (opcode - 1 < prologue->standard_opcode_lengths.size()); + assert (static_cast<size_t>(opcode - 1) < prologue->standard_opcode_lengths.size()); const uint8_t opcode_length = prologue->standard_opcode_lengths[opcode - 1]; for (i=0; i<opcode_length; ++i) debug_line_data.Skip_LEB128(offset_ptr); diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp index 06ac825..488e982 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp @@ -66,11 +66,12 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data) { Timer scoped_timer (__PRETTY_FUNCTION__, "DWARFDebugPubnames::GeneratePubnames (data = %p)", - dwarf2Data); + static_cast<void*>(dwarf2Data)); Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES)); if (log) - log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)", dwarf2Data); + log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)", + static_cast<void*>(dwarf2Data)); m_sets.clear(); DWARFDebugInfo* debug_info = dwarf2Data->DebugInfo(); diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index daa3b0a..0953554 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -143,7 +143,7 @@ DWARFDebugRanges::Dump(Stream &s, const DWARFDataExtractor& debug_ranges_data, l { dw_addr_t begin = debug_ranges_data.GetMaxU64(offset_ptr, addr_size); dw_addr_t end = debug_ranges_data.GetMaxU64(offset_ptr, addr_size); - // Extend 4 byte addresses that consits of 32 bits of 1's to be 64 bits + // Extend 4 byte addresses that consists of 32 bits of 1's to be 64 bits // of ones if (begin == 0xFFFFFFFFull && addr_size == 4) begin = LLDB_INVALID_ADDRESS; diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp index abf6919..5512072 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp @@ -78,7 +78,7 @@ DWARFDeclContext::operator==(const DWARFDeclContext& rhs) const collection::const_iterator rhs_begin = rhs.m_entries.begin(); // The two entry arrays have the same size - // First compare the tags before we do expensize name compares + // First compare the tags before we do expensive name compares for (pos = begin, rhs_pos = rhs_begin; pos != end; ++pos, ++rhs_pos) { if (pos->tag != rhs_pos->tag) diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index abd2737..ab8e68a 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -133,7 +133,7 @@ DWARFFormValue::ExtractValue(const DWARFDataExtractor& data, lldb::offset_t* off case DW_FORM_data8: m_value.value.uval = data.GetU64(offset_ptr); break; case DW_FORM_string: m_value.value.cstr = data.GetCStr(offset_ptr); // Set the string value to also be the data for inlined cstr form values only - // so we can tell the differnence between DW_FORM_string and DW_FORM_strp form + // so we can tell the difference between DW_FORM_string and DW_FORM_strp form // values; m_value.data = (uint8_t*)m_value.value.cstr; break; case DW_FORM_exprloc: diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index 44a24f2..ab0c37b 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -169,7 +169,7 @@ struct DWARFMappedHash { if (return_implementation_only_if_available) { - // We found the one true definiton for this class, so + // We found the one true definition for this class, so // only return that die_offsets.clear(); die_offsets.push_back (die_info_array[i].offset); @@ -388,7 +388,7 @@ struct DWARFMappedHash } size_t - GetMinumumHashDataByteSize () const + GetMinimumHashDataByteSize () const { return min_hash_data_byte_size; } @@ -465,7 +465,7 @@ struct DWARFMappedHash break; default: - // We can always skip atomes we don't know about + // We can always skip atoms we don't know about break; } } @@ -651,11 +651,11 @@ struct DWARFMappedHash } const uint32_t count = m_data.GetU32 (hash_data_offset_ptr); - const size_t min_total_hash_data_size = count * m_header.header_data.GetMinumumHashDataByteSize(); + const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize(); if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size)) { // We have at least one HashData entry, and we have enough - // data to parse at leats "count" HashData enties. + // data to parse at least "count" HashData entries. // First make sure the entire C string matches... const bool match = strcmp (name, strp_cstr) == 0; @@ -678,7 +678,7 @@ struct DWARFMappedHash DIEInfo die_info; if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) { - // Only happend the HashData if the string matched... + // Only happened if the HashData of the string matched... if (match) pair.value.push_back (die_info); } @@ -724,7 +724,7 @@ struct DWARFMappedHash return eResultError; const uint32_t count = m_data.GetU32 (hash_data_offset_ptr); - const size_t min_total_hash_data_size = count * m_header.header_data.GetMinumumHashDataByteSize(); + const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize(); if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size)) { const bool match = regex.Execute(strp_cstr); @@ -747,7 +747,7 @@ struct DWARFMappedHash DIEInfo die_info; if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) { - // Only happend the HashData if the string matched... + // Only happened if the HashData of the string matched... if (match) pair.value.push_back (die_info); } diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp index c9ffa9e..fbbc03c 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp @@ -18,7 +18,7 @@ using namespace lldb; using namespace lldb_private; -// when the one and only logging channel is abled, then this will be non NULL. +// when the one and only logging channel is enabled, then this will be non NULL. static LogChannelDWARF* g_log_channel = NULL; LogChannelDWARF::LogChannelDWARF () : @@ -103,6 +103,7 @@ LogChannelDWARF::Disable (const char **categories, Stream *feedback_strm) else if (::strcasecmp (arg, "lookups") == 0) flag_bits &= ~DWARF_LOG_LOOKUPS; else if (::strcasecmp (arg, "map") == 0) flag_bits &= ~DWARF_LOG_DEBUG_MAP; else if (::strcasecmp (arg, "default") == 0) flag_bits &= ~DWARF_LOG_DEFAULT; + else if (::strcasecmp (arg, "verbose") == 0) flag_bits &= ~DWARF_LOG_VERBOSE; else if (::strncasecmp(arg, "comp", 4) == 0) flag_bits &= ~DWARF_LOG_TYPE_COMPLETION; else { @@ -151,6 +152,7 @@ LogChannelDWARF::Enable else if (::strcasecmp (arg, "lookups") == 0) flag_bits |= DWARF_LOG_LOOKUPS; else if (::strcasecmp (arg, "map") == 0) flag_bits |= DWARF_LOG_DEBUG_MAP; else if (::strcasecmp (arg, "default") == 0) flag_bits |= DWARF_LOG_DEFAULT; + else if (::strcasecmp (arg, "verbose") == 0) flag_bits |= DWARF_LOG_VERBOSE; else if (::strncasecmp(arg, "comp", 4) == 0) flag_bits |= DWARF_LOG_TYPE_COMPLETION; else { diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index c1aecfe..842260d 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -66,6 +66,9 @@ #include <map> +#include <ctype.h> +#include <string.h> + //#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF @@ -110,7 +113,35 @@ DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility) return eAccessNone; } -#if defined(LLDB_CONFIGURATION_DEBUG) or defined(LLDB_CONFIGURATION_RELEASE) +static const char* +removeHostnameFromPathname(const char* path_from_dwarf) +{ + if (!path_from_dwarf || !path_from_dwarf[0]) + { + return path_from_dwarf; + } + + const char *colon_pos = strchr(path_from_dwarf, ':'); + if (!colon_pos) + { + return path_from_dwarf; + } + + // check whether we have a windows path, and so the first character + // is a drive-letter not a hostname. + if ( + colon_pos == path_from_dwarf + 1 && + isalpha(*path_from_dwarf) && + strlen(path_from_dwarf) > 2 && + '\\' == path_from_dwarf[2]) + { + return path_from_dwarf; + } + + return colon_pos + 1; +} + +#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE) class DIEStack { @@ -525,7 +556,7 @@ SymbolFileDWARF::GetClangASTContext () if (!m_is_external_ast_source) { m_is_external_ast_source = true; - llvm::OwningPtr<clang::ExternalASTSource> ast_source_ap ( + llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap ( new ClangExternalASTSourceCallbacks (SymbolFileDWARF::CompleteTagDecl, SymbolFileDWARF::CompleteObjCInterfaceDecl, SymbolFileDWARF::FindExternalVisibleDeclsByName, @@ -829,7 +860,8 @@ SymbolFileDWARF::DebugInfo() { if (m_info.get() == NULL) { - Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); + Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", + __PRETTY_FUNCTION__, static_cast<void*>(this)); if (get_debug_info_data().GetByteSize() > 0) { m_info.reset(new DWARFDebugInfo()); @@ -879,7 +911,8 @@ SymbolFileDWARF::DebugRanges() { if (m_ranges.get() == NULL) { - Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); + Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", + __PRETTY_FUNCTION__, static_cast<void*>(this)); if (get_debug_ranges_data().GetByteSize() > 0) { m_ranges.reset(new DWARFDebugRanges()); @@ -943,7 +976,11 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) } else { + // DWARF2/3 suggests the form hostname:pathname for compilation directory. + // Remove the host part if present. + cu_comp_dir = removeHostnameFromPathname(cu_comp_dir); std::string fullpath(cu_comp_dir); + if (*fullpath.rbegin() != '/') fullpath += '/'; fullpath += cu_die_name; @@ -1170,6 +1207,11 @@ SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpec if (cu_die) { const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL); + + // DWARF2/3 suggests the form hostname:pathname for compilation directory. + // Remove the host part if present. + cu_comp_dir = removeHostnameFromPathname(cu_comp_dir); + dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET); // All file indexes in DWARF are one based and a file of index zero is @@ -1983,7 +2025,7 @@ SymbolFileDWARF::ParseChildMembers const uint64_t word_width = 32; // Objective-C has invalid DW_AT_bit_offset values in older versions - // of clang, so we have to be careful and only insert unnammed bitfields + // of clang, so we have to be careful and only insert unnamed bitfields // if we have a new enough clang. bool detect_unnamed_bitfields = true; @@ -2380,7 +2422,6 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) // The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition // are done. m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType()); - // Disable external storage for this type so we don't get anymore // clang::ExternalASTSource queries for this type. @@ -2395,14 +2436,11 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); if (log) - { GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type->GetName().AsCString()); - - } assert (clang_type); DWARFDebugInfoEntry::Attributes attributes; @@ -2413,11 +2451,10 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) case DW_TAG_class_type: { LayoutInfo layout_info; - + { if (die->HasChildren()) { - LanguageType class_language = eLanguageTypeUnknown; if (clang_type.IsObjCObjectOrInterfaceType()) { @@ -2426,7 +2463,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) // the class is created. clang_type.StartTagDeclarationDefinition (); } - + int tag_decl_kind = -1; AccessType default_accessibility = eAccessNone; if (tag == DW_TAG_structure_type) @@ -2444,14 +2481,14 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) tag_decl_kind = clang::TTK_Class; default_accessibility = eAccessPrivate; } - + SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu)); std::vector<clang::CXXBaseSpecifier *> base_classes; std::vector<int> member_accessibilities; bool is_a_class = false; // Parse members and base classes first DWARFDIECollection member_function_dies; - + DelayedPropertyList delayed_properties; ParseChildMembers (sc, dwarf_cu, @@ -2465,7 +2502,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) default_accessibility, is_a_class, layout_info); - + // Now parse any methods if there were any... size_t num_functions = member_function_dies.Size(); if (num_functions > 0) @@ -2475,13 +2512,12 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) ResolveType(dwarf_cu, member_function_dies.GetDIEPtrAtIndex(i)); } } - + if (class_language == eLanguageTypeObjC) { ConstString class_name (clang_type.GetTypeName()); if (class_name) { - DIEArray method_die_offsets; if (m_using_apple_tables) { @@ -2492,21 +2528,21 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) { if (!m_indexed) Index (); - + m_objc_class_selectors_index.Find (class_name, method_die_offsets); } - + if (!method_die_offsets.empty()) { DWARFDebugInfo* debug_info = DebugInfo(); - + DWARFCompileUnit* method_cu = NULL; const size_t num_matches = method_die_offsets.size(); for (size_t i=0; i<num_matches; ++i) { const dw_offset_t die_offset = method_die_offsets[i]; DWARFDebugInfoEntry *method_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &method_cu); - + if (method_die) ResolveType (method_cu, method_die); else @@ -2519,14 +2555,14 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) } } } - + for (DelayedPropertyList::iterator pi = delayed_properties.begin(), pe = delayed_properties.end(); pi != pe; ++pi) pi->Finalize(); } } - + // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we // need to tell the clang type it is actually a class. if (class_language != eLanguageTypeObjC) @@ -2534,7 +2570,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) if (is_a_class && tag_decl_kind != clang::TTK_Class) clang_type.SetTagTypeKind (clang::TTK_Class); } - + // Since DW_TAG_structure_type gets used for both classes // and structures, we may need to set any DW_TAG_member // fields to have a "private" access if none was specified. @@ -2553,7 +2589,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) &member_accessibilities.front(), member_accessibilities.size()); } - + if (!base_classes.empty()) { // Make sure all base classes refer to complete types and not @@ -2580,7 +2616,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) // is complete. If we don't do this, clang will crash when we // call setBases() inside of "clang_type.SetBaseClassesForClassType()" // below. Since we provide layout assistance, all ivars in this - // class and other classe will be fine, this is the best we can do + // class and other classes will be fine, this is the best we can do // short of crashing. base_class_type.StartTagDeclarationDefinition (); base_class_type.CompleteTagDeclarationDefinition (); @@ -2589,7 +2625,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) } clang_type.SetBaseClassesForClassType (&base_classes.front(), base_classes.size()); - + // Clang will copy each CXXBaseSpecifier in "base_classes" // so we have to free them all. ClangASTType::DeleteBaseClassSpecifiers (&base_classes.front(), @@ -2597,10 +2633,10 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) } } } - + clang_type.BuildIndirectFields (); clang_type.CompleteTagDeclarationDefinition (); - + if (!layout_info.field_offsets.empty() || !layout_info.base_offsets.empty() || !layout_info.vbase_offsets.empty() ) @@ -2609,7 +2645,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) layout_info.bit_size = type->GetByteSize() * 8; if (layout_info.bit_size == 0) layout_info.bit_size = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_byte_size, 0) * 8; - + clang::CXXRecordDecl *record_decl = clang_type.GetAsCXXRecordDecl(); if (record_decl) { @@ -2617,14 +2653,14 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])", - clang_type.GetOpaqueQualType(), - record_decl, + static_cast<void*>(clang_type.GetOpaqueQualType()), + static_cast<void*>(record_decl), layout_info.bit_size, layout_info.alignment, - (uint32_t)layout_info.field_offsets.size(), - (uint32_t)layout_info.base_offsets.size(), - (uint32_t)layout_info.vbase_offsets.size()); - + static_cast<uint32_t>(layout_info.field_offsets.size()), + static_cast<uint32_t>(layout_info.base_offsets.size()), + static_cast<uint32_t>(layout_info.vbase_offsets.size())); + uint32_t idx; { llvm::DenseMap <const clang::FieldDecl *, uint64_t>::const_iterator pos, end = layout_info.field_offsets.end(); @@ -2632,13 +2668,13 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }", - clang_type.GetOpaqueQualType(), + static_cast<void*>(clang_type.GetOpaqueQualType()), idx, - (uint32_t)pos->second, + static_cast<uint32_t>(pos->second), pos->first->getNameAsString().c_str()); } } - + { llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos, base_end = layout_info.base_offsets.end(); for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end; ++base_pos, ++idx) @@ -2657,9 +2693,9 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }", - clang_type.GetOpaqueQualType(), + static_cast<void*>(clang_type.GetOpaqueQualType()), idx, - (uint32_t)vbase_pos->second.getQuantity(), + static_cast<uint32_t>(vbase_pos->second.getQuantity()), vbase_pos->first->getNameAsString().c_str()); } } @@ -2755,9 +2791,8 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_ { Timer scoped_timer(__PRETTY_FUNCTION__, "SymbolFileDWARF::ResolveSymbolContext (so_addr = { section = %p, offset = 0x%" PRIx64 " }, resolve_scope = 0x%8.8x)", - so_addr.GetSection().get(), - so_addr.GetOffset(), - resolve_scope); + static_cast<void*>(so_addr.GetSection().get()), + so_addr.GetOffset(), resolve_scope); uint32_t resolved = 0; if (resolve_scope & ( eSymbolContextCompUnit | eSymbolContextFunction | @@ -3086,7 +3121,7 @@ SymbolFileDWARF::DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl, DWARFCompileUnit* cu, const DWARFDebugInfoEntry* die) { - // No namespace specified, so the answesr i + // No namespace specified, so the answer is if (namespace_decl == NULL) return true; @@ -3116,7 +3151,7 @@ SymbolFileDWARF::DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl, { // We have a namespace_decl that was not NULL but it contained // a NULL "clang::NamespaceDecl", so this means the global namespace - // So as long the the contained decl context DIE isn't a namespace + // So as long the contained decl context DIE isn't a namespace // we should be ok. if (decl_ctx_die->Tag() != DW_TAG_namespace) return true; @@ -3134,18 +3169,15 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) - { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)", name.GetCString(), - namespace_decl, - append, - max_matches); - } - + static_cast<const void*>(namespace_decl), + append, max_matches); + if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) return 0; - + DWARFDebugInfo* info = DebugInfo(); if (info == NULL) return 0; @@ -3159,7 +3191,7 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat const uint32_t original_size = variables.GetSize(); DIEArray die_offsets; - + if (m_using_apple_tables) { if (m_apple_names_ap.get()) @@ -3167,10 +3199,10 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat const char *name_cstr = name.GetCString(); const char *base_name_start; const char *base_name_end = NULL; - + if (!CPPLanguageRuntime::StripNamespacesFromVariableName(name_cstr, base_name_start, base_name_end)) base_name_start = name_cstr; - + m_apple_names_ap->FindByName (base_name_start, die_offsets); } } @@ -3182,14 +3214,14 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat m_global_index.Find (name, die_offsets); } - + const size_t num_die_matches = die_offsets.size(); if (num_die_matches) { SymbolContext sc; sc.module_sp = m_obj_file->GetModule(); assert (sc.module_sp); - + DWARFDebugInfo* debug_info = DebugInfo(); DWARFCompileUnit* dwarf_cu = NULL; const DWARFDebugInfoEntry* die = NULL; @@ -3209,11 +3241,11 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat case DW_TAG_try_block: case DW_TAG_catch_block: break; - + case DW_TAG_variable: { sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); - + if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) continue; @@ -3242,10 +3274,9 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables) => %u", - name.GetCString(), - namespace_decl, - append, - max_matches, + name.GetCString(), + static_cast<const void*>(namespace_decl), + append, max_matches, num_matches); } return num_matches; @@ -3255,13 +3286,12 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) { Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); - + if (log) { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, max_matches=%u, variables)", - regex.GetText(), - append, + regex.GetText(), append, max_matches); } @@ -3959,38 +3989,32 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, return 0; Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); - + if (log) { if (namespace_decl) - { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list)", name.GetCString(), - namespace_decl->GetNamespaceDecl(), + static_cast<void*>(namespace_decl->GetNamespaceDecl()), namespace_decl->GetQualifiedName().c_str(), - append, - max_matches); - } + append, max_matches); else - { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list)", - name.GetCString(), - append, + name.GetCString(), append, max_matches); - } } // If we aren't appending the results to this list, then clear the list if (!append) types.Clear(); - + if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) return 0; DIEArray die_offsets; - + if (m_using_apple_tables) { if (m_apple_types_ap.get()) @@ -4003,10 +4027,10 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, { if (!m_indexed) Index (); - + m_type_index.Find (name, die_offsets); } - + const size_t num_die_matches = die_offsets.size(); if (num_die_matches) @@ -4024,7 +4048,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, { if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) continue; - + Type *matching_type = ResolveType (dwarf_cu, die); if (matching_type) { @@ -4052,10 +4076,9 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list) => %u", name.GetCString(), - namespace_decl->GetNamespaceDecl(), + static_cast<void*>(namespace_decl->GetNamespaceDecl()), namespace_decl->GetQualifiedName().c_str(), - append, - max_matches, + append, max_matches, num_matches); } else @@ -4063,8 +4086,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list) => %u", name.GetCString(), - append, - max_matches, + append, max_matches, num_matches); } } @@ -4156,7 +4178,7 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => clang::NamespaceDecl(%p) \"%s\"", name.GetCString(), - namespace_decl.GetNamespaceDecl(), + static_cast<const void*>(namespace_decl.GetNamespaceDecl()), namespace_decl.GetQualifiedName().c_str()); } @@ -4203,8 +4225,8 @@ SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc, TypeList* type_list, std::vector<ClangASTType>& function_param_types, std::vector<clang::ParmVarDecl*>& function_param_decls, - unsigned &type_quals, - ClangASTContext::TemplateParameterInfos &template_param_infos) + unsigned &type_quals) // , + // ClangASTContext::TemplateParameterInfos &template_param_infos)) { if (parent_die == NULL) return 0; @@ -4357,7 +4379,11 @@ SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc, case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: - ParseTemplateDIE (dwarf_cu, die,template_param_infos); + // The one caller of this was never using the template_param_infos, + // and the local variable was taking up a large amount of stack space + // in SymbolFileDWARF::ParseType() so this was removed. If we ever need + // the template params back, we can add them back. + // ParseTemplateDIE (dwarf_cu, die, template_param_infos); break; default: @@ -4618,20 +4644,20 @@ SymbolFileDWARF::ResolveNamespaceDIE (DWARFCompileUnit *dwarf_cu, const DWARFDeb { GetObjectFile()->GetModule()->LogMessage (log, "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)", - GetClangASTContext().getASTContext(), + static_cast<void*>(GetClangASTContext().getASTContext()), MakeUserID(die->GetOffset()), namespace_name, - namespace_decl, - namespace_decl->getOriginalNamespace()); + static_cast<void*>(namespace_decl), + static_cast<void*>(namespace_decl->getOriginalNamespace())); } else { GetObjectFile()->GetModule()->LogMessage (log, "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)", - GetClangASTContext().getASTContext(), + static_cast<void*>(GetClangASTContext().getASTContext()), MakeUserID(die->GetOffset()), - namespace_decl, - namespace_decl->getOriginalNamespace()); + static_cast<void*>(namespace_decl), + static_cast<void*>(namespace_decl->getOriginalNamespace())); } } @@ -4982,7 +5008,7 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn if (count1 != count2) return false; - // Make sure the DW_TAG values match all the way back up the the + // Make sure the DW_TAG values match all the way back up the // compile unit. If they don't, then we are done. const DWARFDebugInfoEntry *decl_ctx_die1; const DWARFDebugInfoEntry *decl_ctx_die2; @@ -5084,7 +5110,7 @@ SymbolFileDWARF::FindDefinitionTypeForDIE (DWARFCompileUnit* cu, GetObjectFile()->GetModule()->LogMessage (log,"FindByNameAndTagAndQualifiedNameHash()"); m_apple_types_ap->FindByNameAndTagAndQualifiedNameHash (type_name.GetCString(), die->Tag(), qualified_name_hash, die_offsets); } - else if (has_tag > 1) + else if (has_tag) { if (log) GetObjectFile()->GetModule()->LogMessage (log,"FindByNameAndTag()"); @@ -5388,7 +5414,7 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, const DWARFDebugInfoEntry *src_class_die, DWARFCompileUnit* dst_cu, const DWARFDebugInfoEntry *dst_class_die, - llvm::SmallVectorImpl <const DWARFDebugInfoEntry *> &failures) + DWARFDIECollection &failures) { if (!class_type || !src_cu || !src_class_die || !dst_cu || !dst_class_die) return false; @@ -5456,7 +5482,7 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, // Is everything kosher so we can go through the members at top speed? bool fast_path = true; - + if (src_size != dst_size) { if (src_size != 0 && dst_size != 0) @@ -5468,12 +5494,12 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, src_size, dst_size); } - + fast_path = false; } uint32_t idx; - + if (fast_path) { for (idx = 0; idx < src_size; ++idx) @@ -5493,10 +5519,10 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, DW_TAG_value_to_name(src_die->Tag())); fast_path = false; } - + const char *src_name = src_die->GetMangledName (src_symfile, src_cu); const char *dst_name = dst_die->GetMangledName (this, dst_cu); - + // Make sure the names match if (src_name == dst_name || (strcmp (src_name, dst_name) == 0)) continue; @@ -5509,7 +5535,7 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, src_name, dst_die->GetOffset(), dst_name); - + fast_path = false; } } @@ -5523,25 +5549,31 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, { src_die = src_name_to_die.GetValueAtIndexUnchecked (idx); dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx); - + clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die]; if (src_decl_ctx) { if (log) - log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", src_decl_ctx, src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_decl_ctx), + src_die->GetOffset(), dst_die->GetOffset()); LinkDeclContextToDIE (src_decl_ctx, dst_die); } else { if (log) - log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", + src_die->GetOffset(), dst_die->GetOffset()); } - + Type *src_child_type = m_die_to_type[src_die]; if (src_child_type) { if (log) - log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", src_child_type, src_child_type->GetID(), src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_child_type), + src_child_type->GetID(), + src_die->GetOffset(), dst_die->GetOffset()); m_die_to_type[dst_die] = src_child_type; } else @@ -5556,24 +5588,27 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, // We must do this slowly. For each member of the destination, look // up a member in the source with the same name, check its tag, and // unique them if everything matches up. Report failures. - + if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty()) { src_name_to_die.Sort(); - + for (idx = 0; idx < dst_size; ++idx) { const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx); dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx); src_die = src_name_to_die.Find(dst_name, NULL); - + if (src_die && (src_die->Tag() == dst_die->Tag())) { clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die]; if (src_decl_ctx) { if (log) - log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", src_decl_ctx, src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_decl_ctx), + src_die->GetOffset(), + dst_die->GetOffset()); LinkDeclContextToDIE (src_decl_ctx, dst_die); } else @@ -5581,12 +5616,16 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (log) log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); } - + Type *src_child_type = m_die_to_type[src_die]; if (src_child_type) { if (log) - log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", src_child_type, src_child_type->GetID(), src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_child_type), + src_child_type->GetID(), + src_die->GetOffset(), + dst_die->GetOffset()); m_die_to_type[dst_die] = src_child_type; } else @@ -5600,7 +5639,7 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (log) log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die->GetOffset()); - failures.push_back(dst_die); + failures.Append(dst_die); } } } @@ -5614,13 +5653,13 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (src_size_artificial && dst_size_artificial) { dst_name_to_die_artificial.Sort(); - + for (idx = 0; idx < src_size_artificial; ++idx) { const char *src_name_artificial = src_name_to_die_artificial.GetCStringAtIndex(idx); src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked (idx); dst_die = dst_name_to_die_artificial.Find(src_name_artificial, NULL); - + if (dst_die) { // Both classes have the artificial types, link them @@ -5628,7 +5667,9 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (src_decl_ctx) { if (log) - log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", src_decl_ctx, src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_decl_ctx), + src_die->GetOffset(), dst_die->GetOffset()); LinkDeclContextToDIE (src_decl_ctx, dst_die); } else @@ -5636,12 +5677,15 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (log) log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset()); } - + Type *src_child_type = m_die_to_type[src_die]; if (src_child_type) { if (log) - log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", src_child_type, src_child_type->GetID(), src_die->GetOffset(), dst_die->GetOffset()); + log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x", + static_cast<void*>(src_child_type), + src_child_type->GetID(), + src_die->GetOffset(), dst_die->GetOffset()); m_die_to_type[dst_die] = src_child_type; } else @@ -5662,11 +5706,11 @@ SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile, if (log) log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die->GetOffset(), dst_name_artificial); - failures.push_back(dst_die); + failures.Append(dst_die); } } - return (failures.size() != 0); + return (failures.Size() != 0); } TypeSP @@ -5677,7 +5721,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (type_is_new_ptr) *type_is_new_ptr = false; -#if defined(LLDB_CONFIGURATION_DEBUG) or defined(LLDB_CONFIGURATION_RELEASE) +#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE) static DIEStack g_die_stack; DIEStack::ScopedPopper scoped_die_logger(g_die_stack); #endif @@ -5690,15 +5734,15 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, { const DWARFDebugInfoEntry *context_die; clang::DeclContext *context = GetClangDeclContextContainingDIE (dwarf_cu, die, &context_die); - + GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')", - die->GetOffset(), - context, - context_die->GetOffset(), - DW_TAG_value_to_name(die->Tag()), - die->GetName(this, dwarf_cu)); - -#if defined(LLDB_CONFIGURATION_DEBUG) or defined(LLDB_CONFIGURATION_RELEASE) + die->GetOffset(), + static_cast<void*>(context), + context_die->GetOffset(), + DW_TAG_value_to_name(die->Tag()), + die->GetName(this, dwarf_cu)); + +#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE) scoped_die_logger.Push (dwarf_cu, die); g_die_stack.LogDIEs(log, this); #endif @@ -5712,7 +5756,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, // GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData()); // // } - + Type *type_ptr = m_die_to_type.lookup (die); TypeList* type_list = GetTypeList(); if (type_ptr == NULL) @@ -5733,7 +5777,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; ClangASTType clang_type; - + DWARFFormValue form_value; + dw_attr_t attr; switch (tag) @@ -5761,7 +5806,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -5770,7 +5814,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - + type_name_cstr = form_value.AsCString(&get_debug_str_data()); // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't // include the "&"... @@ -5829,7 +5873,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID) && sc.comp_unit != NULL) { bool translation_unit_is_objc = (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus); - + if (translation_unit_is_objc) { if (type_name_cstr != NULL) @@ -5837,7 +5881,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, static ConstString g_objc_type_name_id("id"); static ConstString g_objc_type_name_Class("Class"); static ConstString g_objc_type_name_selector("SEL"); - + if (type_name_const_str == g_objc_type_name_id) { if (log) @@ -5879,11 +5923,11 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid != LLDB_INVALID_UID) { // Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id". - + DWARFDebugInfoEntry* encoding_die = dwarf_cu->GetDIEPtr(encoding_uid); - + if (encoding_die && encoding_die->Tag() == DW_TAG_structure_type) - { + { if (const char *struct_name = encoding_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_name, NULL)) { if (!strcmp(struct_name, "objc_object")) @@ -5903,7 +5947,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, @@ -5914,7 +5958,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, &decl, clang_type, resolve_state)); - + m_die_to_type[die] = type_sp.get(); // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); @@ -5946,7 +5990,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -5996,7 +6039,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_AT_APPLE_objc_complete_type: is_complete_objc_class = form_value.Signed(); break; - + case DW_AT_allocated: case DW_AT_associated: case DW_AT_data_location: @@ -6010,8 +6053,11 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - - UniqueDWARFASTType unique_ast_entry; + + // UniqueDWARFASTType is large, so don't create a local variables on the + // stack, put it on the heap. This function is often called recursively + // and clang isn't good and sharing the stack space for variables in different blocks. + std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(new UniqueDWARFASTType()); // Only try and unique the type if it has a name. if (type_name_const_str && @@ -6021,21 +6067,21 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, die, decl, byte_size_valid ? byte_size : -1, - unique_ast_entry)) + *unique_ast_entry_ap)) { // We have already parsed this type or from another // compile unit. GCC loves to use the "one definition // rule" which can result in multiple definitions // of the same class over and over in each compile // unit. - type_sp = unique_ast_entry.m_type_sp; + type_sp = unique_ast_entry_ap->m_type_sp; if (type_sp) { m_die_to_type[die] = type_sp.get(); return type_sp; } } - + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); int tag_decl_kind = -1; @@ -6055,7 +6101,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, tag_decl_kind = clang::TTK_Class; default_accessibility = eAccessPrivate; } - + if (byte_size_valid && byte_size == 0 && type_name_cstr && die->HasChildren() == false && sc.comp_unit->GetLanguage() == eLanguageTypeObjC) @@ -6093,20 +6139,20 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, // else... type_sp = m_debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true); } - + if (type_sp) { if (log) { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8" PRIx64, - this, + static_cast<void*>(this), die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, type_sp->GetID()); } - + // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die @@ -6115,7 +6161,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - + if (is_forward_declaration) { @@ -6128,12 +6174,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type", - this, + static_cast<void*>(this), die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); } - + DWARFDeclContext die_decl_ctx; die->GetDWARFDeclContext(this, dwarf_cu, die_decl_ctx); @@ -6154,7 +6200,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, { GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8" PRIx64, - this, + static_cast<void*>(this), die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, @@ -6174,12 +6220,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (!clang_type) { const DWARFDebugInfoEntry *decl_ctx_die; - + clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die); if (accessibility == eAccessNone && decl_ctx) { // Check the decl context that contains this class/struct/union. - // If it is a class we must give it an accessability. + // If it is a class we must give it an accessibility. const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind(); if (DeclKindIsCXXClass (containing_decl_kind)) accessibility = default_accessibility; @@ -6199,14 +6245,14 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, type_name_cstr, tag_decl_kind, template_param_infos); - + clang::ClassTemplateSpecializationDecl *class_specialization_decl = ast.CreateClassTemplateSpecializationDecl (decl_ctx, class_template_decl, tag_decl_kind, template_param_infos); clang_type = ast.CreateClassTemplateSpecializationType (class_specialization_decl); clang_type_was_created = true; - + GetClangASTContext().SetMetadata (class_template_decl, metadata); GetClangASTContext().SetMetadata (class_specialization_decl, metadata); } @@ -6238,22 +6284,22 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, &decl, clang_type, Type::eResolveStateForward)); - + type_sp->SetIsCompleteObjCClass(is_complete_objc_class); // Add our type to the unique type map so we don't // end up creating many copies of the same type over // and over in the ASTContext for our module - unique_ast_entry.m_type_sp = type_sp; - unique_ast_entry.m_symfile = this; - unique_ast_entry.m_cu = dwarf_cu; - unique_ast_entry.m_die = die; - unique_ast_entry.m_declaration = decl; - unique_ast_entry.m_byte_size = byte_size; + unique_ast_entry_ap->m_type_sp = type_sp; + unique_ast_entry_ap->m_symfile = this; + unique_ast_entry_ap->m_cu = dwarf_cu; + unique_ast_entry_ap->m_die = die; + unique_ast_entry_ap->m_declaration = decl; + unique_ast_entry_ap->m_byte_size = byte_size; GetUniqueDWARFASTTypeMap().Insert (type_name_const_str, - unique_ast_entry); - + *unique_ast_entry_ap); + if (is_forward_declaration && die->HasChildren()) { // Check to see if the DIE actually has a definition, some version of GCC will @@ -6294,32 +6340,25 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, // No children for this struct/union/class, lets finish it clang_type.StartTagDeclarationDefinition (); clang_type.CompleteTagDeclarationDefinition (); - + if (tag == DW_TAG_structure_type) // this only applies in C { clang::RecordDecl *record_decl = clang_type.GetAsRecordDecl(); - + if (record_decl) - { - LayoutInfo layout_info; - - layout_info.alignment = 0; - layout_info.bit_size = 0; - - m_record_decl_to_layout_map.insert(std::make_pair(record_decl, layout_info)); - } + m_record_decl_to_layout_map.insert(std::make_pair(record_decl, LayoutInfo())); } } else if (clang_type_was_created) { // Start the definition if the class is not objective C since // the underlying decls respond to isCompleteDefinition(). Objective - // C decls dont' respond to isCompleteDefinition() so we can't - // start the declaration definition right away. For C++ classs/union/structs + // C decls don't respond to isCompleteDefinition() so we can't + // start the declaration definition right away. For C++ class/union/structs // we want to start the definition in case the class is needed as the // declaration context for a contained class or type without the need // to complete that type.. - + if (class_language != eLanguageTypeObjC && class_language != eLanguageTypeObjC_plus_plus) clang_type.StartTagDeclarationDefinition (); @@ -6334,7 +6373,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, clang_type.SetHasExternalStorage (true); } } - + } break; @@ -6353,7 +6392,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -6397,12 +6435,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (enumerator_type) enumerator_clang_type = enumerator_type->GetClangFullType(); } - + if (!enumerator_clang_type) enumerator_clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); - + clang_type = ast.CreateEnumerationType (type_name_cstr, GetClangDeclContextContainingDIE (dwarf_cu, die, NULL), decl, @@ -6414,7 +6452,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } LinkDeclContextToDIE(clang_type.GetDeclContextForType(), die); - + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, @@ -6469,7 +6507,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -6491,7 +6528,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_AT_virtuality: is_virtual = form_value.Boolean(); break; case DW_AT_explicit: is_explicit = form_value.Boolean(); break; case DW_AT_artificial: is_artificial = form_value.Boolean(); break; - + case DW_AT_external: if (form_value.Unsigned()) @@ -6554,12 +6591,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, object_pointer_name.assign(s.GetData()); } } - + DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); ClangASTType return_clang_type; Type *func_type = NULL; - + if (type_die_offset != DW_INVALID_OFFSET) func_type = ResolveTypeUID(type_die_offset); @@ -6573,18 +6610,17 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, std::vector<clang::ParmVarDecl*> function_param_decls; // Parse the function children for the parameters - + const DWARFDebugInfoEntry *decl_ctx_die = NULL; clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die); const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); const bool is_cxx_method = DeclKindIsCXXClass (containing_decl_kind); // Start off static. This will be set to false in ParseChildParameters(...) - // if we find a "this" paramters as the first parameter + // if we find a "this" parameters as the first parameter if (is_cxx_method) is_static = true; - ClangASTContext::TemplateParameterInfos template_param_infos; - + if (die->HasChildren()) { bool skip_artificial = true; @@ -6598,8 +6634,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, type_list, function_param_types, function_param_decls, - type_quals, - template_param_infos); + type_quals); } // clang_type will get the function prototype clang type after this call @@ -6608,9 +6643,9 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, function_param_types.size(), is_variadic, type_quals); - + bool ignore_containing_context = false; - + if (type_name_cstr) { bool type_handled = false; @@ -6619,12 +6654,10 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, ObjCLanguageRuntime::MethodName objc_method (type_name_cstr, true); if (objc_method.IsValid(true)) { - SymbolContext empty_sc; ClangASTType class_opaque_type; ConstString class_name(objc_method.GetClassName()); if (class_name) { - TypeList types; TypeSP complete_objc_class_type_sp (FindCompleteObjCDefinitionTypeForDIE (NULL, class_name, false)); if (complete_objc_class_type_sp) @@ -6677,7 +6710,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, SymbolFileDWARF *class_symfile = NULL; DWARFCompileUnitSP class_type_cu_sp; const DWARFDebugInfoEntry *class_type_die = NULL; - + SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) { @@ -6691,8 +6724,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } if (class_type_die) { - llvm::SmallVector<const DWARFDebugInfoEntry *, 0> failures; - + DWARFDIECollection failures; + CopyUniqueClassMethodTypes (class_symfile, class_type, class_type_cu_sp.get(), @@ -6700,12 +6733,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, dwarf_cu, decl_ctx_die, failures); - + // FIXME do something with these failures that's smarter than // just dropping them on the ground. Unfortunately classes don't // like having stuff added to them after their definitions are // complete... - + type_ptr = m_die_to_type[die]; if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { @@ -6714,7 +6747,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - + if (specification_die_offset != DW_INVALID_OFFSET) { // We have a specification which we are going to base our function @@ -6773,7 +6806,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, // in the DWARF for C++ methods... Default to public for now... if (accessibility == eAccessNone) accessibility = eAccessPublic; - + if (!is_static && !die->HasChildren()) { // We have a C++ member function with no children (this pointer!) @@ -6792,7 +6825,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, m_obj_file->GetFileSpec().GetPath().c_str()); const bool is_attr_used = false; - + cxx_method_decl = class_opaque_type.AddMethodToCXXRecordType (type_name_cstr, clang_type, accessibility, @@ -6802,7 +6835,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, is_explicit, is_attr_used, is_artificial); - + type_handled = cxx_method_decl != NULL; if (type_handled) @@ -6811,17 +6844,17 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, Host::SetCrashDescription (NULL); - + ClangASTMetadata metadata; metadata.SetUserID(MakeUserID(die->GetOffset())); - + if (!object_pointer_name.empty()) { metadata.SetObjectPtrName(object_pointer_name.c_str()); if (log) log->Printf ("Setting object pointer name: %s on method object %p.\n", object_pointer_name.c_str(), - cxx_method_decl); + static_cast<void*>(cxx_method_decl)); } GetClangASTContext().SetMetadata (cxx_method_decl, metadata); } @@ -6841,7 +6874,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, // we need to modify the m_die_to_type so it doesn't think we are // trying to parse this DIE anymore... m_die_to_type[die] = NULL; - + // Now we get the full type to force our class type to complete itself // using the clang::ExternalASTSource protocol which will parse all // base classes and all methods (including the method for this DIE). @@ -6854,7 +6887,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, type_sp = type_ptr->shared_from_this(); break; } - + // FIXME This is fixing some even uglier behavior but we really need to // uniq the methods of each class as well as the class itself. // <rdar://problem/11240464> @@ -6865,7 +6898,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - + if (!type_handled) { // We just have a function that isn't part of a class @@ -6893,17 +6926,17 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, ast.SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); - + ClangASTMetadata metadata; metadata.SetUserID(MakeUserID(die->GetOffset())); - + if (!object_pointer_name.empty()) { metadata.SetObjectPtrName(object_pointer_name.c_str()); if (log) log->Printf ("Setting object pointer name: %s on function object %p.", object_pointer_name.c_str(), - function_decl); + static_cast<void*>(function_decl)); } GetClangASTContext().SetMetadata (function_decl, metadata); } @@ -6940,7 +6973,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -7022,13 +7054,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); - + if (num_attributes > 0) { uint32_t i; for (i=0; i<num_attributes; ++i) { attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; if (attributes.ExtractFormValueAtIndex(this, i, form_value)) { switch (attr) @@ -7040,10 +7071,10 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - + Type *pointee_type = ResolveTypeUID(type_die_offset); Type *class_type = ResolveTypeUID(containing_type_die_offset); - + ClangASTType pointee_clang_type = pointee_type->GetClangForwardType(); ClangASTType class_clang_type = class_type->GetClangLayoutType(); @@ -7062,7 +7093,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, clang_type, Type::eResolveStateForward)); } - + break; } default: @@ -7342,6 +7373,7 @@ SymbolFileDWARF::ParseVariableDIE bool is_artificial = false; bool location_is_const_value_data = false; bool has_explicit_location = false; + DWARFFormValue const_value; //AccessType accessibility = eAccessNone; for (i=0; i<num_attributes; ++i) @@ -7380,7 +7412,21 @@ SymbolFileDWARF::ParseVariableDIE const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); uint32_t data_offset = attributes.DIEOffsetAtIndex(i); uint32_t data_length = fixed_form_sizes[form_value.Form()]; - location.CopyOpcodeData(module, debug_info_data, data_offset, data_length); + if (data_length == 0) + { + const uint8_t *data_pointer = form_value.BlockData(); + if (data_pointer) + { + data_length = form_value.Unsigned(); + } + else if (DWARFFormValue::IsDataForm(form_value.Form())) + { + // we need to get the byte size of the type later after we create the variable + const_value = form_value; + } + } + else + location.CopyOpcodeData(module, debug_info_data, data_offset, data_length); } else { @@ -7455,7 +7501,7 @@ SymbolFileDWARF::ParseVariableDIE // DWARF doesn't specify if a DW_TAG_variable is a local, global // or static variable, so we have to do a little digging by - // looking at the location of a varaible to see if it contains + // looking at the location of a variable to see if it contains // a DW_OP_addr opcode _somewhere_ in the definition. I say // somewhere because clang likes to combine small global variables // into the same symbol and have locations like: @@ -7592,10 +7638,15 @@ SymbolFileDWARF::ParseVariableDIE if (symbol_context_scope) { + SymbolFileTypeSP type_sp(new SymbolFileType(*this, type_uid)); + + if (const_value.Form() && type_sp && type_sp->GetType()) + location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), dwarf_cu->GetAddressByteSize()); + var_sp.reset (new Variable (MakeUserID(die->GetOffset()), name, mangled, - SymbolFileTypeSP (new SymbolFileType(*this, type_uid)), + type_sp, scope, symbol_context_scope, &decl, @@ -7763,7 +7814,7 @@ SymbolFileDWARF::ParseVariables if (block == NULL) { // This must be a specification or abstract origin with - // a concrete block couterpart in the current function. We need + // a concrete block counterpart in the current function. We need // to find the concrete block so we can correctly add the // variable to it DWARFCompileUnit *concrete_block_die_cu = dwarf_cu; @@ -8011,12 +8062,11 @@ SymbolFileDWARF::LayoutRecordType (const clang::RecordDecl *record_decl, if (log) GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::LayoutRecordType (record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u],base_offsets[%u], vbase_offsets[%u]) success = %i", - record_decl, - bit_size, - alignment, - (uint32_t)field_offsets.size(), - (uint32_t)base_offsets.size(), - (uint32_t)vbase_offsets.size(), + static_cast<const void*>(record_decl), + bit_size, alignment, + static_cast<uint32_t>(field_offsets.size()), + static_cast<uint32_t>(base_offsets.size()), + static_cast<uint32_t>(vbase_offsets.size()), success); return success; } diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 8dac209..178e514 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -368,9 +368,10 @@ protected: lldb_private::TypeList* type_list, std::vector<lldb_private::ClangASTType>& function_args, std::vector<clang::ParmVarDecl*>& function_param_decls, - unsigned &type_quals, - lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - + unsigned &type_quals); + // lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); // not currently needed + + size_t ParseChildEnumerators( const lldb_private::SymbolContext& sc, lldb_private::ClangASTType &clang_type, @@ -546,7 +547,7 @@ protected: const DWARFDebugInfoEntry *src_class_die, DWARFCompileUnit* dst_cu, const DWARFDebugInfoEntry *dst_class_die, - llvm::SmallVectorImpl <const DWARFDebugInfoEntry *> &failures); + DWARFDIECollection &failures); bool FixupAddress (lldb_private::Address &addr); diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 856c42c..af16c03 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -55,20 +55,19 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa Module *oso_module = exe_symfile->GetModuleByCompUnitInfo (this); if (!oso_module) return file_range_map; - + ObjectFile *oso_objfile = oso_module->GetObjectFile(); if (!oso_objfile) return file_range_map; - + Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP)); if (log) { ConstString object_name (oso_module->GetObjectName()); log->Printf("%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')", - this, + static_cast<void*>(this), oso_module->GetSpecificationDescription().c_str()); } - std::vector<SymbolFileDWARFDebugMap::CompileUnitInfo *> cu_infos; if (exe_symfile->GetCompUnitInfosForModule(oso_module, cu_infos)) @@ -78,12 +77,12 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab(); ModuleSP oso_module_sp (oso_objfile->GetModule()); Symtab *oso_symtab = oso_objfile->GetSymtab(); - + ///const uint32_t fun_resolve_flags = SymbolContext::Module | eSymbolContextCompUnit | eSymbolContextFunction; //SectionList *oso_sections = oso_objfile->Sections(); // Now we need to make sections that map from zero based object - // file addresses to where things eneded up in the main executable. - + // file addresses to where things ended up in the main executable. + assert (comp_unit_info->first_symbol_index != UINT32_MAX); // End index is one past the last valid symbol index const uint32_t oso_end_idx = comp_unit_info->last_symbol_index + 1; @@ -96,12 +95,12 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa { if (exe_symbol->IsDebug() == false) continue; - + switch (exe_symbol->GetType()) { default: break; - + case eSymbolTypeCode: { // For each N_FUN, or function that we run into in the debug map @@ -112,7 +111,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa // before we parse any dwarf info so that when it goes get parsed // all section/offset addresses that get registered will resolve // correctly to the new addresses in the main executable. - + // First we find the original symbol in the .o file's symbol table Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType (exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), eSymbolTypeCode, @@ -125,11 +124,11 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa exe_symbol->GetAddress().GetFileAddress(), oso_fun_symbol->GetAddress().GetFileAddress(), std::min<addr_t>(exe_symbol->GetByteSize(), oso_fun_symbol->GetByteSize())); - + } } break; - + case eSymbolTypeData: { // For each N_GSYM we remap the address for the global by making @@ -144,13 +143,12 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa // fix up these addresses further after all globals have been // parsed to span the gaps, or we can find the global variable // sizes from the DWARF info as we are parsing. - + // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType (exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny); - if (exe_symbol && oso_gsym_symbol && exe_symbol->ValueIsAddress() && oso_gsym_symbol->ValueIsAddress()) @@ -166,7 +164,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa } } } - + exe_symfile->FinalizeOSOFileRanges (this); // We don't need the symbols anymore for the .o files oso_objfile->ClearSymtab(); @@ -216,7 +214,7 @@ public: SymbolVendor* symbol_vendor = Module::GetSymbolVendor(can_create, feedback_strm); if (symbol_vendor) { - // Set a a pointer to this class to set our OSO DWARF file know + // Set a pointer to this class to set our OSO DWARF file know // that the DWARF is being used along with a debug map and that // it will have the remapped sections that we do below. SymbolFileDWARF *oso_symfile = SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(symbol_vendor->GetSymbolFile()); @@ -308,7 +306,7 @@ void SymbolFileDWARFDebugMap::InitializeObject() { // Install our external AST source callbacks so we can complete Clang types. - llvm::OwningPtr<clang::ExternalASTSource> ast_source_ap ( + llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap ( new ClangExternalASTSourceCallbacks (SymbolFileDWARFDebugMap::CompleteTagDecl, SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl, NULL, @@ -341,6 +339,7 @@ SymbolFileDWARFDebugMap::InitOSO() case ObjectFile::eTypeObjectFile: case ObjectFile::eTypeStubLibrary: case ObjectFile::eTypeUnknown: + case ObjectFile::eTypeJIT: return; case ObjectFile::eTypeExecutable: @@ -505,10 +504,16 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf // use the debug map, to add new sections to each .o file and // even though a .o file might not have changed, the sections // that get added to the .o file can change. + ArchSpec oso_arch; + // Only adopt the architecture from the module (not the vendor or OS) + // since .o files for "i386-apple-ios" will historically show up as "i386-apple-macosx" + // due to the lack of a LC_VERSION_MIN_MACOSX or LC_VERSION_MIN_IPHONEOS + // load command... + oso_arch.SetTriple(m_obj_file->GetModule()->GetArchitecture().GetTriple().getArchName().str().c_str()); comp_unit_info->oso_sp->module_sp.reset (new DebugMapModule (obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file, - m_obj_file->GetModule()->GetArchitecture(), + oso_arch, oso_object ? &oso_object : NULL, 0, oso_object ? &comp_unit_info->oso_mod_time : NULL)); diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 06330b9..1493292 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -393,7 +393,7 @@ protected: LinkOSOFileAddress (SymbolFileDWARF *oso_symfile, lldb::addr_t oso_file_addr); //------------------------------------------------------------------ - /// Given a line table full of lines with "file adresses" that are + /// Given a line table full of lines with "file addresses" that are /// for a .o file represented by \a oso_symfile, link a new line table /// and return it. /// @@ -405,7 +405,7 @@ protected: /// /// @return /// Returns a valid line table full of linked addresses, or NULL - /// if none of the line table adresses exist in the main + /// if none of the line table addresses exist in the main /// executable. //------------------------------------------------------------------ lldb_private::LineTable * diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 9beba51..8e85d48 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -145,7 +145,7 @@ SymbolFileSymtab::GetNumCompileUnits() if (m_source_indexes.empty()) return 0; - // If we have any source file symbols we will logically orgnize the object symbols + // If we have any source file symbols we will logically organize the object symbols // using these. return m_source_indexes.size(); } @@ -366,20 +366,6 @@ SymbolFileSymtab::FindFunctions(const RegularExpression& regex, bool include_inl return 0; } -static int CountMethodArgs(const char *method_signature) -{ - int num_args = 0; - - for (const char *colon_pos = strchr(method_signature, ':'); - colon_pos != NULL; - colon_pos = strchr(colon_pos + 1, ':')) - { - num_args++; - } - - return num_args; -} - uint32_t SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, |