@@ -39,6 +39,51 @@ SystemInitializerCommon::SystemInitializerCommon() {}
39
39
40
40
SystemInitializerCommon::~SystemInitializerCommon () {}
41
41
42
+ // / Initialize the FileSystem based on the current reproducer mode.
43
+ static llvm::Error InitializeFileSystem () {
44
+ auto &r = repro::Reproducer::Instance ();
45
+ if (repro::Loader *loader = r.GetLoader ()) {
46
+ FileSpec vfs_mapping = loader->GetFile <FileProvider::Info>();
47
+ if (vfs_mapping) {
48
+ if (llvm::Error e = FileSystem::Initialize (vfs_mapping))
49
+ return e;
50
+ } else {
51
+ FileSystem::Initialize ();
52
+ }
53
+
54
+ llvm::Expected<std::string> cwd =
55
+ loader->LoadBuffer <WorkingDirectoryProvider>();
56
+ if (!cwd)
57
+ return cwd.takeError ();
58
+
59
+ llvm::StringRef working_dir = llvm::StringRef (*cwd).rtrim ();
60
+ if (std::error_code ec = FileSystem::Instance ()
61
+ .GetVirtualFileSystem ()
62
+ ->setCurrentWorkingDirectory (working_dir)) {
63
+ return llvm::errorCodeToError (ec);
64
+ }
65
+
66
+ return llvm::Error::success ();
67
+ }
68
+
69
+ if (repro::Generator *g = r.GetGenerator ()) {
70
+ repro::VersionProvider &vp = g->GetOrCreate <repro::VersionProvider>();
71
+ vp.SetVersion (lldb_private::GetVersion ());
72
+
73
+ repro::FileProvider &fp = g->GetOrCreate <repro::FileProvider>();
74
+ FileSystem::Initialize (fp.GetFileCollector ());
75
+
76
+ repro::WorkingDirectoryProvider &wp =
77
+ g->GetOrCreate <repro::WorkingDirectoryProvider>();
78
+ fp.RecordInterestingDirectory (wp.GetWorkingDirectory ());
79
+
80
+ return llvm::Error::success ();
81
+ }
82
+
83
+ FileSystem::Initialize ();
84
+ return llvm::Error::success ();
85
+ }
86
+
42
87
llvm::Error SystemInitializerCommon::Initialize () {
43
88
#if defined(_WIN32)
44
89
const char *disable_crash_dialog_var = getenv (" LLDB_DISABLE_CRASH_DIALOG" );
@@ -69,36 +114,8 @@ llvm::Error SystemInitializerCommon::Initialize() {
69
114
return e;
70
115
}
71
116
72
- auto &r = repro::Reproducer::Instance ();
73
- if (repro::Loader *loader = r.GetLoader ()) {
74
- FileSpec vfs_mapping = loader->GetFile <FileProvider::Info>();
75
- if (vfs_mapping) {
76
- if (llvm::Error e = FileSystem::Initialize (vfs_mapping))
77
- return e;
78
- } else {
79
- FileSystem::Initialize ();
80
- }
81
- if (llvm::Expected<std::string> cwd =
82
- loader->LoadBuffer <WorkingDirectoryProvider>()) {
83
- llvm::StringRef working_dir = llvm::StringRef (*cwd).rtrim ();
84
- if (std::error_code ec = FileSystem::Instance ()
85
- .GetVirtualFileSystem ()
86
- ->setCurrentWorkingDirectory (working_dir)) {
87
- return llvm::errorCodeToError (ec);
88
- }
89
- } else {
90
- return cwd.takeError ();
91
- }
92
- } else if (repro::Generator *g = r.GetGenerator ()) {
93
- repro::VersionProvider &vp = g->GetOrCreate <repro::VersionProvider>();
94
- vp.SetVersion (lldb_private::GetVersion ());
95
- repro::FileProvider &fp = g->GetOrCreate <repro::FileProvider>();
96
- FileSystem::Initialize (fp.GetFileCollector ());
97
- repro::WorkingDirectoryProvider &wp = g->GetOrCreate <repro::WorkingDirectoryProvider>();
98
- fp.RecordInterestingDirectory (wp.GetWorkingDirectory ());
99
- } else {
100
- FileSystem::Initialize ();
101
- }
117
+ if (auto e = InitializeFileSystem ())
118
+ return e;
102
119
103
120
Log::Initialize ();
104
121
HostInfo::Initialize ();
0 commit comments