2 Test that lldb persistent types works correctly.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class PersistenttypesTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 def test_persistent_types(self):
18 """Test that lldb persistent types works correctly."""
21 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
23 self.runCmd("breakpoint set --name main")
25 self.runCmd("run", RUN_SUCCEEDED)
27 self.runCmd("expression struct $foo { int a; int b; };")
30 "expression struct $foo $my_foo; $my_foo.a = 2; $my_foo.b = 3;",
31 startstr="(int) $0 = 3")
33 self.expect("expression $my_foo",
34 substrs=['a = 2', 'b = 3'])
36 self.runCmd("expression typedef int $bar")
38 self.expect("expression $bar i = 5; i",
39 startstr="($bar) $1 = 5")
42 "expression struct $foobar { char a; char b; char c; char d; };")
46 "memory read foo -t $foobar",
53 "d = 'l'"]) # persistent types are OK to use for memory read
56 "memory read foo -t $foobar -x c",
63 "d = 'l'"]) # persistent types are OK to use for memory read
66 "memory read foo -t foobar",
75 error=True) # the type name is $foobar, make sure we settle for nothing less
77 self.expect("expression struct { int a; int b; } x = { 2, 3 }; x",
78 substrs=['a = 2', 'b = 3'])
81 "expression struct { int x; int y; int z; } object; object.y = 1; object.z = 3; object.x = 2; object",
88 "expression struct A { int x; int y; }; struct { struct A a; int z; } object; object.a.y = 1; object.z = 3; object.a.x = 2; object",