1 """Test lldb's expression evaluations and collect statistics."""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbbench
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import configuration
9 from lldbsuite
.test
import lldbutil
12 class ExpressionEvaluationCase(BenchBase
):
15 self
.source
= "main.cpp"
16 self
.line_to_break
= line_number(self
.source
, "// Set breakpoint here.")
22 bugnumber
="llvm.org/pr22274: need a pexpect replacement for windows",
24 def test_expr_cmd(self
):
25 """Test lldb's expression commands and collect statistics."""
27 self
.exe_name
= "a.out"
30 self
.run_lldb_repeated_exprs(self
.exe_name
, self
.count
)
31 print("lldb expr cmd benchmark:", self
.stopwatch
)
33 def run_lldb_repeated_exprs(self
, exe_name
, count
):
36 exe
= self
.getBuildArtifact(exe_name
)
38 # Set self.child_prompt, which is "(lldb) ".
39 self
.child_prompt
= "(lldb) "
40 prompt
= self
.child_prompt
42 # Reset the stopwatch now.
43 self
.stopwatch
.reset()
44 for i
in range(count
):
45 # So that the child gets torn down after the test.
46 self
.child
= pexpect
.spawn(
47 "%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
)
57 "breakpoint set -f %s -l %d" % (self
.source
, self
.line_to_break
)
59 child
.expect_exact(prompt
)
61 child
.expect_exact(prompt
)
62 expr_cmd1
= "expr ptr[j]->point.x"
63 expr_cmd2
= "expr ptr[j]->point.y"
66 child
.sendline(expr_cmd1
)
67 child
.expect_exact(prompt
)
68 child
.sendline(expr_cmd2
)
69 child
.expect_exact(prompt
)
71 child
.sendline("quit")
73 self
.child
.expect(pexpect
.EOF
)