Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 1 | """Test lldb's response time for 'frame variable' command.""" |
| 2 | |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 3 | from __future__ import print_function |
| 4 | |
Zachary Turner | 0a0490b | 2015-10-27 20:12:05 +0000 | [diff] [blame^] | 5 | import use_lldb_suite |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 6 | |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 7 | import os, sys |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 8 | import lldb |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 9 | from lldbbench import * |
| 10 | |
| 11 | class FrameVariableResponseBench(BenchBase): |
| 12 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 13 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 14 | |
| 15 | def setUp(self): |
| 16 | BenchBase.setUp(self) |
| 17 | if lldb.bmExecutable: |
| 18 | self.exe = lldb.bmExecutable |
| 19 | else: |
Vince Harron | 790d95c | 2015-05-18 19:39:03 +0000 | [diff] [blame] | 20 | self.exe = lldbtest_config.lldbExec |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 21 | if lldb.bmBreakpointSpec: |
| 22 | self.break_spec = lldb.bmBreakpointSpec |
| 23 | else: |
| 24 | self.break_spec = '-n main' |
| 25 | |
| 26 | self.count = lldb.bmIterationCount |
| 27 | if self.count <= 0: |
| 28 | self.count = 20 |
| 29 | |
| 30 | @benchmarks_test |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 31 | @no_debug_info_test |
Zachary Turner | 0c42631 | 2015-01-20 22:36:03 +0000 | [diff] [blame] | 32 | @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 33 | def test_startup_delay(self): |
| 34 | """Test response time for the 'frame variable' command.""" |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 35 | print() |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 36 | self.run_frame_variable_bench(self.exe, self.break_spec, self.count) |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 37 | print("lldb frame variable benchmark:", self.stopwatch) |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 38 | |
| 39 | def run_frame_variable_bench(self, exe, break_spec, count): |
Zachary Turner | 045fde5 | 2014-07-18 01:02:02 +0000 | [diff] [blame] | 40 | import pexpect |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 41 | # Set self.child_prompt, which is "(lldb) ". |
| 42 | self.child_prompt = '(lldb) ' |
| 43 | prompt = self.child_prompt |
| 44 | |
| 45 | # Reset the stopwatchs now. |
| 46 | self.stopwatch.reset() |
| 47 | for i in range(count): |
| 48 | # So that the child gets torn down after the test. |
Vince Harron | 790d95c | 2015-05-18 19:39:03 +0000 | [diff] [blame] | 49 | self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe)) |
Johnny Chen | 31fdfb1 | 2011-10-21 20:19:51 +0000 | [diff] [blame] | 50 | child = self.child |
| 51 | |
| 52 | # Turn on logging for what the child sends back. |
| 53 | if self.TraceOn(): |
| 54 | child.logfile_read = sys.stdout |
| 55 | |
| 56 | # Set our breakpoint. |
| 57 | child.sendline('breakpoint set %s' % break_spec) |
| 58 | child.expect_exact(prompt) |
| 59 | |
| 60 | # Run the target and expect it to be stopped due to breakpoint. |
| 61 | child.sendline('run') # Aka 'process launch'. |
| 62 | child.expect_exact(prompt) |
| 63 | |
| 64 | with self.stopwatch: |
| 65 | # Measure the 'frame variable' response time. |
| 66 | child.sendline('frame variable') |
| 67 | child.expect_exact(prompt) |
| 68 | |
| 69 | child.sendline('quit') |
| 70 | try: |
| 71 | self.child.expect(pexpect.EOF) |
| 72 | except: |
| 73 | pass |
| 74 | |
| 75 | # The test is about to end and if we come to here, the child process has |
| 76 | # been terminated. Mark it so. |
| 77 | self.child = None |