summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Utility/FileCollector.h5
-rw-r--r--lldb/include/lldb/Utility/Reproducer.h7
-rw-r--r--lldb/lit/Reproducer/TestReuseDirectory.test7
-rw-r--r--lldb/source/API/SBDebugger.cpp6
-rw-r--r--lldb/source/Host/common/FileSystem.cpp5
-rw-r--r--lldb/source/Utility/FileCollector.cpp7
-rw-r--r--lldb/unittests/Utility/FileCollectorTest.cpp6
7 files changed, 32 insertions, 11 deletions
diff --git a/lldb/include/lldb/Utility/FileCollector.h b/lldb/include/lldb/Utility/FileCollector.h
index d7bdcf479f8..a89206747fe 100644
--- a/lldb/include/lldb/Utility/FileCollector.h
+++ b/lldb/include/lldb/Utility/FileCollector.h
@@ -25,7 +25,7 @@ namespace lldb_private {
/// the VFS.
class FileCollector {
public:
- FileCollector(const FileSpec &root);
+ FileCollector(const FileSpec &root, const FileSpec &overlay);
void AddFile(const llvm::Twine &file);
void AddFile(const FileSpec &file) { return AddFile(file.GetPath()); }
@@ -59,6 +59,9 @@ protected:
/// The root directory where files are copied.
FileSpec m_root;
+ /// The root directory where the VFS overlay lives.
+ FileSpec m_overlay_root;
+
/// Tracks already seen files so they can be skipped.
llvm::StringSet<> m_seen;
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 9f8a679959e..670041d06bb 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -91,7 +91,8 @@ public:
FileProvider(const FileSpec &directory)
: Provider(directory),
- m_collector(directory.CopyByAppendingPathComponent("root")) {}
+ m_collector(directory.CopyByAppendingPathComponent("root"), directory) {
+ }
FileCollector &GetFileCollector() { return m_collector; }
@@ -132,8 +133,8 @@ public:
class DataRecorder {
public:
DataRecorder(const FileSpec &filename, std::error_code &ec)
- : m_filename(std::move(filename)),
- m_os(m_filename.GetPath(), ec, llvm::sys::fs::F_Text), m_record(true) {}
+ : m_filename(filename.GetFilename().GetStringRef()),
+ m_os(filename.GetPath(), ec, llvm::sys::fs::F_Text), m_record(true) {}
static llvm::Expected<std::unique_ptr<DataRecorder>>
Create(const FileSpec &filename);
diff --git a/lldb/lit/Reproducer/TestReuseDirectory.test b/lldb/lit/Reproducer/TestReuseDirectory.test
index d4867365cf9..76c74b7ee1d 100644
--- a/lldb/lit/Reproducer/TestReuseDirectory.test
+++ b/lldb/lit/Reproducer/TestReuseDirectory.test
@@ -8,3 +8,10 @@
# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture --capture-path %t.repro %t.out | FileCheck %S/TestGDBRemoteRepro.test --check-prefix CHECK --check-prefix CAPTURE
# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture --capture-path %t.repro %t.out | FileCheck %S/TestGDBRemoteRepro.test --check-prefix CHECK --check-prefix CAPTURE
# RUN: %lldb --replay %t.repro | FileCheck %S/TestGDBRemoteRepro.test --check-prefix CHECK --check-prefix REPLAY
+
+# Test that we can replay from a different location, i.e. that the reproducer
+# is relocatable.
+
+# RUN: rm -rf %t.repro_moved
+# RUN: mv %t.repro %t.repro_moved
+# RUN: %lldb --replay %t.repro_moved | FileCheck %S/TestGDBRemoteRepro.test --check-prefix CHECK --check-prefix REPLAY
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7af83324e9f..634c4a92959 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -82,6 +82,12 @@ public:
if (auto err = yin.error())
return {};
+ for (auto &file : files) {
+ FileSpec absolute_path =
+ loader->GetRoot().CopyByAppendingPathComponent(file);
+ file = absolute_path.GetPath();
+ }
+
return llvm::make_unique<CommandLoader>(std::move(files));
}
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index ade7cc95bd7..d5ac05bd447 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -63,8 +63,9 @@ llvm::Error FileSystem::Initialize(const FileSpec &mapping) {
if (!buffer)
return llvm::errorCodeToError(buffer.getError());
- InstanceImpl().emplace(
- llvm::vfs::getVFSFromYAML(std::move(buffer.get()), nullptr, ""), true);
+ InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()),
+ nullptr, mapping.GetPath()),
+ true);
return llvm::Error::success();
}
diff --git a/lldb/source/Utility/FileCollector.cpp b/lldb/source/Utility/FileCollector.cpp
index 1758ad8c82c..566355d4973 100644
--- a/lldb/source/Utility/FileCollector.cpp
+++ b/lldb/source/Utility/FileCollector.cpp
@@ -33,7 +33,8 @@ static bool IsCaseSensitivePath(StringRef path) {
return true;
}
-FileCollector::FileCollector(const FileSpec &root) : m_root(root) {
+FileCollector::FileCollector(const FileSpec &root, const FileSpec &overlay_root)
+ : m_root(root), m_overlay_root(overlay_root) {
sys::fs::create_directories(m_root.GetPath(), true);
}
@@ -133,7 +134,9 @@ std::error_code FileCollector::CopyFiles(bool stop_on_error) {
std::error_code FileCollector::WriteMapping(const FileSpec &mapping_file) {
std::lock_guard<std::mutex> lock(m_mutex);
- const std::string root = m_root.GetPath();
+ llvm::StringRef root = m_overlay_root.GetPath();
+
+ m_vfs_writer.setOverlayDir(root);
m_vfs_writer.setCaseSensitivity(IsCaseSensitivePath(root));
m_vfs_writer.setUseExternalNames(false);
diff --git a/lldb/unittests/Utility/FileCollectorTest.cpp b/lldb/unittests/Utility/FileCollectorTest.cpp
index 346a6347897..348b4cc612a 100644
--- a/lldb/unittests/Utility/FileCollectorTest.cpp
+++ b/lldb/unittests/Utility/FileCollectorTest.cpp
@@ -105,7 +105,7 @@ struct ScopedFile {
TEST(FileCollectorTest, AddFile) {
ScopedDir root("add_file_root", true);
FileSpec root_fs(root.Path);
- TestingFileCollector file_collector(root_fs);
+ TestingFileCollector file_collector(root_fs, root_fs);
file_collector.AddFile(FileSpec("/path/to/a"));
file_collector.AddFile(FileSpec("/path/to/b"));
@@ -132,7 +132,7 @@ TEST(FileCollectorTest, CopyFiles) {
// Create file collector and add files.
ScopedDir root("copy_files_root", true);
FileSpec root_fs(root.Path);
- TestingFileCollector file_collector(root_fs);
+ TestingFileCollector file_collector(root_fs, root_fs);
file_collector.AddFile(a.Path);
file_collector.AddFile(b.Path);
file_collector.AddFile(c.Path);
@@ -174,7 +174,7 @@ TEST(FileCollectorTest, Symlinks) {
// Root where files are copied to.
ScopedDir reproducer_root("reproducer_root", true);
FileSpec root_fs(reproducer_root.Path);
- TestingFileCollector file_collector(root_fs);
+ TestingFileCollector file_collector(root_fs, root_fs);
// Add all the files to the collector.
file_collector.AddFile(a.Path);
OpenPOWER on IntegriCloud