TestRunHooksThenSteppings.py revision 8f8345fe26363c21ab9c04ddc25884a342ca15dd
1"""Test lldb's stepping speed.""" 2 3import os, sys 4import unittest2 5import lldb 6import pexpect 7from lldbbench import * 8 9class RunHooksThenSteppingsBench(BenchBase): 10 11 mydir = os.path.join("benchmarks", "stepping") 12 13 def setUp(self): 14 BenchBase.setUp(self) 15 16 @benchmarks_test 17 def test_lldb_runhooks_then_steppings(self): 18 """Test lldb steppings on a large executable.""" 19 print 20 self.run_lldb_runhooks_then_steppings(50) 21 print "lldb stepping benchmark:", self.stopwatch 22 23 def run_lldb_runhooks_then_steppings(self, count): 24 # Set self.child_prompt, which is "(lldb) ". 25 self.child_prompt = '(lldb) ' 26 prompt = self.child_prompt 27 28 self.child = pexpect.spawn('%s %s' % (self.lldbHere, self.lldbOption)) 29 self.child.expect_exact(prompt) 30 # So that the child gets torn down after the test. 31 child = self.child 32 33 # Turn on logging for what the child sends back. 34 if self.TraceOn(): 35 child.logfile_read = sys.stdout 36 37 #lldb.runHooks = ['process attach -n Mail'] 38 39 # Perform the run hooks to bring lldb debugger to the desired state. 40 self.runHooks(child=child, child_prompt=prompt) 41 42 # Reset the stopwatch now. 43 self.stopwatch.reset() 44 for i in range(count): 45 with self.stopwatch: 46 # Step through the function. 47 child.sendline('next') # Aka 'thread step-over'. 48 child.expect_exact(prompt) 49 50 child.sendline('quit') 51 try: 52 self.child.expect(pexpect.EOF) 53 except: 54 pass 55 56 self.child = None 57 58 59if __name__ == '__main__': 60 import atexit 61 lldb.SBDebugger.Initialize() 62 atexit.register(lambda: lldb.SBDebugger.Terminate()) 63 unittest2.main() 64