[Lldb-commits] [lldb] c354f13 - [lldb] Update TargetProperties::CheckJITObjectsDir to use ReportError
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 16 21:11:59 PDT 2022
Author: Jonas Devlieghere
Date: 2022-03-16T21:11:53-07:00
New Revision: c354f13e6995f092edccfca7653fdd1a656b25f2
URL: https://github.com/llvm/llvm-project/commit/c354f13e6995f092edccfca7653fdd1a656b25f2
DIFF: https://github.com/llvm/llvm-project/commit/c354f13e6995f092edccfca7653fdd1a656b25f2.diff
LOG: [lldb] Update TargetProperties::CheckJITObjectsDir to use ReportError
Added:
Modified:
lldb/source/Target/Target.cpp
Removed:
################################################################################
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7a7ef345682f3..00e9fd1eda571 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4184,8 +4184,10 @@ FileSpec TargetProperties::GetSaveJITObjectsDir() const {
}
void TargetProperties::CheckJITObjectsDir() {
- const uint32_t idx = ePropertySaveObjectsDir;
FileSpec new_dir = GetSaveJITObjectsDir();
+ if (!new_dir)
+ return;
+
const FileSystem &instance = FileSystem::Instance();
bool exists = instance.Exists(new_dir);
bool is_directory = instance.IsDirectory(new_dir);
@@ -4193,26 +4195,25 @@ void TargetProperties::CheckJITObjectsDir() {
bool writable = llvm::sys::fs::can_write(path);
if (exists && is_directory && writable)
return;
- m_collection_sp->GetPropertyAtIndex(nullptr, true, idx)->GetValue()
+
+ m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertySaveObjectsDir)
+ ->GetValue()
->Clear();
- StreamSP error_strm_sp;
- if (m_target) {
- // FIXME: How can I warn the user when setting this on the Debugger?
- error_strm_sp = m_target->GetDebugger().GetAsyncErrorStream();
- } else if (Debugger::GetNumDebuggers() == 1) {
- error_strm_sp = Debugger::GetDebuggerAtIndex(0)->GetAsyncErrorStream();
- }
- if (error_strm_sp) {
- error_strm_sp->Format("JIT object dir '{0}' ", path);
- if (!exists)
- error_strm_sp->PutCString("does not exist.");
- else if (!is_directory)
- error_strm_sp->PutCString("is not a directory.");
- else if (!writable)
- error_strm_sp->PutCString("is not writable.");
- error_strm_sp->EOL();
- error_strm_sp->Flush();
- }
+
+ std::string buffer;
+ llvm::raw_string_ostream os(buffer);
+ os << "JIT object dir '" << path << "' ";
+ if (!exists)
+ os << "does not exist";
+ else if (!is_directory)
+ os << "is not a directory";
+ else if (!writable)
+ os << "is not writable";
+
+ llvm::Optional<lldb::user_id_t> debugger_id = llvm::None;
+ if (m_target)
+ debugger_id = m_target->GetDebugger().GetID();
+ Debugger::ReportError(os.str(), debugger_id);
}
bool TargetProperties::GetEnableSyntheticValue() const {
More information about the lldb-commits
mailing list