1import lldb 2import os 3from lldbsuite.test.decorators import * 4from lldbsuite.test.lldbtest import * 5from lldbsuite.test import lldbutil 6 7 8class TestWithGmodulesDebugInfo(TestBase): 9 10 mydir = TestBase.compute_mydir(__file__) 11 12 @skipIf(bugnumber="llvm.org/pr36146", oslist=["linux"], archs=["i386"]) 13 @add_test_categories(["gmodules"]) 14 def test_specialized_typedef_from_pch(self): 15 self.build() 16 17 src_file = os.path.join(self.getSourceDir(), "main.cpp") 18 src_file_spec = lldb.SBFileSpec(src_file) 19 self.assertTrue(src_file_spec.IsValid(), "breakpoint file") 20 21 # Get the path of the executable 22 exe_path = self.getBuildArtifact("a.out") 23 24 # Load the executable 25 target = self.dbg.CreateTarget(exe_path) 26 self.assertTrue(target.IsValid(), VALID_TARGET) 27 28 # Break on interesting line 29 breakpoint = target.BreakpointCreateBySourceRegex( 30 "break here", src_file_spec) 31 self.assertTrue( 32 breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1, 33 VALID_BREAKPOINT) 34 35 # Launch the process 36 process = target.LaunchSimple( 37 None, None, self.get_process_working_directory()) 38 self.assertTrue(process.IsValid(), PROCESS_IS_VALID) 39 40 # Get the thread of the process 41 self.assertEquals(process.GetState(), lldb.eStateStopped) 42 thread = lldbutil.get_stopped_thread( 43 process, lldb.eStopReasonBreakpoint) 44 self.assertTrue( 45 thread.IsValid(), 46 "There should be a thread stopped due to breakpoint condition") 47 48 # Get frame for current thread 49 frame = thread.frames[0] 50 51 testValue = frame.EvaluateExpression("test") 52 self.assertTrue( 53 testValue.GetError().Success(), 54 "Test expression value invalid: %s" % 55 (testValue.GetError().GetCString())) 56 self.assertTrue( 57 testValue.GetTypeName() == "IntContainer", 58 "Test expression type incorrect") 59 60 memberValue = testValue.GetChildMemberWithName("storage") 61 self.assertTrue( 62 memberValue.GetError().Success(), 63 "Member value missing or invalid: %s" % 64 (testValue.GetError().GetCString())) 65 self.assertTrue( 66 memberValue.GetTypeName() == "int", 67 "Member type incorrect") 68 self.assertEqual( 69 42, 70 memberValue.GetValueAsSigned(), 71 "Member value incorrect") 72 73 testValue = frame.EvaluateExpression("bar") 74 self.assertTrue( 75 testValue.GetError().Success(), 76 "Test expression value invalid: %s" % 77 (testValue.GetError().GetCString())) 78 self.assertTrue( 79 testValue.GetTypeName() == "Foo::Bar", 80 "Test expression type incorrect") 81 82 memberValue = testValue.GetChildMemberWithName("i") 83 self.assertTrue( 84 memberValue.GetError().Success(), 85 "Member value missing or invalid: %s" % 86 (testValue.GetError().GetCString())) 87 self.assertTrue( 88 memberValue.GetTypeName() == "int", 89 "Member type incorrect") 90 self.assertEqual( 91 123, 92 memberValue.GetValueAsSigned(), 93 "Member value incorrect") 94 95