summaryrefslogtreecommitdiffstats
path: root/lldb/source/API
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-12-03 07:53:23 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2019-12-03 07:54:42 -0800
commit62827737acd878af6cd8930758b0d6f297173f40 (patch)
tree126b0cb5ef3db51cf8702002cce68aabda05242d /lldb/source/API
parentf2e7de81c625413a7f682c757ab64e7b63b48800 (diff)
downloadbcm5719-llvm-62827737acd878af6cd8930758b0d6f297173f40.tar.gz
bcm5719-llvm-62827737acd878af6cd8930758b0d6f297173f40.zip
[lldb/Reproducer] Add version check
To ensure a reproducer works correctly, the version of LLDB used for capture and replay must match. Right now the reproducer already contains the LLDB version. However, this is purely informative. LLDB will happily replay a reproducer generated with a different version of LLDB, which can cause subtle differences. This patch adds a version check which compares the current LLDB version with the one in the reproducer. If the version doesn't match, LLDB will refuse to replay. It also adds an escape hatch to make it possible to still replay the reproducer without having to mess with the recorded version. This might prove useful when you know two versions of LLDB match, even though the version string doesn't. This behavior is triggered by passing a new flag -reproducer-skip-version-check to the lldb driver. Differential revision: https://reviews.llvm.org/D70934
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBReproducer.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index d50d95ebb54..1107161a419 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -22,8 +22,8 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBReproducer.h"
-
#include "lldb/Host/FileSystem.h"
+#include "lldb/lldb-private.h"
using namespace lldb;
using namespace lldb_private;
@@ -124,7 +124,7 @@ const char *SBReproducer::Capture(const char *path) {
return nullptr;
}
-const char *SBReproducer::Replay(const char *path) {
+const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
static std::string error;
if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
error = llvm::toString(std::move(e));
@@ -137,6 +137,22 @@ const char *SBReproducer::Replay(const char *path) {
return error.c_str();
}
+ if (!skip_version_check) {
+ llvm::Expected<std::string> version = loader->LoadBuffer<VersionProvider>();
+ if (!version) {
+ error = llvm::toString(version.takeError());
+ return error.c_str();
+ }
+ if (lldb_private::GetVersion() != llvm::StringRef(*version).rtrim()) {
+ error = "reproducer capture and replay version don't match:\n";
+ error.append("reproducer captured with:\n");
+ error.append(*version);
+ error.append("reproducer replayed with:\n");
+ error.append(lldb_private::GetVersion());
+ return error.c_str();
+ }
+ }
+
FileSpec file = loader->GetFile<SBProvider::Info>();
if (!file) {
error = "unable to get replay data from reproducer.";
OpenPOWER on IntegriCloud