Skip to content

Commit beea22b

Browse files
author
git apple-llvm automerger
committed
Merge commit '1589f3e6eddf' from apple/stable/20200714 into swift/master-rebranch
2 parents 8e6a0e0 + 1589f3e commit beea22b

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

lldb/include/lldb/Utility/Reproducer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "lldb/Utility/FileSpec.h"
1313
#include "llvm/ADT/DenseMap.h"
14+
#include "llvm/ADT/StringRef.h"
1415
#include "llvm/Support/Error.h"
1516
#include "llvm/Support/FileCollector.h"
1617
#include "llvm/Support/YAMLTraits.h"
@@ -99,7 +100,7 @@ class FileProvider : public Provider<FileProvider> {
99100
return m_collector;
100101
}
101102

102-
void recordInterestingDirectory(const llvm::Twine &dir);
103+
void RecordInterestingDirectory(const llvm::Twine &dir);
103104

104105
void Keep() override {
105106
auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
@@ -149,6 +150,7 @@ class WorkingDirectoryProvider : public Provider<WorkingDirectoryProvider> {
149150
}
150151

151152
void Update(llvm::StringRef path) { m_cwd = std::string(path); }
153+
llvm::StringRef GetWorkingDirectory() { return m_cwd; }
152154

153155
struct Info {
154156
static const char *name;

lldb/source/API/SBReproducer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ const char *SBReproducer::GetPath() {
234234

235235
void SBReproducer::SetWorkingDirectory(const char *path) {
236236
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
237-
g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
237+
auto &wp = g->GetOrCreate<repro::WorkingDirectoryProvider>();
238+
wp.Update(path);
239+
auto &fp = g->GetOrCreate<repro::FileProvider>();
240+
fp.RecordInterestingDirectory(wp.GetWorkingDirectory());
238241
}
239242
}
240243

lldb/source/Initialization/SystemInitializerCommon.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ llvm::Error SystemInitializerCommon::Initialize() {
9494
vp.SetVersion(lldb_private::GetVersion());
9595
repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
9696
FileSystem::Initialize(fp.GetFileCollector());
97+
repro::WorkingDirectoryProvider &wp = g->GetOrCreate<repro::WorkingDirectoryProvider>();
98+
fp.RecordInterestingDirectory(wp.GetWorkingDirectory());
9799
} else {
98100
FileSystem::Initialize();
99101
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
299299
if (repro::Generator *g =
300300
repro::Reproducer::Instance().GetGenerator()) {
301301
repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
302-
fp.recordInterestingDirectory(dsym_root);
302+
fp.RecordInterestingDirectory(dsym_root);
303303
}
304304
}
305305
return symbol_vendor;

lldb/source/Utility/Reproducer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void WorkingDirectoryProvider::Keep() {
299299
os << m_cwd << "\n";
300300
}
301301

302-
void FileProvider::recordInterestingDirectory(const llvm::Twine &dir) {
302+
void FileProvider::RecordInterestingDirectory(const llvm::Twine &dir) {
303303
if (m_collector)
304304
m_collector->addDirectory(dir);
305305
}

lldb/test/Shell/Reproducer/TestWorkingDir.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@
1515

1616
# RUN: cat %t.repro/cwd.txt | FileCheck %t.check
1717
# RUN: %lldb --replay %t.repro | FileCheck %t.check
18+
19+
# Make sure the current working directory is recorded even when it's not
20+
# referenced.
21+
22+
# RUN: rm -rf %t.repro
23+
# RUN: mkdir -p %t/probably_unique
24+
# RUN: cd %t/probably_unique
25+
# RUN: %lldb -x -b -o 'reproducer generate' --capture --capture-path %t.repro
26+
# RUN: cat %t.repro/cwd.txt | FileCheck %s
27+
# CHECK: probably_unique

0 commit comments

Comments
 (0)