[Lldb-commits] [lldb] [lldb] Fix a couple of return type / return value mismatches (PR #191464)
Sergei Barannikov via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 09:55:24 PDT 2026
https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/191464
* `EmulateInstruction::ReadMemory()` returns a boolean value and is used in boolean contexts, but the return type is specified as `size_t`. Change it to `bool`. This also aligns it with `WriteMemory()`.
* If `Target` is not available,`ClangExpressionDeclMap::GetSymbolAddress()` returns `false`, but it is expected to return an address. Change it to return `LLDB_INVALID_ADDRESS`.
>From 7468a964497c29038e176c9149a8310e91d23dd3 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Fri, 10 Apr 2026 19:52:36 +0300
Subject: [PATCH] [lldb] Fix a couple of return type / return value mismatches
* `EmulateInstruction::ReadMemory()` returns a boolean value and is used
in boolean contexts, but the return type was specified as `size_t`.
Change it to `bool`. This also aligns it with `WriteMemory()`.
* `ClangExpressionDeclMap::GetSymbolAddress()` returned `false` if
`Target` is not available. Change it to return an invalid address.
---
lldb/include/lldb/Core/EmulateInstruction.h | 4 ++--
lldb/source/Core/EmulateInstruction.cpp | 4 ++--
.../Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h
index ff1386cce570b..88cdfc646cd7c 100644
--- a/lldb/include/lldb/Core/EmulateInstruction.h
+++ b/lldb/include/lldb/Core/EmulateInstruction.h
@@ -452,8 +452,8 @@ class EmulateInstruction : public PluginInterface {
lldb::RegisterKind reg_kind, uint32_t reg_num,
uint64_t reg_value);
- size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst,
- size_t dst_len);
+ bool ReadMemory(const Context &context, lldb::addr_t addr, void *dst,
+ size_t dst_len);
uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr,
size_t byte_size, uint64_t fail_value,
diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp
index 5f2c6372acb2a..9eb8dc0af3447 100644
--- a/lldb/source/Core/EmulateInstruction.cpp
+++ b/lldb/source/Core/EmulateInstruction.cpp
@@ -160,8 +160,8 @@ bool EmulateInstruction::WriteRegisterUnsigned(const Context &context,
return false;
}
-size_t EmulateInstruction::ReadMemory(const Context &context, lldb::addr_t addr,
- void *dst, size_t dst_len) {
+bool EmulateInstruction::ReadMemory(const Context &context, lldb::addr_t addr,
+ void *dst, size_t dst_len) {
if (m_read_mem_callback != nullptr)
return m_read_mem_callback(this, m_baton, context, addr, dst, dst_len) ==
dst_len;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 2fa820a3a5095..c0ba0f72da27d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -620,7 +620,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(ConstString name,
assert(m_parser_vars.get());
if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
- return false;
+ return LLDB_INVALID_ADDRESS;
return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(),
m_parser_vars->m_exe_ctx.GetProcessPtr(), name,
More information about the lldb-commits
mailing list