xref: /llvm-project/lldb/test/API/commands/session/history/TestSessionHistory.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test the session history command
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class SessionHistoryTestCase(TestBase):
13    @no_debug_info_test
14    def test_history(self):
15        self.runCmd("session history --clear", inHistory=False)
16        self.runCmd("breakpoint list", check=False, inHistory=True)  # 0
17        self.runCmd("register read", check=False, inHistory=True)  # 1
18        self.runCmd("apropos hello", check=False, inHistory=True)  # 2
19        self.runCmd("memory write", check=False, inHistory=True)  # 3
20        self.runCmd("log list", check=False, inHistory=True)  # 4
21        self.runCmd("disassemble", check=False, inHistory=True)  # 5
22        self.runCmd("expression 1", check=False, inHistory=True)  # 6
23        self.runCmd("type summary list -w default", check=False, inHistory=True)  # 7
24        self.runCmd("version", check=False, inHistory=True)  # 8
25        self.runCmd("frame select 1", check=False, inHistory=True)  # 9
26
27        self.expect(
28            "session history -s 3 -c 3",
29            inHistory=True,
30            substrs=["3: memory write", "4: log list", "5: disassemble"],
31        )
32
33        self.expect(
34            "session history -s 3 -e 3", inHistory=True, substrs=["3: memory write"]
35        )
36
37        self.expect(
38            "session history -s 6 -e 7",
39            inHistory=True,
40            substrs=["6: expression 1", "7: type summary list -w default"],
41        )
42
43        self.expect(
44            "session history -c 2",
45            inHistory=True,
46            substrs=["0: breakpoint list", "1: register read"],
47        )
48
49        self.expect(
50            "session history -e 3 -c 1", inHistory=True, substrs=["3: memory write"]
51        )
52
53        self.expect(
54            "session history -e 2",
55            inHistory=True,
56            substrs=["0: breakpoint list", "1: register read", "2: apropos hello"],
57        )
58
59        self.expect(
60            "session history -s 12",
61            inHistory=True,
62            substrs=[
63                "12: session history -s 6 -e 7",
64                "13: session history -c 2",
65                "14: session history -e 3 -c 1",
66                "15: session history -e 2",
67                "16: session history -s 12",
68            ],
69        )
70
71        self.expect(
72            "session history -s end -c 3",
73            inHistory=True,
74            substrs=[
75                "15: session history -e 2",
76                "16: session history -s 12",
77                "17: session history -s end -c 3",
78            ],
79        )
80
81        self.expect(
82            "session history -s end -e 15",
83            inHistory=True,
84            substrs=[
85                "15: session history -e 2",
86                "16: session history -s 12",
87                "17: session history -s end -c 3",
88                "session history -s end -e 15",
89            ],
90        )
91
92        self.expect(
93            "session history -s 5 -c 1", inHistory=True, substrs=["5: disassemble"]
94        )
95
96        self.expect(
97            "session history -c 1 -s 5", inHistory=True, substrs=["5: disassemble"]
98        )
99
100        self.expect(
101            "session history -c 1 -e 3", inHistory=True, substrs=["3: memory write"]
102        )
103
104        self.expect(
105            "session history -c 1 -e 3 -s 5",
106            error=True,
107            inHistory=True,
108            substrs=[
109                "error: --count, --start-index and --end-index cannot be all specified in the same invocation"
110            ],
111        )
112