The reproducers' working directory is set to the current working
directory when they are initialized. While this is not optimal, as the
cwd can change during a debug session, it has been sufficient so far.
The current approach doesn't work for the API test suite however because
dotest temporarily changes the directory to where the test's Python file
lives.
This patch adds an API to tell the reproducers what to set the CWD to.
This is a NO-OP in every mode but capture.
Differential revision: https://reviews.llvm.org/D79825
static const char *Capture(const char *path);
static const char *PassiveReplay(const char *path);
static bool SetAutoGenerate(bool b);
+ static void SetWorkingDirectory(const char *path);
};
}
static const char *GetPath();
static bool SetAutoGenerate(bool b);
static bool Generate();
+
+ /// The working directory is set to the current working directory when the
+ /// reproducers are initialized. This method allows setting a different
+ /// working directory. This is used by the API test suite which temporarily
+ /// changes the directory to where the test lives. This is a NO-OP in every
+ /// mode but capture.
+ static void SetWorkingDirectory(const char *path);
};
} // namespace lldb
return;
m_cwd = std::string(cwd.str());
}
+
+ void Update(llvm::StringRef path) { m_cwd = std::string(path); }
+
struct Info {
static const char *name;
static const char *file;
if traceAlways:
print("Change dir to:", full_dir, file=sys.stderr)
os.chdir(full_dir)
+ lldb.SBReproducer.SetWorkingDirectory(full_dir)
# Set platform context.
cls.platformContext = lldbplatformutil.createPlatformContext()
return path.c_str();
}
+void SBReproducer::SetWorkingDirectory(const char *path) {
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
+ }
+}
+
char lldb_private::repro::SBProvider::ID = 0;
const char *SBProvider::Info::name = "sbapi";
const char *SBProvider::Info::file = "sbapi.bin";