Skip to content

Commit cdec597

Browse files
committed
[Reproducer] Always use absolute paths for capture & replay.
The VFS requires files to be have absolute paths. The file collector makes paths relative to the reproducer root. If the root is a relative path, this would trigger an assert in the VFS. This patch ensures that we always make the given path absolute. Thank you Ted Woodward for pointing this out! llvm-svn: 373102
1 parent 72c57ec commit cdec597

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

lldb/include/lldb/Utility/Reproducer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class ProcessGDBRemoteProvider
215215
class Generator final {
216216

217217
public:
218-
Generator(const FileSpec &root);
218+
Generator(FileSpec root);
219219
~Generator();
220220

221221
/// Method to indicate we want to keep the reproducer. If reproducer
@@ -272,7 +272,7 @@ class Generator final {
272272

273273
class Loader final {
274274
public:
275-
Loader(const FileSpec &root);
275+
Loader(FileSpec root);
276276

277277
template <typename T> FileSpec GetFile() {
278278
if (!HasFile(T::file))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This tests relative capture paths.
2+
3+
# RUN: mkdir -p %t
4+
# RUN: cd %t
5+
# RUN: rm -rf ./foo
6+
# RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
7+
# RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' --capture --capture-path ./foo %t/reproducer.out
8+
# RUN: %lldb --replay ./foo

lldb/source/Utility/Reproducer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ FileSpec Reproducer::GetReproducerPath() const {
136136
return {};
137137
}
138138

139-
Generator::Generator(const FileSpec &root) : m_root(root), m_done(false) {}
139+
static FileSpec MakeAbsolute(FileSpec file_spec) {
140+
SmallString<128> path;
141+
file_spec.GetPath(path, false);
142+
llvm::sys::fs::make_absolute(path);
143+
return FileSpec(path, file_spec.GetPathStyle());
144+
}
145+
146+
Generator::Generator(FileSpec root)
147+
: m_root(MakeAbsolute(std::move(root))), m_done(false) {}
140148

141149
Generator::~Generator() {}
142150

@@ -188,7 +196,8 @@ void Generator::AddProvidersToIndex() {
188196
yout << files;
189197
}
190198

191-
Loader::Loader(const FileSpec &root) : m_root(root), m_loaded(false) {}
199+
Loader::Loader(FileSpec root)
200+
: m_root(MakeAbsolute(std::move(root))), m_loaded(false) {}
192201

193202
llvm::Error Loader::LoadIndex() {
194203
if (m_loaded)

0 commit comments

Comments
 (0)