1import lldb 2from lldbsuite.test.lldbtest import * 3from lldbsuite.test.decorators import * 4import lldbsuite.test.lldbutil as lldbutil 5 6 7class TestVLA(TestBase): 8 9 @skipIf(compiler="clang", compiler_version=['<', '8.0']) 10 def test_variable_list(self): 11 self.build() 12 _, process, _, _ = lldbutil.run_to_source_breakpoint( 13 self, "break here", lldb.SBFileSpec('main.c')) 14 15 # Make sure no helper expressions show up in frame variable. 16 var_opts = lldb.SBVariablesOptions() 17 var_opts.SetIncludeArguments(False) 18 var_opts.SetIncludeLocals(True) 19 var_opts.SetInScopeOnly(True) 20 var_opts.SetIncludeStatics(False) 21 var_opts.SetIncludeRuntimeSupportValues(False) 22 var_opts.SetUseDynamic(lldb.eDynamicCanRunTarget) 23 all_locals = self.frame().GetVariables(var_opts) 24 for value in all_locals: 25 self.assertNotIn("vla_expr", value.name) 26 27 @decorators.skipIf(compiler="clang", compiler_version=['<', '8.0']) 28 def test_vla(self): 29 self.build() 30 _, process, _, _ = lldbutil.run_to_source_breakpoint( 31 self, "break here", lldb.SBFileSpec('main.c')) 32 33 def test(a): 34 children = [] 35 for i in range(a): 36 name = "[%d]"%i 37 value = str(a-i) 38 self.expect_var_path("vla"+name, type="int", value=value) 39 self.expect_expr("vla"+name, result_type="int", 40 result_value=value) 41 children.append(ValueCheck(name=name, value=value)) 42 self.expect_var_path("vla", type="int[]", children=children) 43 self.expect("expr vla", error=True, substrs=["incomplete"]) 44 45 test(2) 46 process.Continue() 47 test(4) 48 49