aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Symbol
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Symbol')
-rw-r--r--lldb/source/Symbol/CompileUnit.cpp4
-rw-r--r--lldb/source/Symbol/CompilerType.cpp47
-rw-r--r--lldb/source/Symbol/Function.cpp6
-rw-r--r--lldb/source/Symbol/LineEntry.cpp5
-rw-r--r--lldb/source/Symbol/LineTable.cpp2
-rw-r--r--lldb/source/Symbol/ObjectFile.cpp30
-rw-r--r--lldb/source/Symbol/SymbolContext.cpp29
-rw-r--r--lldb/source/Symbol/SymbolFile.cpp8
-rw-r--r--lldb/source/Symbol/Symtab.cpp28
-rw-r--r--lldb/source/Symbol/Type.cpp4
-rw-r--r--lldb/source/Symbol/TypeSystem.cpp11
11 files changed, 94 insertions, 80 deletions
diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp
index 166f111..703ef13 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -27,14 +27,14 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
language, is_optimized) {}
CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
- lldb::SupportFileSP support_file_sp,
+ SupportFileNSP support_file_nsp,
const lldb::user_id_t cu_sym_id,
lldb::LanguageType language,
lldb_private::LazyBool is_optimized,
SupportFileList &&support_files)
: ModuleChild(module_sp), UserID(cu_sym_id), m_user_data(user_data),
m_language(language), m_flags(0),
- m_primary_support_file_sp(support_file_sp),
+ m_primary_support_file_nsp(support_file_nsp),
m_support_files(std::move(support_files)), m_is_optimized(is_optimized) {
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 62c0ddf..1a39ea9 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -240,13 +240,11 @@ bool CompilerType::ShouldTreatScalarValueAsAddress() const {
return false;
}
-bool CompilerType::IsFloatingPointType(uint32_t &count,
- bool &is_complex) const {
+bool CompilerType::IsFloatingPointType(bool &is_complex) const {
if (IsValid()) {
if (auto type_system_sp = GetTypeSystem())
- return type_system_sp->IsFloatingPointType(m_type, count, is_complex);
+ return type_system_sp->IsFloatingPointType(m_type, is_complex);
}
- count = 0;
is_complex = false;
return false;
}
@@ -331,9 +329,8 @@ bool CompilerType::IsInteger() const {
}
bool CompilerType::IsFloat() const {
- uint32_t count = 0;
bool is_complex = false;
- return IsFloatingPointType(count, is_complex);
+ return IsFloatingPointType(is_complex);
}
bool CompilerType::IsEnumerationType() const {
@@ -373,30 +370,10 @@ bool CompilerType::IsScalarOrUnscopedEnumerationType() const {
}
bool CompilerType::IsPromotableIntegerType() const {
- // Unscoped enums are always considered as promotable, even if their
- // underlying type does not need to be promoted (e.g. "int").
- if (IsUnscopedEnumerationType())
- return true;
-
- switch (GetBasicTypeEnumeration()) {
- case lldb::eBasicTypeBool:
- case lldb::eBasicTypeChar:
- case lldb::eBasicTypeSignedChar:
- case lldb::eBasicTypeUnsignedChar:
- case lldb::eBasicTypeShort:
- case lldb::eBasicTypeUnsignedShort:
- case lldb::eBasicTypeWChar:
- case lldb::eBasicTypeSignedWChar:
- case lldb::eBasicTypeUnsignedWChar:
- case lldb::eBasicTypeChar16:
- case lldb::eBasicTypeChar32:
- return true;
-
- default:
- return false;
- }
-
- llvm_unreachable("All cases handled above.");
+ if (IsValid())
+ if (auto type_system_sp = GetTypeSystem())
+ return type_system_sp->IsPromotableIntegerType(m_type);
+ return false;
}
bool CompilerType::IsPointerToVoid() const {
@@ -793,10 +770,10 @@ CompilerType::GetTypeBitAlign(ExecutionContextScope *exe_scope) const {
return {};
}
-lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {
+lldb::Encoding CompilerType::GetEncoding() const {
if (IsValid())
if (auto type_system_sp = GetTypeSystem())
- return type_system_sp->GetEncoding(m_type, count);
+ return type_system_sp->GetEncoding(m_type);
return lldb::eEncodingInvalid;
}
@@ -1093,10 +1070,10 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
if (IsAggregateType()) {
return false; // Aggregate types don't have scalar values
} else {
- uint64_t count = 0;
- lldb::Encoding encoding = GetEncoding(count);
+ // FIXME: check that type is scalar instead of checking encoding?
+ lldb::Encoding encoding = GetEncoding();
- if (encoding == lldb::eEncodingInvalid || count != 1)
+ if (encoding == lldb::eEncodingInvalid || (GetTypeInfo() & eTypeIsComplex))
return false;
auto byte_size_or_err = GetByteSize(exe_scope);
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 2be1e389..11b823c 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -272,7 +272,7 @@ Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
Function::~Function() = default;
-void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp,
+void Function::GetStartLineSourceInfo(SupportFileNSP &source_file_sp,
uint32_t &line_no) {
line_no = 0;
source_file_sp = std::make_shared<SupportFile>();
@@ -300,9 +300,9 @@ void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp,
}
}
-llvm::Expected<std::pair<SupportFileSP, Function::SourceRange>>
+llvm::Expected<std::pair<SupportFileNSP, Function::SourceRange>>
Function::GetSourceInfo() {
- SupportFileSP source_file_sp;
+ SupportFileNSP source_file_sp = std::make_shared<SupportFile>();
uint32_t start_line;
GetStartLineSourceInfo(source_file_sp, start_line);
LineTable *line_table = m_comp_unit->GetLineTable();
diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp
index c941a69..dcfbac8 100644
--- a/lldb/source/Symbol/LineEntry.cpp
+++ b/lldb/source/Symbol/LineEntry.cpp
@@ -14,7 +14,7 @@
using namespace lldb_private;
LineEntry::LineEntry()
- : range(), file_sp(std::make_shared<SupportFile>()),
+ : range(), synthetic(false), file_sp(std::make_shared<SupportFile>()),
original_file_sp(std::make_shared<SupportFile>()),
is_start_of_statement(0), is_start_of_basic_block(0), is_prologue_end(0),
is_epilogue_begin(0), is_terminal_entry(0) {}
@@ -33,7 +33,8 @@ void LineEntry::Clear() {
}
bool LineEntry::IsValid() const {
- return range.GetBaseAddress().IsValid() && line != LLDB_INVALID_LINE_NUMBER;
+ return (range.GetBaseAddress().IsValid() || synthetic) &&
+ line != LLDB_INVALID_LINE_NUMBER;
}
bool LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const {
diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp
index ca3accd..ae2abf5 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -327,7 +327,7 @@ void LineTable::Dump(Stream *s, Target *target, Address::DumpStyle style,
Address::DumpStyle fallback_style, bool show_line_ranges) {
const size_t count = m_entries.size();
LineEntry line_entry;
- SupportFileSP prev_file;
+ SupportFileNSP prev_file = std::make_shared<SupportFile>();
for (size_t idx = 0; idx < count; ++idx) {
ConvertEntryAtIndexToLineEntry(idx, line_entry);
line_entry.Dump(s, target, !prev_file->Equal(*line_entry.original_file_sp),
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 9a79b3c..ab28c17 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -254,13 +254,14 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
: ModuleChild(module_sp),
m_file(), // This file could be different from the original module's file
m_type(eTypeInvalid), m_strata(eStrataInvalid),
- m_file_offset(file_offset), m_length(length), m_data(), m_process_wp(),
+ m_file_offset(file_offset), m_length(length),
+ m_data_nsp(std::make_shared<DataExtractor>()), m_process_wp(),
m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_up(), m_symtab_up(),
m_symtab_once_up(new llvm::once_flag()) {
if (file_spec_ptr)
m_file = *file_spec_ptr;
if (data_sp)
- m_data.SetData(data_sp, data_offset, length);
+ m_data_nsp->SetData(data_sp, data_offset, length);
Log *log = GetLog(LLDBLog::Object);
LLDB_LOGF(log,
"%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
@@ -275,11 +276,12 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
const ProcessSP &process_sp, lldb::addr_t header_addr,
DataBufferSP header_data_sp)
: ModuleChild(module_sp), m_file(), m_type(eTypeInvalid),
- m_strata(eStrataInvalid), m_file_offset(0), m_length(0), m_data(),
- m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_up(),
- m_symtab_up(), m_symtab_once_up(new llvm::once_flag()) {
+ m_strata(eStrataInvalid), m_file_offset(0), m_length(0),
+ m_data_nsp(std::make_shared<DataExtractor>()), m_process_wp(process_sp),
+ m_memory_addr(header_addr), m_sections_up(), m_symtab_up(),
+ m_symtab_once_up(new llvm::once_flag()) {
if (header_data_sp)
- m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
+ m_data_nsp->SetData(header_data_sp, 0, header_data_sp->GetByteSize());
Log *log = GetLog(LLDBLog::Object);
LLDB_LOGF(log,
"%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
@@ -474,16 +476,16 @@ WritableDataBufferSP ObjectFile::ReadMemory(const ProcessSP &process_sp,
size_t ObjectFile::GetData(lldb::offset_t offset, size_t length,
DataExtractor &data) const {
- // The entire file has already been mmap'ed into m_data, so just copy from
+ // The entire file has already been mmap'ed into m_data_nsp, so just copy from
// there as the back mmap buffer will be shared with shared pointers.
- return data.SetData(m_data, offset, length);
+ return data.SetData(*m_data_nsp.get(), offset, length);
}
size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
void *dst) const {
- // The entire file has already been mmap'ed into m_data, so just copy from
+ // The entire file has already been mmap'ed into m_data_nsp, so just copy from
// there Note that the data remains in target byte order.
- return m_data.CopyData(offset, length, dst);
+ return m_data_nsp->CopyData(offset, length, dst);
}
size_t ObjectFile::ReadSectionData(Section *section,
@@ -647,14 +649,14 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
.Case("frame", eSectionTypeDWARFDebugFrame)
.Case("info", eSectionTypeDWARFDebugInfo)
.Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
- .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
- .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+ .Cases({"line", "line.dwo"}, eSectionTypeDWARFDebugLine)
+ .Cases({"line_str", "line_str.dwo"}, eSectionTypeDWARFDebugLineStr)
.Case("loc", eSectionTypeDWARFDebugLoc)
.Case("loc.dwo", eSectionTypeDWARFDebugLocDwo)
.Case("loclists", eSectionTypeDWARFDebugLocLists)
.Case("loclists.dwo", eSectionTypeDWARFDebugLocListsDwo)
.Case("macinfo", eSectionTypeDWARFDebugMacInfo)
- .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+ .Cases({"macro", "macro.dwo"}, eSectionTypeDWARFDebugMacro)
.Case("names", eSectionTypeDWARFDebugNames)
.Case("pubnames", eSectionTypeDWARFDebugPubNames)
.Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
@@ -663,7 +665,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
.Case("str", eSectionTypeDWARFDebugStr)
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
- .Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets)
+ .Cases({"str_offsets", "str_offs"}, eSectionTypeDWARFDebugStrOffsets)
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
.Case("tu_index", eSectionTypeDWARFDebugTuIndex)
.Case("types", eSectionTypeDWARFDebugTypes)
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 3bbd1ef..ead924a 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -324,12 +324,32 @@ uint32_t SymbolContext::GetResolvedMask() const {
bool lldb_private::operator==(const SymbolContext &lhs,
const SymbolContext &rhs) {
- return lhs.function == rhs.function && lhs.symbol == rhs.symbol &&
+ return SymbolContext::CompareWithoutSymbol(lhs, rhs) &&
+ lhs.symbol == rhs.symbol;
+}
+
+bool SymbolContext::CompareConsideringPossiblyNullSymbol(
+ const SymbolContext &lhs, const SymbolContext &rhs) {
+ if (!CompareWithoutSymbol(lhs, rhs))
+ return false;
+
+ // If one (or both) of the symbol context's symbol is empty, consider them
+ // equal.
+ if (!lhs.symbol || !rhs.symbol)
+ return true;
+
+ // If both symbols are present, make sure they're the same.
+ return lhs.symbol == rhs.symbol;
+}
+
+bool SymbolContext::CompareWithoutSymbol(const SymbolContext &lhs,
+ const SymbolContext &rhs) {
+ return lhs.function == rhs.function &&
lhs.module_sp.get() == rhs.module_sp.get() &&
lhs.comp_unit == rhs.comp_unit &&
lhs.target_sp.get() == rhs.target_sp.get() &&
LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0 &&
- lhs.variable == rhs.variable;
+ lhs.variable == rhs.variable && lhs.block == rhs.block;
}
bool lldb_private::operator!=(const SymbolContext &lhs,
@@ -1200,7 +1220,10 @@ bool SymbolContextList::AppendIfUnique(const SymbolContext &sc,
bool merge_symbol_into_function) {
collection::iterator pos, end = m_symbol_contexts.end();
for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
- if (*pos == sc)
+ // Because symbol contexts might first be built without the symbol,
+ // which is then appended later on, compare the symbol contexts taking into
+ // accout that one (or either) of them might not have a symbol yet.
+ if (SymbolContext::CompareConsideringPossiblyNullSymbol(*pos, sc))
return false;
}
if (merge_symbol_into_function && sc.symbol != nullptr &&
diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp
index 870d778d..bfc6300 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -126,6 +126,14 @@ void SymbolFile::FindFunctions(const Module::LookupInfo &lookup_info,
bool include_inlines,
SymbolContextList &sc_list) {}
+void SymbolFile::FindFunctions(llvm::ArrayRef<Module::LookupInfo> lookup_infos,
+ const CompilerDeclContext &parent_decl_ctx,
+ bool include_inlines,
+ SymbolContextList &sc_list) {
+ for (const auto &lookup_info : lookup_infos)
+ FindFunctions(lookup_info, parent_decl_ctx, include_inlines, sc_list);
+}
+
void SymbolFile::FindFunctions(const RegularExpression &regex,
bool include_inlines,
SymbolContextList &sc_list) {}
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 6080703..9964ae4 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -722,15 +722,11 @@ Symtab::AppendSymbolIndexesWithNameAndType(ConstString symbol_name,
std::vector<uint32_t> &indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) {
- std::vector<uint32_t>::iterator pos = indexes.begin();
- while (pos != indexes.end()) {
- if (symbol_type == eSymbolTypeAny ||
- m_symbols[*pos].GetType() == symbol_type)
- ++pos;
- else
- pos = indexes.erase(pos);
- }
+ if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0 &&
+ symbol_type != eSymbolTypeAny) {
+ llvm::erase_if(indexes, [this, symbol_type](uint32_t index) {
+ return m_symbols[index].GetType() != symbol_type;
+ });
}
return indexes.size();
}
@@ -742,15 +738,11 @@ uint32_t Symtab::AppendSymbolIndexesWithNameAndType(
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type,
- symbol_visibility, indexes) > 0) {
- std::vector<uint32_t>::iterator pos = indexes.begin();
- while (pos != indexes.end()) {
- if (symbol_type == eSymbolTypeAny ||
- m_symbols[*pos].GetType() == symbol_type)
- ++pos;
- else
- pos = indexes.erase(pos);
- }
+ symbol_visibility, indexes) > 0 &&
+ symbol_type != eSymbolTypeAny) {
+ llvm::erase_if(indexes, [this, symbol_type](uint32_t index) {
+ return m_symbols[index].GetType() != symbol_type;
+ });
}
return indexes.size();
}
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 952b2bd..0c3246d 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -531,9 +531,9 @@ lldb::TypeSP Type::GetTypedefType() {
lldb::Format Type::GetFormat() { return GetForwardCompilerType().GetFormat(); }
-lldb::Encoding Type::GetEncoding(uint64_t &count) {
+lldb::Encoding Type::GetEncoding() {
// Make sure we resolve our type if it already hasn't been.
- return GetForwardCompilerType().GetEncoding(count);
+ return GetForwardCompilerType().GetEncoding();
}
bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index f7d634f..8712142 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -123,6 +123,17 @@ CompilerType TypeSystem::GetTypeForFormatters(void *type) {
return CompilerType(weak_from_this(), type);
}
+bool TypeSystem::IsPromotableIntegerType(lldb::opaque_compiler_type_t type) {
+ return false;
+}
+
+llvm::Expected<CompilerType>
+TypeSystem::DoIntegralPromotion(CompilerType from,
+ ExecutionContextScope *exe_scope) {
+ return llvm::createStringError(
+ "Integral promotion is not implemented for this TypeSystem");
+}
+
bool TypeSystem::IsTemplateType(lldb::opaque_compiler_type_t type) {
return false;
}