• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test 'frame select' command.
3"""
4
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9class TestFrameSelect(TestBase):
10
11    mydir = TestBase.compute_mydir(__file__)
12
13    @no_debug_info_test
14    @skipIfWindows
15    def test_relative(self):
16        self.build()
17
18        lldbutil.run_to_source_breakpoint(self,
19            "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
20
21        self.expect("frame select -r 1", substrs=["nested2() at"])
22        self.expect("frame select -r -1", substrs=["nested3() at"])
23
24        self.expect("frame select -r -1", error=True, substrs=["Already at the bottom of the stack."])
25        self.expect("frame select -r -2147483647", error=True, substrs=["Already at the bottom of the stack."])
26        self.expect("frame select -r -2147483648", error=True, substrs=["error: invalid frame offset argument '-2147483648'"])
27        self.expect("frame select -r -2147483649", error=True, substrs=["error: invalid frame offset argument '-2147483649'"])
28
29        self.expect("frame select -r 1", substrs=["nested2() at"])
30        self.expect("frame select -r -2", substrs=["nested3() at"])
31        self.expect("frame select -r 1", substrs=["nested2() at"])
32        self.expect("frame select -r -2147483647", substrs=["nested3() at"])
33        self.expect("frame select -r 1", substrs=["nested2() at"])
34        self.expect("frame select -r -2147483648", error=True, substrs=["error: invalid frame offset argument '-2147483648'"])
35        self.expect("frame select -r -2147483649", error=True, substrs=["error: invalid frame offset argument '-2147483649'"])
36
37        self.expect("frame select -r 100")
38        self.expect("frame select -r 1", error=True, substrs=["Already at the top of the stack."])
39
40    @no_debug_info_test
41    @skipIfWindows
42    def test_mixing_relative_and_abs(self):
43        self.build()
44
45        lldbutil.run_to_source_breakpoint(self,
46            "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
47
48        # The function associated with each frame index can change depending
49        # on the function calling main (e.g. `start`), so this only tests that
50        # the frame index number is correct. We test the actual functions
51        # in the relative test.
52
53        # Jump to the top of the stack.
54        self.expect("frame select 0", substrs=["frame #0"])
55
56        # Run some relative commands.
57        self.expect("up", substrs=["frame #1"])
58        self.expect("frame select -r 1", substrs=["frame #2"])
59        self.expect("frame select -r -1", substrs=["frame #1"])
60
61        # Test that absolute indices still work.
62        self.expect("frame select 2", substrs=["frame #2"])
63        self.expect("frame select 1", substrs=["frame #1"])
64        self.expect("frame select 3", substrs=["frame #3"])
65        self.expect("frame select 0", substrs=["frame #0"])
66        self.expect("frame select 1", substrs=["frame #1"])
67
68        # Run some other relative frame select commands.
69        self.expect("down", substrs=["frame #0"])
70        self.expect("frame select -r 1", substrs=["frame #1"])
71        self.expect("frame select -r -1", substrs=["frame #0"])
72
73        # Test that absolute indices still work.
74        self.expect("frame select 2", substrs=["frame #2"])
75        self.expect("frame select 1", substrs=["frame #1"])
76        self.expect("frame select 3", substrs=["frame #3"])
77        self.expect("frame select 0", substrs=["frame #0"])
78