10000 Cherrypick upstream reproducer changes. by JDevlieghere · Pull Request #10 · swiftlang/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

Cherrypick upstream reproducer changes. #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Reproducer] Capture the debugger's working directory
This patch extends the reproducer to capture the debugger's current
working directory. This information will be used later to set the
current working directory of the VFS.

llvm-svn: 375059
(cherry picked from commit 27ef81c)
  • Loading branch information
JDevlieghere committed Oct 21, 2019
commit ebc1975390f1e84083ba5ddb339ef2c7ef4df877
21 changes: 21 additions & 0 deletions lldb/include/lldb/Utility/Reproducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ class VersionProvider : public Provider<VersionProvider> {
static char ID;
};

/// Provider for the LLDB current working directroy.
///
/// When the reproducer is kept, it writes lldb's current working directory to
/// a file named cwd.txt in the reproducer root.
class WorkingDirectoryProvider : public Provider<WorkingDirectoryProvider> {
public:
WorkingDirectoryProvider(const FileSpec &directory) : Provider(directory) {
llvm::SmallString<128> cwd;
if (std::error_code EC = llvm::sys::fs::current_path(cwd))
return;
m_cwd = cwd.str();
}
struct Info {
static const char *name;
static const char *file;
};
void Keep() override;
std::string m_cwd;
static char ID;
};

class DataRecorder {
public:
DataRecorder(const FileSpec &filename, std::error_code &ec)
Expand Down
11 changes: 11 additions & 0 deletions lldb/lit/Reproducer/TestWorkingDir.test
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This tests relative capture paths.

# RUN: echo "CHECK: %t" > %t.check

# RUN: rm -rf %t.repro
# RUN: mkdir -p %t.repro
# 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: cat %t.repro/cwd.txt | FileCheck %t.check
16 changes: 15 additions & 1 deletion lldb/source/Utility/Reproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ static FileSpec MakeAbsolute(FileSpec file_spec) {
}

Generator::Generator(FileSpec root)
: m_root(MakeAbsolute(std::move(root))), m_done(false) {}
: m_root(MakeAbsolute(std::move(root))), m_done(false) {
GetOrCreate<repro::WorkingDirectoryProvider>();
}

Generator::~Generator() {}

Expand Down Expand Up @@ -281,6 +283,15 @@ void VersionProvider::Keep() {
os << m_version << "\n";
}

void WorkingDirectoryProvider::Keep() {
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
if (ec)
return;
os << m_cwd << "\n";
}

llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() {
FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);

Expand Down Expand Up @@ -330,6 +341,7 @@ char FileProvider::ID = 0;
char ProcessGDBRemoteProvider::ID = 0;
char ProviderBase::ID = 0;
char VersionProvider::ID = 0;
char WorkingDirectoryProvider::ID = 0;
const char *CommandProvider::Info::file = "command-interpreter.yaml";
const char *CommandProvider::Info::name = "command-interpreter";
const char *FileProvider::Info::file = "files.yaml";
Expand All @@ -338,3 +350,5 @@ const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";
const char *VersionProvider::Info::file = "version.txt";
const char *VersionProvider::Info::name = "version";
const char *WorkingDirectoryProvider::Info::file = "cwd.txt";
const char *WorkingDirectoryProvider::Info::name = "cwd";
0