]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / rerun / TestRerun.py
1 """
2 Test that argdumper is a viable launching strategy.
3 """
4 from __future__ import print_function
5
6
7
8 import lldb
9 import os
10 import time
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14 class TestRerun(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def test (self):
19         self.build()
20         exe = os.path.join (os.getcwd(), "a.out")
21         
22         self.runCmd("target create %s" % exe)
23         
24         # Create the target
25         target = self.dbg.CreateTarget(exe)
26         
27         # Create any breakpoints we need
28         breakpoint = target.BreakpointCreateBySourceRegex ('break here', lldb.SBFileSpec ("main.cpp", False))
29         self.assertTrue(breakpoint, VALID_BREAKPOINT)
30
31         self.runCmd("process launch 1 2 3")
32
33         process = self.process()
34
35         self.assertTrue(process.GetState() == lldb.eStateStopped,
36                         STOPPED_DUE_TO_BREAKPOINT)
37
38         thread = process.GetThreadAtIndex (0)
39
40         self.assertTrue (thread.IsValid(),
41                          "Process stopped at 'main' should have a valid thread");
42
43         stop_reason = thread.GetStopReason()
44         
45         self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint,
46                          "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint");
47
48         self.expect("frame variable argv[1]", substrs=['1'])
49         self.expect("frame variable argv[2]", substrs=['2'])
50         self.expect("frame variable argv[3]", substrs=['3'])
51         
52         # Let program exit
53         self.runCmd("continue")
54         
55         # Re-run with no args and make sure we still run with 1 2 3 as arguments as
56         # they should have been stored in "target.run-args"
57         self.runCmd("process launch")
58
59         process = self.process()
60         
61         self.assertTrue(process.GetState() == lldb.eStateStopped,
62                         STOPPED_DUE_TO_BREAKPOINT)
63
64         thread = process.GetThreadAtIndex (0)
65
66         self.assertTrue (thread.IsValid(),
67                          "Process stopped at 'main' should have a valid thread");
68
69         stop_reason = thread.GetStopReason()
70         
71         self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint,
72                          "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint");
73
74         self.expect("frame variable argv[1]", substrs=['1'])
75         self.expect("frame variable argv[2]", substrs=['2'])
76         self.expect("frame variable argv[3]", substrs=['3'])