• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test example snippets from the lldb 'help expression' output.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9import lldbutil
10
11class Radar9673644TestCase(TestBase):
12
13    mydir = os.path.join("expression_command", "radar_9673664")
14
15    def setUp(self):
16        # Call super's setUp().
17        TestBase.setUp(self)
18        # Find the line number to break inside main().
19        self.main_source = "main.c"
20        self.line = line_number(self.main_source, '// Set breakpoint here.')
21
22    # rdar://problem/9673664
23    @expectedFailureFreeBSD # llvm.org/pr16697
24    @skipIfLinux # llvm.org/pr14805: expressions that require memory allocation evaluate incorrectly on Linux
25    def test_expr_commands(self):
26        """The following expression commands should just work."""
27        self.buildDefault()
28
29        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
30
31        lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True)
32
33        self.runCmd("run", RUN_SUCCEEDED)
34
35        # rdar://problem/9673664 lldb expression evaluation problem
36
37        self.expect('expr char c[] = "foo"; c[0]',
38            substrs = ["'f'"])
39        # runCmd: expr char c[] = "foo"; c[0]
40        # output: (char) $0 = 'f'
41
42
43if __name__ == '__main__':
44    import atexit
45    lldb.SBDebugger.Initialize()
46    atexit.register(lambda: lldb.SBDebugger.Terminate())
47    unittest2.main()
48