2 Test that an alias can reference other aliases without crashing.
7 from lldbsuite
.test
.lldbtest
import *
8 import lldbsuite
.test
.lldbutil
as lldbutil
11 class NestedAliasTestCase(TestBase
):
12 NO_DEBUG_INFO_TESTCASE
= True
15 # Call super's setUp().
17 # Find the line number to break inside main().
18 self
.line
= line_number("main.cpp", "// break here")
20 def test_nested_alias(self
):
21 """Test that an alias can reference other aliases without crashing."""
23 exe
= self
.getBuildArtifact("a.out")
24 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
26 # Break in main() after the variables are assigned values.
27 lldbutil
.run_break_set_by_file_and_line(
28 self
, "main.cpp", self
.line
, num_expected_locations
=1, loc_exact
=True
31 self
.runCmd("run", RUN_SUCCEEDED
)
33 # The stop reason of the thread should be breakpoint.
36 STOPPED_DUE_TO_BREAKPOINT
,
37 substrs
=["stopped", "stop reason = breakpoint"],
40 # The breakpoint should have a hit count of 1.
41 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)
43 # This is the function to remove the custom aliases in order to have a
44 # clean slate for the next test case.
46 self
.runCmd("command unalias read", check
=False)
47 self
.runCmd("command unalias rd", check
=False)
48 self
.runCmd("command unalias fo", check
=False)
49 self
.runCmd("command unalias foself", check
=False)
50 self
.runCmd("command unalias add_two", check
=False)
51 self
.runCmd("command unalias two", check
=False)
53 # Execute the cleanup function during test case tear down.
54 self
.addTearDownHook(cleanup
)
56 self
.runCmd("command alias read memory read -f A")
57 self
.runCmd("command alias rd read -c 3")
60 "memory read -f A -c 3 `&my_ptr[0]`",
61 substrs
=["deadbeef", "main.cpp:", "feedbeef"],
63 self
.expect("rd `&my_ptr[0]`", substrs
=["deadbeef", "main.cpp:", "feedbeef"])
66 "memory read -f A -c 3 `&my_ptr[0]`", substrs
=["deadfeed"], matching
=False
68 self
.expect("rd `&my_ptr[0]`", substrs
=["deadfeed"], matching
=False)
70 self
.runCmd("command alias fo frame variable -O --")
71 self
.runCmd("command alias foself fo self")
75 substrs
=["--show-all-children", "--raw-output"],
80 substrs
=["Show variables for the current", "stack frame."],
84 # Check that foself was resolved and is now independent of 'fo'.
85 self
.runCmd("command unalias fo")
88 substrs
=["Show variables for the current", "stack frame."],
92 # Check that aliases can be created for raw input commands.
93 self
.expect("command alias two expr -- 2")
94 self
.expect("command alias add_two two +")
95 self
.expect("add_two 3", patterns
=[" = 5$"])
96 # Check that aliases to aliases to raw input commands work the second
97 # and subsequent times.
98 self
.expect("add_two 3", patterns
=[" = 5$"])
99 self
.expect("add_two 3", patterns
=[" = 5$"])