aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-10-17 00:02:00 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-10-17 00:02:00 +0000
commitedd52d48a421ab59a48e65151373c2dd4ba9e10e (patch)
treeadc2c7c835c17dca747bf1234988d44a1a46cc5a
parentb9ff4fc98d99706c58c19f1193f4dee5658f5b8b (diff)
downloadlldb-edd52d48a421ab59a48e65151373c2dd4ba9e10e.tar.gz
[Reproducer] Support dumping the reproducer CWD
Add support for dumping the current working directory with `reproducer dump -p cwd`. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@375061 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--source/Commands/CommandObjectReproducer.cpp21
-rw-r--r--test/Shell/Reproducer/Inputs/WorkingDir.in4
-rw-r--r--test/Shell/Reproducer/TestWorkingDir.test4
3 files changed, 26 insertions, 3 deletions
diff --git a/source/Commands/CommandObjectReproducer.cpp b/source/Commands/CommandObjectReproducer.cpp
index 0c2e95d5d..72afed902 100644
--- a/source/Commands/CommandObjectReproducer.cpp
+++ b/source/Commands/CommandObjectReproducer.cpp
@@ -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 g_reproducer_provider_type[] = {
"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());
}
diff --git a/test/Shell/Reproducer/Inputs/WorkingDir.in b/test/Shell/Reproducer/Inputs/WorkingDir.in
new file mode 100644
index 000000000..4803ef378
--- /dev/null
+++ b/test/Shell/Reproducer/Inputs/WorkingDir.in
@@ -0,0 +1,4 @@
+run
+reproducer status
+reproducer dump -p cwd
+reproducer generate
diff --git a/test/Shell/Reproducer/TestWorkingDir.test b/test/Shell/Reproducer/TestWorkingDir.test
index eb0af843d..cef57e865 100644
--- a/test/Shell/Reproducer/TestWorkingDir.test
+++ b/test/Shell/Reproducer/TestWorkingDir.test
@@ -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