2014-10-22 07:22:56 +00:00
|
|
|
"""
|
|
|
|
|
Test SBSection APIs.
|
|
|
|
|
"""
|
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2014-10-22 07:22:56 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
class SectionAPITestCase(TestBase):
|
|
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
|
|
2015-10-26 09:28:32 +00:00
|
|
|
@add_test_categories(['pyapi'])
|
2015-09-30 10:12:40 +00:00
|
|
|
def test_get_target_byte_size(self):
|
2014-10-22 07:22:56 +00:00
|
|
|
d = {'EXE': 'b.out'}
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build(dictionary=d)
|
2014-10-22 07:22:56 +00:00
|
|
|
self.setTearDownCleanup(dictionary=d)
|
2018-01-30 18:29:16 +00:00
|
|
|
exe = self.getBuildArtifact('b.out')
|
2014-10-22 07:22:56 +00:00
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
# find the .data section of the main module
|
2014-10-22 07:22:56 +00:00
|
|
|
mod = target.GetModuleAtIndex(0)
|
|
|
|
|
data_section = None
|
|
|
|
|
for s in mod.sections:
|
2014-11-03 23:02:08 +00:00
|
|
|
sect_type = s.GetSectionType()
|
|
|
|
|
if sect_type == lldb.eSectionTypeData:
|
2014-10-22 07:22:56 +00:00
|
|
|
data_section = s
|
|
|
|
|
break
|
2014-11-03 23:02:08 +00:00
|
|
|
elif sect_type == lldb.eSectionTypeContainer:
|
|
|
|
|
for i in range(s.GetNumSubSections()):
|
|
|
|
|
ss = s.GetSubSectionAtIndex(i)
|
|
|
|
|
sect_type = ss.GetSectionType()
|
|
|
|
|
if sect_type == lldb.eSectionTypeData:
|
|
|
|
|
data_section = ss
|
|
|
|
|
break
|
2014-10-22 07:22:56 +00:00
|
|
|
|
|
|
|
|
self.assertIsNotNone(data_section)
|
2015-10-26 16:50:39 +00:00
|
|
|
self.assertEqual(data_section.target_byte_size, 1)
|