aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectReproducer.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
commit145449b1e420787bb99721a429341fa6be3adfb6 (patch)
tree1d56ae694a6de602e348dd80165cf881a36600ed /lldb/source/Commands/CommandObjectReproducer.cpp
parentecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff)
Diffstat (limited to 'lldb/source/Commands/CommandObjectReproducer.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectReproducer.cpp131
1 files changed, 3 insertions, 128 deletions
diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp
index 7e0ea65e148e..8d12decba974 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -182,19 +182,9 @@ public:
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 = Reproducer::Instance();
if (auto generator = r.GetGenerator()) {
generator->Keep();
- if (llvm::Error e = repro::Finalize(r.GetReproducerPath())) {
- SetError(result, std::move(e));
- return result.Succeeded();
- }
} else {
result.AppendErrorWithFormat("Unable to get the reproducer generator");
return false;
@@ -227,7 +217,7 @@ public:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -264,12 +254,6 @@ public:
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 = Reproducer::Instance();
if (!r.IsCapturing()) {
@@ -313,12 +297,6 @@ public:
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 = Reproducer::Instance();
if (r.IsCapturing()) {
result.GetOutputStream() << "Reproducer is in capture mode.\n";
@@ -355,7 +333,7 @@ public:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -398,12 +376,6 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (!command.empty()) {
- result.AppendErrorWithFormat("'%s' takes no arguments",
- m_cmd_name.c_str());
- return false;
- }
-
llvm::Optional<Loader> loader_storage;
Loader *loader =
GetLoaderFromPathOrCurrent(loader_storage, result, m_options.file);
@@ -429,7 +401,7 @@ protected:
// Dump the VFS to a buffer.
std::string str;
raw_string_ostream os(str);
- static_cast<vfs::RedirectingFileSystem &>(*vfs).dump(os);
+ static_cast<vfs::RedirectingFileSystem &>(*vfs).print(os);
os.flush();
// Return the string.
@@ -587,101 +559,6 @@ private:
CommandOptions m_options;
};
-class CommandObjectReproducerVerify : public CommandObjectParsed {
-public:
- CommandObjectReproducerVerify(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "reproducer verify",
- "Verify the contents of a reproducer. "
- "If no reproducer is specified during replay, it "
- "verifies the content of the current reproducer.",
- nullptr) {}
-
- ~CommandObjectReproducerVerify() override = default;
-
- Options *GetOptions() override { return &m_options; }
-
- class CommandOptions : public Options {
- public:
- CommandOptions() {}
-
- ~CommandOptions() override = default;
-
- Status SetOptionValue(uint32_t option_idx, StringRef option_arg,
- ExecutionContext *execution_context) override {
- Status error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option) {
- case 'f':
- file.SetFile(option_arg, FileSpec::Style::native);
- FileSystem::Instance().Resolve(file);
- break;
- default:
- llvm_unreachable("Unimplemented option");
- }
-
- return error;
- }
-
- void OptionParsingStarting(ExecutionContext *execution_context) override {
- file.Clear();
- }
-
- ArrayRef<OptionDefinition> GetDefinitions() override {
- return makeArrayRef(g_reproducer_verify_options);
- }
-
- FileSpec file;
- };
-
-protected:
- bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (!command.empty()) {
- result.AppendErrorWithFormat("'%s' takes no arguments",
- m_cmd_name.c_str());
- return false;
- }
-
- llvm::Optional<Loader> loader_storage;
- Loader *loader =
- GetLoaderFromPathOrCurrent(loader_storage, result, m_options.file);
- if (!loader)
- return false;
-
- bool errors = false;
- auto error_callback = [&](llvm::StringRef error) {
- errors = true;
- result.AppendError(error);
- };
-
- bool warnings = false;
- auto warning_callback = [&](llvm::StringRef warning) {
- warnings = true;
- result.AppendWarning(warning);
- };
-
- auto note_callback = [&](llvm::StringRef warning) {
- result.AppendMessage(warning);
- };
-
- Verifier verifier(loader);
- verifier.Verify(error_callback, warning_callback, note_callback);
-
- if (warnings || errors) {
- result.AppendMessage("reproducer verification failed");
- result.SetStatus(eReturnStatusFailed);
- } else {
- result.AppendMessage("reproducer verification succeeded");
- result.SetStatus(eReturnStatusSuccessFinishResult);
- }
-
- return result.Succeeded();
- }
-
-private:
- CommandOptions m_options;
-};
-
CommandObjectReproducer::CommandObjectReproducer(
CommandInterpreter &interpreter)
: CommandObjectMultiword(
@@ -704,8 +581,6 @@ CommandObjectReproducer::CommandObjectReproducer(
new CommandObjectReproducerStatus(interpreter)));
LoadSubCommand("dump",
CommandObjectSP(new CommandObjectReproducerDump(interpreter)));
- LoadSubCommand("verify", CommandObjectSP(
- new CommandObjectReproducerVerify(interpreter)));
LoadSubCommand("xcrash", CommandObjectSP(
new CommandObjectReproducerXCrash(interpreter)));
}