diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
commit | 74a628f776edb588bff8f8f5cc16eac947c9d631 (patch) | |
tree | dc32e010ac4902621e5a279bfeb48628f7f0e166 /source/Plugins/SymbolFile/DWARF | |
parent | afed7be32164a598f8172282c249af7266c48b46 (diff) | |
download | src-74a628f776edb588bff8f8f5cc16eac947c9d631.tar.gz src-74a628f776edb588bff8f8f5cc16eac947c9d631.zip |
Vendor import of lldb trunk r300422:vendor/lldb/lldb-trunk-r300422
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=317027
svn path=/vendor/lldb/lldb-trunk-r300422/; revision=317028; tag=vendor/lldb/lldb-trunk-r300422
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF')
30 files changed, 116 insertions, 353 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/source/Plugins/SymbolFile/DWARF/CMakeLists.txt index 5ce20cc0989c..fb468440f9e0 100644 --- a/source/Plugins/SymbolFile/DWARF/CMakeLists.txt +++ b/source/Plugins/SymbolFile/DWARF/CMakeLists.txt @@ -1,4 +1,4 @@ -add_lldb_library(lldbPluginSymbolFileDWARF +add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN DIERef.cpp DWARFAbbreviationDeclaration.cpp DWARFASTParserClang.cpp @@ -32,4 +32,20 @@ add_lldb_library(lldbPluginSymbolFileDWARF SymbolFileDWARFDwo.cpp SymbolFileDWARFDebugMap.cpp UniqueDWARFASTType.cpp + + LINK_LIBS + clangAST + clangBasic + lldbCore + lldbExpression + lldbHost + lldbInterpreter + lldbSymbol + lldbTarget + lldbUtility + lldbPluginObjCLanguage + lldbPluginCPlusPlusLanguage + lldbPluginExpressionParserClang + LINK_COMPONENTS + Support ) diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index c064d61d71d4..e2902d5ef787 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -21,9 +21,7 @@ #include "UniqueDWARFASTType.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" @@ -38,6 +36,8 @@ #include "lldb/Symbol/TypeMap.h" #include "lldb/Target/Language.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp index 0cf7ff2b938f..2e5be393dea2 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp @@ -2,14 +2,14 @@ #include "DWARFASTParserOCaml.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Utility/Error.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 6d3ff8e35910..ef499a6d5615 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -10,15 +10,16 @@ #include "DWARFCompileUnit.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" +#include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Stream.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Host/StringConvert.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" #include "DWARFDIECollection.h" #include "DWARFDebugAbbrev.h" @@ -256,16 +257,15 @@ size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) { m_die_array.end()); exact_size_die_array.swap(m_die_array); } - Log *verbose_log( - LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE)); - if (verbose_log) { + Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); + if (log && log->GetVerbose()) { StreamString strm; 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->PutString(strm.GetString()); + log->PutString(strm.GetString()); } if (!m_dwo_symbol_file) @@ -324,18 +324,14 @@ bool DWARFCompileUnit::Verify(Stream *s) const { bool abbr_offset_OK = m_dwarf2Data->get_debug_abbrev_data().ValidOffset(GetAbbrevOffset()); bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8)); - bool verbose = s->GetVerbose(); if (valid_offset && length_OK && version_OK && addr_size_OK && abbr_offset_OK) { - if (verbose) - s->Printf(" 0x%8.8x: OK\n", m_offset); return true; } else { s->Printf(" 0x%8.8x: ", m_offset); - - m_dwarf2Data->get_debug_info_data().Dump(s, m_offset, lldb::eFormatHex, 1, - Size(), 32, LLDB_INVALID_ADDRESS, - 0, 0); + DumpDataExtractor(m_dwarf2Data->get_debug_info_data(), s, m_offset, + lldb::eFormatHex, 1, Size(), 32, LLDB_INVALID_ADDRESS, 0, + 0); s->EOL(); if (valid_offset) { if (!length_OK) diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp index 5fb63589591e..1e5bf619f798 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp @@ -11,7 +11,7 @@ #include <algorithm> -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" using namespace lldb_private; using namespace std; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h index 62ddbe8ecd5a..46d09f1ca237 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h @@ -11,12 +11,12 @@ #define liblldb_DWARFDataExtractor_h_ // Other libraries and framework includes. -#include "lldb/Core/DataExtractor.h" #include "lldb/Core/dwarf.h" +#include "lldb/Utility/DataExtractor.h" namespace lldb_private { -class DWARFDataExtractor : public lldb_private::DataExtractor { +class DWARFDataExtractor : public DataExtractor { public: DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {} diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp index fe6df913b762..d681925daeac 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp @@ -9,7 +9,7 @@ #include "DWARFDebugAbbrev.h" #include "DWARFDataExtractor.h" -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp index 06b46f0569eb..cecb69c8fb46 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp @@ -10,7 +10,7 @@ #include "DWARFDebugArangeSet.h" #include "SymbolFileDWARF.h" -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" #include <assert.h> using namespace lldb_private; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index 5e71e9dfcbb3..d571c512658e 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -14,9 +14,9 @@ #include <algorithm> -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "DWARFCompileUnit.h" #include "DWARFDebugInfo.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 9dc656d79326..eff9850d435d 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -12,10 +12,10 @@ #include <algorithm> #include <set> -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Stream.h" #include "DWARFCompileUnit.h" #include "DWARFDebugAranges.h" @@ -430,10 +430,6 @@ static dw_offset_t DumpCallback(SymbolFileDWARF *dwarf2Data, } else { // See if the DIE is in this compile unit? if (cu && dumpInfo->die_offset < cu->GetNextCompileUnitOffset()) { - // This DIE is in this compile unit! - if (s->GetVerbose()) - cu->Dump(s); // Dump the compile unit for the DIE in verbose mode - return next_offset; // // We found our compile unit that contains our DIE, just skip to // dumping the requested DIE... diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index a05a8886bb48..be4e18b12be0 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -15,7 +15,7 @@ #include "DWARFDIE.h" #include "SymbolFileDWARF.h" -#include "lldb/lldb-private.h" +#include "lldb/Core/STLUtils.h" #include "lldb/lldb-private.h" typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject> diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index a824c4ac6afe..e00eda4f35c5 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -14,9 +14,9 @@ #include <algorithm> #include "lldb/Core/Module.h" -#include "lldb/Core/Stream.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Stream.h" #include "DWARFCompileUnit.h" #include "DWARFDIECollection.h" @@ -666,13 +666,9 @@ void DWARFDebugInfoEntry::DumpAttribute( SymbolFileDWARF *dwarf2Data, const DWARFCompileUnit *cu, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, Stream &s, dw_attr_t attr, dw_form_t form) { - bool verbose = s.GetVerbose(); bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm); - if (verbose) - s.Offset(*offset_ptr); - else - s.Printf(" "); + s.Printf(" "); s.Indent(DW_AT_value_to_name(attr)); if (show_form) { @@ -694,35 +690,18 @@ void DWARFDebugInfoEntry::DumpAttribute( s.PutCString("( "); - // Always dump form value if verbose is enabled - if (verbose) { - form_value.Dump(s); - } - // Check to see if we have any special attribute formatters switch (attr) { case DW_AT_stmt_list: - if (verbose) - s.PutCString(" ( "); s.Printf("0x%8.8" PRIx64, form_value.Unsigned()); - if (verbose) - s.PutCString(" )"); break; case DW_AT_language: - if (verbose) - s.PutCString(" ( "); s.PutCString(DW_LANG_value_to_name(form_value.Unsigned())); - if (verbose) - s.PutCString(" )"); break; case DW_AT_encoding: - if (verbose) - s.PutCString(" ( "); s.PutCString(DW_ATE_value_to_name(form_value.Unsigned())); - if (verbose) - s.PutCString(" )"); break; case DW_AT_frame_base: @@ -730,32 +709,20 @@ void DWARFDebugInfoEntry::DumpAttribute( case DW_AT_data_member_location: { const uint8_t *blockData = form_value.BlockData(); if (blockData) { - if (!verbose) - form_value.Dump(s); - // Location description is inlined in data in the form value DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned()); - if (verbose) - s.PutCString(" ( "); DWARFExpression::PrintDWARFExpression( s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false); - if (verbose) - s.PutCString(" )"); } else { // We have a location list offset as the value that is // the offset into the .debug_loc section that describes // the value over it's lifetime uint64_t debug_loc_offset = form_value.Unsigned(); if (dwarf2Data) { - if (!verbose) - form_value.Dump(s); DWARFExpression::PrintDWARFLocationList( s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset); - } else { - if (!verbose) - form_value.Dump(s); } } } break; @@ -765,25 +732,17 @@ void DWARFDebugInfoEntry::DumpAttribute( uint64_t abstract_die_offset = form_value.Reference(); form_value.Dump(s); // *ostrm_ptr << HEX32 << abstract_die_offset << " ( "; - if (verbose) - s.PutCString(" ( "); GetName(dwarf2Data, cu, abstract_die_offset, s); - if (verbose) - s.PutCString(" )"); } break; case DW_AT_type: { uint64_t type_die_offset = form_value.Reference(); - if (!verbose) - form_value.Dump(s); s.PutCString(" ( "); AppendTypeName(dwarf2Data, cu, type_die_offset, s); s.PutCString(" )"); } break; case DW_AT_ranges: { - if (!verbose) - form_value.Dump(s); lldb::offset_t ranges_offset = form_value.Unsigned(); dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0; if (dwarf2Data) @@ -792,8 +751,6 @@ void DWARFDebugInfoEntry::DumpAttribute( } break; default: - if (!verbose) - form_value.Dump(s); break; } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp index bce21c44b73e..077675be2271 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -13,10 +13,10 @@ #include <assert.h> #include "lldb/Core/FileSpecList.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" +#include "lldb/Utility/Log.h" #include "LogChannelDWARF.h" #include "SymbolFileDWARF.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp index d56463039a19..19074b8865ff 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp @@ -12,7 +12,7 @@ #include "DWARFDebugMacinfoEntry.h" #include "SymbolFileDWARF.h" -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" using namespace lldb_private; using namespace std; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp index 45498590236f..f078fbd44f2f 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp @@ -9,7 +9,7 @@ #include "DWARFDebugMacinfoEntry.h" -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" using namespace lldb_private; using namespace std; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp index d4281bac79a1..81e27f2bc95e 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp @@ -9,8 +9,8 @@ #include "DWARFDebugPubnames.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" +#include "lldb/Utility/Stream.h" #include "DWARFCompileUnit.h" #include "DWARFDIECollection.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp index 4518d65811b5..21e2482783a1 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp @@ -9,8 +9,8 @@ #include "DWARFDebugPubnamesSet.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/RegularExpression.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/RegularExpression.h" #include "SymbolFileDWARF.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h index 9654ee3d6da7..6e7d3f38aa85 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h @@ -11,6 +11,7 @@ #define SymbolFileDWARF_DWARFDebugPubnamesSet_h_ #include "SymbolFileDWARF.h" +#include <map> #include <string> #include <vector> #if __cplusplus >= 201103L || defined(_MSC_VER) @@ -19,6 +20,8 @@ #include <ext/hash_map> #endif +#include "lldb/Core/STLUtils.h" + class DWARFDebugPubnamesSet { public: struct Header { diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index ef3566855298..515c083fedb0 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -9,7 +9,7 @@ #include "DWARFDebugRanges.h" #include "SymbolFileDWARF.h" -#include "lldb/Core/Stream.h" +#include "lldb/Utility/Stream.h" #include <assert.h> using namespace lldb_private; @@ -82,7 +82,6 @@ void DWARFDebugRanges::Dump(Stream &s, lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr) { uint32_t addr_size = s.GetAddressByteSize(); - bool verbose = s.GetVerbose(); dw_addr_t base_addr = cu_base_addr; while ( @@ -95,10 +94,6 @@ void DWARFDebugRanges::Dump(Stream &s, begin = LLDB_INVALID_ADDRESS; s.Indent(); - if (verbose) { - s.AddressRange(begin, end, sizeof(dw_addr_t), " offsets = "); - } - if (begin == 0 && end == 0) { s.PutCString(" End"); break; @@ -111,8 +106,7 @@ void DWARFDebugRanges::Dump(Stream &s, dw_addr_t begin_addr = begin + base_addr; dw_addr_t end_addr = end + base_addr; - s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), - verbose ? " ==> addrs = " : NULL); + s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), NULL); } } } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h index 0d0a5a317262..1f3c59768fdf 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h @@ -15,7 +15,7 @@ #include <string> #include <vector> // Other libraries and framework includes -#include "lldb/Core/ConstString.h" +#include "lldb/Utility/ConstString.h" // Project includes #include "DWARFDefines.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp index c5260bb1cb1a..f0d66720c55c 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "DWARFDefines.h" -#include "lldb/Core/ConstString.h" +#include "lldb/Utility/ConstString.h" #include <cstdio> #include <cstring> #include <string> diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 39c52a8a5e57..0853671ee874 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -9,8 +9,8 @@ #include <assert.h> -#include "lldb/Core/Stream.h" #include "lldb/Core/dwarf.h" +#include "lldb/Utility/Stream.h" #include "DWARFCompileUnit.h" #include "DWARFFormValue.h" @@ -406,8 +406,6 @@ void DWARFFormValue::Dump(Stream &s) const { uint64_t uvalue = Unsigned(); bool cu_relative_offset = false; - bool verbose = s.GetVerbose(); - switch (m_form) { case DW_FORM_addr: s.Address(uvalue, sizeof(uint64_t)); @@ -476,8 +474,6 @@ void DWARFFormValue::Dump(Stream &s) const { case DW_FORM_strp: { const char *dbg_str = AsCString(); if (dbg_str) { - if (verbose) - s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); s.QuotedCString(dbg_str); } else { s.PutHex32(uvalue); @@ -496,28 +492,18 @@ void DWARFFormValue::Dump(Stream &s) const { } case DW_FORM_ref1: cu_relative_offset = true; - if (verbose) - s.Printf("cu + 0x%2.2x", (uint8_t)uvalue); break; case DW_FORM_ref2: cu_relative_offset = true; - if (verbose) - s.Printf("cu + 0x%4.4x", (uint16_t)uvalue); break; case DW_FORM_ref4: cu_relative_offset = true; - if (verbose) - s.Printf("cu + 0x%4.4x", (uint32_t)uvalue); break; case DW_FORM_ref8: cu_relative_offset = true; - if (verbose) - s.Printf("cu + 0x%8.8" PRIx64, uvalue); break; case DW_FORM_ref_udata: cu_relative_offset = true; - if (verbose) - s.Printf("cu + 0x%" PRIx64, uvalue); break; // All DW_FORM_indirect attributes should be resolved prior to calling this @@ -535,9 +521,6 @@ void DWARFFormValue::Dump(Stream &s) const { if (cu_relative_offset) { assert(m_cu); // CU must be valid for DW_FORM_ref forms that are compile // unit relative or we will get this wrong - if (verbose) - s.PutCString(" => "); - s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_cu->GetOffset()); } } diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index c1cb30b60045..959517529e52 100644 --- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -13,8 +13,8 @@ #include <vector> #include "lldb/Core/MappedHash.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Core/dwarf.h" +#include "lldb/Utility/RegularExpression.h" #include "lldb/lldb-defines.h" #include "DWARFDefines.h" diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp index 1385e3dd28de..0b06713f9543 100644 --- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp +++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp @@ -9,195 +9,35 @@ #include "LogChannelDWARF.h" -#include "SymbolFileDWARF.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/StreamFile.h" -#include "lldb/Interpreter/Args.h" - -using namespace lldb; using namespace lldb_private; -// when the one and only logging channel is enabled, then this will be non NULL. -static LogChannelDWARF *g_log_channel = NULL; - -LogChannelDWARF::LogChannelDWARF() : LogChannel() {} - -LogChannelDWARF::~LogChannelDWARF() {} +static constexpr Log::Category g_categories[] = { + {{"aranges"}, + {"log the parsing of .debug_aranges"}, + DWARF_LOG_DEBUG_ARANGES}, + {{"comp"}, + {"log insertions of object files into DWARF debug maps"}, + DWARF_LOG_TYPE_COMPLETION}, + {{"info"}, {"log the parsing of .debug_info"}, DWARF_LOG_DEBUG_INFO}, + {{"line"}, {"log the parsing of .debug_line"}, DWARF_LOG_DEBUG_LINE}, + {{"lookups"}, + {"log any lookups that happen by name, regex, or address"}, + DWARF_LOG_LOOKUPS}, + {{"map"}, + {"log struct/unions/class type completions"}, + DWARF_LOG_DEBUG_MAP}, + {{"pubnames"}, + {"log the parsing of .debug_pubnames"}, + DWARF_LOG_DEBUG_PUBNAMES}, + {{"pubtypes"}, + {"log the parsing of .debug_pubtypes"}, + DWARF_LOG_DEBUG_PUBTYPES}, +}; + +Log::Channel LogChannelDWARF::g_channel(g_categories, DWARF_LOG_DEFAULT); void LogChannelDWARF::Initialize() { - PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), - LogChannelDWARF::CreateInstance); -} - -void LogChannelDWARF::Terminate() { - PluginManager::UnregisterPlugin(LogChannelDWARF::CreateInstance); -} - -LogChannel *LogChannelDWARF::CreateInstance() { return new LogChannelDWARF(); } - -lldb_private::ConstString LogChannelDWARF::GetPluginNameStatic() { - return SymbolFileDWARF::GetPluginNameStatic(); -} - -const char *LogChannelDWARF::GetPluginDescriptionStatic() { - return "DWARF log channel for debugging plug-in issues."; -} - -lldb_private::ConstString LogChannelDWARF::GetPluginName() { - return GetPluginNameStatic(); + Log::Register("dwarf", g_channel); } -uint32_t LogChannelDWARF::GetPluginVersion() { return 1; } - -void LogChannelDWARF::Delete() { g_log_channel = NULL; } - -void LogChannelDWARF::Disable(const char **categories, Stream *feedback_strm) { - if (m_log_ap.get() == NULL) - return; - - uint32_t flag_bits = m_log_ap->GetMask().Get(); - for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = categories[i]; - - if (::strcasecmp(arg, "all") == 0) - flag_bits &= ~DWARF_LOG_ALL; - else if (::strcasecmp(arg, "info") == 0) - flag_bits &= ~DWARF_LOG_DEBUG_INFO; - else if (::strcasecmp(arg, "line") == 0) - flag_bits &= ~DWARF_LOG_DEBUG_LINE; - else if (::strcasecmp(arg, "pubnames") == 0) - flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES; - else if (::strcasecmp(arg, "pubtypes") == 0) - flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES; - else if (::strcasecmp(arg, "aranges") == 0) - flag_bits &= ~DWARF_LOG_DEBUG_ARANGES; - 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 { - feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); - ListCategories(feedback_strm); - } - } - - if (flag_bits == 0) - Delete(); - else - m_log_ap->GetMask().Reset(flag_bits); - - return; -} - -bool LogChannelDWARF::Enable( - StreamSP &log_stream_sp, uint32_t log_options, - Stream *feedback_strm, // Feedback stream for argument errors etc - const char **categories // The categories to enable within this logging - // stream, if empty, enable default set - ) { - Delete(); - - if (m_log_ap) - m_log_ap->SetStream(log_stream_sp); - else - m_log_ap.reset(new Log(log_stream_sp)); - - g_log_channel = this; - uint32_t flag_bits = 0; - bool got_unknown_category = false; - for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = categories[i]; - - if (::strcasecmp(arg, "all") == 0) - flag_bits |= DWARF_LOG_ALL; - else if (::strcasecmp(arg, "info") == 0) - flag_bits |= DWARF_LOG_DEBUG_INFO; - else if (::strcasecmp(arg, "line") == 0) - flag_bits |= DWARF_LOG_DEBUG_LINE; - else if (::strcasecmp(arg, "pubnames") == 0) - flag_bits |= DWARF_LOG_DEBUG_PUBNAMES; - else if (::strcasecmp(arg, "pubtypes") == 0) - flag_bits |= DWARF_LOG_DEBUG_PUBTYPES; - else if (::strcasecmp(arg, "aranges") == 0) - flag_bits |= DWARF_LOG_DEBUG_ARANGES; - 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 { - feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); - if (got_unknown_category == false) { - got_unknown_category = true; - ListCategories(feedback_strm); - } - } - } - if (flag_bits == 0) - flag_bits = DWARF_LOG_DEFAULT; - m_log_ap->GetMask().Reset(flag_bits); - m_log_ap->GetOptions().Reset(log_options); - return m_log_ap.get() != NULL; -} - -void LogChannelDWARF::ListCategories(Stream *strm) { - strm->Printf( - "Logging categories for '%s':\n" - " all - turn on all available logging categories\n" - " info - log the parsing of .debug_info\n" - " line - log the parsing of .debug_line\n" - " pubnames - log the parsing of .debug_pubnames\n" - " pubtypes - log the parsing of .debug_pubtypes\n" - " aranges - log the parsing of .debug_aranges\n" - " lookups - log any lookups that happen by name, regex, or address\n" - " completion - log struct/unions/class type completions\n" - " map - log insertions of object files into DWARF debug maps\n", - SymbolFileDWARF::GetPluginNameStatic().GetCString()); -} - -Log *LogChannelDWARF::GetLog() { - if (g_log_channel) - return g_log_channel->m_log_ap.get(); - - return NULL; -} - -Log *LogChannelDWARF::GetLogIfAll(uint32_t mask) { - if (g_log_channel && g_log_channel->m_log_ap.get()) { - if (g_log_channel->m_log_ap->GetMask().AllSet(mask)) - return g_log_channel->m_log_ap.get(); - } - return NULL; -} - -Log *LogChannelDWARF::GetLogIfAny(uint32_t mask) { - if (g_log_channel && g_log_channel->m_log_ap.get()) { - if (g_log_channel->m_log_ap->GetMask().AnySet(mask)) - return g_log_channel->m_log_ap.get(); - } - return NULL; -} - -void LogChannelDWARF::LogIf(uint32_t mask, const char *format, ...) { - if (g_log_channel) { - Log *log = g_log_channel->m_log_ap.get(); - if (log && log->GetMask().AnySet(mask)) { - va_list args; - va_start(args, format); - log->VAPrintf(format, args); - va_end(args); - } - } -} +void LogChannelDWARF::Terminate() { Log::Unregister("dwarf"); } diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h index 4802f858f3a1..0293fbd7c495 100644 --- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h +++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h @@ -14,9 +14,8 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/Log.h" +#include "lldb/Utility/Log.h" -#define DWARF_LOG_VERBOSE (1u << 0) #define DWARF_LOG_DEBUG_INFO (1u << 1) #define DWARF_LOG_DEBUG_LINE (1u << 2) #define DWARF_LOG_DEBUG_PUBNAMES (1u << 3) @@ -28,47 +27,17 @@ #define DWARF_LOG_ALL (UINT32_MAX) #define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO) -class LogChannelDWARF : public lldb_private::LogChannel { -public: - LogChannelDWARF(); - - ~LogChannelDWARF() override; +namespace lldb_private { +class LogChannelDWARF { + static Log::Channel g_channel; +public: static void Initialize(); - static void Terminate(); - static lldb_private::ConstString GetPluginNameStatic(); - - static const char *GetPluginDescriptionStatic(); - - static lldb_private::LogChannel *CreateInstance(); - - lldb_private::ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override; - - void Disable(const char **categories, - lldb_private::Stream *feedback_strm) override; - - void Delete(); - - bool Enable(lldb::StreamSP &log_stream_sp, uint32_t log_options, - lldb_private::Stream - *feedback_strm, // Feedback stream for argument errors etc - const char **categories) override; // The categories to enable - // within this logging stream, - // if empty, enable default set - - void ListCategories(lldb_private::Stream *strm) override; - - static lldb_private::Log *GetLog(); - - static lldb_private::Log *GetLogIfAll(uint32_t mask); - - static lldb_private::Log *GetLogIfAny(uint32_t mask); - - static void LogIf(uint32_t mask, const char *format, ...); + static Log *GetLogIfAll(uint32_t mask) { return g_channel.GetLogIfAll(mask); } + static Log *GetLogIfAny(uint32_t mask) { return g_channel.GetLogIfAny(mask); } }; +} #endif // SymbolFileDWARF_LogChannelDWARF_h_ diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp index c3d90d171b79..f5f979caa38e 100644 --- a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -8,11 +8,11 @@ //===----------------------------------------------------------------------===// #include "NameToDIE.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" -#include "lldb/Core/StreamString.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" #include "DWARFCompileUnit.h" #include "DWARFDebugInfo.h" diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 5c44ee03b02c..856c371636d9 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -11,19 +11,20 @@ // Other libraries and framework includes #include "llvm/Support/Casting.h" +#include "llvm/Support/Threading.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/StreamString.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -71,6 +72,8 @@ #include "SymbolFileDWARFDebugMap.h" #include "SymbolFileDWARFDwo.h" +#include "llvm/Support/FileSystem.h" + #include <map> #include <ctype.h> @@ -190,7 +193,9 @@ static const char *resolveCompDir(const char *path_from_dwarf) { if (!is_symlink) return local_path; - if (!local_path_spec.IsSymbolicLink()) + namespace fs = llvm::sys::fs; + if (fs::get_file_type(local_path_spec.GetPath(), false) != + fs::file_type::symlink_file) return local_path; FileSpec resolved_local_path_spec; @@ -222,7 +227,7 @@ void SymbolFileDWARF::DebuggerInitialize(Debugger &debugger) { void SymbolFileDWARF::Terminate() { PluginManager::UnregisterPlugin(CreateInstance); - LogChannelDWARF::Initialize(); + LogChannelDWARF::Terminate(); } lldb_private::ConstString SymbolFileDWARF::GetPluginNameStatic() { @@ -553,8 +558,9 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { const DWARFDataExtractor & SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type, DWARFDataSegment &data_segment) { - std::call_once(data_segment.m_flag, &SymbolFileDWARF::LoadSectionData, this, - sect_type, std::ref(data_segment.m_data)); + llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] { + this->LoadSectionData(sect_type, std::ref(data_segment.m_data)); + }); return data_segment.m_data; } @@ -1935,7 +1941,7 @@ void SymbolFileDWARF::Index() { std::vector<NameToDIE> namespace_index(num_compile_units); std::vector<bool> clear_cu_dies(num_compile_units, false); - auto parser_fn = [this, debug_info, &function_basename_index, + auto parser_fn = [debug_info, &function_basename_index, &function_fullname_index, &function_method_index, &function_selector_index, &objc_class_selectors_index, &global_index, &type_index, @@ -1951,7 +1957,7 @@ void SymbolFileDWARF::Index() { return cu_idx; }; - auto extract_fn = [this, debug_info, num_compile_units](uint32_t cu_idx) { + auto extract_fn = [debug_info](uint32_t cu_idx) { DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx); if (dwarf_cu) { // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 52937697500f..14b29fa44fa3 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -21,9 +21,10 @@ // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" +#include "llvm/Support/Threading.h" + +#include "lldb/Utility/Flags.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Flags.h" #include "lldb/Core/RangeMap.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Core/dwarf.h" @@ -31,6 +32,7 @@ #include "lldb/Symbol/DebugMacros.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolFile.h" +#include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" // Project includes @@ -305,7 +307,7 @@ protected: typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE; struct DWARFDataSegment { - std::once_flag m_flag; + llvm::once_flag m_flag; lldb_private::DWARFDataExtractor m_data; }; diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 16bb578e99c2..45519663f71f 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -19,9 +19,9 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Core/Section.h" #include "lldb/Host/FileSystem.h" +#include "lldb/Utility/RegularExpression.h" //#define DEBUG_OSO_DMAP // DO NOT CHECKIN WITH THIS NOT COMMENTED OUT #if defined(DEBUG_OSO_DMAP) diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 109da631d771..dcca4268b6eb 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -11,6 +11,7 @@ #define SymbolFileDWARF_SymbolFileDWARFDebugMap_h_ #include <bitset> +#include <map> #include <vector> #include "lldb/Core/RangeMap.h" |