[Lldb-commits] [lldb] r375061 - [Reproducer] Support dumping the reproducer CWD

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 16 17:02:00 PDT 2019


Author: jdevlieghere
Date: Wed Oct 16 17:02:00 2019
New Revision: 375061

URL: http://llvm.org/viewvc/llvm-project?rev=375061&view=rev
Log:
[Reproducer] Support dumping the reproducer CWD

Add support for dumping the current working directory with
`reproducer dump -p cwd`.

Added:
    lldb/trunk/test/Shell/Reproducer/Inputs/WorkingDir.in
Modified:
    lldb/trunk/source/Commands/CommandObjectReproducer.cpp
    lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test

Modified: lldb/trunk/source/Commands/CommandObjectReproducer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectReproducer.cpp?rev=375061&r1=375060&r2=375061&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectReproducer.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectReproducer.cpp Wed Oct 16 17:02:00 2019
@@ -9,8 +9,8 @@
 #include "CommandObjectReproducer.h"
 
 #include "lldb/Host/OptionParser.h"
-#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/GDBRemote.h"
+#include "lldb/Utility/Reproducer.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
@@ -27,6 +27,7 @@ enum ReproducerProvider {
   eReproducerProviderFiles,
   eReproducerProviderGDB,
   eReproducerProviderVersion,
+  eReproducerProviderWorkingDirectory,
   eReproducerProviderNone
 };
 
@@ -52,6 +53,11 @@ static constexpr OptionEnumValueElement
         "Version",
     },
     {
+        eReproducerProviderWorkingDirectory,
+        "cwd",
+        "Working Directory",
+    },
+    {
         eReproducerProviderNone,
         "none",
         "None",
@@ -274,6 +280,17 @@ protected:
       result.SetStatus(eReturnStatusSuccessFinishResult);
       return true;
     }
+    case eReproducerProviderWorkingDirectory: {
+      Expected<std::string> cwd =
+          loader->LoadBuffer<WorkingDirectoryProvider>();
+      if (!cwd) {
+        SetError(result, cwd.takeError());
+        return false;
+      }
+      result.AppendMessage(*cwd);
+      result.SetStatus(eReturnStatusSuccessFinishResult);
+      return true;
+    }
     case eReproducerProviderCommands: {
       // Create a new command loader.
       std::unique_ptr<repro::CommandLoader> command_loader =
@@ -320,7 +337,7 @@ protected:
         return false;
       }
 
-      for (GDBRemotePacket& packet : packets) {
+      for (GDBRemotePacket &packet : packets) {
         packet.Dump(result.GetOutputStream());
       }
 

Added: lldb/trunk/test/Shell/Reproducer/Inputs/WorkingDir.in
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/Reproducer/Inputs/WorkingDir.in?rev=375061&view=auto
==============================================================================
--- lldb/trunk/test/Shell/Reproducer/Inputs/WorkingDir.in (added)
+++ lldb/trunk/test/Shell/Reproducer/Inputs/WorkingDir.in Wed Oct 16 17:02:00 2019
@@ -0,0 +1,4 @@
+run
+reproducer status
+reproducer dump -p cwd
+reproducer generate

Modified: lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test?rev=375061&r1=375060&r2=375061&view=diff
==============================================================================
--- lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test (original)
+++ lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test Wed Oct 16 17:02:00 2019
@@ -7,5 +7,7 @@
 # RUN: mkdir -p %t
 # RUN: cd %t
 # RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
-# RUN: %lldb -x -b -s %S/Inputs/FileCapture.in --capture --capture-path %t.repro %t/reproducer.out
+# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro %t/reproducer.out
+
 # RUN: cat %t.repro/cwd.txt | FileCheck %t.check
+# RUN: %lldb --replay %t.repro | FileCheck %t.check




More information about the lldb-commits mailing list