From df14b94243e9e8ade2747e6adb8a3d9d2cfa71ae Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 15 Nov 2018 01:05:40 +0000 Subject: [PATCH] [reproducer] Post-commit cleanup After committing the initial reproducer feature I noticed a few small issues which warranted addressing here. It fixes incorrect documentation in the command object and extract some duplicated code into the debugger object. llvm-svn: 346919 --- lldb/include/lldb/Core/Debugger.h | 2 ++ lldb/source/Commands/CommandObjectReproducer.cpp | 13 +++++-------- lldb/source/Core/Debugger.cpp | 7 +++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 0419bdefac1c..52750180d011 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -266,6 +266,8 @@ public: void SetReproducerPath(llvm::StringRef p); void SetReproducerPath(const char *) = delete; + llvm::Error SetReproducerCapture(bool b); + bool GetUseExternalEditor() const; bool SetUseExternalEditor(bool use_external_editor_p); diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp index e69a6308892b..a1fdb4a1fcdf 100644 --- a/lldb/source/Commands/CommandObjectReproducer.cpp +++ b/lldb/source/Commands/CommandObjectReproducer.cpp @@ -11,6 +11,7 @@ #include "lldb/Utility/Reproducer.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Interpreter/OptionGroupBoolean.h" @@ -40,8 +41,7 @@ protected: return false; } - auto &r = repro::Reproducer::Instance(); - if (auto e = r.SetGenerateReproducer(true)) { + if (auto e = m_interpreter.GetDebugger().SetReproducerCapture(true)) { AppendErrorToResult(std::move(e), result); return false; } @@ -68,8 +68,7 @@ protected: return false; } - auto &r = repro::Reproducer::Instance(); - if (auto e = r.SetGenerateReproducer(false)) { + if (auto e = m_interpreter.GetDebugger().SetReproducerCapture(false)) { AppendErrorToResult(std::move(e), result); return false; } @@ -114,10 +113,8 @@ protected: class CommandObjectReproducerReplay : public CommandObjectParsed { public: CommandObjectReproducerReplay(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "reproducer capture", - "Enable or disable gathering of information needed " - "to generate a reproducer.", - nullptr) { + : CommandObjectParsed(interpreter, "reproducer replay", + "Replay a reproducer.", nullptr) { CommandArgumentEntry arg1; CommandArgumentData path_arg; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 1494783bc8f4..c8af32841623 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -424,6 +424,13 @@ void Debugger::SetReproducerPath(llvm::StringRef p) { llvm::consumeError(std::move(e)); } +llvm::Error Debugger::SetReproducerCapture(bool b) { + auto &r = repro::Reproducer::Instance(); + if (auto e = r.SetGenerateReproducer(false)) + return e; + return llvm::Error::success(); +} + const FormatEntity::Entry *Debugger::GetThreadFormat() const { const uint32_t idx = ePropertyThreadFormat; return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);