blob: 40e9c6d90e8f0af8d704762d619e4c9f3d039a62 [file] [log] [blame]
Enrico Granata7a2421092015-01-22 19:33:53 +00001"""
2Test lldb data formatter subsystem.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbbench import *
9import lldbutil
10
11class TestBenchmarkContinue(BenchBase):
12
13 mydir = TestBase.compute_mydir(__file__)
14
15 @benchmarks_test
16 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
17 @dsym_test
18 def test_with_dsym_and_run_command(self):
19 """Benchmark different ways to continue a process"""
20 self.buildDsym()
21 self.data_formatter_commands()
22
23 @benchmarks_test
24 @skipIfLinux # No standard locations for libc++ on Linux, so skip for now
25 @dwarf_test
26 def test_with_dwarf_and_run_command(self):
27 """Benchmark different ways to continue a process"""
28 self.buildDwarf()
29 self.data_formatter_commands()
30
31 def setUp(self):
32 # Call super's setUp().
33 BenchBase.setUp(self)
34
35 def data_formatter_commands(self):
36 """Benchmark different ways to continue a process"""
37 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
38
39 bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "// break here"))
40
41 self.runCmd("run", RUN_SUCCEEDED)
42
43 # The stop reason of the thread should be breakpoint.
44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
45 substrs = ['stopped',
46 'stop reason = breakpoint'])
47
48 # This is the function to remove the custom formats in order to have a
49 # clean slate for the next test case.
50 def cleanup():
51 self.runCmd('type format clear', check=False)
52 self.runCmd('type summary clear', check=False)
53 self.runCmd('type filter clear', check=False)
54 self.runCmd('type synth clear', check=False)
55 self.runCmd("settings set target.max-children-count 256", check=False)
56
57 # Execute the cleanup function during test case tear down.
58 self.addTearDownHook(cleanup)
59
60 runCmd_sw = Stopwatch()
61 lldbutil_sw = Stopwatch()
62
63 for i in range(0,15):
64 runCmd_sw.start()
65 self.runCmd("continue")
66 runCmd_sw.stop()
67
68 for i in range(0,15):
69 lldbutil_sw.start()
70 lldbutil.continue_to_breakpoint(self.process(), bkpt)
71 lldbutil_sw.stop()
72
73 print "runCmd: %s\nlldbutil: %s" % (runCmd_sw,lldbutil_sw)
74
75if __name__ == '__main__':
76 import atexit
77 lldb.SBDebugger.Initialize()
78 atexit.register(lambda: lldb.SBDebugger.Terminate())
79 unittest2.main()