[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon May 13 14:28:15 PDT 2024
================
@@ -0,0 +1,124 @@
+"""
+Test SBAddressRange APIs.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+
+
+class AddressRangeTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_address_range_default(self):
+ """Testing default constructor."""
+ empty_range = lldb.SBAddressRange()
+ self.assertEqual(empty_range.IsValid(), False)
+
+ def test_address_range_construction(self):
+ """Make sure the construction and getters work."""
+ range = lldb.SBAddressRange(0x00000400, 8)
+ self.assertEqual(range.IsValid(), True)
+ self.assertEqual(range.GetBaseAddress().GetOffset(), 0x00000400)
+ self.assertEqual(range.GetByteSize(), 8)
+
+ def test_address_range_clear(self):
+ """Make sure the clear method works."""
+ range = lldb.SBAddressRange(0x00000400, 8)
+ self.assertEqual(range.IsValid(), True)
+ self.assertEqual(range.GetBaseAddress().GetOffset(), 0x00000400)
+ self.assertEqual(range.GetByteSize(), 8)
+
+ range.Clear()
+ self.assertEqual(range.IsValid(), False)
+
+ def test_function(self):
+ """Make sure the range works in SBFunction APIs."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Setup breakpoints in main
+ bp = target.BreakpointCreateByName("main", "a.out")
+ loc = bp.GetLocationAtIndex(0)
+ loc_addr = loc.GetAddress()
+ func = loc_addr.GetFunction()
+ # block = loc_addr.GetBlock()
+ range = func.GetRange()
+ # block_ranges = block.GetRangeAtIndex(0)
----------------
bulbazord wrote:
Please remove the commented out lines in the test (or uncomment them and use them)
https://github.com/llvm/llvm-project/pull/92014
More information about the lldb-commits
mailing list