1 """Disassemble lldb's Driver::MainLoop() functions comparing Xcode 4.1 vs. 4.2's gdb."""
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
16 class XCode41Vs42GDBDisassembly(BenchBase):
18 mydir = TestBase.compute_mydir(__file__)
22 self.gdb_41_exe = '/Xcode41/usr/bin/gdb'
23 self.gdb_42_exe = '/Developer/usr/bin/gdb'
24 self.exe = lldbtest_config.lldbExec
25 self.function = 'Driver::MainLoop()'
26 self.gdb_41_avg = None
27 self.gdb_42_avg = None
34 bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
35 def test_run_41_then_42(self):
36 """Test disassembly on a large function with 4.1 vs. 4.2's gdb."""
38 self.run_gdb_disassembly(
43 print("4.1 gdb benchmark:", self.stopwatch)
44 self.gdb_41_avg = self.stopwatch.avg()
45 self.run_gdb_disassembly(
50 print("4.2 gdb benchmark:", self.stopwatch)
51 self.gdb_42_avg = self.stopwatch.avg()
52 print("gdb_42_avg/gdb_41_avg: %f" %
53 (self.gdb_42_avg / self.gdb_41_avg))
59 bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
60 def test_run_42_then_41(self):
61 """Test disassembly on a large function with 4.1 vs. 4.2's gdb."""
63 self.run_gdb_disassembly(
68 print("4.2 gdb benchmark:", self.stopwatch)
69 self.gdb_42_avg = self.stopwatch.avg()
70 self.run_gdb_disassembly(
75 print("4.1 gdb benchmark:", self.stopwatch)
76 self.gdb_41_avg = self.stopwatch.avg()
77 print("gdb_42_avg/gdb_41_avg: %f" %
78 (self.gdb_42_avg / self.gdb_41_avg))
80 def run_gdb_disassembly(self, gdb_exe_path, exe, function, count):
82 # Set self.child_prompt, which is "(gdb) ".
83 self.child_prompt = '(gdb) '
84 prompt = self.child_prompt
86 # So that the child gets torn down after the test.
87 self.child = pexpect.spawn('%s --nx %s' % (gdb_exe_path, exe))
90 # Turn on logging for what the child sends back.
92 child.logfile_read = sys.stdout
94 child.expect_exact(prompt)
95 child.sendline('break %s' % function)
96 child.expect_exact(prompt)
98 child.expect_exact(prompt)
100 # Reset the stopwatch now.
101 self.stopwatch.reset()
102 for i in range(count):
104 # Disassemble the function.
105 child.sendline('disassemble')
106 child.expect_exact(prompt)
107 child.sendline('next')
108 child.expect_exact(prompt)
110 child.sendline('quit')
111 child.expect_exact('The program is running. Exit anyway?')
114 self.child.expect(pexpect.EOF)
119 print("gdb disassembly benchmark:", str(self.stopwatch))