1"""
2Test some more expression commands.
3"""
4
5import os
6import unittest2
7import lldb
8import lldbutil
9from lldbtest import *
10
11class ExprCommands2TestCase(TestBase):
12
13    mydir = os.path.join("expression_command", "test")
14
15    def setUp(self):
16        # Call super's setUp().
17        TestBase.setUp(self)
18        # Find the line number to break for main.c.
19        self.line = line_number('main.cpp',
20                                '// Please test many expressions while stopped at this line:')
21
22    @expectedFailurei386
23    def test_more_expr_commands(self):
24        """Test some more expression commands."""
25        self.buildDefault()
26
27        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
28
29        lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1,loc_exact=False)
30
31        self.runCmd("run", RUN_SUCCEEDED)
32
33        # Does static casting work?
34        self.expect("expression (int*)argv",
35            startstr = "(int *) $0 = 0x")
36        # (int *) $0 = 0x00007fff5fbff258
37
38        # Do anonymous symbols work?
39        self.expect("expression ((char**)environ)[0]",
40            startstr = "(char *) $1 = 0x")
41        # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render"
42
43        # Do return values containing the contents of expression locals work?
44        self.expect("expression int i = 5; i",
45            startstr = "(int) $2 = 5")
46        # (int) $2 = 5
47        self.expect("expression $2 + 1",
48            startstr = "(int) $3 = 6")
49        # (int) $3 = 6
50
51        # Do return values containing the results of static expressions work?
52        self.expect("expression 20 + 3",
53            startstr = "(int) $4 = 23")
54        # (int) $4 = 5
55        self.expect("expression $4 + 1",
56            startstr = "(int) $5 = 24")
57        # (int) $5 = 6
58
59
60if __name__ == '__main__':
61    import atexit
62    lldb.SBDebugger.Initialize()
63    atexit.register(lambda: lldb.SBDebugger.Terminate())
64    unittest2.main()
65