]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / expression_command / persistent_types / TestPersistentTypes.py
1 """
2 Test that lldb persistent types works correctly.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12
13 class PersistenttypesTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     @expectedFailureWindows("llvm.org/pr21765")
18     def test_persistent_types(self):
19         """Test that lldb persistent types works correctly."""
20         self.build()
21
22         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
23
24         self.runCmd("breakpoint set --name main")
25
26         self.runCmd("run", RUN_SUCCEEDED)
27
28         self.runCmd("expression struct $foo { int a; int b; };")
29
30         self.expect("expression struct $foo $my_foo; $my_foo.a = 2; $my_foo.b = 3;",
31                     startstr = "(int) $0 = 3")
32
33         self.expect("expression $my_foo",
34                     substrs = ['a = 2', 'b = 3'])
35
36         self.runCmd("expression typedef int $bar")
37
38         self.expect("expression $bar i = 5; i",
39                     startstr = "($bar) $1 = 5")
40
41         self.runCmd("expression struct $foobar { char a; char b; char c; char d; };")
42         self.runCmd("next")
43
44         self.expect("memory read foo -t $foobar",
45                     substrs = ['($foobar) 0x', ' = ', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"]) # persistent types are OK to use for memory read
46
47         self.expect("memory read foo -t foobar",
48                     substrs = ['($foobar) 0x', ' = ', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"],matching=False,error=True) # the type name is $foobar, make sure we settle for nothing less
49
50         self.expect("expression struct { int a; int b; } x = { 2, 3 }; x",
51                     substrs = ['a = 2', 'b = 3'])
52
53         self.expect("expression struct { int x; int y; int z; } object; object.y = 1; object.z = 3; object.x = 2; object",
54                     substrs = ['x = 2', 'y = 1', 'z = 3'])
55
56         self.expect("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",
57                     substrs = ['x = 2', 'y = 1', 'z = 3'])