From edd52d48a421ab59a48e65151373c2dd4ba9e10e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 17 Oct 2019 00:02:00 +0000 Subject: [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 --- source/Commands/CommandObjectReproducer.cpp | 21 +++++++++++++++++++-- test/Shell/Reproducer/Inputs/WorkingDir.in | 4 ++++ test/Shell/Reproducer/TestWorkingDir.test | 4 +++- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/Shell/Reproducer/Inputs/WorkingDir.in 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 }; @@ -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/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 -- cgit v1.2.3