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 mydir = TestBase.compute_mydir(__file__) 10 11 @skipIf(compiler="clang", compiler_version=['<', '8.0']) 12 def test_variable_list(self): 13 self.build() 14 _, process, _, _ = lldbutil.run_to_source_breakpoint( 15 self, "break here", lldb.SBFileSpec('main.c')) 16 17 # Make sure no helper expressions show up in frame variable. 18 var_opts = lldb.SBVariablesOptions() 19 var_opts.SetIncludeArguments(False) 20 var_opts.SetIncludeLocals(True) 21 var_opts.SetInScopeOnly(True) 22 var_opts.SetIncludeStatics(False) 23 var_opts.SetIncludeRuntimeSupportValues(False) 24 var_opts.SetUseDynamic(lldb.eDynamicCanRunTarget) 25 all_locals = self.frame().GetVariables(var_opts) 26 for value in all_locals: 27 self.assertFalse("vla_expr" in value.name) 28 29 @decorators.skipIf(compiler="clang", compiler_version=['<', '8.0']) 30 def test_vla(self): 31 self.build() 32 _, process, _, _ = lldbutil.run_to_source_breakpoint( 33 self, "break here", lldb.SBFileSpec('main.c')) 34 35 def test(a, array): 36 for i in range(a): 37 self.expect("fr v vla[%d]"%i, substrs=["int", "%d"%(a-i)]) 38 self.expect("expr vla[%d]"%i, substrs=["int", "%d"%(a-i)]) 39 self.expect("fr v vla", substrs=array) 40 self.expect("expr vla", error=True, substrs=["incomplete"]) 41 42 test(2, ["int []", "[0] = 2, [1] = 1"]) 43 process.Continue() 44 test(4, ["int []", "[0] = 4, [1] = 3, [2] = 2, [3] = 1"]) 45 46