aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp96
1 files changed, 49 insertions, 47 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 027a4caf5555..c0bf13e0281d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -21,6 +21,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
@@ -95,6 +96,7 @@
using namespace lldb;
using namespace lldb_private;
+using namespace lldb_private::dwarf;
LLDB_PLUGIN_DEFINE(SymbolFileDWARF)
@@ -272,7 +274,7 @@ TypeList &SymbolFileDWARF::GetTypeList() {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile())
return debug_map_symfile->GetTypeList();
- return SymbolFile::GetTypeList();
+ return SymbolFileCommon::GetTypeList();
}
void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset,
dw_offset_t max_die_offset, uint32_t type_mask,
@@ -405,7 +407,7 @@ SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die) {
SymbolFileDWARF::SymbolFileDWARF(ObjectFileSP objfile_sp,
SectionList *dwo_section_list)
- : SymbolFile(std::move(objfile_sp)),
+ : SymbolFileCommon(std::move(objfile_sp)),
UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to
// when this class parses .o files to
// contain the .o file index/ID
@@ -564,23 +566,21 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
if (section)
debug_line_file_size = section->GetFileSize();
} else {
- const char *symfile_dir_cstr =
- m_objfile_sp->GetFileSpec().GetDirectory().GetCString();
- if (symfile_dir_cstr) {
- if (strcasestr(symfile_dir_cstr, ".dsym")) {
- if (m_objfile_sp->GetType() == ObjectFile::eTypeDebugInfo) {
- // We have a dSYM file that didn't have a any debug info. If the
- // string table has a size of 1, then it was made from an
- // executable with no debug info, or from an executable that was
- // stripped.
- section =
- section_list->FindSectionByType(eSectionTypeDWARFDebugStr, true)
- .get();
- if (section && section->GetFileSize() == 1) {
- m_objfile_sp->GetModule()->ReportWarning(
- "empty dSYM file detected, dSYM was created with an "
- "executable with no debug info.");
- }
+ llvm::StringRef symfile_dir =
+ m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef();
+ if (symfile_dir.contains_insensitive(".dsym")) {
+ if (m_objfile_sp->GetType() == ObjectFile::eTypeDebugInfo) {
+ // We have a dSYM file that didn't have a any debug info. If the
+ // string table has a size of 1, then it was made from an
+ // executable with no debug info, or from an executable that was
+ // stripped.
+ section =
+ section_list->FindSectionByType(eSectionTypeDWARFDebugStr, true)
+ .get();
+ if (section && section->GetFileSize() == 1) {
+ m_objfile_sp->GetModule()->ReportWarning(
+ "empty dSYM file detected, dSYM was created with an "
+ "executable with no debug info.");
}
}
}
@@ -825,8 +825,8 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err), "Unable to parse function");
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
+ "Unable to parse function");
return nullptr;
}
DWARFASTParser *dwarf_ast = type_system_or_err->GetDWARFParser();
@@ -1371,9 +1371,9 @@ user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
if (GetDebugMapSymfile())
return GetID() | ref.die_offset();
- lldbassert(GetDwoNum().getValueOr(0) <= 0x3fffffff);
- return user_id_t(GetDwoNum().getValueOr(0)) << 32 | ref.die_offset() |
- lldb::user_id_t(GetDwoNum().hasValue()) << 62 |
+ lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff);
+ return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() |
+ lldb::user_id_t(GetDwoNum().has_value()) << 62 |
lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
}
@@ -1744,8 +1744,14 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
dwo_file.AppendPathComponent(dwo_name);
}
- if (!FileSystem::Instance().Exists(dwo_file))
+ if (!FileSystem::Instance().Exists(dwo_file)) {
+ if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
+ GetObjectFile()->GetModule()->ReportWarning(
+ "unable to locate separate debug file (dwo, dwp). Debugging will be "
+ "degraded.");
+ }
return nullptr;
+ }
const lldb::offset_t file_offset = 0;
DataBufferSP dwo_file_data_sp;
@@ -1891,7 +1897,7 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
lldb::addr_t byte_size = 1;
if (var_sp->GetType())
byte_size =
- var_sp->GetType()->GetByteSize(nullptr).getValueOr(0);
+ var_sp->GetType()->GetByteSize(nullptr).value_or(0);
m_global_aranges_up->Append(GlobalVariableMap::Entry(
file_addr, byte_size, var_sp.get()));
}
@@ -2098,8 +2104,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
auto type_system_or_err = GetTypeSystemForLanguage(
decl_ctx_type_system->GetMinimumLanguage(nullptr));
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err),
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
"Unable to match namespace decl using TypeSystem");
return false;
}
@@ -2868,10 +2873,9 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
if (language != eLanguageTypeUnknown) {
auto type_system_or_err = GetTypeSystemForLanguage(language);
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(
- lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err), "Cannot get TypeSystem for language {}",
- Language::GetNameForLanguageType(language));
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
+ "Cannot get TypeSystem for language {}",
+ Language::GetNameForLanguageType(language));
} else {
type_system = &type_system_or_err.get();
}
@@ -2967,8 +2971,8 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err), "Unable to parse type");
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
+ "Unable to parse type");
return {};
}
@@ -3240,7 +3244,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
DataExtractor data = die.GetCU()->GetLocationData();
dw_offset_t offset = location_form.Unsigned();
if (location_form.Form() == DW_FORM_loclistx)
- offset = die.GetCU()->GetLoclistOffset(offset).getValueOr(-1);
+ offset = die.GetCU()->GetLoclistOffset(offset).value_or(-1);
if (data.ValidOffset(offset)) {
data = DataExtractor(data, offset, data.GetByteSize() - offset);
location = DWARFExpression(module, data, die.GetCU());
@@ -3461,7 +3465,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
if (use_type_size_for_value && type_sp->GetType())
location.UpdateValue(const_value_form.Unsigned(),
- type_sp->GetType()->GetByteSize(nullptr).getValueOr(0),
+ type_sp->GetType()->GetByteSize(nullptr).value_or(0),
die.GetCU()->GetAddressByteSize());
return std::make_shared<Variable>(
@@ -3801,7 +3805,7 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
if (!has_call_edges)
return {};
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ Log *log = GetLog(LLDBLog::Step);
LLDB_LOG(log, "CollectCallEdges: Found call site info in {0}",
function_die.GetPubname());
@@ -3924,7 +3928,7 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
if (log) {
StreamString call_target_desc;
call_target->GetDescription(&call_target_desc, eDescriptionLevelBrief,
- LLDB_INVALID_ADDRESS, nullptr);
+ nullptr);
LLDB_LOG(log, "CollectCallEdges: Found indirect call target: {0}",
call_target_desc.GetString());
}
@@ -3937,11 +3941,9 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
for (const CallSiteParameter &param : parameters) {
StreamString callee_loc_desc, caller_loc_desc;
param.LocationInCallee.GetDescription(&callee_loc_desc,
- eDescriptionLevelBrief,
- LLDB_INVALID_ADDRESS, nullptr);
+ eDescriptionLevelBrief, nullptr);
param.LocationInCaller.GetDescription(&caller_loc_desc,
- eDescriptionLevelBrief,
- LLDB_INVALID_ADDRESS, nullptr);
+ eDescriptionLevelBrief, nullptr);
LLDB_LOG(log, "CollectCallEdges: \tparam: {0} => {1}",
callee_loc_desc.GetString(), caller_loc_desc.GetString());
}
@@ -3966,7 +3968,7 @@ SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
}
void SymbolFileDWARF::Dump(lldb_private::Stream &s) {
- SymbolFile::Dump(s);
+ SymbolFileCommon::Dump(s);
m_index->Dump(s);
}
@@ -3985,8 +3987,8 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
if (m_debug_map_symfile == nullptr) {
lldb::ModuleSP module_sp(m_debug_map_module_wp.lock());
if (module_sp) {
- m_debug_map_symfile =
- static_cast<SymbolFileDWARFDebugMap *>(module_sp->GetSymbolFile());
+ m_debug_map_symfile = llvm::cast<SymbolFileDWARFDebugMap>(
+ module_sp->GetSymbolFile()->GetBackingSymbolFile());
}
}
return m_debug_map_symfile;
@@ -4025,8 +4027,8 @@ llvm::Expected<TypeSystem &> SymbolFileDWARF::GetTypeSystem(DWARFUnit &unit) {
DWARFASTParser *SymbolFileDWARF::GetDWARFParser(DWARFUnit &unit) {
auto type_system_or_err = GetTypeSystem(unit);
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err), "Unable to get DWARFASTParser");
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
+ "Unable to get DWARFASTParser");
return nullptr;
}
return type_system_or_err->GetDWARFParser();