[lldb] Return Expected<ModuleSP> 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.
This commit is contained in:
Alex Langford authored and GitHub committed 2026-02-05 11:49:17 -08:00
1 parent fad9b2e0e0
commit 9ebdeb2e8c
11 files changed
+159 -61

No files matched your search

+8 -1
View File
@@ -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<ModuleSP> 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;