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