[Reproducer] Support dumping the reproducer CWD

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

llvm-svn: 375061
This commit is contained in:
Jonas Devlieghere 2019-10-17 00:02:00 +00:00
parent b2575da9aa
commit f4f120125e
3 changed files with 26 additions and 3 deletions

View File

@ -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<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());
}

View File

@ -0,0 +1,4 @@
run
reproducer status
reproducer dump -p cwd
reproducer generate

View File

@ -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