blob: 01bf470f9c83ebca315ffec733e01b9006a9bd15 [file] [log] [blame]
Johnny Chenfb35e2a2011-07-18 23:11:07 +00001//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
12%feature("docstring",
13"Represents an executable image and its associated object and symbol files.
14
15The module is designed to be able to select a single slice of an
16executable image as it would appear on disk and during program
17execution.
18
19You can retrieve SBModule from SBSymbolContext, which in turn is available
20from SBFrame.
21
22SBModule supports symbol iteration, for example,
23
24 for symbol in module:
25 name = symbol.GetName()
26 saddr = symbol.GetStartAddress()
27 eaddr = symbol.GetEndAddress()
28
29and rich comparion methods which allow the API program to use,
30
31 if thisModule == thatModule:
32 print 'This module is the same as that module'
33
Johnny Chendc0cbd12011-09-24 04:51:43 +000034to test module equality. A module also contains object file sections, namely
Johnny Chenbf338e62011-09-30 00:42:49 +000035SBSection. SBModule supports section iteration through section_iter(), for
36example,
37
38 print 'Number of sections: %d' % module.GetNumSections()
39 for sec in module.section_iter():
40 print sec
41
42And to iterate the symbols within a SBSection, use symbol_in_section_iter(),
43
44 # Iterates the text section and prints each symbols within each sub-section.
45 for subsec in text_sec:
46 print INDENT + repr(subsec)
47 for sym in exe_module.symbol_in_section_iter(subsec):
48 print INDENT2 + repr(sym)
49 print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
50
Johnny Chen5cac6a52011-10-01 01:19:45 +000051produces this following output:
Johnny Chenbf338e62011-09-30 00:42:49 +000052
53 [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
54 id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
55 symbol type: code
56 id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
57 symbol type: code
58 id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
59 symbol type: code
60 id = {0x00000023}, name = 'start', address = 0x0000000100001780
61 symbol type: code
62 [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
63 id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
64 symbol type: trampoline
65 id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
66 symbol type: trampoline
67 id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
68 symbol type: trampoline
69 id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
70 symbol type: trampoline
71 id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
72 symbol type: trampoline
73 id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
74 symbol type: trampoline
75 id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
76 symbol type: trampoline
77 id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
78 symbol type: trampoline
79 id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
80 symbol type: trampoline
81 id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
82 symbol type: trampoline
83 id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
84 symbol type: trampoline
85 id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
86 symbol type: trampoline
87 [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
88 [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
89 [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
90 [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
91"
Johnny Chenfb35e2a2011-07-18 23:11:07 +000092) SBModule;
93class SBModule
94{
95public:
96
97 SBModule ();
98
99 SBModule (const SBModule &rhs);
100
101 ~SBModule ();
102
103 bool
104 IsValid () const;
105
106 %feature("docstring", "
107 //------------------------------------------------------------------
108 /// Get const accessor for the module file specification.
109 ///
110 /// This function returns the file for the module on the host system
111 /// that is running LLDB. This can differ from the path on the
112 /// platform since we might be doing remote debugging.
113 ///
114 /// @return
115 /// A const reference to the file specification object.
116 //------------------------------------------------------------------
117 ") GetFileSpec;
118 lldb::SBFileSpec
119 GetFileSpec () const;
120
121 %feature("docstring", "
122 //------------------------------------------------------------------
123 /// Get accessor for the module platform file specification.
124 ///
125 /// Platform file refers to the path of the module as it is known on
126 /// the remote system on which it is being debugged. For local
127 /// debugging this is always the same as Module::GetFileSpec(). But
128 /// remote debugging might mention a file '/usr/lib/liba.dylib'
129 /// which might be locally downloaded and cached. In this case the
130 /// platform file could be something like:
131 /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
132 /// The file could also be cached in a local developer kit directory.
133 ///
134 /// @return
135 /// A const reference to the file specification object.
136 //------------------------------------------------------------------
137 ") GetPlatformFileSpec;
138 lldb::SBFileSpec
139 GetPlatformFileSpec () const;
140
141 bool
142 SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
143
144 %feature("docstring", "Returns the UUID of the module as a Python string."
145 ) GetUUIDString;
146 const char *
147 GetUUIDString () const;
148
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000149 lldb::SBSection
150 FindSection (const char *sect_name);
151
152 lldb::SBAddress
153 ResolveFileAddress (lldb::addr_t vm_addr);
Johnny Chenfb35e2a2011-07-18 23:11:07 +0000154
155 lldb::SBSymbolContext
156 ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
157 uint32_t resolve_scope);
158
159 bool
160 GetDescription (lldb::SBStream &description);
161
162 size_t
163 GetNumSymbols ();
164
165 lldb::SBSymbol
166 GetSymbolAtIndex (size_t idx);
167
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000168 size_t
169 GetNumSections ();
170
171 lldb::SBSection
172 GetSectionAtIndex (size_t idx);
173
174
Johnny Chenfb35e2a2011-07-18 23:11:07 +0000175 %feature("docstring", "
176 //------------------------------------------------------------------
177 /// Find functions by name.
178 ///
179 /// @param[in] name
180 /// The name of the function we are looking for.
181 ///
182 /// @param[in] name_type_mask
183 /// A logical OR of one or more FunctionNameType enum bits that
184 /// indicate what kind of names should be used when doing the
185 /// lookup. Bits include fully qualified names, base names,
186 /// C++ methods, or ObjC selectors.
187 /// See FunctionNameType for more details.
188 ///
189 /// @param[in] append
190 /// If true, any matches will be appended to \a sc_list, else
191 /// matches replace the contents of \a sc_list.
192 ///
193 /// @param[out] sc_list
194 /// A symbol context list that gets filled in with all of the
195 /// matches.
196 ///
197 /// @return
198 /// The number of matches added to \a sc_list.
199 //------------------------------------------------------------------
200 ") FindFunctions;
201 uint32_t
202 FindFunctions (const char *name,
203 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
204 bool append,
205 lldb::SBSymbolContextList& sc_list);
Enrico Granata979e20d2011-07-29 19:53:35 +0000206
207 lldb::SBType
208 FindFirstType (const char* name);
209
210 lldb::SBTypeList
211 FindTypes (const char* type);
212
Johnny Chenfb35e2a2011-07-18 23:11:07 +0000213
214 %feature("docstring", "
215 //------------------------------------------------------------------
216 /// Find global and static variables by name.
217 ///
218 /// @param[in] target
219 /// A valid SBTarget instance representing the debuggee.
220 ///
221 /// @param[in] name
222 /// The name of the global or static variable we are looking
223 /// for.
224 ///
225 /// @param[in] max_matches
226 /// Allow the number of matches to be limited to \a max_matches.
227 ///
228 /// @return
229 /// A list of matched variables in an SBValueList.
230 //------------------------------------------------------------------
231 ") FindGlobalVariables;
232 lldb::SBValueList
233 FindGlobalVariables (lldb::SBTarget &target,
234 const char *name,
235 uint32_t max_matches);
236};
237
238} // namespace lldb