[Lldb-commits] [lldb] [lldb] Fix SBAddressRange validation checks. (PR #95997)

Miro Bucko via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 18 14:43:53 PDT 2024


https://github.com/mbucko created https://github.com/llvm/llvm-project/pull/95997

None

>From 786e94dae236eafb71c2f001f48ed17651abd3e3 Mon Sep 17 00:00:00 2001
From: Miro Bucko <mbucko at meta.com>
Date: Tue, 18 Jun 2024 14:35:55 -0700
Subject: [PATCH] [lldb] Fix SBAddressRange validation checks.

---
 lldb/source/API/SBAddressRange.cpp             | 18 +++---------------
 .../address_range/TestAddressRange.py          |  2 +-
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/lldb/source/API/SBAddressRange.cpp b/lldb/source/API/SBAddressRange.cpp
index 9b1affdade439..0fba252979093 100644
--- a/lldb/source/API/SBAddressRange.cpp
+++ b/lldb/source/API/SBAddressRange.cpp
@@ -50,8 +50,6 @@ const SBAddressRange &SBAddressRange::operator=(const SBAddressRange &rhs) {
 bool SBAddressRange::operator==(const SBAddressRange &rhs) {
   LLDB_INSTRUMENT_VA(this, rhs);
 
-  if (!IsValid() || !rhs.IsValid())
-    return false;
   return m_opaque_up->operator==(*(rhs.m_opaque_up));
 }
 
@@ -64,28 +62,24 @@ bool SBAddressRange::operator!=(const SBAddressRange &rhs) {
 void SBAddressRange::Clear() {
   LLDB_INSTRUMENT_VA(this);
 
-  m_opaque_up.reset();
+  m_opaque_up->Clear();
 }
 
 bool SBAddressRange::IsValid() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return m_opaque_up && m_opaque_up->IsValid();
+  return m_opaque_up->IsValid();
 }
 
 lldb::SBAddress SBAddressRange::GetBaseAddress() const {
   LLDB_INSTRUMENT_VA(this);
 
-  if (!IsValid())
-    return lldb::SBAddress();
   return lldb::SBAddress(m_opaque_up->GetBaseAddress());
 }
 
 lldb::addr_t SBAddressRange::GetByteSize() const {
   LLDB_INSTRUMENT_VA(this);
 
-  if (!IsValid())
-    return 0;
   return m_opaque_up->GetByteSize();
 }
 
@@ -93,11 +87,5 @@ bool SBAddressRange::GetDescription(SBStream &description,
                                     const SBTarget target) {
   LLDB_INSTRUMENT_VA(this, description, target);
 
-  Stream &stream = description.ref();
-  if (!IsValid()) {
-    stream << "<invalid>";
-    return true;
-  }
-  m_opaque_up->GetDescription(&stream, target.GetSP().get());
-  return true;
+  return m_opaque_up->GetDescription(&description.ref(), target.GetSP().get());
 }
diff --git a/lldb/test/API/python_api/address_range/TestAddressRange.py b/lldb/test/API/python_api/address_range/TestAddressRange.py
index 86ca4a62155f0..ae4b8c7c90ce4 100644
--- a/lldb/test/API/python_api/address_range/TestAddressRange.py
+++ b/lldb/test/API/python_api/address_range/TestAddressRange.py
@@ -166,7 +166,7 @@ def test_address_range_list_iterator(self):
     def test_address_range_print_invalid(self):
         """Make sure the SBAddressRange can be printed when invalid."""
         range = lldb.SBAddressRange()
-        self.assertEqual(str(range), "<invalid>")
+        self.assertEqual(str(range), "[0xffffffffffffffff-0xffffffffffffffff)")
 
     def test_address_range_print_resolved(self):
         """Make sure the SBAddressRange can be printed when resolved."""



More information about the lldb-commits mailing list