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