xref: /llvm-project-15.0.7/lldb/test/API/python_api/section/TestSectionAPI.py (revision b505ed9d)
  • 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    mydir = TestBase.compute_mydir(__file__)
15
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 = self.getBuildArtifact('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)
42

served by {OpenGrok

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