summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-11-12 20:16:33 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2019-11-12 20:16:33 -0800
commit7ba28644a1eeb554e818644556f98abfc0795b02 (patch)
tree4a73c1d35e940c4d62570169f2094a483a135bb4
parentd8b6b1114307558a5245de3806bb70f53f6f3efe (diff)
downloadbcm5719-llvm-7ba28644a1eeb554e818644556f98abfc0795b02.tar.gz
bcm5719-llvm-7ba28644a1eeb554e818644556f98abfc0795b02.zip
[Reproducer] Discard reproducer directory if not generated.
If lldb was run in capture mode, but no reproducer was generated, make sure we clean up the reproducer directory.
-rw-r--r--lldb/include/lldb/Utility/Reproducer.h2
-rw-r--r--lldb/source/Utility/Reproducer.cpp8
-rw-r--r--lldb/test/Shell/Reproducer/Inputs/Discard.in5
-rw-r--r--lldb/test/Shell/Reproducer/TestDiscard.test13
4 files changed, 24 insertions, 4 deletions
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 3db98a781d4..ddb1f45a721 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -288,7 +288,7 @@ private:
FileSpec m_root;
/// Flag to ensure that we never call both keep and discard.
- bool m_done;
+ bool m_done = false;
};
class Loader final {
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp
index 4777d7576a3..e0806f5f598 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -143,12 +143,14 @@ static FileSpec MakeAbsolute(FileSpec file_spec) {
return FileSpec(path, file_spec.GetPathStyle());
}
-Generator::Generator(FileSpec root)
- : m_root(MakeAbsolute(std::move(root))), m_done(false) {
+Generator::Generator(FileSpec root) : m_root(MakeAbsolute(std::move(root))) {
GetOrCreate<repro::WorkingDirectoryProvider>();
}
-Generator::~Generator() {}
+Generator::~Generator() {
+ if (!m_done)
+ Discard();
+}
ProviderBase *Generator::Register(std::unique_ptr<ProviderBase> provider) {
std::lock_guard<std::mutex> lock(m_providers_mutex);
diff --git a/lldb/test/Shell/Reproducer/Inputs/Discard.in b/lldb/test/Shell/Reproducer/Inputs/Discard.in
new file mode 100644
index 00000000000..a2c4e48d1f4
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/Inputs/Discard.in
@@ -0,0 +1,5 @@
+breakpoint set -f simple.c -l 12
+run
+bt
+cont
+reproducer status
diff --git a/lldb/test/Shell/Reproducer/TestDiscard.test b/lldb/test/Shell/Reproducer/TestDiscard.test
new file mode 100644
index 00000000000..db9614aabb8
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/TestDiscard.test
@@ -0,0 +1,13 @@
+# UNSUPPORTED: system-windows
+# This ensures that the reproducer properly cleans up after itself.
+
+# Build the inferior.
+# RUN: mkdir -p %t
+# RUN: rm -rf %t.repro
+# RUN: %clang_host %S/Inputs/simple.c -g -o %t/reproducer.out
+
+# Capture but don't generate the reproducer.
+# RUN: %lldb -x -b -s %S/Inputs/Discard.in --capture --capture-path %t.repro %t/reproducer.out
+
+# Make sure the directory doesn't exist.
+# RUN: mkdir %t.repro
OpenPOWER on IntegriCloud