2011-10-10 22:03:44 +00:00
|
|
|
"""Test lldb's stepping speed."""
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2015-10-22 20:06:20 +00:00
|
|
|
|
2011-10-10 22:03:44 +00:00
|
|
|
import os, sys
|
|
|
|
import lldb
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbbench import *
|
2011-10-10 22:03:44 +00:00
|
|
|
|
|
|
|
class SteppingSpeedBench(BenchBase):
|
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2011-10-10 22:03:44 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
BenchBase.setUp(self)
|
|
|
|
if lldb.bmExecutable:
|
|
|
|
self.exe = lldb.bmExecutable
|
|
|
|
else:
|
2015-05-18 19:39:03 +00:00
|
|
|
self.exe = lldbtest_config.lldbExec
|
2011-10-10 22:03:44 +00:00
|
|
|
if lldb.bmBreakpointSpec:
|
|
|
|
self.break_spec = lldb.bmBreakpointSpec
|
|
|
|
else:
|
2011-10-26 22:58:02 +00:00
|
|
|
self.break_spec = '-n main'
|
2011-10-20 17:45:39 +00:00
|
|
|
|
2011-10-20 18:43:28 +00:00
|
|
|
self.count = lldb.bmIterationCount
|
|
|
|
if self.count <= 0:
|
|
|
|
self.count = 50
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
#print("self.exe=%s" % self.exe)
|
|
|
|
#print("self.break_spec=%s" % self.break_spec)
|
2011-10-10 22:03:44 +00:00
|
|
|
|
|
|
|
@benchmarks_test
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2015-01-20 22:36:03 +00:00
|
|
|
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
2011-10-10 22:03:44 +00:00
|
|
|
def test_run_lldb_steppings(self):
|
|
|
|
"""Test lldb steppings on a large executable."""
|
2015-10-23 17:04:29 +00:00
|
|
|
print()
|
2011-10-20 18:43:28 +00:00
|
|
|
self.run_lldb_steppings(self.exe, self.break_spec, self.count)
|
2015-10-23 17:04:29 +00:00
|
|
|
print("lldb stepping benchmark:", self.stopwatch)
|
2011-10-10 22:03:44 +00:00
|
|
|
|
|
|
|
def run_lldb_steppings(self, exe, break_spec, count):
|
2014-07-18 01:02:02 +00:00
|
|
|
import pexpect
|
2011-10-10 22:03:44 +00:00
|
|
|
# Set self.child_prompt, which is "(lldb) ".
|
|
|
|
self.child_prompt = '(lldb) '
|
|
|
|
prompt = self.child_prompt
|
|
|
|
|
|
|
|
# So that the child gets torn down after the test.
|
2015-05-18 19:39:03 +00:00
|
|
|
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
2011-10-10 22:03:44 +00:00
|
|
|
child = self.child
|
|
|
|
|
|
|
|
# Turn on logging for what the child sends back.
|
|
|
|
if self.TraceOn():
|
|
|
|
child.logfile_read = sys.stdout
|
|
|
|
|
|
|
|
child.expect_exact(prompt)
|
|
|
|
child.sendline('breakpoint set %s' % break_spec)
|
|
|
|
child.expect_exact(prompt)
|
|
|
|
child.sendline('run')
|
|
|
|
child.expect_exact(prompt)
|
|
|
|
|
|
|
|
# Reset the stopwatch now.
|
|
|
|
self.stopwatch.reset()
|
|
|
|
for i in range(count):
|
|
|
|
with self.stopwatch:
|
|
|
|
# Disassemble the function.
|
|
|
|
child.sendline('next') # Aka 'thread step-over'.
|
|
|
|
child.expect_exact(prompt)
|
|
|
|
|
|
|
|
child.sendline('quit')
|
|
|
|
try:
|
|
|
|
self.child.expect(pexpect.EOF)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
self.child = None
|