[Lldb-commits] [lldb] 34eb15b - [lldb] Remove reproducer verifier and corresponding command
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 3 11:21:11 PST 2022
Author: Jonas Devlieghere
Date: 2022-03-03T11:21:00-08:00
New Revision: 34eb15b5c30601085acb0921f5410aafc0389232
URL: https://github.com/llvm/llvm-project/commit/34eb15b5c30601085acb0921f5410aafc0389232
DIFF: https://github.com/llvm/llvm-project/commit/34eb15b5c30601085acb0921f5410aafc0389232.diff
LOG: [lldb] Remove reproducer verifier and corresponding command
This removes the reproducer verifier and the corresponding `reproducer
verify` subcommand.
Added:
Modified:
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Utility/Reproducer.cpp
lldb/test/Shell/Reproducer/TestDebugSymbols.test
Removed:
lldb/test/Shell/Reproducer/TestVerify.test
################################################################################
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 35043d6885111..672f82fcb9565 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -220,17 +220,6 @@ class Reproducer {
mutable std::mutex m_mutex;
};
-class Verifier {
-public:
- Verifier(Loader *loader) : m_loader(loader) {}
- void Verify(llvm::function_ref<void(llvm::StringRef)> error_callback,
- llvm::function_ref<void(llvm::StringRef)> warning_callback,
- llvm::function_ref<void(llvm::StringRef)> note_callback) const;
-
-private:
- Loader *m_loader;
-};
-
struct ReplayOptions {
bool verify = true;
bool check_version = true;
diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp
index 7e0ea65e148ee..8b67b27c10f95 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -587,101 +587,6 @@ class CommandObjectReproducerDump : public CommandObjectParsed {
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 +609,6 @@ CommandObjectReproducer::CommandObjectReproducer(
new CommandObjectReproducerStatus(interpreter)));
LoadSubCommand("dump",
CommandObjectSP(new CommandObjectReproducerDump(interpreter)));
- LoadSubCommand("verify", CommandObjectSP(
- new CommandObjectReproducerVerify(interpreter)));
LoadSubCommand("xcrash", CommandObjectSP(
new CommandObjectReproducerXCrash(interpreter)));
}
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp
index 1e71dba472ed7..a2ada12140cf6 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -230,97 +230,6 @@ bool Loader::HasFile(StringRef file) {
return (it != m_files.end()) && (*it == file);
}
-void Verifier::Verify(
- llvm::function_ref<void(llvm::StringRef)> error_callback,
- llvm::function_ref<void(llvm::StringRef)> warning_callback,
- llvm::function_ref<void(llvm::StringRef)> note_callack) const {
- if (!m_loader) {
- error_callback("invalid loader");
- return;
- }
-
- FileSpec vfs_mapping = m_loader->GetFile<FileProvider::Info>();
- ErrorOr<std::unique_ptr<MemoryBuffer>> buffer =
- vfs::getRealFileSystem()->getBufferForFile(vfs_mapping.GetPath());
- if (!buffer) {
- error_callback("unable to read files: " + buffer.getError().message());
- return;
- }
-
- IntrusiveRefCntPtr<vfs::FileSystem> vfs = vfs::getVFSFromYAML(
- std::move(buffer.get()), nullptr, vfs_mapping.GetPath());
- if (!vfs) {
- error_callback("unable to initialize the virtual file system");
- return;
- }
-
- auto &redirecting_vfs = static_cast<vfs::RedirectingFileSystem &>(*vfs);
- redirecting_vfs.setFallthrough(false);
-
- {
- llvm::Expected<std::string> working_dir =
- GetDirectoryFrom<WorkingDirectoryProvider>(m_loader);
- if (working_dir) {
- if (!vfs->exists(*working_dir))
- warning_callback("working directory '" + *working_dir + "' not in VFS");
- vfs->setCurrentWorkingDirectory(*working_dir);
- } else {
- warning_callback("no working directory in reproducer: " +
- toString(working_dir.takeError()));
- }
- }
-
- {
- llvm::Expected<std::string> home_dir =
- GetDirectoryFrom<HomeDirectoryProvider>(m_loader);
- if (home_dir) {
- if (!vfs->exists(*home_dir))
- warning_callback("home directory '" + *home_dir + "' not in VFS");
- } else {
- warning_callback("no home directory in reproducer: " +
- toString(home_dir.takeError()));
- }
- }
-
- {
- Expected<std::string> symbol_files =
- m_loader->LoadBuffer<SymbolFileProvider>();
- if (symbol_files) {
- std::vector<SymbolFileProvider::Entry> entries;
- llvm::yaml::Input yin(*symbol_files);
- yin >> entries;
- for (const auto &entry : entries) {
- if (!entry.module_path.empty() && !vfs->exists(entry.module_path)) {
- warning_callback("'" + entry.module_path + "': module path for " +
- entry.uuid + " not in VFS");
- }
- if (!entry.symbol_path.empty() && !vfs->exists(entry.symbol_path)) {
- warning_callback("'" + entry.symbol_path + "': symbol path for " +
- entry.uuid + " not in VFS");
- }
- }
- } else {
- llvm::consumeError(symbol_files.takeError());
- }
- }
-
- // Missing files in the VFS are notes rather than warnings. Because the VFS
- // is a snapshot, temporary files could have been removed between when they
- // were recorded and when the reproducer was generated.
- std::vector<llvm::StringRef> roots = redirecting_vfs.getRoots();
- for (llvm::StringRef root : roots) {
- std::error_code ec;
- vfs::recursive_directory_iterator iter(*vfs, root, ec);
- vfs::recursive_directory_iterator end;
- for (; iter != end && !ec; iter.increment(ec)) {
- ErrorOr<vfs::Status> status = vfs->status(iter->path());
- if (!status)
- note_callack("'" + iter->path().str() +
- "': " + status.getError().message());
- }
- }
-}
-
static llvm::Error addPaths(StringRef path,
function_ref<void(StringRef)> callback) {
auto buffer = llvm::MemoryBuffer::getFile(path);
diff --git a/lldb/test/Shell/Reproducer/TestDebugSymbols.test b/lldb/test/Shell/Reproducer/TestDebugSymbols.test
index 986452ec35e86..6a3cc1249cbd1 100644
--- a/lldb/test/Shell/Reproducer/TestDebugSymbols.test
+++ b/lldb/test/Shell/Reproducer/TestDebugSymbols.test
@@ -12,7 +12,3 @@
# DUMP: uuid: AD52358C-94F8-3796-ADD6-B20FFAC00E5C
# DUMP-NEXT: module path: /path/to/unstripped/executable
# DUMP-NEXT: symbol path: /path/to/foo.dSYM/Contents/Resources/DWARF/foo
-
-# RUN: not %lldb -b -o 'reproducer verify -f %t.repro' 2>&1 | FileCheck %s --check-prefix VERIFY
-# VERIFY: warning: '/path/to/unstripped/executable': module path for AD52358C-94F8-3796-ADD6-B20FFAC00E5C not in VFS
-# VERIFY: warning: '/path/to/foo.dSYM/Contents/Resources/DWARF/foo': symbol path for AD52358C-94F8-3796-ADD6-B20FFAC00E5C not in VFS
diff --git a/lldb/test/Shell/Reproducer/TestVerify.test b/lldb/test/Shell/Reproducer/TestVerify.test
deleted file mode 100644
index b03a670293faa..0000000000000
--- a/lldb/test/Shell/Reproducer/TestVerify.test
+++ /dev/null
@@ -1,15 +0,0 @@
-# RUN: rm -rf %t.repro
-# RUN: rm -rf %t.repro2
-# RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
-# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture --capture-path %t.repro %t.out
-
-# RUN: echo "/bogus/home/dir" > %t.repro/home.txt
-# RUN: echo "/bogus/current/working/dir" > %t.repro/cwd.txt
-
-# RUN: not %lldb -b -o 'reproducer verify -f %t.repro' 2>&1 | FileCheck %s
-# CHECK: working directory '/bogus/current/working/dir' not in VFS
-# CHECK: home directory '/bogus/home/dir' not in VFS
-
-# RUN: rm %t.repro/root/%S/Inputs/GDBRemoteCapture.in
-# RUN: echo "CHECK: '%S/Inputs/GDBRemoteCapture.in': No such file or directory" > %t.check
-# RUN: not %lldb -b -o 'reproducer verify -f %t.repro' 2>&1 | FileCheck %t.check
More information about the lldb-commits
mailing list