1 //===-- SWIG Interface for SBCompileUnit ------------------------*- 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 a compilation unit, or compiled source file.
13 
14 SBCompileUnit supports line entry iteration. For example,::
15 
16     # Now get the SBSymbolContext from this frame.  We want everything. :-)
17     context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
18     ...
19 
20     compileUnit = context.GetCompileUnit()
21 
22     for lineEntry in compileUnit:
23         print('line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
24                                     lineEntry.GetLine()))
25         print('start addr: %s' % str(lineEntry.GetStartAddress()))
26         print('end   addr: %s' % str(lineEntry.GetEndAddress()))
27 
28 produces: ::
29 
30   line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20
31   start addr: a.out[0x100000d98]
32   end   addr: a.out[0x100000da3]
33   line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21
34   start addr: a.out[0x100000da3]
35   end   addr: a.out[0x100000da9]
36   line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22
37   start addr: a.out[0x100000da9]
38   end   addr: a.out[0x100000db6]
39   line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23
40   start addr: a.out[0x100000db6]
41   end   addr: a.out[0x100000dbc]
42   ...
43 
44 See also :py:class:`SBSymbolContext` and :py:class:`SBLineEntry`"
45 ) SBCompileUnit;
46 class SBCompileUnit
47 {
48 public:
49 
50     SBCompileUnit ();
51 
52     SBCompileUnit (const lldb::SBCompileUnit &rhs);
53 
54     ~SBCompileUnit ();
55 
56     bool
57     IsValid () const;
58 
59     explicit operator bool() const;
60 
61     lldb::SBFileSpec
62     GetFileSpec () const;
63 
64     uint32_t
65     GetNumLineEntries () const;
66 
67     lldb::SBLineEntry
68     GetLineEntryAtIndex (uint32_t idx) const;
69 
70     uint32_t
71     FindLineEntryIndex (uint32_t start_idx,
72                         uint32_t line,
73                         lldb::SBFileSpec *inline_file_spec) const;
74 
75     uint32_t
76     FindLineEntryIndex (uint32_t start_idx,
77                         uint32_t line,
78                         lldb::SBFileSpec *inline_file_spec,
79 			bool exact) const;
80 
81     SBFileSpec
82     GetSupportFileAtIndex (uint32_t idx) const;
83 
84     uint32_t
85     GetNumSupportFiles () const;
86 
87     uint32_t
88     FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
89 
90     %feature("docstring", "
91      Get all types matching type_mask from debug info in this
92      compile unit.
93 
94      @param[in] type_mask
95         A bitfield that consists of one or more bits logically OR'ed
96         together from the lldb::TypeClass enumeration. This allows
97         you to request only structure types, or only class, struct
98         and union types. Passing in lldb::eTypeClassAny will return
99         all types found in the debug information for this compile
100         unit.
101 
102      @return
103         A list of types in this compile unit that match type_mask") GetTypes;
104     lldb::SBTypeList
105     GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
106 
107      lldb::LanguageType
108      GetLanguage ();
109 
110     bool
111     GetDescription (lldb::SBStream &description);
112 
113     bool
114     operator == (const lldb::SBCompileUnit &rhs) const;
115 
116     bool
117     operator != (const lldb::SBCompileUnit &rhs) const;
118 
119     STRING_EXTENSION(SBCompileUnit)
120 
121 #ifdef SWIGPYTHON
122     %pythoncode %{
123         def __iter__(self):
124             '''Iterate over all line entries in a lldb.SBCompileUnit object.'''
125             return lldb_iter(self, 'GetNumLineEntries', 'GetLineEntryAtIndex')
126 
127         def __len__(self):
128             '''Return the number of line entries in a lldb.SBCompileUnit
129             object.'''
130             return self.GetNumLineEntries()
131 
132         file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''')
133         num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''')
134     %}
135 #endif
136 };
137 
138 } // namespace lldb
139