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