aboutsummaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/lldb-private-enumerations.h7
-rw-r--r--lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp40
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp75
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h10
-rw-r--r--lldb/source/Utility/RegisterValue.cpp2
5 files changed, 69 insertions, 65 deletions
diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h
index b8f5045..68e060f 100644
--- a/lldb/include/lldb/lldb-private-enumerations.h
+++ b/lldb/include/lldb/lldb-private-enumerations.h
@@ -240,6 +240,13 @@ enum LoadDependentFiles {
eLoadDependentsNo,
};
+/// Useful for callbacks whose return type indicates
+/// whether to continue iteration or short-circuit.
+enum class IterationAction {
+ Continue = 0,
+ Stop,
+};
+
inline std::string GetStatDescription(lldb_private::StatisticKind K) {
switch (K) {
case StatisticKind::ExpressionSuccessful:
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
index a39aa228..5459981 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -84,51 +84,43 @@ void DynamicLoaderStatic::LoadAllImagesAtFileAddresses() {
// Disable JIT for static dynamic loader targets
m_process->SetCanJIT(false);
+ Target &target = m_process->GetTarget();
for (ModuleSP module_sp : module_list.Modules()) {
if (module_sp) {
bool changed = false;
+ bool no_load_addresses = true;
+ // If this module has a section with a load address set in
+ // the target, assume all necessary work is already done. There
+ // may be sections without a load address set intentionally
+ // and we don't want to mutate that.
+ // For a module with no load addresses set, set the load addresses
+ // to slide == 0, the same as the file addresses, in the target.
ObjectFile *image_object_file = module_sp->GetObjectFile();
if (image_object_file) {
SectionList *section_list = image_object_file->GetSectionList();
if (section_list) {
- // All sections listed in the dyld image info structure will all
- // either be fixed up already, or they will all be off by a single
- // slide amount that is determined by finding the first segment that
- // is at file offset zero which also has bytes (a file size that is
- // greater than zero) in the object file.
-
- // Determine the slide amount (if any)
const size_t num_sections = section_list->GetSize();
- size_t sect_idx = 0;
- for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
- // Iterate through the object file sections to find the first
- // section that starts of file offset zero and that has bytes in
- // the file...
+ for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
if (section_sp) {
- // If this section already has a load address set in the target,
- // don't re-set it to the file address. Something may have
- // set it to a more correct value already.
- if (m_process->GetTarget()
- .GetSectionLoadList()
- .GetSectionLoadAddress(section_sp) !=
- LLDB_INVALID_ADDRESS) {
- continue;
+ if (target.GetSectionLoadList().GetSectionLoadAddress(
+ section_sp) != LLDB_INVALID_ADDRESS) {
+ no_load_addresses = false;
+ break;
}
- if (m_process->GetTarget().SetSectionLoadAddress(
- section_sp, section_sp->GetFileAddress()))
- changed = true;
}
}
}
}
+ if (no_load_addresses)
+ module_sp->SetLoadAddress(target, 0, true /*value_is_offset*/, changed);
if (changed)
loaded_module_list.AppendIfNeeded(module_sp);
}
}
- m_process->GetTarget().ModulesDidLoad(loaded_module_list);
+ target.ModulesDidLoad(loaded_module_list);
}
ThreadPlanSP
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 4bc2cfd..1de5858 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -37,6 +37,7 @@
#include "LogChannelDWARF.h"
#include "SymbolFileDWARF.h"
+#include "lldb/lldb-private-enumerations.h"
#include <memory>
#include <optional>
@@ -803,13 +804,13 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID(
bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) {
bool success = false;
if (compiler_type) {
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
if (oso_dwarf->HasForwardDeclForCompilerType(compiler_type)) {
oso_dwarf->CompleteType(compiler_type);
success = true;
- return true;
+ return IterationAction::Stop;
}
- return false;
+ return IterationAction::Continue;
});
}
return success;
@@ -915,7 +916,7 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
uint32_t total_matches = 0;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
const uint32_t old_size = variables.GetSize();
oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
variables);
@@ -925,18 +926,18 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
// Are we getting all matches?
if (max_matches == UINT32_MAX)
- return false; // Yep, continue getting everything
+ return IterationAction::Continue; // Yep, continue getting everything
// If we have found enough matches, lets get out
if (max_matches >= total_matches)
- return true;
+ return IterationAction::Stop;
// Update the max matches for any subsequent calls to find globals in any
// other object files with DWARF
max_matches -= oso_matches;
}
- return false;
+ return IterationAction::Continue;
});
}
@@ -945,7 +946,7 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
uint32_t total_matches = 0;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
const uint32_t old_size = variables.GetSize();
oso_dwarf->FindGlobalVariables(regex, max_matches, variables);
@@ -955,18 +956,18 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
// Are we getting all matches?
if (max_matches == UINT32_MAX)
- return false; // Yep, continue getting everything
+ return IterationAction::Continue; // Yep, continue getting everything
// If we have found enough matches, lets get out
if (max_matches >= total_matches)
- return true;
+ return IterationAction::Stop;
// Update the max matches for any subsequent calls to find globals in any
// other object files with DWARF
max_matches -= oso_matches;
}
- return false;
+ return IterationAction::Continue;
});
}
@@ -1071,7 +1072,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(
LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
lookup_info.GetLookupName().GetCString());
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
uint32_t sc_idx = sc_list.GetSize();
oso_dwarf->FindFunctions(lookup_info, parent_decl_ctx, include_inlines,
sc_list);
@@ -1079,7 +1080,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
sc_idx);
}
- return false;
+ return IterationAction::Continue;
});
}
@@ -1090,7 +1091,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
regex.GetText().str().c_str());
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
uint32_t sc_idx = sc_list.GetSize();
oso_dwarf->FindFunctions(regex, include_inlines, sc_list);
@@ -1098,7 +1099,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
sc_idx);
}
- return false;
+ return IterationAction::Continue;
});
}
@@ -1121,9 +1122,9 @@ void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
}
} else {
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
- return false;
+ return IterationAction::Continue;
});
}
}
@@ -1141,9 +1142,9 @@ SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(
TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
const DWARFDIE &die) {
TypeSP type_sp;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
- return ((bool)type_sp);
+ return type_sp ? IterationAction::Stop : IterationAction::Continue;
});
return type_sp;
}
@@ -1152,13 +1153,13 @@ bool SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type(
SymbolFileDWARF *skip_dwarf_oso) {
if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolCalculate) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
if (skip_dwarf_oso != oso_dwarf &&
oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(nullptr)) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
- return true;
+ return IterationAction::Stop;
}
- return false;
+ return IterationAction::Continue;
});
}
return m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolYes;
@@ -1217,10 +1218,10 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
if (!must_be_implementation) {
TypeSP type_sp;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE(
die, type_name, must_be_implementation);
- return (bool)type_sp;
+ return type_sp ? IterationAction::Stop : IterationAction::Continue;
});
return type_sp;
@@ -1231,9 +1232,10 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery &query,
TypeResults &results) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
oso_dwarf->FindTypes(query, results);
- return results.Done(query); // Keep iterating if we aren't done.
+ return results.Done(query) ? IterationAction::Stop
+ : IterationAction::Continue;
});
}
@@ -1243,23 +1245,24 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
CompilerDeclContext matching_namespace;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
matching_namespace =
oso_dwarf->FindNamespace(name, parent_decl_ctx, only_root_namespaces);
- return (bool)matching_namespace;
+ return matching_namespace ? IterationAction::Stop
+ : IterationAction::Continue;
});
return matching_namespace;
}
void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) {
- ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) {
oso_dwarf->DumpClangAST(s);
// The underlying assumption is that DumpClangAST(...) will obtain the
// AST from the underlying TypeSystem and therefore we only need to do
// this once and can stop after the first iteration hence we return true.
- return true;
+ return IterationAction::Stop;
});
}
@@ -1389,9 +1392,9 @@ SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
void SymbolFileDWARFDebugMap::ParseDeclsForContext(
lldb_private::CompilerDeclContext decl_ctx) {
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
oso_dwarf->ParseDeclsForContext(decl_ctx);
- return false; // Keep iterating
+ return IterationAction::Continue;
});
}
@@ -1519,14 +1522,14 @@ SymbolFileDWARFDebugMap::AddOSOARanges(SymbolFileDWARF *dwarf2Data,
ModuleList SymbolFileDWARFDebugMap::GetDebugInfoModules() {
ModuleList oso_modules;
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
ObjectFile *oso_objfile = oso_dwarf->GetObjectFile();
if (oso_objfile) {
ModuleSP module_sp = oso_objfile->GetModule();
if (module_sp)
oso_modules.Append(module_sp);
}
- return false; // Keep iterating
+ return IterationAction::Continue;
});
return oso_modules;
}
@@ -1579,8 +1582,8 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
void SymbolFileDWARFDebugMap::GetCompileOptions(
std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
- ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
oso_dwarf->GetCompileOptions(args);
- return false;
+ return IterationAction::Continue;
});
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index d639ee50..de22dd6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -20,6 +20,7 @@
#include "UniqueDWARFASTType.h"
#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-private-enumerations.h"
class DWARFASTParserClang;
@@ -233,13 +234,14 @@ protected:
SymbolFileDWARF *GetSymbolFileByOSOIndex(uint32_t oso_idx);
- // If closure returns "false", iteration continues. If it returns
- // "true", iteration terminates.
- void ForEachSymbolFile(std::function<bool(SymbolFileDWARF *)> closure) {
+ /// If closure returns \ref IterationAction::Continue, iteration
+ /// continues. Otherwise, iteration terminates.
+ void
+ ForEachSymbolFile(std::function<IterationAction(SymbolFileDWARF *)> closure) {
for (uint32_t oso_idx = 0, num_oso_idxs = m_compile_unit_infos.size();
oso_idx < num_oso_idxs; ++oso_idx) {
if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
- if (closure(oso_dwarf))
+ if (closure(oso_dwarf) == IterationAction::Stop)
return;
}
}
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index fa92ba8..cbf8402 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -199,7 +199,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo &reg_info,
else if (reg_info.byte_size <= 16) {
uint64_t data1 = src.GetU64(&src_offset);
uint64_t data2 = src.GetU64(&src_offset);
- if (src.GetByteSize() == eByteOrderBig) {
+ if (src.GetByteOrder() == eByteOrderBig) {
int128.x[0] = data1;
int128.x[1] = data2;
} else {