1""" 2Test that argdumper is a viable launching strategy. 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class TestRerun(TestBase): 13 def test(self): 14 self.build() 15 exe = self.getBuildArtifact("a.out") 16 17 self.runCmd("target create %s" % exe) 18 19 # Create the target 20 target = self.dbg.CreateTarget(exe) 21 22 # Create any breakpoints we need 23 breakpoint = target.BreakpointCreateBySourceRegex( 24 "break here", lldb.SBFileSpec("main.cpp", False) 25 ) 26 self.assertTrue(breakpoint, VALID_BREAKPOINT) 27 28 self.runCmd("process launch 1 2 3") 29 30 process = self.process() 31 thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) 32 self.assertIsNotNone( 33 thread, "Process should be stopped at a breakpoint in main" 34 ) 35 self.assertTrue(thread.IsValid(), "Stopped thread is not valid") 36 37 self.expect("frame variable argv[1]", substrs=["1"]) 38 self.expect("frame variable argv[2]", substrs=["2"]) 39 self.expect("frame variable argv[3]", substrs=["3"]) 40 41 # Let program exit 42 self.runCmd("continue") 43 44 # Re-run with no args and make sure we still run with 1 2 3 as arguments as 45 # they should have been stored in "target.run-args" 46 self.runCmd("process launch") 47 48 process = self.process() 49 thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) 50 51 self.assertIsNotNone( 52 thread, "Process should be stopped at a breakpoint in main" 53 ) 54 self.assertTrue(thread.IsValid(), "Stopped thread is not valid") 55 56 self.expect("frame variable argv[1]", substrs=["1"]) 57 self.expect("frame variable argv[2]", substrs=["2"]) 58 self.expect("frame variable argv[3]", substrs=["3"]) 59