1""" 2Test lldb-vscode variables/stackTrace request for optimized code 3""" 4 5from __future__ import print_function 6 7import unittest2 8import vscode 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbtest import * 11from lldbsuite.test import lldbutil 12import lldbvscode_testcase 13 14 15class TestVSCode_optimized(lldbvscode_testcase.VSCodeTestCaseBase): 16 mydir = TestBase.compute_mydir(__file__) 17 18 @skipIfWindows 19 @skipIfRemote 20 def test_stack_frame_name(self): 21 ''' Test optimized frame has special name suffix. 22 ''' 23 program = self.getBuildArtifact("a.out") 24 self.build_and_launch(program) 25 source = 'main.cpp' 26 breakpoint_line = line_number(source, '// breakpoint 1') 27 lines = [breakpoint_line] 28 breakpoint_ids = self.set_source_breakpoints(source, lines) 29 self.assertEqual(len(breakpoint_ids), len(lines), 30 "expect correct number of breakpoints") 31 self.continue_to_breakpoints(breakpoint_ids) 32 leaf_frame = self.vscode.get_stackFrame(frameIndex=0) 33 self.assertTrue(leaf_frame['name'].endswith(' [opt]')) 34 parent_frame = self.vscode.get_stackFrame(frameIndex=1) 35 self.assertTrue(parent_frame['name'].endswith(' [opt]')) 36 37 @skipIfWindows 38 @skipIfRemote 39 def test_optimized_variable(self): 40 ''' Test optimized variable value contains error. 41 ''' 42 program = self.getBuildArtifact("a.out") 43 self.build_and_launch(program) 44 source = 'main.cpp' 45 breakpoint_line = line_number(source, '// breakpoint 2') 46 lines = [breakpoint_line] 47 # Set breakpoint in the thread function so we can step the threads 48 breakpoint_ids = self.set_source_breakpoints(source, lines) 49 self.assertEqual(len(breakpoint_ids), len(lines), 50 "expect correct number of breakpoints") 51 self.continue_to_breakpoints(breakpoint_ids) 52 optimized_variable = self.vscode.get_local_variable('optimized') 53 54 self.assertTrue(optimized_variable['value'].startswith('<error:')) 55