From 9ebdeb2e8cbe8285c8383d8079663b6c73accac8 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Thu, 5 Feb 2026 11:49:17 -0800 Subject: [lldb] Return Expected from Process::ReadModuleFromMemory (#179583) I noticed that Module::GetMemoryObjectFile populates a Status object upon error but it's effectively dropped on the floor. Instead, the clients can report the error as desired. At the moment, all clients are either (1) consuming the error because it's only trying to find a module, or (2) log the error and bail out early. I tried to preserve existing behavior as faithfully as possible. --- lldb/source/API/SBModule.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lldb/source/API/SBModule.cpp') diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 32067ac1c650..c48d1abd88c5 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -52,7 +52,14 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) { ProcessSP process_sp(process.GetSP()); if (process_sp) { - m_opaque_sp = process_sp->ReadModuleFromMemory(FileSpec(), header_addr); + llvm::Expected module_sp_or_err = + process_sp->ReadModuleFromMemory(FileSpec(), header_addr); + if (auto err = module_sp_or_err.takeError()) { + llvm::consumeError(std::move(err)); + return; + } + + m_opaque_sp = *module_sp_or_err; if (m_opaque_sp) { Target &target = process_sp->GetTarget(); bool changed = false; -- cgit v1.2.3