JDevlieghere updated this revision to Diff 204361.
JDevlieghere marked 3 inline comments as done.
JDevlieghere added a comment.

Adrian's feedback


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63229/new/

https://reviews.llvm.org/D63229

Files:
  lldb/include/lldb/Utility/Reproducer.h
  lldb/lit/Reproducer/TestFileRepro.test
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/source/Utility/Reproducer.cpp

Index: lldb/source/Utility/Reproducer.cpp
===================================================================
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-private.h"
 
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Threading.h"
@@ -263,11 +264,23 @@
 
 void CommandProvider::Discard() { m_data_recorders.clear(); }
 
+void VersionProvider::Keep() {
+  FileSpec file = GetRoot().CopyByAppendingPathComponent(info::file);
+  std::error_code ec;
+  llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::F_Text);
+  if (ec)
+    return;
+  os << lldb_private::GetVersion() << "\n";
+}
+
 void ProviderBase::anchor() {}
 char ProviderBase::ID = 0;
 char FileProvider::ID = 0;
+char VersionProvider::ID = 0;
 char CommandProvider::ID = 0;
 const char *FileInfo::name = "files";
 const char *FileInfo::file = "files.yaml";
+const char *VersionInfo::name = "version";
+const char *VersionInfo::file = "version.txt";
 const char *CommandInfo::name = "command-interpreter";
 const char *CommandInfo::file = "command-interpreter.yaml";
Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===================================================================
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/lldb-private.h"
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -67,7 +68,6 @@
       return e;
   }
 
-  // Initialize the file system.
   auto &r = repro::Reproducer::Instance();
   if (repro::Loader *loader = r.GetLoader()) {
     FileSpec vfs_mapping = loader->GetFile<FileInfo>();
@@ -78,6 +78,8 @@
       FileSystem::Initialize();
     }
   } else if (repro::Generator *g = r.GetGenerator()) {
+    repro::VersionProvider &vp = g->GetOrCreate<repro::VersionProvider>();
+    vp.SetVersion(lldb_private::GetVersion());
     repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
     FileSystem::Initialize(fp.GetFileCollector());
   } else {
Index: lldb/lit/Reproducer/TestFileRepro.test
===================================================================
--- lldb/lit/Reproducer/TestFileRepro.test
+++ lldb/lit/Reproducer/TestFileRepro.test
@@ -11,6 +11,7 @@
 # RUN: %lldb -x -b -s %S/Inputs/FileCapture.in --capture --capture-path %t.repro %t.out | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE
 # RUN: rm %t.out
 # RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK --check-prefix REPLAY
+# RUN: cat %t.repro/version.txt | FileCheck %s --check-prefix VERSION
 
 # CAPTURE: testing
 # REPLAY-NOT: testing
@@ -19,3 +20,5 @@
 
 # CAPTURE: Reproducer is in capture mode.
 # CAPTURE: Reproducer written
+
+# VERSION: lldb version
Index: lldb/include/lldb/Utility/Reproducer.h
===================================================================
--- lldb/include/lldb/Utility/Reproducer.h
+++ lldb/include/lldb/Utility/Reproducer.h
@@ -111,6 +111,29 @@
   FileCollector m_collector;
 };
 
+struct VersionInfo {
+  static const char *name;
+  static const char *file;
+};
+
+/// Provider for the LLDB version number.
+///
+/// When the reproducer is kept, it writes the lldb version to a file named
+/// version.txt in the reproducer root.
+class VersionProvider : public Provider<VersionProvider> {
+public:
+  VersionProvider(const FileSpec &directory)
+      : Provider(directory) {}
+  typedef VersionInfo info;
+  void SetVersion(std::string version) {
+    assert(m_version.empty());
+    m_version = std::move(version);
+  }
+  void Keep() override;
+  std::string m_version;
+  static char ID;
+};
+
 class DataRecorder {
 public:
   DataRecorder(const FileSpec &filename, std::error_code &ec)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to