aboutsummaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-01-12 16:26:22 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2024-01-16 21:27:20 -0800
commitff9fcc74a356b8542e5ac782426c9d4c817143f3 (patch)
treefe356e6297a761ac5fc6ec97462bb3c12691f4d2 /lldb
parent4e64159c866446ed7f5783649f8f5699f84bb1a6 (diff)
downloadllvm-ff9fcc74a356b8542e5ac782426c9d4c817143f3.zip
llvm-ff9fcc74a356b8542e5ac782426c9d4c817143f3.tar.gz
llvm-ff9fcc74a356b8542e5ac782426c9d4c817143f3.tar.bz2
[lldb] Store SupportFile in CompileUnit (NFC)
Store a SupportFile, rather than a FileSpec, in CompileUnit. This commit works towards having the SourceManager operate on SupportFiles so that it can (1) validate the Checksum and (2) materialize the content of inline source information.
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Symbol/CompileUnit.h16
-rw-r--r--lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp9
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp9
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp11
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp6
-rw-r--r--lldb/source/Symbol/CompileUnit.cpp11
6 files changed, 36 insertions, 26 deletions
diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h
index 89e853a..c20a37e 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -91,7 +91,7 @@ public:
/// \param[in] user_data
/// User data where the SymbolFile parser can store data.
///
- /// \param[in] file_spec
+ /// \param[in] support_file_sp
/// The file specification for the source file of this compile
/// unit.
///
@@ -116,7 +116,7 @@ public:
/// An rvalue list of already parsed support files.
/// \see lldb::LanguageType
CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
- const FileSpec &file_spec, lldb::user_id_t uid,
+ lldb::SupportFileSP support_file_sp, lldb::user_id_t uid,
lldb::LanguageType language, lldb_private::LazyBool is_optimized,
SupportFileList &&support_files = {});
@@ -226,11 +226,15 @@ 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; }
+ /// Return the primary source spec associated with this compile unit.
+ const FileSpec &GetPrimaryFile() const {
+ return m_primary_support_file_sp->GetSpecOnly();
+ }
/// Return the primary source file associated with this compile unit.
- void SetPrimaryFile(const FileSpec &fs) { m_file_spec = fs; }
+ lldb::SupportFileSP GetPrimarySupportFile() const {
+ return m_primary_support_file_sp;
+ }
/// Get the line table for the compile unit.
///
@@ -419,7 +423,7 @@ protected:
/// compile unit.
std::vector<SourceModule> m_imported_modules;
/// The primary file associated with this compile unit.
- FileSpec m_file_spec;
+ lldb::SupportFileSP m_primary_support_file_sp;
/// Files associated with this compile unit's line table and declarations.
SupportFileList m_support_files;
/// Line table that will get parsed on demand.
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 47c8074..b1f7397 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -216,10 +216,11 @@ CompUnitSP SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) {
spec = (*m_files)[record->FileNum];
}
- auto cu_sp = std::make_shared<CompileUnit>(m_objfile_sp->GetModule(),
- /*user_data*/ nullptr, spec, index,
- eLanguageTypeUnknown,
- /*is_optimized*/ eLazyBoolNo);
+ auto cu_sp = std::make_shared<CompileUnit>(
+ m_objfile_sp->GetModule(),
+ /*user_data*/ nullptr, std::make_shared<SupportFile>(spec), index,
+ eLanguageTypeUnknown,
+ /*is_optimized*/ eLazyBoolNo);
SetCompileUnitAtIndex(index, cu_sp);
return cu_sp;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index bec8111..fed97858 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -783,12 +783,12 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
} else {
ModuleSP module_sp(m_objfile_sp->GetModule());
if (module_sp) {
- auto initialize_cu = [&](const FileSpec &file_spec,
+ auto initialize_cu = [&](lldb::SupportFileSP support_file_sp,
LanguageType cu_language,
SupportFileList &&support_files = {}) {
BuildCuTranslationTable();
cu_sp = std::make_shared<CompileUnit>(
- module_sp, &dwarf_cu, file_spec,
+ module_sp, &dwarf_cu, support_file_sp,
*GetDWARFUnitIndex(dwarf_cu.GetID()), cu_language,
eLazyBoolCalculate, std::move(support_files));
@@ -821,7 +821,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
return false;
if (support_files.GetSize() == 0)
return false;
- initialize_cu(support_files.GetFileSpecAtIndex(0),
+ initialize_cu(support_files.GetSupportFileAtIndex(0),
eLanguageTypeUnknown, std::move(support_files));
return true;
};
@@ -840,7 +840,8 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
// case ParseSupportFiles takes care of the remapping.
MakeAbsoluteAndRemap(cu_file_spec, dwarf_cu, module_sp);
- initialize_cu(cu_file_spec, cu_language);
+ initialize_cu(std::make_shared<SupportFile>(cu_file_spec),
+ cu_language);
}
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 9094a5e..6dd3eb3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -598,10 +598,10 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) {
// User zero as the ID to match the compile unit at offset zero in each
// .o file.
lldb::user_id_t cu_id = 0;
- cu_info.compile_units_sps.push_back(
- std::make_shared<CompileUnit>(
- m_objfile_sp->GetModule(), nullptr, so_file_spec, cu_id,
- eLanguageTypeUnknown, eLazyBoolCalculate));
+ cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>(
+ m_objfile_sp->GetModule(), nullptr,
+ std::make_shared<SupportFile>(so_file_spec), cu_id,
+ eLanguageTypeUnknown, eLazyBoolCalculate));
cu_info.id_to_index_map.insert({0, 0});
SetCompileUnitAtIndex(cu_idx, cu_info.compile_units_sps[0]);
// If there's a symbol file also register all the extra compile units.
@@ -615,7 +615,8 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) {
if (dwarf_cu->GetID() == 0)
continue;
cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>(
- m_objfile_sp->GetModule(), nullptr, so_file_spec,
+ m_objfile_sp->GetModule(), nullptr,
+ std::make_shared<SupportFile>(so_file_spec),
dwarf_cu->GetID(), eLanguageTypeUnknown, eLazyBoolCalculate));
cu_info.id_to_index_map.insert(
{dwarf_cu->GetID(), cu_info.compile_units_sps.size() - 1});
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 9234768..745685a 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -534,9 +534,9 @@ SymbolFileNativePDB::CreateCompileUnit(const CompilandIndexItem &cci) {
FileSpec fs(llvm::sys::path::convert_to_slash(
source_file_name, llvm::sys::path::Style::windows_backslash));
- CompUnitSP cu_sp =
- std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), nullptr, fs,
- toOpaqueUid(cci.m_id), lang, optimized);
+ CompUnitSP cu_sp = std::make_shared<CompileUnit>(
+ m_objfile_sp->GetModule(), nullptr, std::make_shared<SupportFile>(fs),
+ toOpaqueUid(cci.m_id), lang, optimized);
SetCompileUnitAtIndex(cci.m_id.modi, cu_sp);
return cu_sp;
diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp
index a6b6c8e..1b3cd23 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -22,16 +22,19 @@ 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)
- : CompileUnit(module_sp, user_data, FileSpec(pathname), cu_sym_id, language,
- is_optimized) {}
+ : CompileUnit(module_sp, user_data,
+ std::make_shared<SupportFile>(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::SupportFileSP support_file_sp,
+ 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_file_spec(fspec),
+ m_language(language), m_flags(0),
+ m_primary_support_file_sp(support_file_sp),
m_support_files(std::move(support_files)), m_is_optimized(is_optimized) {
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);