2 Test lldb data formatter subsystem.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class LibCxxFunctionTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 # Run frame var for a variable twice. Verify we do not hit the cache
18 # the first time but do the second time.
19 def run_frame_var_check_cache_use(self, variable, result_to_match, skip_find_function=False):
20 self.runCmd("log timers reset")
21 self.expect("frame variable " + variable,
22 substrs=[variable + " = " + result_to_match])
23 if not skip_find_function:
24 self.expect("log timers dump",
25 substrs=["lldb_private::CompileUnit::FindFunction"])
27 self.runCmd("log timers reset")
28 self.expect("frame variable " + variable,
29 substrs=[variable + " = " + result_to_match])
30 self.expect("log timers dump",
32 substrs=["lldb_private::CompileUnit::FindFunction"])
35 @add_test_categories(["libc++"])
37 """Test that std::function as defined by libc++ is correctly printed by LLDB"""
39 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
41 bkpt = self.target().FindBreakpointByID(
42 lldbutil.run_break_set_by_source_regexp(
43 self, "Set break point at this line."))
45 self.runCmd("run", RUN_SUCCEEDED)
47 # The stop reason of the thread should be breakpoint.
48 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
50 'stop reason = breakpoint'])
52 self.run_frame_var_check_cache_use("foo2_f", "Lambda in File main.cpp at Line 30")
54 lldbutil.continue_to_breakpoint(self.process(), bkpt)
56 self.run_frame_var_check_cache_use("add_num2_f", "Lambda in File main.cpp at Line 21")
58 lldbutil.continue_to_breakpoint(self.process(), bkpt)
60 self.run_frame_var_check_cache_use("f2", "Lambda in File main.cpp at Line 43")
61 self.run_frame_var_check_cache_use("f3", "Lambda in File main.cpp at Line 47", True)
62 # TODO reenable this case when std::function formatter supports
63 # general callable object case.
64 #self.run_frame_var_check_cache_use("f4", "Function in File main.cpp at Line 16")
66 # These cases won't hit the cache at all but also don't require
67 # an expensive lookup.
68 self.expect("frame variable f1",
69 substrs=['f1 = Function = foo(int, int)'])
71 self.expect("frame variable f5",
72 substrs=['f5 = Function = Bar::add_num(int) const'])