summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lldbutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbutil.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 6d82eb30f2c..5100dd596d0 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -760,7 +760,7 @@ def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True):
test.assertTrue(target, "Target: %s is not valid."%(exe_name))
return target
-def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None):
+def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None, only_one_thread = True):
# Launch the process, and do not stop at the entry point.
if not launch_info:
@@ -778,14 +778,20 @@ def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None):
threads = get_threads_stopped_at_breakpoint(
process, bkpt)
- test.assertTrue(len(threads) == 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads)))
+ num_threads = len(threads)
+ if only_one_thread:
+ test.assertEqual(num_threads, 1, "Expected 1 thread to stop at breakpoint, %d did."%(num_threads))
+ else:
+ test.assertGreater(num_threads, 0, "No threads stopped at breakpoint")
+
thread = threads[0]
return (target, process, thread, bkpt)
def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
exe_name = "a.out",
bkpt_module = None,
- in_cwd = True):
+ in_cwd = True,
+ only_one_thread = True):
"""Start up a target, using exe_name as the executable, and run it to
a breakpoint set by name on bkpt_name restricted to bkpt_module.
@@ -807,6 +813,11 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
If successful it returns a tuple with the target process and
thread that hit the breakpoint, and the breakpoint that we set
for you.
+
+ If only_one_thread is true, we require that there be only one
+ thread stopped at the breakpoint. Otherwise we only require one
+ or more threads stop there. If there are more than one, we return
+ the first thread that stopped.
"""
target = run_to_breakpoint_make_target(test, exe_name, in_cwd)
@@ -816,12 +827,13 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
test.assertTrue(breakpoint.GetNumLocations() > 0,
"No locations found for name breakpoint: '%s'."%(bkpt_name))
- return run_to_breakpoint_do_run(test, target, breakpoint, launch_info)
+ return run_to_breakpoint_do_run(test, target, breakpoint, launch_info, only_one_thread)
def run_to_source_breakpoint(test, bkpt_pattern, source_spec,
launch_info = None, exe_name = "a.out",
bkpt_module = None,
- in_cwd = True):
+ in_cwd = True,
+ only_one_thread = True):
"""Start up a target, using exe_name as the executable, and run it to
a breakpoint set by source regex bkpt_pattern.
@@ -835,12 +847,13 @@ def run_to_source_breakpoint(test, bkpt_pattern, source_spec,
test.assertTrue(breakpoint.GetNumLocations() > 0,
'No locations found for source breakpoint: "%s", file: "%s", dir: "%s"'
%(bkpt_pattern, source_spec.GetFilename(), source_spec.GetDirectory()))
- return run_to_breakpoint_do_run(test, target, breakpoint, launch_info)
+ return run_to_breakpoint_do_run(test, target, breakpoint, launch_info, only_one_thread)
def run_to_line_breakpoint(test, source_spec, line_number, column = 0,
launch_info = None, exe_name = "a.out",
bkpt_module = None,
- in_cwd = True):
+ in_cwd = True,
+ only_one_thread = True):
"""Start up a target, using exe_name as the executable, and run it to
a breakpoint set by (source_spec, line_number(, column)).
@@ -855,7 +868,7 @@ def run_to_line_breakpoint(test, source_spec, line_number, column = 0,
'No locations found for line breakpoint: "%s:%d(:%d)", dir: "%s"'
%(source_spec.GetFilename(), line_number, column,
source_spec.GetDirectory()))
- return run_to_breakpoint_do_run(test, target, breakpoint, launch_info)
+ return run_to_breakpoint_do_run(test, target, breakpoint, launch_info, only_one_thread)
def continue_to_breakpoint(process, bkpt):
OpenPOWER on IntegriCloud