Enrico Granata | 7a242109 | 2015-01-22 19:33:53 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb data formatter subsystem. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbbench import * |
| 9 | import lldbutil |
| 10 | |
| 11 | class TestBenchmarkContinue(BenchBase): |
| 12 | |
| 13 | mydir = TestBase.compute_mydir(__file__) |
| 14 | |
| 15 | @benchmarks_test |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 16 | def test_run_command(self): |
Enrico Granata | 7a242109 | 2015-01-22 19:33:53 +0000 | [diff] [blame] | 17 | """Benchmark different ways to continue a process""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 18 | self.build() |
Enrico Granata | 7a242109 | 2015-01-22 19:33:53 +0000 | [diff] [blame] | 19 | self.data_formatter_commands() |
| 20 | |
| 21 | def setUp(self): |
| 22 | # Call super's setUp(). |
| 23 | BenchBase.setUp(self) |
| 24 | |
| 25 | def data_formatter_commands(self): |
| 26 | """Benchmark different ways to continue a process""" |
| 27 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 28 | |
| 29 | bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "// break here")) |
| 30 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 31 | self.runCmd("run", RUN_SUCCEEDED) |
Enrico Granata | 7a242109 | 2015-01-22 19:33:53 +0000 | [diff] [blame] | 32 | |
| 33 | # The stop reason of the thread should be breakpoint. |
| 34 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 35 | substrs = ['stopped', |
| 36 | 'stop reason = breakpoint']) |
| 37 | |
| 38 | # This is the function to remove the custom formats in order to have a |
| 39 | # clean slate for the next test case. |
| 40 | def cleanup(): |
| 41 | self.runCmd('type format clear', check=False) |
| 42 | self.runCmd('type summary clear', check=False) |
| 43 | self.runCmd('type filter clear', check=False) |
| 44 | self.runCmd('type synth clear', check=False) |
| 45 | self.runCmd("settings set target.max-children-count 256", check=False) |
| 46 | |
| 47 | # Execute the cleanup function during test case tear down. |
| 48 | self.addTearDownHook(cleanup) |
| 49 | |
| 50 | runCmd_sw = Stopwatch() |
| 51 | lldbutil_sw = Stopwatch() |
| 52 | |
| 53 | for i in range(0,15): |
| 54 | runCmd_sw.start() |
| 55 | self.runCmd("continue") |
| 56 | runCmd_sw.stop() |
| 57 | |
| 58 | for i in range(0,15): |
| 59 | lldbutil_sw.start() |
| 60 | lldbutil.continue_to_breakpoint(self.process(), bkpt) |
| 61 | lldbutil_sw.stop() |
| 62 | |
| 63 | print "runCmd: %s\nlldbutil: %s" % (runCmd_sw,lldbutil_sw) |
| 64 | |
| 65 | if __name__ == '__main__': |
| 66 | import atexit |
| 67 | lldb.SBDebugger.Initialize() |
| 68 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 69 | unittest2.main() |