Skip to content

Commit f4f1201

Browse files
committed
[Reproducer] Support dumping the reproducer CWD
Add support for dumping the current working directory with `reproducer dump -p cwd`. llvm-svn: 375061
1 parent b2575da commit f4f1201

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

lldb/source/Commands/CommandObjectReproducer.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include "CommandObjectReproducer.h"
1010

1111
#include "lldb/Host/OptionParser.h"
12-
#include "lldb/Utility/Reproducer.h"
1312
#include "lldb/Utility/GDBRemote.h"
13+
#include "lldb/Utility/Reproducer.h"
1414

1515
#include "lldb/Interpreter/CommandInterpreter.h"
1616
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -27,6 +27,7 @@ enum ReproducerProvider {
2727
eReproducerProviderFiles,
2828
eReproducerProviderGDB,
2929
eReproducerProviderVersion,
30+
eReproducerProviderWorkingDirectory,
3031
eReproducerProviderNone
3132
};
3233

@@ -51,6 +52,11 @@ static constexpr OptionEnumValueElement g_reproducer_provider_type[] = {
5152
"version",
5253
"Version",
5354
},
55+
{
56+
eReproducerProviderWorkingDirectory,
57+
"cwd",
58+
"Working Directory",
59+
},
5460
{
5561
eReproducerProviderNone,
5662
"none",
@@ -274,6 +280,17 @@ class CommandObjectReproducerDump : public CommandObjectParsed {
274280
result.SetStatus(eReturnStatusSuccessFinishResult);
275281
return true;
276282
}
283+
case eReproducerProviderWorkingDirectory: {
284+
Expected<std::string> cwd =
285+
loader->LoadBuffer<WorkingDirectoryProvider>();
286+
if (!cwd) {
287+
SetError(result, cwd.takeError());
288+
return false;
289+
}
290+
result.AppendMessage(*cwd);
291+
result.SetStatus(eReturnStatusSuccessFinishResult);
292+
return true;
293+
}
277294
case eReproducerProviderCommands: {
278295
// Create a new command loader.
279296
std::unique_ptr<repro::CommandLoader> command_loader =
@@ -320,7 +337,7 @@ class CommandObjectReproducerDump : public CommandObjectParsed {
320337
return false;
321338
}
322339

323-
for (GDBRemotePacket& packet : packets) {
340+
for (GDBRemotePacket &packet : packets) {
324341
packet.Dump(result.GetOutputStream());
325342
}
326343

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
run
2+
reproducer status
3+
reproducer dump -p cwd
4+
reproducer generate

lldb/test/Shell/Reproducer/TestWorkingDir.test

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
# RUN: mkdir -p %t
88
# RUN: cd %t
99
# RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
10-
# RUN: %lldb -x -b -s %S/Inputs/FileCapture.in --capture --capture-path %t.repro %t/reproducer.out
10+
# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro %t/reproducer.out
11+
1112
# RUN: cat %t.repro/cwd.txt | FileCheck %t.check
13+
# RUN: %lldb --replay %t.repro | FileCheck %t.check

0 commit comments

Comments
 (0)