Skip to content

Commit c354f13

Browse files
committed
[lldb] Update TargetProperties::CheckJITObjectsDir to use ReportError
1 parent 1c04b52 commit c354f13

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

lldb/source/Target/Target.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4184,35 +4184,36 @@ FileSpec TargetProperties::GetSaveJITObjectsDir() const {
41844184
}
41854185

41864186
void TargetProperties::CheckJITObjectsDir() {
4187-
const uint32_t idx = ePropertySaveObjectsDir;
41884187
FileSpec new_dir = GetSaveJITObjectsDir();
4188+
if (!new_dir)
4189+
return;
4190+
41894191
const FileSystem &instance = FileSystem::Instance();
41904192
bool exists = instance.Exists(new_dir);
41914193
bool is_directory = instance.IsDirectory(new_dir);
41924194
std::string path = new_dir.GetPath(true);
41934195
bool writable = llvm::sys::fs::can_write(path);
41944196
if (exists && is_directory && writable)
41954197
return;
4196-
m_collection_sp->GetPropertyAtIndex(nullptr, true, idx)->GetValue()
4198+
4199+
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertySaveObjectsDir)
4200+
->GetValue()
41974201
->Clear();
4198-
StreamSP error_strm_sp;
4199-
if (m_target) {
4200-
// FIXME: How can I warn the user when setting this on the Debugger?
4201-
error_strm_sp = m_target->GetDebugger().GetAsyncErrorStream();
4202-
} else if (Debugger::GetNumDebuggers() == 1) {
4203-
error_strm_sp = Debugger::GetDebuggerAtIndex(0)->GetAsyncErrorStream();
4204-
}
4205-
if (error_strm_sp) {
4206-
error_strm_sp->Format("JIT object dir '{0}' ", path);
4207-
if (!exists)
4208-
error_strm_sp->PutCString("does not exist.");
4209-
else if (!is_directory)
4210-
error_strm_sp->PutCString("is not a directory.");
4211-
else if (!writable)
4212-
error_strm_sp->PutCString("is not writable.");
4213-
error_strm_sp->EOL();
4214-
error_strm_sp->Flush();
4215-
}
4202+
4203+
std::string buffer;
4204+
llvm::raw_string_ostream os(buffer);
4205+
os << "JIT object dir '" << path << "' ";
4206+
if (!exists)
4207+
os << "does not exist";
4208+
else if (!is_directory)
4209+
os << "is not a directory";
4210+
else if (!writable)
4211+
os << "is not writable";
4212+
4213+
llvm::Optional<lldb::user_id_t> debugger_id = llvm::None;
4214+
if (m_target)
4215+
debugger_id = m_target->GetDebugger().GetID();
4216+
Debugger::ReportError(os.str(), debugger_id);
42164217
}
42174218

42184219
bool TargetProperties::GetEnableSyntheticValue() const {

0 commit comments

Comments
 (0)