[lldb] Remove FileSpec->CompileUnit inheritance
Summary: CompileUnit is a complicated class. Having it be implicitly convertible to a FileSpec makes reasoning about it even harder. This patch replaces the inheritance by a simple member and an accessor function. This avoid the need for casting in places where one needed to force a CompileUnit to be treated as a FileSpec, and does not add much verbosity elsewhere. It also fixes a bug where we were wrongly comparing CompileUnit& and a CompileUnit*, which compiled due to a combination of this inheritance and the FileSpec*->FileSpec implicit constructor. Reviewers: teemperor, JDevlieghere, jdoerfert Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70827
This commit is contained in:
1 parent
e478385e77
commit
38870af859
22 files changed
+82
-76
No files matched your search
@@ -13,6 +13,7 @@
|
||||
#include "lldb/Core/ModuleChild.h"
|
||||
#include "lldb/Symbol/DebugMacros.h"
|
||||
#include "lldb/Symbol/Function.h"
|
||||
#include "lldb/Symbol/LineTable.h"
|
||||
#include "lldb/Symbol/SourceModule.h"
|
||||
#include "lldb/Utility/Stream.h"
|
||||
#include "lldb/Utility/UserID.h"
|
||||
@@ -35,7 +36,6 @@ namespace lldb_private {
|
||||
/// table.
|
||||
class CompileUnit : public std::enable_shared_from_this<CompileUnit>,
|
||||
public ModuleChild,
|
||||
public FileSpec,
|
||||
public UserID,
|
||||
public SymbolContextScope {
|
||||
public:
|
||||
@@ -116,9 +116,6 @@ public:
|
||||
const FileSpec &file_spec, lldb::user_id_t uid,
|
||||
lldb::LanguageType language, lldb_private::LazyBool is_optimized);
|
||||
|
||||
/// Destructor
|
||||
~CompileUnit() override;
|
||||
|
||||
/// Add a function to this compile unit.
|
||||
///
|
||||
/// Typically called by the SymbolFile plug-ins as they partially parse the
|
||||
@@ -225,6 +222,9 @@ public:
|
||||
const FileSpec *file_spec_ptr, bool exact,
|
||||
LineEntry *line_entry);
|
||||
|
||||
/// Return the primary source file associated with this compile unit.
|
||||
const FileSpec &GetPrimaryFile() const { return m_file_spec; }
|
||||
|
||||
/// Get the line table for the compile unit.
|
||||
///
|
||||
/// Called by clients and the SymbolFile plug-in. The SymbolFile plug-ins
|
||||
@@ -415,6 +415,8 @@ protected:
|
||||
/// All modules, including the current module, imported by this
|
||||
/// compile unit.
|
||||
std::vector<SourceModule> m_imported_modules;
|
||||
/// The primary file associated with this compile unit.
|
||||
FileSpec m_file_spec;
|
||||
/// Files associated with this compile unit's line table and
|
||||
/// declarations.
|
||||
FileSpecList m_support_files;
|
||||
|
||||
@@ -50,7 +50,7 @@ SBFileSpec SBCompileUnit::GetFileSpec() const {
|
||||
|
||||
SBFileSpec file_spec;
|
||||
if (m_opaque_ptr)
|
||||
file_spec.SetFileSpec(*m_opaque_ptr);
|
||||
file_spec.SetFileSpec(m_opaque_ptr->GetPrimaryFile());
|
||||
return LLDB_RECORD_RESULT(file_spec);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
|
||||
if (inline_file_spec && inline_file_spec->IsValid())
|
||||
file_spec = inline_file_spec->ref();
|
||||
else
|
||||
file_spec = *m_opaque_ptr;
|
||||
file_spec = m_opaque_ptr->GetPrimaryFile();
|
||||
|
||||
index = m_opaque_ptr->FindLineEntry(
|
||||
start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr,
|
||||
|
||||
@@ -638,7 +638,8 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
|
||||
} else {
|
||||
// Otherwise we will compare by name...
|
||||
if (old_sc.comp_unit && new_sc.comp_unit) {
|
||||
if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true)) {
|
||||
if (FileSpec::Equal(old_sc.comp_unit->GetPrimaryFile(),
|
||||
new_sc.comp_unit->GetPrimaryFile(), true)) {
|
||||
// Now check the functions:
|
||||
if (old_sc.function && new_sc.function &&
|
||||
(old_sc.function->GetName() == new_sc.function->GetName())) {
|
||||
|
||||
@@ -525,7 +525,7 @@ void BreakpointLocation::GetDescription(Stream *s,
|
||||
if (sc.comp_unit != nullptr) {
|
||||
s->EOL();
|
||||
s->Indent("compile unit = ");
|
||||
static_cast<FileSpec *>(sc.comp_unit)->GetFilename().Dump(s);
|
||||
sc.comp_unit->GetPrimaryFile().GetFilename().Dump(s);
|
||||
|
||||
if (sc.function != nullptr) {
|
||||
s->EOL();
|
||||
|
||||
@@ -102,7 +102,7 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
|
||||
return eCallbackReturnContinue;
|
||||
|
||||
CompileUnit *cu = context.comp_unit;
|
||||
FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu));
|
||||
FileSpec cu_file_spec = cu->GetPrimaryFile();
|
||||
std::vector<uint32_t> line_matches;
|
||||
context.target_sp->GetSourceManager().FindLinesMatchingRegex(
|
||||
cu_file_spec, m_regex, 1, UINT32_MAX, line_matches);
|
||||
|
||||
@@ -378,8 +378,10 @@ CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const char *cur_file_name = context.comp_unit->GetFilename().GetCString();
|
||||
const char *cur_dir_name = context.comp_unit->GetDirectory().GetCString();
|
||||
const char *cur_file_name =
|
||||
context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
|
||||
const char *cur_dir_name =
|
||||
context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
|
||||
|
||||
bool match = false;
|
||||
if (m_file_name && cur_file_name &&
|
||||
@@ -391,7 +393,7 @@ CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter,
|
||||
match = false;
|
||||
|
||||
if (match) {
|
||||
m_matching_files.AppendIfUnique(context.comp_unit);
|
||||
m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,8 @@ protected:
|
||||
if (num_matches > 0)
|
||||
strm << "\n\n";
|
||||
strm << "Lines found for file " << file_spec_name
|
||||
<< " in compilation unit " << cu->GetFilename() << " in `"
|
||||
<< " in compilation unit "
|
||||
<< cu->GetPrimaryFile().GetFilename() << " in `"
|
||||
<< module_file_name << "\n";
|
||||
cu_header_printed = true;
|
||||
}
|
||||
@@ -1077,7 +1078,8 @@ protected:
|
||||
if (m_options.show_bp_locs) {
|
||||
m_breakpoint_locations.Clear();
|
||||
const bool show_inlines = true;
|
||||
m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines);
|
||||
m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0,
|
||||
show_inlines);
|
||||
SearchFilterForUnconstrainedSearches target_search_filter(
|
||||
target->shared_from_this());
|
||||
target_search_filter.Search(m_breakpoint_locations);
|
||||
@@ -1106,8 +1108,8 @@ protected:
|
||||
? sc.line_entry.column
|
||||
: 0;
|
||||
target->GetSourceManager().DisplaySourceLinesWithLineNumbers(
|
||||
sc.comp_unit, sc.line_entry.line, column, lines_to_back_up,
|
||||
m_options.num_lines - lines_to_back_up, "->",
|
||||
sc.comp_unit->GetPrimaryFile(), sc.line_entry.line, column,
|
||||
lines_to_back_up, m_options.num_lines - lines_to_back_up, "->",
|
||||
&result.GetOutputStream(), GetBreakpointLocations());
|
||||
result.SetStatus(eReturnStatusSuccessFinishResult);
|
||||
}
|
||||
@@ -1190,18 +1192,18 @@ protected:
|
||||
|
||||
if (num_matches > 1) {
|
||||
bool got_multiple = false;
|
||||
FileSpec *test_cu_spec = nullptr;
|
||||
CompileUnit *test_cu = nullptr;
|
||||
|
||||
for (unsigned i = 0; i < num_matches; i++) {
|
||||
SymbolContext sc;
|
||||
sc_list.GetContextAtIndex(i, sc);
|
||||
if (sc.comp_unit) {
|
||||
if (test_cu_spec) {
|
||||
if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit))
|
||||
if (test_cu) {
|
||||
if (test_cu != sc.comp_unit)
|
||||
got_multiple = true;
|
||||
break;
|
||||
} else
|
||||
test_cu_spec = sc.comp_unit;
|
||||
test_cu = sc.comp_unit;
|
||||
}
|
||||
}
|
||||
if (got_multiple) {
|
||||
@@ -1218,7 +1220,8 @@ protected:
|
||||
if (sc.comp_unit) {
|
||||
if (m_options.show_bp_locs) {
|
||||
const bool show_inlines = true;
|
||||
m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines);
|
||||
m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0,
|
||||
show_inlines);
|
||||
SearchFilterForUnconstrainedSearches target_search_filter(
|
||||
target->shared_from_this());
|
||||
target_search_filter.Search(m_breakpoint_locations);
|
||||
@@ -1229,7 +1232,7 @@ protected:
|
||||
m_options.num_lines = 10;
|
||||
const uint32_t column = 0;
|
||||
target->GetSourceManager().DisplaySourceLinesWithLineNumbers(
|
||||
sc.comp_unit, m_options.start_line, column, 0,
|
||||
sc.comp_unit->GetPrimaryFile(), m_options.start_line, column, 0,
|
||||
m_options.num_lines, "", &result.GetOutputStream(),
|
||||
GetBreakpointLocations());
|
||||
|
||||
|
||||
@@ -816,15 +816,14 @@ protected:
|
||||
return;
|
||||
if (sc.module_sp) {
|
||||
if (sc.comp_unit) {
|
||||
s.Printf("Global variables for %s in %s:\n",
|
||||
sc.comp_unit->GetPath().c_str(),
|
||||
sc.module_sp->GetFileSpec().GetPath().c_str());
|
||||
s.Format("Global variables for {0} in {1}:\n",
|
||||
sc.comp_unit->GetPrimaryFile(), sc.module_sp->GetFileSpec());
|
||||
} else {
|
||||
s.Printf("Global variables for %s\n",
|
||||
sc.module_sp->GetFileSpec().GetPath().c_str());
|
||||
}
|
||||
} else if (sc.comp_unit) {
|
||||
s.Printf("Global variables for %s\n", sc.comp_unit->GetPath().c_str());
|
||||
s.Format("Global variables for {0}\n", sc.comp_unit->GetPrimaryFile());
|
||||
}
|
||||
|
||||
for (VariableSP var_sp : variable_list) {
|
||||
@@ -926,9 +925,9 @@ protected:
|
||||
if (!success) {
|
||||
if (frame) {
|
||||
if (comp_unit)
|
||||
result.AppendErrorWithFormat(
|
||||
"no global variables in current compile unit: %s\n",
|
||||
comp_unit->GetPath().c_str());
|
||||
result.AppendErrorWithFormatv(
|
||||
"no global variables in current compile unit: {0}\n",
|
||||
comp_unit->GetPrimaryFile());
|
||||
else
|
||||
result.AppendErrorWithFormat(
|
||||
"no debug information for frame %u\n",
|
||||
@@ -1327,8 +1326,8 @@ static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter,
|
||||
if (i > 0)
|
||||
strm << "\n\n";
|
||||
|
||||
strm << "Line table for " << *static_cast<FileSpec *>(sc.comp_unit)
|
||||
<< " in `" << module->GetFileSpec().GetFilename() << "\n";
|
||||
strm << "Line table for " << sc.comp_unit->GetPrimaryFile() << " in `"
|
||||
<< module->GetFileSpec().GetFilename() << "\n";
|
||||
LineTable *line_table = sc.comp_unit->GetLineTable();
|
||||
if (line_table)
|
||||
line_table->GetDescription(
|
||||
|
||||
@@ -1193,7 +1193,7 @@ protected:
|
||||
LineEntry line_entry;
|
||||
const bool exact = false;
|
||||
start_idx_ptr = sc.comp_unit->FindLineEntry(
|
||||
start_idx_ptr, line_number, sc.comp_unit, exact, &line_entry);
|
||||
start_idx_ptr, line_number, nullptr, exact, &line_entry);
|
||||
if (start_idx_ptr == UINT32_MAX)
|
||||
break;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ FileLineResolver::SearchCallback(SearchFilter &filter, SymbolContext &context,
|
||||
Address *addr) {
|
||||
CompileUnit *cu = context.comp_unit;
|
||||
|
||||
if (m_inlines ||
|
||||
m_file_spec.Compare(*cu, m_file_spec, (bool)m_file_spec.GetDirectory())) {
|
||||
if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec,
|
||||
(bool)m_file_spec.GetDirectory())) {
|
||||
uint32_t start_file_idx = 0;
|
||||
uint32_t file_idx =
|
||||
cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);
|
||||
|
||||
@@ -1376,8 +1376,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
|
||||
if (sc) {
|
||||
CompileUnit *cu = sc->comp_unit;
|
||||
if (cu) {
|
||||
// CompileUnit is a FileSpec
|
||||
if (DumpFile(s, *cu, (FileKind)entry.number))
|
||||
if (DumpFile(s, cu->GetPrimaryFile(), (FileKind)entry.number))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,7 +617,8 @@ void Module::FindCompileUnits(const FileSpec &path,
|
||||
for (size_t i = 0; i < num_compile_units; ++i) {
|
||||
sc.comp_unit = GetCompileUnitAtIndex(i).get();
|
||||
if (sc.comp_unit) {
|
||||
if (FileSpec::Equal(*sc.comp_unit, path, compare_directory))
|
||||
if (FileSpec::Equal(sc.comp_unit->GetPrimaryFile(), path,
|
||||
compare_directory))
|
||||
sc_list.Append(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -726,8 +726,11 @@ bool SearchFilterByModuleListAndCU::AddressPasses(Address &address) {
|
||||
if (m_cu_spec_list.GetSize() != 0)
|
||||
return false; // Has no comp_unit so can't pass the file check.
|
||||
}
|
||||
if (m_cu_spec_list.FindFileIndex(0, sym_ctx.comp_unit, false) == UINT32_MAX)
|
||||
return false; // Fails the file check
|
||||
FileSpec cu_spec;
|
||||
if (sym_ctx.comp_unit)
|
||||
cu_spec = sym_ctx.comp_unit->GetPrimaryFile();
|
||||
if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX)
|
||||
return false; // Fails the file check
|
||||
return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp);
|
||||
}
|
||||
|
||||
@@ -736,8 +739,8 @@ bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec &fileSpec) {
|
||||
}
|
||||
|
||||
bool SearchFilterByModuleListAndCU::CompUnitPasses(CompileUnit &compUnit) {
|
||||
bool in_cu_list =
|
||||
m_cu_spec_list.FindFileIndex(0, compUnit, false) != UINT32_MAX;
|
||||
bool in_cu_list = m_cu_spec_list.FindFileIndex(0, compUnit.GetPrimaryFile(),
|
||||
false) != UINT32_MAX;
|
||||
if (in_cu_list) {
|
||||
ModuleSP module_sp(compUnit.GetModule());
|
||||
if (module_sp) {
|
||||
@@ -787,8 +790,9 @@ void SearchFilterByModuleListAndCU::Search(Searcher &searcher) {
|
||||
CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx);
|
||||
matchingContext.comp_unit = cu_sp.get();
|
||||
if (matchingContext.comp_unit) {
|
||||
if (m_cu_spec_list.FindFileIndex(0, *matchingContext.comp_unit,
|
||||
false) != UINT32_MAX) {
|
||||
if (m_cu_spec_list.FindFileIndex(
|
||||
0, matchingContext.comp_unit->GetPrimaryFile(), false) !=
|
||||
UINT32_MAX) {
|
||||
shouldContinue =
|
||||
DoCUIteration(module_sp, matchingContext, searcher);
|
||||
if (shouldContinue == Searcher::eCallbackReturnStop)
|
||||
|
||||
@@ -399,24 +399,25 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
|
||||
if (num_matches != 0) {
|
||||
if (num_matches > 1) {
|
||||
SymbolContext sc;
|
||||
FileSpec *test_cu_spec = nullptr;
|
||||
CompileUnit *test_cu = nullptr;
|
||||
|
||||
for (unsigned i = 0; i < num_matches; i++) {
|
||||
sc_list.GetContextAtIndex(i, sc);
|
||||
if (sc.comp_unit) {
|
||||
if (test_cu_spec) {
|
||||
if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit))
|
||||
if (test_cu) {
|
||||
if (test_cu != sc.comp_unit)
|
||||
got_multiple = true;
|
||||
break;
|
||||
} else
|
||||
test_cu_spec = sc.comp_unit;
|
||||
test_cu = sc.comp_unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!got_multiple) {
|
||||
SymbolContext sc;
|
||||
sc_list.GetContextAtIndex(0, sc);
|
||||
m_file_spec = sc.comp_unit;
|
||||
if (sc.comp_unit)
|
||||
m_file_spec = sc.comp_unit->GetPrimaryFile();
|
||||
m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
|
||||
}
|
||||
if (next_addr)
|
||||
finish_sequence();
|
||||
data.support_files = map.translate(cu, *m_files);
|
||||
data.support_files = map.translate(cu.GetPrimaryFile(), *m_files);
|
||||
}
|
||||
|
||||
void SymbolFileBreakpad::ParseUnwindData() {
|
||||
|
||||
@@ -1046,7 +1046,8 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
|
||||
|
||||
comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
|
||||
comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(),
|
||||
dwarf_cu->GetCompilationDirectory().GetCString(), FileSpec(comp_unit)));
|
||||
dwarf_cu->GetCompilationDirectory().GetCString(),
|
||||
comp_unit.GetPrimaryFile()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1951,7 +1952,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
|
||||
|
||||
const bool full_match = (bool)file_spec.GetDirectory();
|
||||
bool file_spec_matches_cu_file_spec =
|
||||
FileSpec::Equal(file_spec, *dc_cu, full_match);
|
||||
FileSpec::Equal(file_spec, dc_cu->GetPrimaryFile(), full_match);
|
||||
if (check_inlines || file_spec_matches_cu_file_spec) {
|
||||
SymbolContext sc(m_objfile_sp->GetModule());
|
||||
sc.comp_unit = dc_cu;
|
||||
|
||||
@@ -604,7 +604,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo *
|
||||
SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) {
|
||||
const uint32_t cu_count = GetNumCompileUnits();
|
||||
for (uint32_t i = 0; i < cu_count; ++i) {
|
||||
if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get())
|
||||
if (&comp_unit == m_compile_unit_infos[i].compile_unit_sp.get())
|
||||
return &m_compile_unit_infos[i];
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -373,7 +373,7 @@ bool SymbolFilePDB::ParseSupportFiles(
|
||||
|
||||
// LLDB uses the DWARF-like file numeration (one based),
|
||||
// the zeroth file is the compile unit itself
|
||||
support_files.Insert(0, comp_unit);
|
||||
support_files.Insert(0, comp_unit.GetPrimaryFile());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1780,7 +1780,6 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
|
||||
auto line_table = std::make_unique<LineTable>(&comp_unit);
|
||||
|
||||
// Find contributions to `compiland` from all source and header files.
|
||||
std::string path = comp_unit.GetPath();
|
||||
auto files = m_session_up->getSourceFilesForCompiland(*compiland_up);
|
||||
if (!files)
|
||||
return false;
|
||||
|
||||
@@ -21,30 +21,21 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
|
||||
const char *pathname, const lldb::user_id_t cu_sym_id,
|
||||
lldb::LanguageType language,
|
||||
lldb_private::LazyBool is_optimized)
|
||||
: ModuleChild(module_sp), FileSpec(pathname), UserID(cu_sym_id),
|
||||
m_user_data(user_data), m_language(language), m_flags(0),
|
||||
m_support_files(), m_line_table_up(), m_variables(),
|
||||
m_is_optimized(is_optimized) {
|
||||
if (language != eLanguageTypeUnknown)
|
||||
m_flags.Set(flagsParsedLanguage);
|
||||
assert(module_sp);
|
||||
}
|
||||
: CompileUnit(module_sp, user_data, FileSpec(pathname), cu_sym_id, language,
|
||||
is_optimized) {}
|
||||
|
||||
CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
|
||||
const FileSpec &fspec, const lldb::user_id_t cu_sym_id,
|
||||
lldb::LanguageType language,
|
||||
lldb_private::LazyBool is_optimized)
|
||||
: ModuleChild(module_sp), FileSpec(fspec), UserID(cu_sym_id),
|
||||
m_user_data(user_data), m_language(language), m_flags(0),
|
||||
m_support_files(), m_line_table_up(), m_variables(),
|
||||
: ModuleChild(module_sp), UserID(cu_sym_id), m_user_data(user_data),
|
||||
m_language(language), m_flags(0), m_file_spec(fspec),
|
||||
m_is_optimized(is_optimized) {
|
||||
if (language != eLanguageTypeUnknown)
|
||||
m_flags.Set(flagsParsedLanguage);
|
||||
assert(module_sp);
|
||||
}
|
||||
|
||||
CompileUnit::~CompileUnit() {}
|
||||
|
||||
void CompileUnit::CalculateSymbolContext(SymbolContext *sc) {
|
||||
sc->comp_unit = this;
|
||||
GetModule()->CalculateSymbolContext(sc);
|
||||
@@ -63,7 +54,7 @@ void CompileUnit::GetDescription(Stream *s,
|
||||
lldb::DescriptionLevel level) const {
|
||||
const char *language = Language::GetNameForLanguageType(m_language);
|
||||
*s << "id = " << (const UserID &)*this << ", file = \""
|
||||
<< (const FileSpec &)*this << "\", language = \"" << language << '"';
|
||||
<< this->GetPrimaryFile() << "\", language = \"" << language << '"';
|
||||
}
|
||||
|
||||
void CompileUnit::ForeachFunction(
|
||||
@@ -117,8 +108,7 @@ void CompileUnit::Dump(Stream *s, bool show_context) const {
|
||||
s->Printf("%p: ", static_cast<const void *>(this));
|
||||
s->Indent();
|
||||
*s << "CompileUnit" << static_cast<const UserID &>(*this) << ", language = \""
|
||||
<< language << "\", file = '" << static_cast<const FileSpec &>(*this)
|
||||
<< "'\n";
|
||||
<< language << "\", file = '" << GetPrimaryFile() << "'\n";
|
||||
|
||||
// m_types.Dump(s);
|
||||
|
||||
@@ -255,7 +245,7 @@ void CompileUnit::ResolveSymbolContext(const FileSpec &file_spec,
|
||||
std::vector<uint32_t> file_indexes;
|
||||
const bool full_match = (bool)file_spec.GetDirectory();
|
||||
bool file_spec_matches_cu_file_spec =
|
||||
FileSpec::Equal(file_spec, *this, full_match);
|
||||
FileSpec::Equal(file_spec, this->GetPrimaryFile(), full_match);
|
||||
|
||||
// If we are not looking for inlined functions and our file spec doesn't
|
||||
// match then we are done...
|
||||
|
||||
@@ -340,7 +340,8 @@ Block &Function::GetBlock(bool can_create) {
|
||||
"error: unable to find module "
|
||||
"shared pointer for function '%s' "
|
||||
"in %s\n",
|
||||
GetName().GetCString(), m_comp_unit->GetPath().c_str());
|
||||
GetName().GetCString(),
|
||||
m_comp_unit->GetPrimaryFile().GetPath().c_str());
|
||||
}
|
||||
m_block.SetBlockInfoHasBeenParsed(true, true);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ void SymbolContext::Dump(Stream *s, Target *target) const {
|
||||
*s << "CompileUnit = " << comp_unit;
|
||||
if (comp_unit != nullptr)
|
||||
s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(),
|
||||
*static_cast<FileSpec *>(comp_unit));
|
||||
comp_unit->GetPrimaryFile());
|
||||
s->EOL();
|
||||
s->Indent();
|
||||
*s << "Function = " << function;
|
||||
@@ -1055,7 +1055,8 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
|
||||
// Next check the comp unit, but only if the SymbolContext was not
|
||||
// inlined.
|
||||
if (!was_inlined && sc.comp_unit != nullptr) {
|
||||
if (!FileSpec::Equal(*(sc.comp_unit), *(m_file_spec_up.get()), false))
|
||||
if (!FileSpec::Equal(sc.comp_unit->GetPrimaryFile(), *m_file_spec_up,
|
||||
false))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +549,8 @@ Error opts::symbols::findVariables(lldb_private::Module &Module) {
|
||||
CompUnitSP CU;
|
||||
for (size_t Ind = 0; !CU && Ind < Module.GetNumCompileUnits(); ++Ind) {
|
||||
CompUnitSP Candidate = Module.GetCompileUnitAtIndex(Ind);
|
||||
if (!Candidate || Candidate->GetFilename().GetStringRef() != File)
|
||||
if (!Candidate ||
|
||||
Candidate->GetPrimaryFile().GetFilename().GetStringRef() != File)
|
||||
continue;
|
||||
if (CU)
|
||||
return make_string_error("Multiple compile units for file `{0}` found.",
|
||||
@@ -653,7 +654,8 @@ Error opts::symbols::verify(lldb_private::Module &Module) {
|
||||
if (!comp_unit)
|
||||
return make_string_error("Connot parse compile unit {0}.", i);
|
||||
|
||||
outs() << "Processing '" << comp_unit->GetFilename().AsCString()
|
||||
outs() << "Processing '"
|
||||
<< comp_unit->GetPrimaryFile().GetFilename().AsCString()
|
||||
<< "' compile unit.\n";
|
||||
|
||||
LineTable *lt = comp_unit->GetLineTable();
|
||||
|
||||
Reference in new issue
Block a user