Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lldb/source/API/SBProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions lldb/source/Host/posix/MainLoopPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -392,6 +393,11 @@ bool MainLoopPosix::Interrupt() {
return true;

char c = '.';
llvm::Expected<size_t> result = m_interrupt_pipe.Write(&c, 1);
return result && *result != 0;
llvm::Expected<size_t> 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;
}
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/ScriptInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScriptInterpreterIORedirect>(
new ScriptInterpreterIORedirect(std::move(*nullin), std::move(*nullout)));
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 10 additions & 4 deletions lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
9 changes: 5 additions & 4 deletions lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -265,8 +264,10 @@ bool ScriptedThread::LoadArtificialStackFrames() {
if (!frame_from_script_obj_or_err) {
return ScriptedInterface::ErrorWithMessage<bool>(
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <optional>
#include <string_view>

Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,11 @@ bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) {
for (const LineColumnEntry &group : lines) {
llvm::Expected<uint32_t> 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(
Expand Down Expand Up @@ -1542,8 +1545,11 @@ void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id,
FileSpec decl_file;
llvm::Expected<uint32_t> 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;
Expand Down Expand Up @@ -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<TypeSystemClang>(ts.get());
if (!clang)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ GetFileForModule(const ModuleSpec &module_spec,
PluginProperties &plugin_props = GetGlobalPluginProperties();
llvm::Expected<std::string> 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<llvm::StringRef> debuginfod_urls =
llvm::getDefaultDebuginfodUrls();
Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Symbol/SymbolFileOnDemand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,12 @@ SymbolFileOnDemand::GetParameterStackSize(Symbol &symbol) {
if (log) {
llvm::Expected<lldb::addr_t> 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);
}
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Target/Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}");
}
}

Expand Down
5 changes: 4 additions & 1 deletion lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StreamString *>(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;
Expand Down
7 changes: 6 additions & 1 deletion lldb/source/ValueObject/DILEval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -94,7 +95,7 @@ Interpreter::UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location) {
llvm::Expected<uint64_t> 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);
Expand Down Expand Up @@ -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<DILDiagnosticError>(
m_expr, std::move(errMsg), location,
target_type.TypeDescription().length());
Expand All @@ -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<DILDiagnosticError>(
m_expr, std::move(errMsg), location,
source_type.TypeDescription().length());
Expand Down
10 changes: 8 additions & 2 deletions lldb/source/ValueObject/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,17 @@ llvm::Expected<bool> 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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/ValueObject/ValueObjectMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -158,6 +159,9 @@ llvm::Expected<uint64_t> 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());
Expand Down