@@ -767,12 +767,18 @@ def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True):
767
767
768
768
return target
769
769
770
- def run_to_breakpoint_do_run (test , target , bkpt , launch_info = None ):
770
+ def run_to_breakpoint_do_run (test , target , bkpt , launch_info = None ,
771
+ only_one_thread = True , extra_images = None ):
772
+
771
773
# Launch the process, and do not stop at the entry point.
772
774
if not launch_info :
773
775
launch_info = target .GetLaunchInfo ()
774
776
launch_info .SetWorkingDirectory (test .get_process_working_directory ())
775
777
778
+ if extra_images and lldb .remote_platform :
779
+ environ = test .registerSharedLibrariesWithTarget (target , extra_images )
780
+ launch_info .SetEnvironmentEntries (environ , True )
781
+
776
782
error = lldb .SBError ()
777
783
process = target .Launch (launch_info , error )
778
784
@@ -784,18 +790,21 @@ def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None):
784
790
threads = get_threads_stopped_at_breakpoint (
785
791
process , bkpt )
786
792
787
- buf = '\n '
788
- for i in range (launch_info .GetNumEnvironmentEntries ()):
789
- buf += 'Env: ' + launch_info .GetEnvironmentEntryAtIndex (i ) + '\n '
793
+ num_threads = len (threads )
794
+ if only_one_thread :
795
+ test .assertEqual (num_threads , 1 , "Expected 1 thread to stop at breakpoint, %d did." % (num_threads ))
796
+ else :
797
+ test .assertGreater (num_threads , 0 , "No threads stopped at breakpoint" )
790
798
791
- test .assertTrue (len (threads ) == 1 , "Expected 1 thread to stop at breakpoint, %d did. Launch info: %s" % (len (threads ), buf ))
792
799
thread = threads [0 ]
793
800
return (target , process , thread , bkpt )
794
801
795
802
def run_to_name_breakpoint (test , bkpt_name , launch_info = None ,
796
803
exe_name = "a.out" ,
797
804
bkpt_module = None ,
798
- in_cwd = True ):
805
+ in_cwd = True ,
806
+ only_one_thread = True ,
807
+ extra_images = None ):
799
808
"""Start up a target, using exe_name as the executable, and run it to
800
809
a breakpoint set by name on bkpt_name restricted to bkpt_module.
801
810
@@ -817,6 +826,11 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
817
826
If successful it returns a tuple with the target process and
818
827
thread that hit the breakpoint, and the breakpoint that we set
819
828
for you.
829
+
830
+ If only_one_thread is true, we require that there be only one
831
+ thread stopped at the breakpoint. Otherwise we only require one
832
+ or more threads stop there. If there are more than one, we return
833
+ the first thread that stopped.
820
834
"""
821
835
822
836
target = run_to_breakpoint_make_target (test , exe_name , in_cwd )
@@ -826,12 +840,15 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = None,
826
840
827
841
test .assertTrue (breakpoint .GetNumLocations () > 0 ,
828
842
"No locations found for name breakpoint: '%s'." % (bkpt_name ))
829
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
843
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
844
+ only_one_thread , extra_images )
830
845
831
846
def run_to_source_breakpoint (test , bkpt_pattern , source_spec ,
832
847
launch_info = None , exe_name = "a.out" ,
833
848
bkpt_module = None ,
834
- in_cwd = True ):
849
+ in_cwd = True ,
850
+ only_one_thread = True ,
851
+ extra_images = None ):
835
852
"""Start up a target, using exe_name as the executable, and run it to
836
853
a breakpoint set by source regex bkpt_pattern.
837
854
@@ -845,12 +862,15 @@ def run_to_source_breakpoint(test, bkpt_pattern, source_spec,
845
862
test .assertTrue (breakpoint .GetNumLocations () > 0 ,
846
863
'No locations found for source breakpoint: "%s", file: "%s", dir: "%s"'
847
864
% (bkpt_pattern , source_spec .GetFilename (), source_spec .GetDirectory ()))
848
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
865
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
866
+ only_one_thread , extra_images )
849
867
850
868
def run_to_line_breakpoint (test , source_spec , line_number , column = 0 ,
851
869
launch_info = None , exe_name = "a.out" ,
852
870
bkpt_module = None ,
853
- in_cwd = True ):
871
+ in_cwd = True ,
872
+ only_one_thread = True ,
873
+ extra_images = None ):
854
874
"""Start up a target, using exe_name as the executable, and run it to
855
875
a breakpoint set by (source_spec, line_number(, column)).
856
876
@@ -865,7 +885,8 @@ def run_to_line_breakpoint(test, source_spec, line_number, column = 0,
865
885
'No locations found for line breakpoint: "%s:%d(:%d)", dir: "%s"'
866
886
% (source_spec .GetFilename (), line_number , column ,
867
887
source_spec .GetDirectory ()))
868
- return run_to_breakpoint_do_run (test , target , breakpoint , launch_info )
888
+ return run_to_breakpoint_do_run (test , target , breakpoint , launch_info ,
889
+ only_one_thread , extra_images )
869
890
870
891
871
892
def continue_to_breakpoint (process , bkpt ):
0 commit comments