[Lldb-commits] [PATCH] D126435: NFC delay tilde expansion on source path remappings until we are opening a source file
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu May 26 00:37:15 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc274b6e5830e: Defer source path remap tilde expansion until source file use (authored by jasonmolenda).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126435/new/
https://reviews.llvm.org/D126435
Files:
lldb/source/Core/SourceManager.cpp
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
Index: lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
===================================================================
--- lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -237,13 +237,6 @@
!original_DBGSourcePath_value.empty()) {
DBGSourcePath = original_DBGSourcePath_value;
}
- if (DBGSourcePath[0] == '~') {
- FileSpec resolved_source_path(
- DBGSourcePath.c_str());
- FileSystem::Instance().Resolve(
- resolved_source_path);
- DBGSourcePath = resolved_source_path.GetPath();
- }
module_sp->GetSourceMappingList().Append(
key.GetStringRef(), DBGSourcePath, true);
// With version 2 of DBGSourcePathRemapping, we
@@ -275,11 +268,6 @@
DBGBuildSourcePath);
plist.GetValueAsString("DBGSourcePath", DBGSourcePath);
if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
- if (DBGSourcePath[0] == '~') {
- FileSpec resolved_source_path(DBGSourcePath.c_str());
- FileSystem::Instance().Resolve(resolved_source_path);
- DBGSourcePath = resolved_source_path.GetPath();
- }
module_sp->GetSourceMappingList().Append(
DBGBuildSourcePath, DBGSourcePath, true);
}
Index: lldb/source/Core/SourceManager.cpp
===================================================================
--- lldb/source/Core/SourceManager.cpp
+++ lldb/source/Core/SourceManager.cpp
@@ -49,6 +49,13 @@
static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
+static void resolve_tilde(FileSpec &file_spec) {
+ if (!FileSystem::Instance().Exists(file_spec) &&
+ file_spec.GetDirectory().GetCString()[0] == '~') {
+ FileSystem::Instance().Resolve(file_spec);
+ }
+}
+
// SourceManager constructor
SourceManager::SourceManager(const TargetSP &target_sp)
: m_last_line(0), m_last_count(0), m_default_set(false),
@@ -66,10 +73,13 @@
if (!file_spec)
return nullptr;
+ FileSpec resolved_fspec = file_spec;
+ resolve_tilde(resolved_fspec);
+
DebuggerSP debugger_sp(m_debugger_wp.lock());
FileSP file_sp;
if (debugger_sp && debugger_sp->GetUseSourceCache())
- file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
+ file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(resolved_fspec);
TargetSP target_sp(m_target_wp.lock());
@@ -87,9 +97,9 @@
// If file_sp is no good or it points to a non-existent file, reset it.
if (!file_sp || !FileSystem::Instance().Exists(file_sp->GetFileSpec())) {
if (target_sp)
- file_sp = std::make_shared<File>(file_spec, target_sp.get());
+ file_sp = std::make_shared<File>(resolved_fspec, target_sp.get());
else
- file_sp = std::make_shared<File>(file_spec, debugger_sp);
+ file_sp = std::make_shared<File>(resolved_fspec, debugger_sp);
if (debugger_sp && debugger_sp->GetUseSourceCache())
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
@@ -441,6 +451,7 @@
}
}
}
+ resolve_tilde(m_file_spec);
// Try remapping if m_file_spec does not correspond to an existing file.
if (!FileSystem::Instance().Exists(m_file_spec)) {
// Check target specific source remappings (i.e., the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126435.432207.patch
Type: text/x-patch
Size: 3866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220526/a274a407/attachment.bin>
More information about the lldb-commits
mailing list