1 """Test lldb's expression evaluations and collect statistics."""
3 from __future__ import print_function
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbbench import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import configuration
13 from lldbsuite.test import lldbutil
15 class ExpressionEvaluationCase(BenchBase):
17 mydir = TestBase.compute_mydir(__file__)
21 self.source = 'main.cpp'
22 self.line_to_break = line_number(self.source, '// Set breakpoint here.')
26 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
27 def test_expr_cmd(self):
28 """Test lldb's expression commands and collect statistics."""
30 self.exe_name = 'a.out'
33 self.run_lldb_repeated_exprs(self.exe_name, self.count)
34 print("lldb expr cmd benchmark:", self.stopwatch)
36 def run_lldb_repeated_exprs(self, exe_name, count):
38 exe = os.path.join(os.getcwd(), exe_name)
40 # Set self.child_prompt, which is "(lldb) ".
41 self.child_prompt = '(lldb) '
42 prompt = self.child_prompt
44 # Reset the stopwatch now.
45 self.stopwatch.reset()
46 for i in range(count):
47 # So that the child gets torn down after the test.
48 self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
51 # Turn on logging for what the child sends back.
53 child.logfile_read = sys.stdout
55 child.expect_exact(prompt)
56 child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break))
57 child.expect_exact(prompt)
59 child.expect_exact(prompt)
60 expr_cmd1 = 'expr ptr[j]->point.x'
61 expr_cmd2 = 'expr ptr[j]->point.y'
64 child.sendline(expr_cmd1)
65 child.expect_exact(prompt)
66 child.sendline(expr_cmd2)
67 child.expect_exact(prompt)
69 child.sendline('quit')
71 self.child.expect(pexpect.EOF)