[Lldb-commits] [lldb] [lldb][FreeBSDKernel] Add missing error checks in DynamicLoader (PR #189250)
Minsoo Choo via lldb-commits
lldb-commits at lists.llvm.org
Sun Mar 29 08:05:32 PDT 2026
https://github.com/mchoo7 created https://github.com/llvm/llvm-project/pull/189250
Add extra guards in case a call to function fails. For example, the result of `ReadMemory()` cannot be trusted when `error.Fail()` is true, and this change ensures the code executes properly according to the value of the error.
>From 73740df74878c2666761e7f287b0d45a8788f6ad Mon Sep 17 00:00:00 2001
From: Minsoo Choo <minsoochoo0122 at proton.me>
Date: Sun, 29 Mar 2026 23:47:23 +0900
Subject: [PATCH] [lldb][FreeBSDKernel] Add missing error checks in
DynamicLoader
Signed-off-by: Minsoo Choo <minsoochoo0122 at proton.me>
---
.../FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
index 00b1de6aee369..c2329f17b339d 100644
--- a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
@@ -162,7 +162,7 @@ bool DynamicLoaderFreeBSDKernel::ReadELFHeader(Process *process,
*read_error = false;
if (process->ReadMemory(addr, &header, sizeof(header), error) !=
- sizeof(header)) {
+ sizeof(header) || error.Fail()) {
if (read_error)
*read_error = true;
return false;
@@ -291,7 +291,7 @@ bool DynamicLoaderFreeBSDKernel::KModImageInfo::ReadMemoryModule(
llvm::ELF::Elf64_Ehdr elf_eheader;
Status error;
if (process->ReadMemory(m_load_address, &elf_eheader, sizeof(elf_eheader),
- error) == sizeof(elf_eheader))
+ error) == sizeof(elf_eheader) && error.Success())
size_to_read = sizeof(llvm::ELF::Elf64_Ehdr) +
elf_eheader.e_phnum * elf_eheader.e_phentsize;
}
@@ -358,7 +358,7 @@ bool DynamicLoaderFreeBSDKernel::KModImageInfo::LoadImageUsingMemoryModule(
if (IsKernel()) {
Status error;
if (PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
- true)) {
+ true) && error.Success()) {
if (FileSystem::Instance().Exists(module_spec.GetFileSpec()))
m_module_sp = std::make_shared<Module>(module_spec.GetFileSpec(),
target.GetArchitecture());
More information about the lldb-commits
mailing list