mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
This patch changes the way the reproducer is initialized. Rather than making changes at run time we now do everything at initialization time. To make this happen we had to introduce initializer options and their SB variant. This allows us to tell the initializer that we're running in reproducer capture/replay mode. Because of this change we also had to alter our testing strategy. We cannot reinitialize LLDB when using the dotest infrastructure. Instead we use lit and invoke two instances of the driver. Another consequence is that we can no longer enable capture or replay through commands. This was bound to go away form the beginning, but I had something in mind where you could enable/disable specific providers. However this seems like it adds very little value right now so the corresponding commands were removed. Finally this change also means you now have to control this through the driver, for which I replaced --reproducer with --capture and --replay to differentiate between the two modes. Differential revision: https://reviews.llvm.org/D55038 llvm-svn: 348152
98 lines
3.2 KiB
C++
98 lines
3.2 KiB
C++
//===-- CommandObjectReproducer.cpp -----------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "CommandObjectReproducer.h"
|
|
|
|
#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"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
class CommandObjectReproducerGenerate : public CommandObjectParsed {
|
|
public:
|
|
CommandObjectReproducerGenerate(CommandInterpreter &interpreter)
|
|
: CommandObjectParsed(interpreter, "reproducer generate",
|
|
"Generate reproducer on disk.", nullptr) {}
|
|
|
|
~CommandObjectReproducerGenerate() override = default;
|
|
|
|
protected:
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
if (!command.empty()) {
|
|
result.AppendErrorWithFormat("'%s' takes no arguments",
|
|
m_cmd_name.c_str());
|
|
return false;
|
|
}
|
|
|
|
auto &r = repro::Reproducer::Instance();
|
|
if (auto generator = r.GetGenerator()) {
|
|
generator->Keep();
|
|
} else {
|
|
result.AppendErrorWithFormat("Unable to get the reproducer generator");
|
|
return false;
|
|
}
|
|
|
|
result.GetOutputStream()
|
|
<< "Reproducer written to '" << r.GetReproducerPath() << "'\n";
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
return result.Succeeded();
|
|
}
|
|
};
|
|
|
|
class CommandObjectReproducerStatus : public CommandObjectParsed {
|
|
public:
|
|
CommandObjectReproducerStatus(CommandInterpreter &interpreter)
|
|
: CommandObjectParsed(interpreter, "reproducer status",
|
|
"Show the current reproducer status.", nullptr) {}
|
|
|
|
~CommandObjectReproducerStatus() override = default;
|
|
|
|
protected:
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
if (!command.empty()) {
|
|
result.AppendErrorWithFormat("'%s' takes no arguments",
|
|
m_cmd_name.c_str());
|
|
return false;
|
|
}
|
|
|
|
auto &r = repro::Reproducer::Instance();
|
|
if (auto generator = r.GetGenerator()) {
|
|
result.GetOutputStream() << "Reproducer is in capture mode.\n";
|
|
} else if (auto generator = r.GetLoader()) {
|
|
result.GetOutputStream() << "Reproducer is in replay mode.\n";
|
|
} else {
|
|
|
|
result.GetOutputStream() << "Reproducer is off.\n";
|
|
}
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
return result.Succeeded();
|
|
}
|
|
};
|
|
|
|
CommandObjectReproducer::CommandObjectReproducer(
|
|
CommandInterpreter &interpreter)
|
|
: CommandObjectMultiword(interpreter, "reproducer",
|
|
"Commands controlling LLDB reproducers.",
|
|
"log <subcommand> [<command-options>]") {
|
|
LoadSubCommand(
|
|
"generate",
|
|
CommandObjectSP(new CommandObjectReproducerGenerate(interpreter)));
|
|
LoadSubCommand("status", CommandObjectSP(
|
|
new CommandObjectReproducerStatus(interpreter)));
|
|
}
|
|
|
|
CommandObjectReproducer::~CommandObjectReproducer() = default;
|