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 14 mydir = TestBase.compute_mydir(__file__) 15 16 def test(self): 17 self.build() 18 exe = self.getBuildArtifact("a.out") 19 20 self.runCmd("target create %s" % exe) 21 22 # Create the target 23 target = self.dbg.CreateTarget(exe) 24 25 # Create any breakpoints we need 26 breakpoint = target.BreakpointCreateBySourceRegex( 27 'break here', lldb.SBFileSpec("main.cpp", False)) 28 self.assertTrue(breakpoint, VALID_BREAKPOINT) 29 30 self.runCmd("process launch 1 2 3") 31 32 process = self.process() 33 thread = lldbutil.get_one_thread_stopped_at_breakpoint( 34 process, breakpoint) 35 self.assertIsNotNone( 36 thread, "Process should be stopped at a breakpoint in main") 37 self.assertTrue(thread.IsValid(), "Stopped thread is not valid") 38 39 self.expect("frame variable argv[1]", substrs=['1']) 40 self.expect("frame variable argv[2]", substrs=['2']) 41 self.expect("frame variable argv[3]", substrs=['3']) 42 43 # Let program exit 44 self.runCmd("continue") 45 46 # Re-run with no args and make sure we still run with 1 2 3 as arguments as 47 # they should have been stored in "target.run-args" 48 self.runCmd("process launch") 49 50 process = self.process() 51 thread = lldbutil.get_one_thread_stopped_at_breakpoint( 52 process, breakpoint) 53 54 self.assertIsNotNone( 55 thread, "Process should be stopped at a breakpoint in main") 56 self.assertTrue(thread.IsValid(), "Stopped thread is not valid") 57 58 self.expect("frame variable argv[1]", substrs=['1']) 59 self.expect("frame variable argv[2]", substrs=['2']) 60 self.expect("frame variable argv[3]", substrs=['3']) 61