xref: /llvm-project-15.0.7/lldb/test/API/python_api/section/TestSectionAPI.py (revision be6af89f)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    def test_get_target_byte_size(self):
15        d = {'EXE': 'b.out'}
16        self.build(dictionary=d)
17        self.setTearDownCleanup(dictionary=d)
18        exe = self.getBuildArtifact('b.out')
19        target = self.dbg.CreateTarget(exe)
20        self.assertTrue(target, VALID_TARGET)
21
22        # find the .data section of the main module
23        mod = target.GetModuleAtIndex(0)
24        data_section = None
25        for s in mod.sections:
26            sect_type = s.GetSectionType()
27            if sect_type == lldb.eSectionTypeData:
28                data_section = s
29                break
30            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
37
38        self.assertIsNotNone(data_section)
39        self.assertEqual(data_section.target_byte_size, 1)
40

served by {OpenGrok

Last Index Update: Tue Oct 21 18:42:31 GMT 2025