]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/bindings/interface/SBSection.i
Merge once more from ^/vendor/llvm-project/release-10.x, to get the
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / bindings / interface / SBSection.i
1 //===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 namespace lldb {
10
11 %feature("docstring",
12 "Represents an executable image section.
13
14 SBSection supports iteration through its subsection, represented as SBSection
15 as well.  For example,
16
17     for sec in exe_module:
18         if sec.GetName() == '__TEXT':
19             print sec
20             break
21     print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections()
22     for subsec in sec:
23         print INDENT + repr(subsec)
24
25 produces:
26
27 [0x0000000100000000-0x0000000100002000) a.out.__TEXT
28     Number of subsections: 6
29     [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
30     [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
31     [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
32     [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
33     [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
34     [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
35
36 See also SBModule."
37 ) SBSection;
38
39 class SBSection
40 {
41 public:
42
43     SBSection ();
44
45     SBSection (const lldb::SBSection &rhs);
46
47     ~SBSection ();
48
49     bool
50     IsValid () const;
51
52     explicit operator bool() const;
53
54     const char *
55     GetName ();
56
57     lldb::SBSection
58     GetParent();
59
60     lldb::SBSection
61     FindSubSection (const char *sect_name);
62
63     size_t
64     GetNumSubSections ();
65
66     lldb::SBSection
67     GetSubSectionAtIndex (size_t idx);
68
69     lldb::addr_t
70     GetFileAddress ();
71
72     lldb::addr_t
73     GetLoadAddress (lldb::SBTarget &target);
74
75     lldb::addr_t
76     GetByteSize ();
77
78     uint64_t
79     GetFileOffset ();
80
81     uint64_t
82     GetFileByteSize ();
83
84     lldb::SBData
85     GetSectionData ();
86
87     lldb::SBData
88     GetSectionData (uint64_t offset,
89                     uint64_t size);
90
91     SectionType
92     GetSectionType ();
93
94     uint32_t
95     GetPermissions() const;
96
97     %feature("docstring", "
98     Return the size of a target's byte represented by this section
99     in numbers of host bytes. Note that certain architectures have
100     varying minimum addressable unit (i.e. byte) size for their
101     CODE or DATA buses.
102
103     @return
104         The number of host (8-bit) bytes needed to hold a target byte") GetTargetByteSize;
105     uint32_t
106     GetTargetByteSize ();
107
108     bool
109     GetDescription (lldb::SBStream &description);
110
111     bool
112     operator == (const lldb::SBSection &rhs);
113
114     bool
115     operator != (const lldb::SBSection &rhs);
116
117     STRING_EXTENSION(SBSection)
118
119 #ifdef SWIGPYTHON
120     %pythoncode %{
121         def __iter__(self):
122             '''Iterate over all subsections in a lldb.SBSection object.'''
123             return lldb_iter(self, 'GetNumSubSections', 'GetSubSectionAtIndex')
124
125         def __len__(self):
126             '''Return the number of subsections in a lldb.SBSection object.'''
127             return self.GetNumSubSections()
128
129         def get_addr(self):
130             return SBAddress(self, 0)
131
132         name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''')
133         addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''')
134         file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''')
135         size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''')
136         file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''')
137         file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''')
138         data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''')
139         type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''')
140         target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''')
141     %}
142 #endif
143
144 private:
145
146     std::unique_ptr<lldb_private::SectionImpl> m_opaque_ap;
147 };
148
149 } // namespace lldb