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 %feature("docstring", " 71 Get the index for a provided line entry in this compile unit. 72 73 @param[in] line_entry 74 The SBLineEntry object for which we are looking for the index. 75 76 @param[in] exact 77 An optional boolean defaulting to false that ensures that the provided 78 line entry has a perfect match in the compile unit. 79 80 @return 81 The index of the user-provided line entry. UINT32_MAX if the line entry 82 was not found in the compile unit.") FindLineEntryIndex; 83 uint32_t 84 FindLineEntryIndex (lldb::SBLineEntry &line_entry, bool exact = false) const; 85 86 uint32_t 87 FindLineEntryIndex (uint32_t start_idx, 88 uint32_t line, 89 lldb::SBFileSpec *inline_file_spec) const; 90 91 uint32_t 92 FindLineEntryIndex (uint32_t start_idx, 93 uint32_t line, 94 lldb::SBFileSpec *inline_file_spec, 95 bool exact) const; 96 97 SBFileSpec 98 GetSupportFileAtIndex (uint32_t idx) const; 99 100 uint32_t 101 GetNumSupportFiles () const; 102 103 uint32_t 104 FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); 105 106 %feature("docstring", " 107 Get all types matching type_mask from debug info in this 108 compile unit. 109 110 @param[in] type_mask 111 A bitfield that consists of one or more bits logically OR'ed 112 together from the lldb::TypeClass enumeration. This allows 113 you to request only structure types, or only class, struct 114 and union types. Passing in lldb::eTypeClassAny will return 115 all types found in the debug information for this compile 116 unit. 117 118 @return 119 A list of types in this compile unit that match type_mask") GetTypes; 120 lldb::SBTypeList 121 GetTypes (uint32_t type_mask = lldb::eTypeClassAny); 122 123 lldb::LanguageType 124 GetLanguage (); 125 126 bool 127 GetDescription (lldb::SBStream &description); 128 129 bool 130 operator == (const lldb::SBCompileUnit &rhs) const; 131 132 bool 133 operator != (const lldb::SBCompileUnit &rhs) const; 134 135 STRING_EXTENSION(SBCompileUnit) 136 137 #ifdef SWIGPYTHON 138 %pythoncode %{ 139 def __iter__(self): 140 '''Iterate over all line entries in a lldb.SBCompileUnit object.''' 141 return lldb_iter(self, 'GetNumLineEntries', 'GetLineEntryAtIndex') 142 143 def __len__(self): 144 '''Return the number of line entries in a lldb.SBCompileUnit 145 object.''' 146 return self.GetNumLineEntries() 147 148 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.''') 149 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.''') 150 %} 151 #endif 152 }; 153 154 } // namespace lldb 155