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