1""" 2Test SBSection APIs. 3""" 4 5 6 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class SectionAPITestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 @add_test_categories(['pyapi']) 17 def test_get_target_byte_size(self): 18 d = {'EXE': 'b.out'} 19 self.build(dictionary=d) 20 self.setTearDownCleanup(dictionary=d) 21 exe = self.getBuildArtifact('b.out') 22 target = self.dbg.CreateTarget(exe) 23 self.assertTrue(target, VALID_TARGET) 24 25 # find the .data section of the main module 26 mod = target.GetModuleAtIndex(0) 27 data_section = None 28 for s in mod.sections: 29 sect_type = s.GetSectionType() 30 if sect_type == lldb.eSectionTypeData: 31 data_section = s 32 break 33 elif sect_type == lldb.eSectionTypeContainer: 34 for i in range(s.GetNumSubSections()): 35 ss = s.GetSubSectionAtIndex(i) 36 sect_type = ss.GetSectionType() 37 if sect_type == lldb.eSectionTypeData: 38 data_section = ss 39 break 40 41 self.assertIsNotNone(data_section) 42 self.assertEqual(data_section.target_byte_size, 1) 43