diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 49ff0737acef8..c0f7c732ad2d4 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -630,8 +630,7 @@ class Debugger : public std::enable_shared_from_this, std::optional debugger_id, uint32_t progress_category_bit = eBroadcastBitProgress); - static void ReportDiagnosticImpl(DiagnosticEventData::Type type, - std::string message, + static void ReportDiagnosticImpl(lldb::Severity severity, std::string message, std::optional debugger_id, std::once_flag *once); diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 74bb05e6e6bf8..49a4ecf8e537e 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -76,19 +76,15 @@ class ProgressEventData : public EventData { class DiagnosticEventData : public EventData { public: - enum class Type { - Info, - Warning, - Error, - }; - DiagnosticEventData(Type type, std::string message, bool debugger_specific) - : m_message(std::move(message)), m_type(type), + DiagnosticEventData(lldb::Severity severity, std::string message, + bool debugger_specific) + : m_message(std::move(message)), m_severity(severity), m_debugger_specific(debugger_specific) {} ~DiagnosticEventData() override = default; const std::string &GetMessage() const { return m_message; } bool IsDebuggerSpecific() const { return m_debugger_specific; } - Type GetType() const { return m_type; } + lldb::Severity GetSeverity() const { return m_severity; } llvm::StringRef GetPrefix() const; @@ -105,7 +101,7 @@ class DiagnosticEventData : public EventData { protected: std::string m_message; - Type m_type; + lldb::Severity m_severity; const bool m_debugger_specific; DiagnosticEventData(const DiagnosticEventData &) = delete; diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h index 06bf1d115f154..d49b7c99b114f 100644 --- a/lldb/include/lldb/Expression/DiagnosticManager.h +++ b/lldb/include/lldb/Expression/DiagnosticManager.h @@ -28,12 +28,6 @@ enum DiagnosticOrigin { eDiagnosticOriginLLVM }; -enum DiagnosticSeverity { - eDiagnosticSeverityError, - eDiagnosticSeverityWarning, - eDiagnosticSeverityRemark -}; - const uint32_t LLDB_INVALID_COMPILER_ID = UINT32_MAX; class Diagnostic { @@ -55,7 +49,7 @@ class Diagnostic { } } - Diagnostic(llvm::StringRef message, DiagnosticSeverity severity, + Diagnostic(llvm::StringRef message, lldb::Severity severity, DiagnosticOrigin origin, uint32_t compiler_id) : m_message(message), m_severity(severity), m_origin(origin), m_compiler_id(compiler_id) {} @@ -68,7 +62,7 @@ class Diagnostic { virtual bool HasFixIts() const { return false; } - DiagnosticSeverity GetSeverity() const { return m_severity; } + lldb::Severity GetSeverity() const { return m_severity; } uint32_t GetCompilerID() const { return m_compiler_id; } @@ -83,7 +77,7 @@ class Diagnostic { protected: std::string m_message; - DiagnosticSeverity m_severity; + lldb::Severity m_severity; DiagnosticOrigin m_origin; uint32_t m_compiler_id; // Compiler-specific diagnostic ID }; @@ -106,7 +100,7 @@ class DiagnosticManager { }); } - void AddDiagnostic(llvm::StringRef message, DiagnosticSeverity severity, + void AddDiagnostic(llvm::StringRef message, lldb::Severity severity, DiagnosticOrigin origin, uint32_t compiler_id = LLDB_INVALID_COMPILER_ID) { m_diagnostics.emplace_back( @@ -127,9 +121,9 @@ class DiagnosticManager { other.Clear(); } - size_t Printf(DiagnosticSeverity severity, const char *format, ...) + size_t Printf(lldb::Severity severity, const char *format, ...) __attribute__((format(printf, 3, 4))); - void PutString(DiagnosticSeverity severity, llvm::StringRef str); + void PutString(lldb::Severity severity, llvm::StringRef str); void AppendMessageToDiagnostic(llvm::StringRef str) { if (!m_diagnostics.empty()) diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index b0cb477d82fa1..9d0994978402f 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -87,15 +87,8 @@ class Host { StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid); - /// System log level. - enum SystemLogLevel { - eSystemLogInfo, - eSystemLogWarning, - eSystemLogError, - }; - /// Emit the given message to the operating system log. - static void SystemLog(SystemLogLevel log_level, llvm::StringRef message); + static void SystemLog(lldb::Severity severity, llvm::StringRef message); /// Get the process ID for the calling process. /// diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 15e4585718609..437971b3364cd 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1347,6 +1347,13 @@ enum DebuggerBroadcastBit { eBroadcastBitProgressCategory = (1 << 3), }; +/// Used for expressing severity in logs and diagnostics. +enum Severity { + eSeverityError, + eSeverityWarning, + eSeverityInfo, // Equivalent to Remark used in clang. +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index cac4642873b77..065f70c3880aa 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1476,19 +1476,18 @@ void Debugger::ReportProgress(uint64_t progress_id, std::string title, } } -static void PrivateReportDiagnostic(Debugger &debugger, - DiagnosticEventData::Type type, +static void PrivateReportDiagnostic(Debugger &debugger, Severity severity, std::string message, bool debugger_specific) { uint32_t event_type = 0; - switch (type) { - case DiagnosticEventData::Type::Info: - assert(false && "DiagnosticEventData::Type::Info should not be broadcast"); + switch (severity) { + case eSeverityInfo: + assert(false && "eSeverityInfo should not be broadcast"); return; - case DiagnosticEventData::Type::Warning: + case eSeverityWarning: event_type = Debugger::eBroadcastBitWarning; break; - case DiagnosticEventData::Type::Error: + case eSeverityError: event_type = Debugger::eBroadcastBitError; break; } @@ -1497,19 +1496,19 @@ static void PrivateReportDiagnostic(Debugger &debugger, if (!broadcaster.EventTypeHasListeners(event_type)) { // Diagnostics are too important to drop. If nobody is listening, print the // diagnostic directly to the debugger's error stream. - DiagnosticEventData event_data(type, std::move(message), debugger_specific); + DiagnosticEventData event_data(severity, std::move(message), + debugger_specific); StreamSP stream = debugger.GetAsyncErrorStream(); event_data.Dump(stream.get()); return; } EventSP event_sp = std::make_shared( event_type, - new DiagnosticEventData(type, std::move(message), debugger_specific)); + new DiagnosticEventData(severity, std::move(message), debugger_specific)); broadcaster.BroadcastEvent(event_sp); } -void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type, - std::string message, +void Debugger::ReportDiagnosticImpl(Severity severity, std::string message, std::optional debugger_id, std::once_flag *once) { auto ReportDiagnosticLambda = [&]() { @@ -1519,7 +1518,7 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type, Diagnostics::Instance().Report(message); // We don't broadcast info events. - if (type == DiagnosticEventData::Type::Info) + if (severity == lldb::eSeverityInfo) return; // Check if this diagnostic is for a specific debugger. @@ -1528,7 +1527,8 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type, // still exists. DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id); if (debugger_sp) - PrivateReportDiagnostic(*debugger_sp, type, std::move(message), true); + PrivateReportDiagnostic(*debugger_sp, severity, std::move(message), + true); return; } // The diagnostic event is not debugger specific, iterate over all debuggers @@ -1536,7 +1536,7 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type, if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) { std::lock_guard guard(*g_debugger_list_mutex_ptr); for (const auto &debugger : *g_debugger_list_ptr) - PrivateReportDiagnostic(*debugger, type, message, false); + PrivateReportDiagnostic(*debugger, severity, message, false); } }; @@ -1549,22 +1549,19 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type, void Debugger::ReportWarning(std::string message, std::optional debugger_id, std::once_flag *once) { - ReportDiagnosticImpl(DiagnosticEventData::Type::Warning, std::move(message), - debugger_id, once); + ReportDiagnosticImpl(eSeverityWarning, std::move(message), debugger_id, once); } void Debugger::ReportError(std::string message, std::optional debugger_id, std::once_flag *once) { - ReportDiagnosticImpl(DiagnosticEventData::Type::Error, std::move(message), - debugger_id, once); + ReportDiagnosticImpl(eSeverityError, std::move(message), debugger_id, once); } void Debugger::ReportInfo(std::string message, std::optional debugger_id, std::once_flag *once) { - ReportDiagnosticImpl(DiagnosticEventData::Type::Info, std::move(message), - debugger_id, once); + ReportDiagnosticImpl(eSeverityInfo, std::move(message), debugger_id, once); } void Debugger::ReportSymbolChange(const ModuleSpec &module_spec) { diff --git a/lldb/source/Core/DebuggerEvents.cpp b/lldb/source/Core/DebuggerEvents.cpp index 65aed0eba9c41..2fa6efd155af7 100644 --- a/lldb/source/Core/DebuggerEvents.cpp +++ b/lldb/source/Core/DebuggerEvents.cpp @@ -73,19 +73,19 @@ ProgressEventData::GetAsStructuredData(const Event *event_ptr) { } llvm::StringRef DiagnosticEventData::GetPrefix() const { - switch (m_type) { - case Type::Info: + switch (m_severity) { + case Severity::eSeverityInfo: return "info"; - case Type::Warning: + case Severity::eSeverityWarning: return "warning"; - case Type::Error: + case Severity::eSeverityError: return "error"; } llvm_unreachable("Fully covered switch above!"); } void DiagnosticEventData::Dump(Stream *s) const { - llvm::HighlightColor color = m_type == Type::Warning + llvm::HighlightColor color = m_severity == lldb::eSeverityWarning ? llvm::HighlightColor::Warning : llvm::HighlightColor::Error; llvm::WithColor(s->AsRawOstream(), color, llvm::ColorMode::Enable) diff --git a/lldb/source/Expression/DiagnosticManager.cpp b/lldb/source/Expression/DiagnosticManager.cpp index 9a1100df78db2..a8330138f3d53 100644 --- a/lldb/source/Expression/DiagnosticManager.cpp +++ b/lldb/source/Expression/DiagnosticManager.cpp @@ -31,17 +31,17 @@ void DiagnosticManager::Dump(Log *log) { log->PutCString(str.c_str()); } -static const char *StringForSeverity(DiagnosticSeverity severity) { +static const char *StringForSeverity(lldb::Severity severity) { switch (severity) { // this should be exhaustive - case lldb_private::eDiagnosticSeverityError: + case lldb::eSeverityError: return "error: "; - case lldb_private::eDiagnosticSeverityWarning: + case lldb::eSeverityWarning: return "warning: "; - case lldb_private::eDiagnosticSeverityRemark: + case lldb::eSeverityInfo: return ""; } - llvm_unreachable("switch needs another case for DiagnosticSeverity enum"); + llvm_unreachable("switch needs another case for lldb::Severity enum"); } std::string DiagnosticManager::GetString(char separator) { @@ -65,8 +65,8 @@ std::string DiagnosticManager::GetString(char separator) { return ret; } -size_t DiagnosticManager::Printf(DiagnosticSeverity severity, - const char *format, ...) { +size_t DiagnosticManager::Printf(lldb::Severity severity, const char *format, + ...) { StreamString ss; va_list args; @@ -79,7 +79,7 @@ size_t DiagnosticManager::Printf(DiagnosticSeverity severity, return result; } -void DiagnosticManager::PutString(DiagnosticSeverity severity, +void DiagnosticManager::PutString(lldb::Severity severity, llvm::StringRef str) { if (str.empty()) return; diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp index ffadbf9b32ec5..5ac2b0681ebbe 100644 --- a/lldb/source/Expression/FunctionCaller.cpp +++ b/lldb/source/Expression/FunctionCaller.cpp @@ -67,27 +67,25 @@ bool FunctionCaller::WriteFunctionWrapper( Process *process = exe_ctx.GetProcessPtr(); if (!process) { - diagnostic_manager.Printf(eDiagnosticSeverityError, "no process."); + diagnostic_manager.Printf(lldb::eSeverityError, "no process."); return false; } lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); if (process != jit_process_sp.get()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, - "process does not match the stored process."); + diagnostic_manager.Printf(lldb::eSeverityError, + "process does not match the stored process."); return false; } if (process->GetState() != lldb::eStateStopped) { - diagnostic_manager.Printf(eDiagnosticSeverityError, - "process is not stopped"); + diagnostic_manager.Printf(lldb::eSeverityError, "process is not stopped"); return false; } if (!m_compiled) { - diagnostic_manager.Printf(eDiagnosticSeverityError, - "function not compiled"); + diagnostic_manager.Printf(lldb::eSeverityError, "function not compiled"); return false; } @@ -101,7 +99,7 @@ bool FunctionCaller::WriteFunctionWrapper( can_interpret, eExecutionPolicyAlways)); if (!jit_error.Success()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "Error in PrepareForExecution: %s.", jit_error.AsCString()); return false; @@ -144,7 +142,7 @@ bool FunctionCaller::WriteFunctionArguments( // All the information to reconstruct the struct is provided by the // StructExtractor. if (!m_struct_valid) { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "Argument information was not correctly " "parsed, so the function cannot be called."); return false; @@ -192,7 +190,7 @@ bool FunctionCaller::WriteFunctionArguments( size_t num_args = arg_values.GetSize(); if (num_args != m_arg_values.GetSize()) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "Wrong number of arguments - was: %" PRIu64 " should be: %" PRIu64 "", (uint64_t)num_args, (uint64_t)m_arg_values.GetSize()); return false; @@ -231,11 +229,11 @@ bool FunctionCaller::InsertFunction(ExecutionContext &exe_ctx, // the caller, we need to be stopped. Process *process = exe_ctx.GetProcessPtr(); if (!process) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "no process"); + diagnostic_manager.PutString(lldb::eSeverityError, "no process"); return false; } if (process->GetState() != lldb::eStateStopped) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "process running"); + diagnostic_manager.PutString(lldb::eSeverityError, "process running"); return false; } if (CompileFunction(exe_ctx.GetThreadSP(), diagnostic_manager) != 0) @@ -267,8 +265,7 @@ lldb::ThreadPlanSP FunctionCaller::GetThreadPlanToCallFunction( Thread *thread = exe_ctx.GetThreadPtr(); if (thread == nullptr) { diagnostic_manager.PutString( - eDiagnosticSeverityError, - "Can't call a function without a valid thread."); + lldb::eSeverityError, "Can't call a function without a valid thread."); return nullptr; } diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp index 1434011c80ad8..b4fdfc4d1fa8b 100644 --- a/lldb/source/Expression/LLVMUserExpression.cpp +++ b/lldb/source/Expression/LLVMUserExpression.cpp @@ -73,7 +73,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, if (m_jit_start_addr == LLDB_INVALID_ADDRESS && !m_can_interpret) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "Expression can't be run, because there is no JIT compiled function"); return lldb::eExpressionSetupError; } @@ -83,7 +83,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, if (!PrepareToExecuteJITExpression(diagnostic_manager, exe_ctx, struct_address)) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__); return lldb::eExpressionSetupError; @@ -98,8 +98,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, if (!module || !function) { diagnostic_manager.PutString( - eDiagnosticSeverityError, - "supposed to interpret, but nothing is there"); + lldb::eSeverityError, "supposed to interpret, but nothing is there"); return lldb::eExpressionSetupError; } @@ -108,7 +107,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, std::vector args; if (!AddArguments(exe_ctx, args, struct_address, diagnostic_manager)) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "errored out in %s, couldn't AddArguments", __FUNCTION__); return lldb::eExpressionSetupError; @@ -122,14 +121,14 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, function_stack_top, exe_ctx, options.GetTimeout()); if (!interpreter_error.Success()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "supposed to interpret, but failed: %s", interpreter_error.AsCString()); return lldb::eExpressionDiscarded; } } else { if (!exe_ctx.HasThreadScope()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "%s called with no thread selected", __FUNCTION__); return lldb::eExpressionSetupError; @@ -144,7 +143,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, std::vector args; if (!AddArguments(exe_ctx, args, struct_address, diagnostic_manager)) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "errored out in %s, couldn't AddArguments", __FUNCTION__); return lldb::eExpressionSetupError; @@ -156,7 +155,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, StreamString ss; if (!call_plan_sp || !call_plan_sp->ValidatePlan(&ss)) { - diagnostic_manager.PutString(eDiagnosticSeverityError, ss.GetString()); + diagnostic_manager.PutString(lldb::eSeverityError, ss.GetString()); return lldb::eExpressionSetupError; } @@ -194,11 +193,11 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, error_desc = real_stop_info_sp->GetDescription(); } if (error_desc) - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "Execution was interrupted, reason: %s.", error_desc); else - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "Execution was interrupted."); if ((execution_result == lldb::eExpressionInterrupted && @@ -221,7 +220,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, return execution_result; } else if (execution_result == lldb::eExpressionStoppedForDebug) { diagnostic_manager.PutString( - eDiagnosticSeverityRemark, + lldb::eSeverityInfo, "Execution was halted at the first instruction of the expression " "function because \"debug\" was requested.\n" "Use \"thread return -x\" to return to the state before expression " @@ -229,7 +228,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, return execution_result; } else if (execution_result == lldb::eExpressionThreadVanished) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "Couldn't complete execution; the thread " "on which the expression was being run: 0x%" PRIx64 " exited during its execution.", @@ -237,7 +236,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, return execution_result; } else if (execution_result != lldb::eExpressionCompleted) { diagnostic_manager.Printf( - eDiagnosticSeverityError, "Couldn't execute function; result was %s", + lldb::eSeverityError, "Couldn't execute function; result was %s", Process::ExecutionResultAsCString(execution_result)); return execution_result; } @@ -261,7 +260,7 @@ bool LLVMUserExpression::FinalizeJITExecution( "after execution --"); if (!m_dematerializer_sp) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "Couldn't apply expression side effects : no " "dematerializer is present"); return false; @@ -273,7 +272,7 @@ bool LLVMUserExpression::FinalizeJITExecution( function_stack_top); if (!dematerialize_error.Success()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "Couldn't apply expression side effects : %s", dematerialize_error.AsCString("unknown error")); return false; @@ -299,7 +298,7 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression( if (!LockAndCheckContext(exe_ctx, target, process, frame)) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "The context has changed before we could JIT the expression!"); return false; } @@ -322,7 +321,7 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression( if (!alloc_error.Success()) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "Couldn't allocate space for materialized struct: %s", alloc_error.AsCString()); return false; @@ -354,7 +353,7 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression( if (!alloc_error.Success()) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "Couldn't allocate space for the stack frame: %s", alloc_error.AsCString()); return false; @@ -367,7 +366,7 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression( frame, *m_execution_unit_sp, struct_address, materialize_error); if (!materialize_error.Success()) { - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "Couldn't materialize: %s", materialize_error.AsCString()); return false; diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 45b2a62b5c72a..06ccc0e2b3424 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -91,33 +91,33 @@ using namespace lldb_private; #if !defined(__APPLE__) #if !defined(_WIN32) #include -void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) { +void Host::SystemLog(Severity severity, llvm::StringRef message) { static llvm::once_flag g_openlog_once; llvm::call_once(g_openlog_once, [] { openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); }); int level = LOG_DEBUG; - switch (log_level) { - case eSystemLogInfo: + switch (severity) { + case lldb::eSeverityInfo: level = LOG_INFO; break; - case eSystemLogWarning: + case lldb::eSeverityWarning: level = LOG_WARNING; break; - case eSystemLogError: + case lldb::eSeverityError: level = LOG_ERR; break; } syslog(level, "%s", message.data()); } #else -void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) { - switch (log_level) { - case eSystemLogInfo: - case eSystemLogWarning: +void Host::SystemLog(Severity severity, llvm::StringRef message) { + switch (severity) { + case lldb::eSeverityInfo: + case lldb::eSeverityWarning: llvm::outs() << message; break; - case eSystemLogError: + case lldb::eSeverityError: llvm::errs() << message; break; } @@ -651,5 +651,5 @@ char SystemLogHandler::ID; SystemLogHandler::SystemLogHandler() {} void SystemLogHandler::Emit(llvm::StringRef message) { - Host::SystemLog(Host::eSystemLogInfo, message); + Host::SystemLog(lldb::eSeverityInfo, message); } diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index 1f67141de55d7..4fba5550ba10a 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -102,17 +102,17 @@ static os_log_t g_os_log; static std::once_flag g_os_log_once; -void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) { +void Host::SystemLog(Severity severity, llvm::StringRef message) { if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) { std::call_once(g_os_log_once, []() { g_os_log = os_log_create("com.apple.dt.lldb", "lldb"); }); - switch (log_level) { - case eSystemLogInfo: - case eSystemLogWarning: + switch (severity) { + case lldb::eSeverityInfo: + case lldb::eSeverityWarning: os_log(g_os_log, "%{public}s", message.str().c_str()); break; - case eSystemLogError: + case lldb::eSeverityError: os_log_error(g_os_log, "%{public}s", message.str().c_str()); break; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h index 7459b715dbe2b..21abd71cc34ee 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h @@ -29,7 +29,7 @@ class ClangDiagnostic : public Diagnostic { return diag->getKind() == eDiagnosticOriginClang; } - ClangDiagnostic(llvm::StringRef message, DiagnosticSeverity severity, + ClangDiagnostic(llvm::StringRef message, lldb::Severity severity, uint32_t compiler_id) : Diagnostic(message, severity, eDiagnosticOriginClang, compiler_id) {} diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 31f6447d66f64..f994d02504335 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -228,8 +228,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl, std::string msg = llvm::formatv("redefinition of persistent variable '{0}'", name).str(); m_parser_vars->m_diagnostics->AddDiagnostic( - msg, DiagnosticSeverity::eDiagnosticSeverityError, - DiagnosticOrigin::eDiagnosticOriginLLDB); + msg, lldb::eSeverityError, DiagnosticOrigin::eDiagnosticOriginLLDB); return false; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 72c7cda13ecb7..1dd98567f8d69 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -207,20 +207,20 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { m_passthrough->HandleDiagnostic(DiagLevel, Info); m_os->flush(); - lldb_private::DiagnosticSeverity severity; + lldb::Severity severity; bool make_new_diagnostic = true; switch (DiagLevel) { case DiagnosticsEngine::Level::Fatal: case DiagnosticsEngine::Level::Error: - severity = eDiagnosticSeverityError; + severity = lldb::eSeverityError; break; case DiagnosticsEngine::Level::Warning: - severity = eDiagnosticSeverityWarning; + severity = lldb::eSeverityWarning; break; case DiagnosticsEngine::Level::Remark: case DiagnosticsEngine::Level::Ignored: - severity = eDiagnosticSeverityRemark; + severity = lldb::eSeverityInfo; break; case DiagnosticsEngine::Level::Note: m_manager->AppendMessageToDiagnostic(m_output); @@ -238,7 +238,7 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { if (!clang_diag || clang_diag->HasFixIts()) break; // Ignore all Fix-Its that are not associated with an error. - if (clang_diag->GetSeverity() != eDiagnosticSeverityError) + if (clang_diag->GetSeverity() != lldb::eSeverityError) break; AddAllFixIts(clang_diag, Info); break; @@ -256,7 +256,7 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { // enough context in an expression for the warning to be useful. // FIXME: Should we try to filter out FixIts that apply to our generated // code, and not the user's expression? - if (severity == eDiagnosticSeverityError) + if (severity == lldb::eSeverityError) AddAllFixIts(new_diagnostic.get(), Info); m_manager->AddDiagnostic(std::move(new_diagnostic)); @@ -1164,7 +1164,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, if (m_pp_callbacks && m_pp_callbacks->hasErrors()) { num_errors++; - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "while importing modules:"); diagnostic_manager.AppendMessageToDiagnostic( m_pp_callbacks->getErrorString()); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp index 5235cd2a14617..59321e375bdca 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp @@ -138,7 +138,7 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp, type_name = clang_qual_type.GetTypeName().AsCString(""); } else { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "Could not determine type of input value %" PRIu64 ".", (uint64_t)i); return 1; @@ -194,7 +194,7 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp, num_errors = clang_parser->Parse(diagnostic_manager); m_parser.reset(clang_parser); } else { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "no process - unable to inject function"); num_errors = 1; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 5ea7bc02a6e48..c7e98d12590d9 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -331,12 +331,11 @@ bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_man m_result_delegate.RegisterPersistentState(persistent_state); } else { diagnostic_manager.PutString( - eDiagnosticSeverityError, - "couldn't start parsing (no persistent data)"); + lldb::eSeverityError, "couldn't start parsing (no persistent data)"); return false; } } else { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "error: couldn't start parsing (no target)"); return false; } @@ -384,12 +383,11 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target, // The error stream already contains several Clang diagnostics that might // be either errors or warnings, so just print them all as one remark // diagnostic to prevent that the message starts with "error: error:". - diagnostic_manager.PutString(eDiagnosticSeverityRemark, - error_stream.GetString()); + diagnostic_manager.PutString(lldb::eSeverityInfo, error_stream.GetString()); return; } - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "Unknown error while loading modules needed for " "current compilation unit."); } @@ -424,7 +422,7 @@ void ClangUserExpression::CreateSourceCode( if (!m_source_code->GetText(m_transformed_text, exe_ctx, !m_ctx_obj, for_completion, modules_to_import)) { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "couldn't construct expression body"); return; } @@ -531,7 +529,7 @@ bool ClangUserExpression::PrepareForParsing( ScanContext(exe_ctx, err); if (!err.Success()) { - diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString()); + diagnostic_manager.PutString(lldb::eSeverityWarning, err.AsCString()); } //////////////////////////////////// @@ -564,7 +562,7 @@ bool ClangUserExpression::TryParse( if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "current process state is unsuitable for expression parsing"); return false; } @@ -611,9 +609,9 @@ bool ClangUserExpression::TryParse( if (!jit_error.Success()) { const char *error_cstr = jit_error.AsCString(); if (error_cstr && error_cstr[0]) - diagnostic_manager.PutString(eDiagnosticSeverityError, error_cstr); + diagnostic_manager.PutString(lldb::eSeverityError, error_cstr); else - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "expression can't be interpreted or run"); return false; } @@ -663,7 +661,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, Target *target = exe_ctx.GetTargetPtr(); if (!target) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "invalid target"); + diagnostic_manager.PutString(lldb::eSeverityError, "invalid target"); return false; } @@ -707,11 +705,9 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, if (!static_init_error.Success()) { const char *error_cstr = static_init_error.AsCString(); if (error_cstr && error_cstr[0]) - diagnostic_manager.Printf(eDiagnosticSeverityError, - "%s\n", - error_cstr); + diagnostic_manager.Printf(lldb::eSeverityError, "%s\n", error_cstr); else - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "couldn't run static initializers\n"); return false; } @@ -825,7 +821,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx, if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "current process state is unsuitable for expression parsing"); return false; @@ -902,7 +898,7 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, if (!m_in_cplusplus_method && !m_in_objectivec_method) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "need object pointer but don't know the language"); return false; } @@ -944,7 +940,7 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, if (!object_ptr_error.Success()) { diagnostic_manager.Printf( - eDiagnosticSeverityWarning, + lldb::eSeverityWarning, "couldn't get cmd pointer (substituting NULL): %s", object_ptr_error.AsCString()); cmd_ptr = 0; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp index 56d6cf19ee4c3..1f44200c4cff8 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -75,8 +75,7 @@ ClangUtilityFunction::~ClangUtilityFunction() = default; bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { if (m_jit_start_addr != LLDB_INVALID_ADDRESS) { - diagnostic_manager.PutString(eDiagnosticSeverityWarning, - "already installed"); + diagnostic_manager.PutString(lldb::eSeverityWarning, "already installed"); return false; } @@ -87,21 +86,21 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, Target *target = exe_ctx.GetTargetPtr(); if (!target) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "invalid target"); + diagnostic_manager.PutString(lldb::eSeverityError, "invalid target"); return false; } Process *process = exe_ctx.GetProcessPtr(); if (!process) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "invalid process"); + diagnostic_manager.PutString(lldb::eSeverityError, "invalid process"); return false; } // Since we might need to call allocate memory and maybe call code to make // the caller, we need to be stopped. if (process->GetState() != lldb::eStateStopped) { - diagnostic_manager.PutString(eDiagnosticSeverityError, "process running"); + diagnostic_manager.PutString(lldb::eSeverityError, "process running"); return false; } ////////////////////////// @@ -114,7 +113,7 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, if (!DeclMap()->WillParse(exe_ctx, nullptr)) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "current process state is unsuitable for expression parsing"); return false; } @@ -166,9 +165,9 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, } else { const char *error_cstr = jit_error.AsCString(); if (error_cstr && error_cstr[0]) { - diagnostic_manager.Printf(eDiagnosticSeverityError, "%s", error_cstr); + diagnostic_manager.Printf(lldb::eSeverityError, "%s", error_cstr); } else { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "expression can't be interpreted or run"); } return false; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 30c240b064b59..25afade9a8275 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4738,27 +4738,26 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, if (!thread_plan_sp) { diagnostic_manager.PutString( - eDiagnosticSeverityError, - "RunThreadPlan called with empty thread plan."); + lldb::eSeverityError, "RunThreadPlan called with empty thread plan."); return eExpressionSetupError; } if (!thread_plan_sp->ValidatePlan(nullptr)) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "RunThreadPlan called with an invalid thread plan."); return eExpressionSetupError; } if (exe_ctx.GetProcessPtr() != this) { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "RunThreadPlan called on wrong process."); return eExpressionSetupError; } Thread *thread = exe_ctx.GetThreadPtr(); if (thread == nullptr) { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "RunThreadPlan called with invalid thread."); return eExpressionSetupError; } @@ -4793,7 +4792,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, if (m_private_state.GetValue() != eStateStopped) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "RunThreadPlan called while the private state was not stopped."); return eExpressionSetupError; } @@ -4807,7 +4806,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, selected_frame_sp = thread->GetSelectedFrame(DoNoSelectMostRelevantFrame); if (!selected_frame_sp) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "RunThreadPlan called without a selected frame on thread %d", thread_idx_id); return eExpressionSetupError; @@ -4818,7 +4817,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, // be smaller than the overall timeout. if (options.GetOneThreadTimeout() && options.GetTimeout() && *options.GetTimeout() < *options.GetOneThreadTimeout()) { - diagnostic_manager.PutString(eDiagnosticSeverityError, + diagnostic_manager.PutString(lldb::eSeverityError, "RunThreadPlan called with one thread " "timeout greater than total timeout"); return eExpressionSetupError; @@ -4946,7 +4945,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, Event *other_events = listener_sp->PeekAtNextEvent(); if (other_events != nullptr) { diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "RunThreadPlan called with pending events on the queue."); return eExpressionSetupError; } @@ -4989,7 +4988,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, Status resume_error = PrivateResume(); if (!resume_error.Success()) { diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "couldn't resume inferior the %d time: \"%s\".", num_resumes, resume_error.AsCString()); return_value = eExpressionSetupError; @@ -5005,7 +5004,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, "resume %" PRIu32 ", exiting.", num_resumes); - diagnostic_manager.Printf(eDiagnosticSeverityError, + diagnostic_manager.Printf(lldb::eSeverityError, "didn't get any event after resume %" PRIu32 ", exiting.", num_resumes); @@ -5041,7 +5040,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, } diagnostic_manager.Printf( - eDiagnosticSeverityError, + lldb::eSeverityError, "didn't get running event after initial resume, got %s instead.", StateAsCString(stop_state)); return_value = eExpressionSetupError; @@ -5099,7 +5098,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, const bool use_run_lock = false; Halt(clear_thread_plans, use_run_lock); return_value = eExpressionInterrupted; - diagnostic_manager.PutString(eDiagnosticSeverityRemark, + diagnostic_manager.PutString(lldb::eSeverityInfo, "execution halted by user interrupt."); LLDB_LOGF(log, "Process::RunThreadPlan(): Got interrupted by " "eBroadcastBitInterrupted, exiting."); @@ -5152,7 +5151,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, event_to_broadcast_sp = event_sp; diagnostic_manager.PutString( - eDiagnosticSeverityError, + lldb::eSeverityError, "execution stopped with unexpected state."); return_value = eExpressionInterrupted; break; diff --git a/lldb/unittests/Expression/DiagnosticManagerTest.cpp b/lldb/unittests/Expression/DiagnosticManagerTest.cpp index cab26debedb14..05fe7c164d681 100644 --- a/lldb/unittests/Expression/DiagnosticManagerTest.cpp +++ b/lldb/unittests/Expression/DiagnosticManagerTest.cpp @@ -19,7 +19,7 @@ class FixItDiag : public Diagnostic { public: FixItDiag(llvm::StringRef msg, bool has_fixits) - : Diagnostic(msg, DiagnosticSeverity::eDiagnosticSeverityError, + : Diagnostic(msg, lldb::eSeverityError, DiagnosticOrigin::eDiagnosticOriginLLDB, custom_diag_id), m_has_fixits(has_fixits) {} bool HasFixIts() const override { return m_has_fixits; } @@ -29,7 +29,7 @@ class FixItDiag : public Diagnostic { namespace { class TextDiag : public Diagnostic { public: - TextDiag(llvm::StringRef msg, DiagnosticSeverity severity) + TextDiag(llvm::StringRef msg, lldb::Severity severity) : Diagnostic(msg, severity, DiagnosticOrigin::eDiagnosticOriginLLDB, custom_diag_id) {} }; @@ -40,7 +40,7 @@ TEST(DiagnosticManagerTest, AddDiagnostic) { EXPECT_EQ(0U, mgr.Diagnostics().size()); std::string msg = "foo bar has happened"; - DiagnosticSeverity severity = DiagnosticSeverity::eDiagnosticSeverityError; + lldb::Severity severity = lldb::eSeverityError; DiagnosticOrigin origin = DiagnosticOrigin::eDiagnosticOriginLLDB; auto diag = std::make_unique(msg, severity, origin, custom_diag_id); @@ -82,8 +82,7 @@ TEST(DiagnosticManagerTest, GetStringNoDiags) { TEST(DiagnosticManagerTest, GetStringBasic) { DiagnosticManager mgr; - mgr.AddDiagnostic( - std::make_unique("abc", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("abc", lldb::eSeverityError)); EXPECT_EQ("error: abc\n", mgr.GetString()); } @@ -91,18 +90,15 @@ TEST(DiagnosticManagerTest, GetStringMultiline) { DiagnosticManager mgr; // Multiline diagnostics should only get one severity label. - mgr.AddDiagnostic( - std::make_unique("b\nc", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("b\nc", lldb::eSeverityError)); EXPECT_EQ("error: b\nc\n", mgr.GetString()); } TEST(DiagnosticManagerTest, GetStringMultipleDiags) { DiagnosticManager mgr; - mgr.AddDiagnostic( - std::make_unique("abc", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("abc", lldb::eSeverityError)); EXPECT_EQ("error: abc\n", mgr.GetString()); - mgr.AddDiagnostic( - std::make_unique("def", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("def", lldb::eSeverityError)); EXPECT_EQ("error: abc\nerror: def\n", mgr.GetString()); } @@ -110,13 +106,10 @@ TEST(DiagnosticManagerTest, GetStringSeverityLabels) { DiagnosticManager mgr; // Different severities should cause different labels. - mgr.AddDiagnostic( - std::make_unique("foo", eDiagnosticSeverityError)); - mgr.AddDiagnostic( - std::make_unique("bar", eDiagnosticSeverityWarning)); + mgr.AddDiagnostic(std::make_unique("foo", lldb::eSeverityError)); + mgr.AddDiagnostic(std::make_unique("bar", lldb::eSeverityWarning)); // Remarks have no labels. - mgr.AddDiagnostic( - std::make_unique("baz", eDiagnosticSeverityRemark)); + mgr.AddDiagnostic(std::make_unique("baz", lldb::eSeverityInfo)); EXPECT_EQ("error: foo\nwarning: bar\nbaz\n", mgr.GetString()); } @@ -124,12 +117,9 @@ TEST(DiagnosticManagerTest, GetStringPreserveOrder) { DiagnosticManager mgr; // Make sure we preserve the diagnostic order and do not sort them in any way. - mgr.AddDiagnostic( - std::make_unique("baz", eDiagnosticSeverityRemark)); - mgr.AddDiagnostic( - std::make_unique("bar", eDiagnosticSeverityWarning)); - mgr.AddDiagnostic( - std::make_unique("foo", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("baz", lldb::eSeverityInfo)); + mgr.AddDiagnostic(std::make_unique("bar", lldb::eSeverityWarning)); + mgr.AddDiagnostic(std::make_unique("foo", lldb::eSeverityError)); EXPECT_EQ("baz\nwarning: bar\nerror: foo\n", mgr.GetString()); } @@ -144,10 +134,8 @@ TEST(DiagnosticManagerTest, AppendMessageNoDiag) { TEST(DiagnosticManagerTest, AppendMessageAttachToLastDiag) { DiagnosticManager mgr; - mgr.AddDiagnostic( - std::make_unique("foo", eDiagnosticSeverityError)); - mgr.AddDiagnostic( - std::make_unique("bar", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("foo", lldb::eSeverityError)); + mgr.AddDiagnostic(std::make_unique("bar", lldb::eSeverityError)); // This should append to 'bar' and not to 'foo'. mgr.AppendMessageToDiagnostic("message text"); @@ -157,12 +145,10 @@ TEST(DiagnosticManagerTest, AppendMessageAttachToLastDiag) { TEST(DiagnosticManagerTest, AppendMessageSubsequentDiags) { DiagnosticManager mgr; - mgr.AddDiagnostic( - std::make_unique("bar", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("bar", lldb::eSeverityError)); mgr.AppendMessageToDiagnostic("message text"); // Pushing another diag after the message should work fine. - mgr.AddDiagnostic( - std::make_unique("foo", eDiagnosticSeverityError)); + mgr.AddDiagnostic(std::make_unique("foo", lldb::eSeverityError)); EXPECT_EQ("error: bar\nmessage text\nerror: foo\n", mgr.GetString()); } @@ -170,7 +156,7 @@ TEST(DiagnosticManagerTest, AppendMessageSubsequentDiags) { TEST(DiagnosticManagerTest, PutString) { DiagnosticManager mgr; - mgr.PutString(eDiagnosticSeverityError, "foo"); + mgr.PutString(lldb::eSeverityError, "foo"); EXPECT_EQ(1U, mgr.Diagnostics().size()); EXPECT_EQ(eDiagnosticOriginLLDB, mgr.Diagnostics().front()->getKind()); EXPECT_EQ("error: foo\n", mgr.GetString()); @@ -180,8 +166,8 @@ TEST(DiagnosticManagerTest, PutStringMultiple) { DiagnosticManager mgr; // Multiple PutString should behave like multiple diagnostics. - mgr.PutString(eDiagnosticSeverityError, "foo"); - mgr.PutString(eDiagnosticSeverityError, "bar"); + mgr.PutString(lldb::eSeverityError, "foo"); + mgr.PutString(lldb::eSeverityError, "bar"); EXPECT_EQ(2U, mgr.Diagnostics().size()); EXPECT_EQ("error: foo\nerror: bar\n", mgr.GetString()); } @@ -191,8 +177,8 @@ TEST(DiagnosticManagerTest, PutStringSeverities) { // Multiple PutString with different severities should behave like we // created multiple diagnostics. - mgr.PutString(eDiagnosticSeverityError, "foo"); - mgr.PutString(eDiagnosticSeverityWarning, "bar"); + mgr.PutString(lldb::eSeverityError, "foo"); + mgr.PutString(lldb::eSeverityWarning, "bar"); EXPECT_EQ(2U, mgr.Diagnostics().size()); EXPECT_EQ("error: foo\nwarning: bar\n", mgr.GetString()); }