@@ -760,13 +760,18 @@ def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True):
760
760
test .assertTrue (target , "Target: %s is not valid." % (exe_name ))
761
761
return target
762
762
763
- def run_to_breakpoint_do_run (test , target , bkpt , launch_info = None ):
763
+ def run_to_breakpoint_do_run (test , target , bkpt , launch_info = None ,
764
+ only_one_thread = True , extra_images = None ):
764
765
765
766
# Launch the process, and do not stop at the entry point.
766
767
if not launch_info :
767
768
launch_info = lldb .SBLaunchInfo (None )
768
769
launch_info .SetWorkingDirectory (test .get_process_working_directory ())
769
770
771
+ if extra_images and lldb .remote_platform :
772
+ environ = test .registerSharedLibrariesWithTarget (target , extra_images )
773
+ launch_info .SetEnvironmentEntries (environ , True )
774
+
770
775
error = lldb .SBError ()
771
776
process = target .Launch (launch_info , error )
772
777
@@ -778,14 +783,21 @@ def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None):
778
783
threads = get_threads_stopped_at_breakpoint (
779
784
process , bkpt )
780
785
781
- test .assertTrue (len (threads ) == 1 , "Expected 1 thread to stop at breakpoint, %d did." % (len (threads )))
786
+ num_threads = len (threads )
787
+ if only_one_thread :
788
+ test .assertEqual (num_threads , 1 , "Expected 1 thread to stop at breakpoint, %d did." % (num_threads ))
789
+ else :
790
+ test .assertGreater (num_threads , 0 , "No threads stopped at breakpoint" )
791
+
782
792
thread = threads [0 ]
783
793
return (target , process , thread , bkpt )
784
794
785
795
def run_to_name_breakpoint (test , bkpt_name , launch_info = None ,
786
796
exe_name = "a.out" ,
787
797
bkpt_module = None ,
788
- in_cwd = True ):
798
+ in_cwd = True ,
799
+ only_one_thread = True ,
800
+ extra_images = None ):
789
801
"""Start up a target, using exe_name as the executable, and run it to
790
802
a breakpoint set by name on bkpt_name restricted to bkpt_module.
791
803
@@ -807,6 +819,11 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
807
819
If successful it returns a tuple with the target process and
808
820
thread that hit the breakpoint, and the breakpoint that we set
809
821
for you.
822
+
823
+ If only_one_thread is true, we require that there be only one
824
+ thread stopped at the breakpoint. Otherwise we only require one
825
+ or more threads stop there. If there are more than one, we return
826
+ the first thread that stopped.
810
827
"""
811
828
812
829
target = run_to_breakpoint_make_target (test , exe_name , in_cwd )
@@ -816,12 +833,15 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
816
833
817
834
test .assertTrue (breakpoint .GetNumLocations () > 0 ,
818
835
"No locations found for name breakpoint: '%s'." % (bkpt_name ))
819
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
836
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
837
+ only_one_thread , extra_images )
820
838
821
839
def run_to_source_breakpoint (test , bkpt_pattern , source_spec ,
822
840
launch_info = None , exe_name = "a.out" ,
823
841
bkpt_module = None ,
824
- in_cwd = True ):
842
+ in_cwd = True ,
843
+ only_one_thread = True ,
844
+ extra_images = None ):
825
845
"""Start up a target, using exe_name as the executable, and run it to
826
846
a breakpoint set by source regex bkpt_pattern.
827
847
@@ -835,12 +855,15 @@ def run_to_source_breakpoint(test, bkpt_pattern, source_spec,
835
855
test .assertTrue (breakpoint .GetNumLocations () > 0 ,
836
856
'No locations found for source breakpoint: "%s", file: "%s", dir: "%s"'
837
857
% (bkpt_pattern , source_spec .GetFilename (), source_spec .GetDirectory ()))
838
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
858
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
859
+ only_one_thread , extra_images )
839
860
840
861
def run_to_line_breakpoint (test , source_spec , line_number , column = 0 ,
841
862
launch_info = None , exe_name = "a.out" ,
842
863
bkpt_module = None ,
843
- in_cwd = True ):
864
+ in_cwd = True ,
865
+ only_one_thread = True ,
866
+ extra_images = None ):
844
867
"""Start up a target, using exe_name as the executable, and run it to
845
868
a breakpoint set by (source_spec, line_number(, column)).
846
869
@@ -855,7 +878,8 @@ def run_to_line_breakpoint(test, source_spec, line_number, column = 0,
855
878
'No locations found for line breakpoint: "%s:%d(:%d)", dir: "%s"'
856
879
% (source_spec .GetFilename (), line_number , column ,
857
880
source_spec .GetDirectory ()))
858
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
881
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
882
+ only_one_thread , extra_images )
859
883
860
884
861
885
def continue_to_breakpoint (process , bkpt ):
0 commit comments