From f4f120125eade60089b45b4679bb3f34bbd96b86 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 17 Oct 2019 00:02:00 +0000 Subject: [PATCH] [Reproducer] Support dumping the reproducer CWD Add support for dumping the current working directory with `reproducer dump -p cwd`. llvm-svn: 375061 --- .../Commands/CommandObjectReproducer.cpp | 21 +++++++++++++++++-- .../Shell/Reproducer/Inputs/WorkingDir.in | 4 ++++ .../test/Shell/Reproducer/TestWorkingDir.test | 4 +++- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 lldb/test/Shell/Reproducer/Inputs/WorkingDir.in diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp index 0c2e95d5d21f..72afed902649 100644 --- a/lldb/source/Commands/CommandObjectReproducer.cpp +++ b/lldb/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 }; @@ -51,6 +52,11 @@ static constexpr OptionEnumValueElement g_reproducer_provider_type[] = { "version", "Version", }, + { + eReproducerProviderWorkingDirectory, + "cwd", + "Working Directory", + }, { eReproducerProviderNone, "none", @@ -274,6 +280,17 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); return true; } + case eReproducerProviderWorkingDirectory: { + Expected cwd = + loader->LoadBuffer(); + 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 command_loader = @@ -320,7 +337,7 @@ protected: return false; } - for (GDBRemotePacket& packet : packets) { + for (GDBRemotePacket &packet : packets) { packet.Dump(result.GetOutputStream()); } diff --git a/lldb/test/Shell/Reproducer/Inputs/WorkingDir.in b/lldb/test/Shell/Reproducer/Inputs/WorkingDir.in new file mode 100644 index 000000000000..4803ef378507 --- /dev/null +++ b/lldb/test/Shell/Reproducer/Inputs/WorkingDir.in @@ -0,0 +1,4 @@ +run +reproducer status +reproducer dump -p cwd +reproducer generate diff --git a/lldb/test/Shell/Reproducer/TestWorkingDir.test b/lldb/test/Shell/Reproducer/TestWorkingDir.test index eb0af843dfb3..cef57e865110 100644 --- a/lldb/test/Shell/Reproducer/TestWorkingDir.test +++ b/lldb/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