blob: fa18afb87c62eaeba821dd42e5f2e44b7b988e55 [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
Robert Flack13c7ad92015-03-30 14:12:17 +000016 @skipUnlessDarwin
Enrico Granata7a2421092015-01-22 19:33:53 +000017 @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
Enrico Granata7a2421092015-01-22 19:33:53 +000024 @dwarf_test
25 def test_with_dwarf_and_run_command(self):
26 """Benchmark different ways to continue a process"""
27 self.buildDwarf()
28 self.data_formatter_commands()
29
30 def setUp(self):
31 # Call super's setUp().
32 BenchBase.setUp(self)
33
34 def data_formatter_commands(self):
35 """Benchmark different ways to continue a process"""
36 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
37
38 bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "// break here"))
39
Sean Callanan05834cd2015-07-01 23:56:30 +000040 self.runCmd("run", RUN_SUCCEEDED)
Enrico Granata7a2421092015-01-22 19:33:53 +000041
42 # The stop reason of the thread should be breakpoint.
43 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
44 substrs = ['stopped',
45 'stop reason = breakpoint'])
46
47 # This is the function to remove the custom formats in order to have a
48 # clean slate for the next test case.
49 def cleanup():
50 self.runCmd('type format clear', check=False)
51 self.runCmd('type summary clear', check=False)
52 self.runCmd('type filter clear', check=False)
53 self.runCmd('type synth clear', check=False)
54 self.runCmd("settings set target.max-children-count 256", check=False)
55
56 # Execute the cleanup function during test case tear down.
57 self.addTearDownHook(cleanup)
58
59 runCmd_sw = Stopwatch()
60 lldbutil_sw = Stopwatch()
61
62 for i in range(0,15):
63 runCmd_sw.start()
64 self.runCmd("continue")
65 runCmd_sw.stop()
66
67 for i in range(0,15):
68 lldbutil_sw.start()
69 lldbutil.continue_to_breakpoint(self.process(), bkpt)
70 lldbutil_sw.stop()
71
72 print "runCmd: %s\nlldbutil: %s" % (runCmd_sw,lldbutil_sw)
73
74if __name__ == '__main__':
75 import atexit
76 lldb.SBDebugger.Initialize()
77 atexit.register(lambda: lldb.SBDebugger.Terminate())
78 unittest2.main()