[Lldb-commits] [lldb] [lldb] Fix a couple of return type / return value mismatches (PR #191464)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 09:55:58 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Sergei Barannikov (s-barannikov)
<details>
<summary>Changes</summary>
* `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`.
---
Full diff: https://github.com/llvm/llvm-project/pull/191464.diff
3 Files Affected:
- (modified) lldb/include/lldb/Core/EmulateInstruction.h (+2-2)
- (modified) lldb/source/Core/EmulateInstruction.cpp (+2-2)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+1-1)
``````````diff
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,
``````````
</details>
https://github.com/llvm/llvm-project/pull/191464
More information about the lldb-commits
mailing list