blob: 7a6bc3ac81245e2a2958fe16b44aba04d467dff8 [file] [log] [blame]
Matthew Gardinerc928de32014-10-22 07:22:56 +00001"""
2Test SBSection APIs.
3"""
4
Zachary Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Matthew Gardinerc928de32014-10-22 07:22:56 +00007from lldbtest import *
8
9class SectionAPITestCase(TestBase):
10
11 mydir = TestBase.compute_mydir(__file__)
12
Matthew Gardinerc928de32014-10-22 07:22:56 +000013 @python_api_test
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000014 def test_get_target_byte_size(self):
Matthew Gardinerc928de32014-10-22 07:22:56 +000015 d = {'EXE': 'b.out'}
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000016 self.build(dictionary=d)
Matthew Gardinerc928de32014-10-22 07:22:56 +000017 self.setTearDownCleanup(dictionary=d)
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000018 exe = os.path.join(os.getcwd(), 'b.out')
Matthew Gardinerc928de32014-10-22 07:22:56 +000019 target = self.dbg.CreateTarget(exe)
20 self.assertTrue(target, VALID_TARGET)
Matthew Gardinerc928de32014-10-22 07:22:56 +000021
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000022 # find the .data section of the main module
Matthew Gardinerc928de32014-10-22 07:22:56 +000023 mod = target.GetModuleAtIndex(0)
24 data_section = None
25 for s in mod.sections:
Greg Claytoned59d752014-11-03 23:02:08 +000026 sect_type = s.GetSectionType()
27 if sect_type == lldb.eSectionTypeData:
Matthew Gardinerc928de32014-10-22 07:22:56 +000028 data_section = s
29 break
Greg Claytoned59d752014-11-03 23:02:08 +000030 elif sect_type == lldb.eSectionTypeContainer:
31 for i in range(s.GetNumSubSections()):
32 ss = s.GetSubSectionAtIndex(i)
33 sect_type = ss.GetSectionType()
34 if sect_type == lldb.eSectionTypeData:
35 data_section = ss
36 break
Matthew Gardinerc928de32014-10-22 07:22:56 +000037
38 self.assertIsNotNone(data_section)
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000039 self.assertEquals(data_section.target_byte_size, 1)