static const char *Replay(const char *path);
static const char *Replay(const char *path, bool skip_version_check);
static const char *GetPath();
+ static bool SetAutoGenerate(bool b);
static bool Generate();
};
/// might need to clean up files already written to disk.
void Discard();
+ /// Enable or disable auto generate.
+ void SetAutoGenerate(bool b);
+
/// Create and register a new provider.
template <typename T> T *Create() {
std::unique_ptr<ProviderBase> provider = std::make_unique<T>(m_root);
/// Flag to ensure that we never call both keep and discard.
bool m_done = false;
+
+ /// Flag to auto generate a reproducer when it would otherwise be discarded.
+ bool m_auto_generate = false;
};
class Loader final {
return false;
}
+bool SBReproducer::SetAutoGenerate(bool b) {
+ auto &r = Reproducer::Instance();
+ if (auto generator = r.GetGenerator()) {
+ generator->SetAutoGenerate(b);
+ return true;
+ }
+ return false;
+}
+
const char *SBReproducer::GetPath() {
static std::string path;
auto &r = Reproducer::Instance();
}
Generator::~Generator() {
- if (!m_done)
- Discard();
+ if (!m_done) {
+ if (m_auto_generate)
+ Keep();
+ else
+ Discard();
+ }
}
ProviderBase *Generator::Register(std::unique_ptr<ProviderBase> provider) {
llvm::sys::fs::remove_directories(m_root.GetPath());
}
+void Generator::SetAutoGenerate(bool b) { m_auto_generate = b; }
+
const FileSpec &Generator::GetRoot() const { return m_root; }
void Generator::AddProvidersToIndex() {
# RUN: %lldb --capture --capture-path %t.repro -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
# RUN: %lldb --capture -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE
+# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' --reproducer-auto-generate 2>&1 | FileCheck %s --check-prefix WARNING2
#
# NO-WARNING-NOT: warning: -capture-path specified without -capture
# WARNING: warning: -capture-path specified without -capture
+# WARNING2: warning: -reproducer-auto-generate specified without -capture
# STATUS-CAPTURE: Reproducer is in capture mode.
+
+# Check auto generate.
+# RUN: rm -rf %t.repro
+# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING
+# RUN: cat %t.repro/index.yaml
}
bool capture = input_args.hasArg(OPT_capture);
+ bool auto_generate = input_args.hasArg(OPT_auto_generate);
auto *capture_path = input_args.getLastArg(OPT_capture_path);
+ if (auto_generate && !capture) {
+ WithColor::warning()
+ << "-reproducer-auto-generate specified without -capture\n";
+ }
+
if (capture || capture_path) {
if (capture_path) {
if (!capture)
return 1;
}
}
+ if (auto_generate)
+ SBReproducer::SetAutoGenerate(true);
}
return llvm::None;
HelpText<"Tells the debugger to replay a reproducer from <filename>.">;
def skip_version_check: F<"reproducer-skip-version-check">,
HelpText<"Skip the reproducer version check.">;
+def auto_generate: F<"reproducer-auto-generate">,
+ HelpText<"Generate reproducer on exit.">;
def REM : R<["--"], "">;