https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/151767


The method ConvertRegisterKindToRegisterNumber should return INVALID_REGNUM, 
and not "false" upon failure: false would mean 0 which is usually the number 
for generic PC.

Likewise, NumSupportedHardwareBreakpoints should return 0 instead of false 
(though for this one they are equivalent).

>From e872f13dfe28395fd29f8f30aa2f78a44551b850 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiove...@apple.com>
Date: Fri, 1 Aug 2025 13:18:33 -0700
Subject: [PATCH] [lldb] Fix incorrect conversion from boolean in
 RegisterContextThreadMemory

The method ConvertRegisterKindToRegisterNumber should return
INVALID_REGNUM, and not "false" upon failure: false would mean 0 which
is usually the number for generic PC.

Likewise, NumSupportedHardwareBreakpoints should return 0 instead of
false (though for this one they are equivalent).
---
 .../Plugins/Process/Utility/RegisterContextThreadMemory.cpp   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 29927e3b5e4ed..b5577874e211b 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -153,14 +153,14 @@ uint32_t 
RegisterContextThreadMemory::ConvertRegisterKindToRegisterNumber(
   UpdateRegisterContext();
   if (m_reg_ctx_sp)
     return m_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(kind, num);
-  return false;
+  return LLDB_INVALID_REGNUM;
 }
 
 uint32_t RegisterContextThreadMemory::NumSupportedHardwareBreakpoints() {
   UpdateRegisterContext();
   if (m_reg_ctx_sp)
     return m_reg_ctx_sp->NumSupportedHardwareBreakpoints();
-  return false;
+  return 0;
 }
 
 uint32_t RegisterContextThreadMemory::SetHardwareBreakpoint(lldb::addr_t addr,

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to