Skip to content

Commit 56ac85a

Browse files
committed
Revert "Defer source path remap tilde expansion until source file use"
This reverts commit c274b6e. The x86_64 debian bot got a failure with this patch, https://lab.llvm.org/buildbot#builders/68/builds/33078 where SymbolFile/DWARF/x86/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s is crashing here - #2 0x0000000000425a9f SignalHandler(int) Signals.cpp:0:0 #3 0x00007f57160e9140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140) #4 0x00007f570d911e43 lldb_private::SourceManager::GetFile(lldb_private::FileSpec const&) crtstuff.c:0:0 #5 0x00007f570d914270 lldb_private::SourceManager::DisplaySourceLinesWithLineNumbers(lldb_private::FileSpec const&, unsigned int, unsigned int, unsigned int, unsigned int, char const*, lldb_private::Stream*, lldb_private::SymbolContextList const*) crtstuff.c:0:0 #6 0x00007f570da662c8 lldb_private::StackFrame::GetStatus(lldb_private::Stream&, bool, bool, bool, char const*) crtstuff.c:0:0 I don't get a failure here my mac, I'll review this method more closely tomorrow.
1 parent c274b6e commit 56ac85a

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

lldb/source/Core/SourceManager.cpp

+3-14
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ using namespace lldb_private;
4949

5050
static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
5151

52-
static void resolve_tilde(FileSpec &file_spec) {
53-
if (!FileSystem::Instance().Exists(file_spec) &&
54-
file_spec.GetDirectory().GetCString()[0] == '~') {
55-
FileSystem::Instance().Resolve(file_spec);
56-
}
57-
}
58-
5952
// SourceManager constructor
6053
SourceManager::SourceManager(const TargetSP &target_sp)
6154
: m_last_line(0), m_last_count(0), m_default_set(false),
@@ -73,13 +66,10 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
7366
if (!file_spec)
7467
return nullptr;
7568

76-
FileSpec resolved_fspec = file_spec;
77-
resolve_tilde(resolved_fspec);
78-
7969
DebuggerSP debugger_sp(m_debugger_wp.lock());
8070
FileSP file_sp;
8171
if (debugger_sp && debugger_sp->GetUseSourceCache())
82-
file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(resolved_fspec);
72+
file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
8373

8474
TargetSP target_sp(m_target_wp.lock());
8575

@@ -97,9 +87,9 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
9787
// If file_sp is no good or it points to a non-existent file, reset it.
9888
if (!file_sp || !FileSystem::Instance().Exists(file_sp->GetFileSpec())) {
9989
if (target_sp)
100-
file_sp = std::make_shared<File>(resolved_fspec, target_sp.get());
90+
file_sp = std::make_shared<File>(file_spec, target_sp.get());
10191
else
102-
file_sp = std::make_shared<File>(resolved_fspec, debugger_sp);
92+
file_sp = std::make_shared<File>(file_spec, debugger_sp);
10393

10494
if (debugger_sp && debugger_sp->GetUseSourceCache())
10595
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
@@ -451,7 +441,6 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
451441
}
452442
}
453443
}
454-
resolve_tilde(m_file_spec);
455444
// Try remapping if m_file_spec does not correspond to an existing file.
456445
if (!FileSystem::Instance().Exists(m_file_spec)) {
457446
// Check target specific source remappings (i.e., the

lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
237237
!original_DBGSourcePath_value.empty()) {
238238
DBGSourcePath = original_DBGSourcePath_value;
239239
}
240+
if (DBGSourcePath[0] == '~') {
241+
FileSpec resolved_source_path(
242+
DBGSourcePath.c_str());
243+
FileSystem::Instance().Resolve(
244+
resolved_source_path);
245+
DBGSourcePath = resolved_source_path.GetPath();
246+
}
240247
module_sp->GetSourceMappingList().Append(
241248
key.GetStringRef(), DBGSourcePath, true);
242249
// With version 2 of DBGSourcePathRemapping, we
@@ -268,6 +275,11 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
268275
DBGBuildSourcePath);
269276
plist.GetValueAsString("DBGSourcePath", DBGSourcePath);
270277
if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
278+
if (DBGSourcePath[0] == '~') {
279+
FileSpec resolved_source_path(DBGSourcePath.c_str());
280+
FileSystem::Instance().Resolve(resolved_source_path);
281+
DBGSourcePath = resolved_source_path.GetPath();
282+
}
271283
module_sp->GetSourceMappingList().Append(
272284
DBGBuildSourcePath, DBGSourcePath, true);
273285
}

0 commit comments

Comments
 (0)