summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Utility/Reproducer.h4
-rw-r--r--lldb/lit/Reproducer/TestRelativePath.test8
-rw-r--r--lldb/source/Utility/Reproducer.cpp13
3 files changed, 21 insertions, 4 deletions
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 556f39034ab..1ad7638eec4 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -215,7 +215,7 @@ private:
class Generator final {
public:
- Generator(const FileSpec &root);
+ Generator(FileSpec root);
~Generator();
/// Method to indicate we want to keep the reproducer. If reproducer
@@ -272,7 +272,7 @@ private:
class Loader final {
public:
- Loader(const FileSpec &root);
+ Loader(FileSpec root);
template <typename T> FileSpec GetFile() {
if (!HasFile(T::file))
diff --git a/lldb/lit/Reproducer/TestRelativePath.test b/lldb/lit/Reproducer/TestRelativePath.test
new file mode 100644
index 00000000000..1c871ee81e8
--- /dev/null
+++ b/lldb/lit/Reproducer/TestRelativePath.test
@@ -0,0 +1,8 @@
+# This tests relative capture paths.
+
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: rm -rf ./foo
+# RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
+# RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' --capture --capture-path ./foo %t/reproducer.out
+# RUN: %lldb --replay ./foo
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp
index 8e44f080177..a8a581f0761 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -136,7 +136,15 @@ FileSpec Reproducer::GetReproducerPath() const {
return {};
}
-Generator::Generator(const FileSpec &root) : m_root(root), m_done(false) {}
+static FileSpec MakeAbsolute(FileSpec file_spec) {
+ SmallString<128> path;
+ file_spec.GetPath(path, false);
+ llvm::sys::fs::make_absolute(path);
+ return FileSpec(path, file_spec.GetPathStyle());
+}
+
+Generator::Generator(FileSpec root)
+ : m_root(MakeAbsolute(std::move(root))), m_done(false) {}
Generator::~Generator() {}
@@ -188,7 +196,8 @@ void Generator::AddProvidersToIndex() {
yout << files;
}
-Loader::Loader(const FileSpec &root) : m_root(root), m_loaded(false) {}
+Loader::Loader(FileSpec root)
+ : m_root(MakeAbsolute(std::move(root))), m_loaded(false) {}
llvm::Error Loader::LoadIndex() {
if (m_loaded)
OpenPOWER on IntegriCloud