aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorSYNOPSYS\georgiev <georgiev@synopsys.com>2021-11-17 08:37:30 +0000
committerSYNOPSYS\georgiev <georgiev@synopsys.com>2021-11-17 08:37:30 +0000
commit9f0b5f9a39ea6e70c98c69a720d7e4f5d3800bf6 (patch)
tree76a4d3ec2f9746997dc94830c70d68897af9d16e /lldb/packages/Python/lldbsuite/test
parentf5ca3ac748af2c88736212d7dbc105d99ac721c1 (diff)
downloadllvm-9f0b5f9a39ea6e70c98c69a720d7e4f5d3800bf6.zip
llvm-9f0b5f9a39ea6e70c98c69a720d7e4f5d3800bf6.tar.gz
llvm-9f0b5f9a39ea6e70c98c69a720d7e4f5d3800bf6.tar.bz2
[lldb/test] Added lldbutil function to test a breakpoint
Testing the breakpoint itself rather than the lldb string. Differential Revision: https://reviews.llvm.org/D111899
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 2ab372d..c92626f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -730,6 +730,57 @@ def check_breakpoint_result(
(out_module_name,
module_name))
+def check_breakpoint(
+ test,
+ bpno,
+ expected_locations = None,
+ expected_resolved_count = None,
+ expected_hit_count = None,
+ location_id = None,
+ expected_location_resolved = True,
+ expected_location_hit_count = None):
+ """
+ Test breakpoint or breakpoint location.
+ Breakpoint resolved count is always checked. If not specified the assumption is that all locations
+ should be resolved.
+ To test a breakpoint location, breakpoint number (bpno) and location_id must be set. In this case
+ the resolved count for a breakpoint is not tested by default. The location is expected to be resolved,
+ unless expected_location_resolved is set to False.
+ test - test context
+ bpno - breakpoint number to test
+ expected_locations - expected number of locations for this breakpoint. If 'None' this parameter is not tested.
+ expected_resolved_count - expected resolved locations number for the breakpoint. If 'None' - all locations should be resolved.
+ expected_hit_count - expected hit count for this breakpoint. If 'None' this parameter is not tested.
+ location_id - If not 'None' sets the location ID for the breakpoint to test.
+ expected_location_resolved - Extected resolved status for the location_id (True/False). Default - True.
+ expected_location_hit_count - Expected hit count for the breakpoint at location_id. Must be set if the location_id parameter is set.
+ """
+
+ bkpt = test.target().FindBreakpointByID(bpno)
+ test.assertTrue(bkpt.IsValid(), "Breakpoint is not valid.")
+
+ if expected_locations is not None:
+ test.assertEquals(expected_locations, bkpt.GetNumLocations())
+
+ if expected_resolved_count is not None:
+ test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
+ else:
+ expected_resolved_count = bkpt.GetNumLocations()
+ if location_id is None:
+ test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
+
+ if expected_hit_count is not None:
+ test.assertEquals(expected_hit_count, bkpt.GetHitCount())
+
+ if location_id is not None:
+ loc_bkpt = bkpt.FindLocationByID(location_id)
+ test.assertTrue(loc_bkpt.IsValid(), "Breakpoint location is not valid.")
+ test.assertEquals(loc_bkpt.IsResolved(), expected_location_resolved)
+ if expected_location_hit_count is not None:
+ test.assertEquals(expected_location_hit_count, loc_bkpt.GetHitCount())
+
+
+
# ==================================================
# Utility functions related to Threads and Processes
# ==================================================