Skip to content

Commit 84b9985

Browse files
hawkinswJDevlieghere
authored andcommitted
[lldb] Fix broken bad-address-breakpoint test
After changing the "fallback" behavior when a user sets a breakpoint without specifying a module the bad-address-breakpoint test case failed incorrectly. This patch updates that test case in order to more thoroughly discover an illegal address and use that as the means for testing whether a breakpoint set at an illegal address fails to resolve. Differential revision: https://reviews.llvm.org/D126109
1 parent 48ca3a5 commit 84b9985

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,26 @@ def address_breakpoints(self):
2727
"Set a breakpoint here",
2828
lldb.SBFileSpec("main.c"))
2929

30-
# Now see if we can read from 0. If I can't do that, I don't
31-
# have a good way to know what an illegal address is...
32-
error = lldb.SBError()
3330

34-
ptr = process.ReadPointerFromMemory(0x0, error)
3531

36-
if not error.Success():
37-
bkpt = target.BreakpointCreateByAddress(0x0)
32+
# illegal_address will hold (optionally) an address that, if
33+
# used as a breakpoint, will generate an unresolved breakpoint.
34+
illegal_address = None
35+
36+
# Walk through all the memory regions in the process and
37+
# find an address that is invalid.
38+
regions = process.GetMemoryRegions()
39+
for region_idx in range(regions.GetSize()):
40+
region = lldb.SBMemoryRegionInfo()
41+
regions.GetMemoryRegionAtIndex(region_idx, region)
42+
if illegal_address == None or \
43+
region.GetRegionEnd() > illegal_address:
44+
illegal_address = region.GetRegionEnd()
45+
46+
if illegal_address is not None:
47+
# Now, set a breakpoint at the address we know is illegal.
48+
bkpt = target.BreakpointCreateByAddress(illegal_address)
49+
# Verify that breakpoint is not resolved.
3850
for bp_loc in bkpt:
3951
self.assertEquals(bp_loc.IsResolved(), False)
4052
else:

0 commit comments

Comments
 (0)