5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class TestCppScopes(TestBase):
12 mydir = TestBase.compute_mydir(__file__)
14 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
15 def test_all_but_c(self):
18 # There's a global symbol in libsystem on Darwin that messes up
19 # the lookup of class C. Breaking that test out from the others
20 # since that is a odd failure, and I don't want it to mask the
21 # real purpose of this test.
22 @expectedFailureDarwin(bugnumber="<rdar://problem/28623427>")
23 @expectedFailureAll(oslist=["windows"])
27 def do_test(self, test_c):
30 # Get main source file
32 src_file_spec = lldb.SBFileSpec(src_file)
33 self.assertTrue(src_file_spec.IsValid(), "Main source file")
35 # Get the path of the executable
38 exe_path = os.path.join(cwd, exe_file)
41 target = self.dbg.CreateTarget(exe_path)
42 self.assertTrue(target.IsValid(), VALID_TARGET)
44 # Break on main function
45 main_breakpoint = target.BreakpointCreateBySourceRegex(
46 "// break here", src_file_spec)
48 main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1,
54 process = target.LaunchSimple(
55 args, env, self.get_process_working_directory())
56 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
58 # Get the thread of the process
60 process.GetState() == lldb.eStateStopped,
62 thread = lldbutil.get_stopped_thread(
63 process, lldb.eStopReasonBreakpoint)
65 # Get current fream of the thread at the breakpoint
66 frame = thread.GetSelectedFrame()
68 # Test result for scopes of variables
70 global_variables = frame.GetVariables(True, True, True, False)
71 global_variables_assert = {
80 global_variables.GetSize() == 4,
81 "target variable returns all variables")
82 for variable in global_variables:
83 name = variable.GetName()
85 name in global_variables_assert,
86 "target variable returns wrong variable " + name)
88 for name in global_variables_assert:
89 if name is "C::a" and not test_c:
91 if name is not "C::a" and test_c:
94 value = frame.EvaluateExpression(name)
95 assert_value = global_variables_assert[name]
97 value.IsValid() and value.GetValueAsSigned() == assert_value,
98 name + " = " + str(assert_value))