2015-03-26 00:27:46 +00:00
|
|
|
"""
|
|
|
|
Test that argdumper is a viable launching strategy.
|
|
|
|
"""
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
import lldb
|
|
|
|
import os
|
|
|
|
import time
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2015-03-26 00:27:46 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
class TestRerun(TestBase):
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
def test(self):
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build()
|
2016-09-06 20:57:50 +00:00
|
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
self.runCmd("target create %s" % exe)
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
# Create the target
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
# Create any breakpoints we need
|
2016-09-06 20:57:50 +00:00
|
|
|
breakpoint = target.BreakpointCreateBySourceRegex(
|
|
|
|
'break here', lldb.SBFileSpec("main.cpp", False))
|
2015-03-26 00:27:46 +00:00
|
|
|
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
|
|
|
|
|
|
|
self.runCmd("process launch 1 2 3")
|
|
|
|
|
|
|
|
process = self.process()
|
2016-09-06 20:57:50 +00:00
|
|
|
thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
|
|
|
process, breakpoint)
|
|
|
|
self.assertIsNotNone(
|
|
|
|
thread, "Process should be stopped at a breakpoint in main")
|
2016-01-26 01:19:50 +00:00
|
|
|
self.assertTrue(thread.IsValid(), "Stopped thread is not valid")
|
2015-03-26 00:27:46 +00:00
|
|
|
|
|
|
|
self.expect("frame variable argv[1]", substrs=['1'])
|
|
|
|
self.expect("frame variable argv[2]", substrs=['2'])
|
|
|
|
self.expect("frame variable argv[3]", substrs=['3'])
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
# Let program exit
|
|
|
|
self.runCmd("continue")
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 00:27:46 +00:00
|
|
|
# Re-run with no args and make sure we still run with 1 2 3 as arguments as
|
|
|
|
# they should have been stored in "target.run-args"
|
|
|
|
self.runCmd("process launch")
|
|
|
|
|
|
|
|
process = self.process()
|
2016-09-06 20:57:50 +00:00
|
|
|
thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
|
|
|
process, breakpoint)
|
2015-03-26 00:27:46 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertIsNotNone(
|
|
|
|
thread, "Process should be stopped at a breakpoint in main")
|
2016-01-26 01:19:50 +00:00
|
|
|
self.assertTrue(thread.IsValid(), "Stopped thread is not valid")
|
2015-03-26 00:27:46 +00:00
|
|
|
|
|
|
|
self.expect("frame variable argv[1]", substrs=['1'])
|
|
|
|
self.expect("frame variable argv[2]", substrs=['2'])
|
|
|
|
self.expect("frame variable argv[3]", substrs=['3'])
|