diff options
| author | Alex Langford <alangford@apple.com> | 2026-02-05 11:49:17 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-05 11:49:17 -0800 |
| commit | 9ebdeb2e8cbe8285c8383d8079663b6c73accac8 (patch) | |
| tree | f44ece689d06b0299eb408265888bbdc62ad121c /lldb/source/API | |
| parent | fad9b2e0e0dd8b65a0ac0ecc58c658092d400863 (diff) | |
| download | llvm-9ebdeb2e8cbe8285c8383d8079663b6c73accac8.tar.gz llvm-9ebdeb2e8cbe8285c8383d8079663b6c73accac8.tar.bz2 llvm-9ebdeb2e8cbe8285c8383d8079663b6c73accac8.zip | |
[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.
Diffstat (limited to 'lldb/source/API')
| -rw-r--r-- | lldb/source/API/SBModule.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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<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; |
