diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 020e5be0ec575..05ae9b50a29b0 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1039,8 +1039,11 @@ SBStructuredData SBProcess::GetExtendedCrashInformation() { auto expected_data = platform_sp->FetchExtendedCrashInformation(*process_sp.get()); - if (!expected_data) + if (!expected_data) { + LLDB_LOG_ERROR(GetLog(LLDBLog::API), expected_data.takeError(), + "FetchExtendedCrashInformation failed: {0}"); return data; + } StructuredData::ObjectSP fetched_data = *expected_data; data.m_impl_up->SetObjectSP(fetched_data); diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index c6fe7814bd22e..b84411d3aa754 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -9,6 +9,7 @@ #include "lldb/Host/posix/MainLoopPosix.h" #include "lldb/Host/Config.h" #include "lldb/Host/PosixApi.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Status.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/Errno.h" @@ -392,6 +393,11 @@ bool MainLoopPosix::Interrupt() { return true; char c = '.'; - llvm::Expected result = m_interrupt_pipe.Write(&c, 1); - return result && *result != 0; + llvm::Expected result_or_err = m_interrupt_pipe.Write(&c, 1); + if (!result_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Host), result_or_err.takeError(), + "interrupt pipe write failed: {0}"); + return false; + } + return *result_or_err != 0; } diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 5165e93abe315..77818f1a32ca4 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -263,7 +263,7 @@ ScriptInterpreterIORedirect::Create(bool enable_io, Debugger &debugger, auto nullout = FileSystem::Instance().Open(FileSpec(FileSystem::DEV_NULL), File::eOpenOptionWriteOnly); if (!nullout) - return nullin.takeError(); + return nullout.takeError(); return std::unique_ptr( new ScriptInterpreterIORedirect(std::move(*nullin), std::move(*nullout))); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 4055dc2fd9503..633f7ebf8199a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -17,6 +17,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/ValueObject/ValueObject.h" diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp index f836710033b09..7c0253450e071 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -213,17 +213,23 @@ Status ProcessMinidump::DoLoadCore() { m_thread_list = m_minidump_parser->GetThreads(); auto exception_stream_it = m_minidump_parser->GetExceptionStreams(); - for (auto exception_stream : exception_stream_it) { + for (auto exception_stream_or_err : exception_stream_it) { // If we can't read an exception stream skip it // We should probably serve a warning - if (!exception_stream) + if (!exception_stream_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Process), + exception_stream_or_err.takeError(), + "failed to read exception stream: {0}"); continue; + } + const llvm::minidump::ExceptionStream &exception_stream = + *exception_stream_or_err; if (!m_exceptions_by_tid - .try_emplace(exception_stream->ThreadId, exception_stream.get()) + .try_emplace(exception_stream.ThreadId, exception_stream) .second) { return Status::FromErrorStringWithFormatv( - "Duplicate exception stream for tid {0}", exception_stream->ThreadId); + "Duplicate exception stream for tid {0}", exception_stream.ThreadId); } } diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp index f1d39a85cb18e..d07cb0003ec27 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -174,8 +174,7 @@ bool ScriptedThread::LoadArtificialStackFrames() { LLVM_PRETTY_FUNCTION, llvm::Twine( "StackFrame array size (" + llvm::Twine(arr_size) + - llvm::Twine( - ") is greater than maximum authorized for a StackFrameList.")) + ") is greater than maximum authorized for a StackFrameList.") .str(), error, LLDBLog::Thread); @@ -265,8 +264,10 @@ bool ScriptedThread::LoadArtificialStackFrames() { if (!frame_from_script_obj_or_err) { return ScriptedInterface::ErrorWithMessage( LLVM_PRETTY_FUNCTION, - llvm::Twine("Couldn't add artificial frame (" + llvm::Twine(idx) + - llvm::Twine(") to ScriptedThread StackFrameList.")) + llvm::Twine( + "Couldn't add artificial frame (" + llvm::Twine(idx) + + llvm::Twine(") to ScriptedThread StackFrameList: ") + + llvm::toString(frame_from_script_obj_or_err.takeError())) .str(), error, LLDBLog::Thread); } else { diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilderClang.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilderClang.cpp index 1b6bbbc2e7ab9..1784481fec54c 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilderClang.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilderClang.cpp @@ -24,6 +24,7 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/LLDBLog.h" #include #include @@ -909,6 +910,9 @@ clang::FunctionDecl *PdbAstBuilderClang::CreateFunctionDecl( index.tpi().findFullDeclForForwardRef(class_index); if (eti) { tag_record = CVTagRecord::create(index.tpi().getType(*eti)).asTag(); + } else { + LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), eti.takeError(), + "failed to find full decl for forward ref: {0}"); } } if (!tag_record.FieldList.isSimple()) { diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 3b516bd40e8e4..ddb7c3aeda31a 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1338,8 +1338,11 @@ bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { for (const LineColumnEntry &group : lines) { llvm::Expected file_index_or_err = GetFileIndex(*cii, group.NameIndex); - if (!file_index_or_err) + if (!file_index_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), file_index_or_err.takeError(), + "failed to get file index for line entry: {0}"); continue; + } uint32_t file_index = file_index_or_err.get(); lldbassert(!group.LineNumbers.empty()); CompilandIndexItem::GlobalLineTable::Entry line_entry( @@ -1542,8 +1545,11 @@ void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id, FileSpec decl_file; llvm::Expected file_index_or_err = GetFileIndex(*cii, inlinee_line.Header->FileID); - if (!file_index_or_err) + if (!file_index_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), file_index_or_err.takeError(), + "failed to get file index for inline site: {0}"); return; + } uint32_t file_offset = file_index_or_err.get(); decl_file = files.GetFileSpecAtIndex(file_offset); uint32_t decl_line = inlinee_line.Header->SourceLineNum; @@ -1771,8 +1777,11 @@ size_t SymbolFileNativePDB::ParseSymbolArrayInScope( void SymbolFileNativePDB::DumpClangAST(Stream &s, llvm::StringRef filter) { auto ts_or_err = GetTypeSystemForLanguage(eLanguageTypeC_plus_plus); - if (!ts_or_err) + if (!ts_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), ts_or_err.takeError(), + "failed to get C++ type system: {0}"); return; + } auto ts = *ts_or_err; TypeSystemClang *clang = llvm::dyn_cast_or_null(ts.get()); if (!clang) diff --git a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp index f9aa6b1a98765..4aa0379d5cc19 100644 --- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp +++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp @@ -174,8 +174,11 @@ GetFileForModule(const ModuleSpec &module_spec, PluginProperties &plugin_props = GetGlobalPluginProperties(); llvm::Expected cache_path_or_err = plugin_props.GetCachePath(); // A cache location is *required*. - if (!cache_path_or_err) + if (!cache_path_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), cache_path_or_err.takeError(), + "debuginfod cache path unavailable: {0}"); return {}; + } std::string cache_path = *cache_path_or_err; llvm::SmallVector debuginfod_urls = llvm::getDefaultDebuginfodUrls(); diff --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp b/lldb/source/Symbol/SymbolFileOnDemand.cpp index 807c2124e48d9..68e5eeaa04295 100644 --- a/lldb/source/Symbol/SymbolFileOnDemand.cpp +++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp @@ -515,10 +515,12 @@ SymbolFileOnDemand::GetParameterStackSize(Symbol &symbol) { if (log) { llvm::Expected stack_size = m_sym_file_impl->GetParameterStackSize(symbol); - if (stack_size) { + if (stack_size) LLDB_LOG(log, "{0} stack size would return for symbol {1} if hydrated.", *stack_size, symbol.GetName()); - } + else + LLDB_LOG_ERROR(log, stack_size.takeError(), + "failed to get parameter stack size: {0}"); } return SymbolFile::GetParameterStackSize(symbol); } diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index 909f335687b21..46ded78474d25 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -17,6 +17,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/StructuredData.h" using namespace lldb; @@ -498,6 +499,9 @@ llvm::json::Value DebuggerStats::ReportStatistics( if (auto json_transcript = llvm::json::parse(buffer)) global_stats.try_emplace("transcript", std::move(json_transcript.get())); + else + LLDB_LOG_ERROR(GetLog(LLDBLog::Target), json_transcript.takeError(), + "failed to parse transcript JSON: {0}"); } } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 0d63f37945b63..f9d83541e5f0e 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4267,8 +4267,11 @@ Target::StopHookScripted::HandleStop(ExecutionContext &exc_ctx, auto should_stop_or_err = m_interface_sp->HandleStop(exc_ctx, stream); output_sp->PutCString( reinterpret_cast(stream.get())->GetData()); - if (!should_stop_or_err) + if (!should_stop_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Target), should_stop_or_err.takeError(), + "scripted stop hook HandleStop failed: {0}"); return StopHookResult::KeepStopped; + } return *should_stop_or_err ? StopHookResult::KeepStopped : StopHookResult::RequestContinue; diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index 7009bdb42addd..59df936975e07 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -12,6 +12,7 @@ #include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/ValueObject/DILAST.h" #include "lldb/ValueObject/DILParser.h" #include "lldb/ValueObject/ValueObject.h" @@ -94,7 +95,7 @@ Interpreter::UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location) { llvm::Expected uint_bit_size = uint_type.GetBitSize(m_exe_ctx_scope.get()); if (!uint_bit_size) - return int_bit_size.takeError(); + return uint_bit_size.takeError(); if (bitfield_size < *int_bit_size || (in_type.IsSigned() && bitfield_size == *int_bit_size)) return valobj->CastToBasicType(int_type); @@ -1098,6 +1099,8 @@ Interpreter::VerifyArithmeticCast(CompilerType source_type, } else { std::string errMsg = llvm::formatv("unable to get byte size for type {0}", target_type.TypeDescription()); + LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), temp.takeError(), + "GetByteSize failed: {0}"); return llvm::make_error( m_expr, std::move(errMsg), location, target_type.TypeDescription().length()); @@ -1108,6 +1111,8 @@ Interpreter::VerifyArithmeticCast(CompilerType source_type, } else { std::string errMsg = llvm::formatv("unable to get byte size for type {0}", source_type.TypeDescription()); + LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), temp.takeError(), + "GetByteSize failed: {0}"); return llvm::make_error( m_expr, std::move(errMsg), location, source_type.TypeDescription().length()); diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index 51eb5fb8b9dc2..1b0ef3d26f2bd 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1224,11 +1224,17 @@ llvm::Expected ValueObject::GetValueAsBool() { auto value_or_err = GetValueAsAPSInt(); if (value_or_err) return value_or_err->getBoolValue(); + else + LLDB_LOG_ERROR(GetLog(LLDBLog::Types), value_or_err.takeError(), + "GetValueAsAPSInt failed: {0}"); } if (HasFloatingRepresentation(val_type)) { auto value_or_err = GetValueAsAPFloat(); if (value_or_err) return value_or_err->isNonZero(); + else + LLDB_LOG_ERROR(GetLog(LLDBLog::Types), value_or_err.takeError(), + "GetValueAsAPFloat failed: {0}"); } if (val_type.IsArrayType()) return GetAddressOf().address != 0; @@ -1311,14 +1317,14 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp, if (value_or_err) SetValueFromInteger(*value_or_err, error, can_update_var); else - error = Status::FromErrorString("error getting APSInt from new_val_sp"); + error = Status::FromError(value_or_err.takeError()); } else if (HasFloatingRepresentation(new_val_type)) { auto value_or_err = new_val_sp->GetValueAsAPFloat(); if (value_or_err) SetValueFromInteger(value_or_err->bitcastToAPInt(), error, can_update_var); else - error = Status::FromErrorString("error getting APFloat from new_val_sp"); + error = Status::FromError(value_or_err.takeError()); } else if (new_val_type.IsPointerType()) { bool success = true; uint64_t int_val = new_val_sp->GetValueAsUnsigned(0, &success); diff --git a/lldb/source/ValueObject/ValueObjectMemory.cpp b/lldb/source/ValueObject/ValueObjectMemory.cpp index 8a8a5e4e7aa9f..83cb4a27d0130 100644 --- a/lldb/source/ValueObject/ValueObjectMemory.cpp +++ b/lldb/source/ValueObject/ValueObjectMemory.cpp @@ -12,6 +12,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/ValueObject/ValueObject.h" @@ -158,6 +159,9 @@ llvm::Expected ValueObjectMemory::GetByteSize() { if (auto size = m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope())) return *size; + else + LLDB_LOG_ERROR(GetLog(LLDBLog::Types), size.takeError(), + "failed to get byte size from type: {0}"); return llvm::createStringError("could not get byte size of memory object"); } return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());