Author: Jonas Devlieghere Date: 2019-11-12T20:16:33-08:00 New Revision: 7ba28644a1eeb554e818644556f98abfc0795b02
URL: https://github.com/llvm/llvm-project/commit/7ba28644a1eeb554e818644556f98abfc0795b02 DIFF: https://github.com/llvm/llvm-project/commit/7ba28644a1eeb554e818644556f98abfc0795b02.diff LOG: [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. Added: lldb/test/Shell/Reproducer/Inputs/Discard.in lldb/test/Shell/Reproducer/TestDiscard.test Modified: lldb/include/lldb/Utility/Reproducer.h lldb/source/Utility/Reproducer.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h index 3db98a781d4c..ddb1f45a7219 100644 --- a/lldb/include/lldb/Utility/Reproducer.h +++ b/lldb/include/lldb/Utility/Reproducer.h @@ -288,7 +288,7 @@ class Generator final { 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 4777d7576a32..e0806f5f5981 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 000000000000..a2c4e48d1f46 --- /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 000000000000..db9614aabb84 --- /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 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits