1 //===-- SBModule.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBModule_h_
11 #define LLDB_SBModule_h_
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBError.h"
15 #include "lldb/API/SBSection.h"
16 #include "lldb/API/SBSymbolContext.h"
17 #include "lldb/API/SBValueList.h"
21 class LLDB_API SBModule {
25 SBModule(const SBModule &rhs);
27 SBModule(const SBModuleSpec &module_spec);
29 const SBModule &operator=(const SBModule &rhs);
31 SBModule(lldb::SBProcess &process, lldb::addr_t header_addr);
39 //------------------------------------------------------------------
40 /// Get const accessor for the module file specification.
42 /// This function returns the file for the module on the host system
43 /// that is running LLDB. This can differ from the path on the
44 /// platform since we might be doing remote debugging.
47 /// A const reference to the file specification object.
48 //------------------------------------------------------------------
49 lldb::SBFileSpec GetFileSpec() const;
51 //------------------------------------------------------------------
52 /// Get accessor for the module platform file specification.
54 /// Platform file refers to the path of the module as it is known on
55 /// the remote system on which it is being debugged. For local
56 /// debugging this is always the same as Module::GetFileSpec(). But
57 /// remote debugging might mention a file '/usr/lib/liba.dylib'
58 /// which might be locally downloaded and cached. In this case the
59 /// platform file could be something like:
60 /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
61 /// The file could also be cached in a local developer kit directory.
64 /// A const reference to the file specification object.
65 //------------------------------------------------------------------
66 lldb::SBFileSpec GetPlatformFileSpec() const;
68 bool SetPlatformFileSpec(const lldb::SBFileSpec &platform_file);
70 //------------------------------------------------------------------
71 /// Get accessor for the remote install path for a module.
73 /// When debugging to a remote platform by connecting to a remote
74 /// platform, the install path of the module can be set. If the
75 /// install path is set, every time the process is about to launch
76 /// the target will install this module on the remote platform prior
80 /// A file specification object.
81 //------------------------------------------------------------------
82 lldb::SBFileSpec GetRemoteInstallFileSpec();
84 //------------------------------------------------------------------
85 /// Set accessor for the remote install path for a module.
87 /// When debugging to a remote platform by connecting to a remote
88 /// platform, the install path of the module can be set. If the
89 /// install path is set, every time the process is about to launch
90 /// the target will install this module on the remote platform prior
93 /// If \a file specifies a full path to an install location, the
94 /// module will be installed to this path. If the path is relative
95 /// (no directory specified, or the path is partial like "usr/lib"
96 /// or "./usr/lib", then the install path will be resolved using
97 /// the platform's current working directory as the base path.
100 /// A file specification object.
101 //------------------------------------------------------------------
102 bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file);
104 lldb::ByteOrder GetByteOrder();
106 uint32_t GetAddressByteSize();
108 const char *GetTriple();
110 const uint8_t *GetUUIDBytes() const;
112 const char *GetUUIDString() const;
114 bool operator==(const lldb::SBModule &rhs) const;
116 bool operator!=(const lldb::SBModule &rhs) const;
118 lldb::SBSection FindSection(const char *sect_name);
120 lldb::SBAddress ResolveFileAddress(lldb::addr_t vm_addr);
122 lldb::SBSymbolContext
123 ResolveSymbolContextForAddress(const lldb::SBAddress &addr,
124 uint32_t resolve_scope);
126 bool GetDescription(lldb::SBStream &description);
128 uint32_t GetNumCompileUnits();
130 lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t);
132 //------------------------------------------------------------------
133 /// Find compile units related to *this module and passed source
136 /// @param[in] sb_file_spec
137 /// A lldb::SBFileSpec object that contains source file
141 /// A lldb::SBSymbolContextList that gets filled in with all of
142 /// the symbol contexts for all the matches.
143 //------------------------------------------------------------------
144 lldb::SBSymbolContextList
145 FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
147 size_t GetNumSymbols();
149 lldb::SBSymbol GetSymbolAtIndex(size_t idx);
151 lldb::SBSymbol FindSymbol(const char *name,
152 lldb::SymbolType type = eSymbolTypeAny);
154 lldb::SBSymbolContextList FindSymbols(const char *name,
155 lldb::SymbolType type = eSymbolTypeAny);
157 size_t GetNumSections();
159 lldb::SBSection GetSectionAtIndex(size_t idx);
160 //------------------------------------------------------------------
161 /// Find functions by name.
164 /// The name of the function we are looking for.
166 /// @param[in] name_type_mask
167 /// A logical OR of one or more FunctionNameType enum bits that
168 /// indicate what kind of names should be used when doing the
169 /// lookup. Bits include fully qualified names, base names,
170 /// C++ methods, or ObjC selectors.
171 /// See FunctionNameType for more details.
174 /// A lldb::SBSymbolContextList that gets filled in with all of
175 /// the symbol contexts for all the matches.
176 //------------------------------------------------------------------
177 lldb::SBSymbolContextList
178 FindFunctions(const char *name,
179 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
181 //------------------------------------------------------------------
182 /// Find global and static variables by name.
184 /// @param[in] target
185 /// A valid SBTarget instance representing the debuggee.
188 /// The name of the global or static variable we are looking
191 /// @param[in] max_matches
192 /// Allow the number of matches to be limited to \a max_matches.
195 /// A list of matched variables in an SBValueList.
196 //------------------------------------------------------------------
197 lldb::SBValueList FindGlobalVariables(lldb::SBTarget &target,
198 const char *name, uint32_t max_matches);
200 //------------------------------------------------------------------
201 /// Find the first global (or static) variable by name.
203 /// @param[in] target
204 /// A valid SBTarget instance representing the debuggee.
207 /// The name of the global or static variable we are looking
211 /// An SBValue that gets filled in with the found variable (if any).
212 //------------------------------------------------------------------
213 lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
216 lldb::SBType FindFirstType(const char *name);
218 lldb::SBTypeList FindTypes(const char *type);
220 //------------------------------------------------------------------
221 /// Get a type using its type ID.
223 /// Each symbol file reader will assign different user IDs to their
224 /// types, but it is sometimes useful when debugging type issues to
225 /// be able to grab a type using its type ID.
227 /// For DWARF debug info, the type ID is the DIE offset.
230 /// The type user ID.
233 /// An SBType for the given type ID, or an empty SBType if the
234 /// type was not found.
235 //------------------------------------------------------------------
236 lldb::SBType GetTypeByID(lldb::user_id_t uid);
238 lldb::SBType GetBasicType(lldb::BasicType type);
240 //------------------------------------------------------------------
241 /// Get all types matching \a type_mask from debug info in this
244 /// @param[in] type_mask
245 /// A bitfield that consists of one or more bits logically OR'ed
246 /// together from the lldb::TypeClass enumeration. This allows
247 /// you to request only structure types, or only class, struct
248 /// and union types. Passing in lldb::eTypeClassAny will return
249 /// all types found in the debug information for this module.
252 /// A list of types in this module that match \a type_mask
253 //------------------------------------------------------------------
254 lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
256 //------------------------------------------------------------------
257 /// Get the module version numbers.
259 /// Many object files have a set of version numbers that describe
260 /// the version of the executable or shared library. Typically there
261 /// are major, minor and build, but there may be more. This function
262 /// will extract the versions from object files if they are available.
264 /// If \a versions is NULL, or if \a num_versions is 0, the return
265 /// value will indicate how many version numbers are available in
266 /// this object file. Then a subsequent call can be made to this
267 /// function with a value of \a versions and \a num_versions that
268 /// has enough storage to store some or all version numbers.
270 /// @param[out] versions
271 /// A pointer to an array of uint32_t types that is \a num_versions
272 /// long. If this value is NULL, the return value will indicate
273 /// how many version numbers are required for a subsequent call
274 /// to this function so that all versions can be retrieved. If
275 /// the value is non-NULL, then at most \a num_versions of the
276 /// existing versions numbers will be filled into \a versions.
277 /// If there is no version information available, \a versions
278 /// will be filled with \a num_versions UINT32_MAX values
279 /// and zero will be returned.
281 /// @param[in] num_versions
282 /// The maximum number of entries to fill into \a versions. If
283 /// this value is zero, then the return value will indicate
284 /// how many version numbers there are in total so another call
285 /// to this function can be make with adequate storage in
286 /// \a versions to get all of the version numbers. If \a
287 /// num_versions is less than the actual number of version
288 /// numbers in this object file, only \a num_versions will be
289 /// filled into \a versions (if \a versions is non-NULL).
292 /// This function always returns the number of version numbers
293 /// that this object file has regardless of the number of
294 /// version numbers that were copied into \a versions.
295 //------------------------------------------------------------------
296 uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
298 //------------------------------------------------------------------
299 /// Get accessor for the symbol file specification.
301 /// When debugging an object file an additional debug information can
302 /// be provided in separate file. Therefore if you debugging something
303 /// like '/usr/lib/liba.dylib' then debug information can be located
304 /// in folder like '/usr/lib/liba.dylib.dSYM/'.
307 /// A const reference to the file specification object.
308 //------------------------------------------------------------------
309 lldb::SBFileSpec GetSymbolFileSpec() const;
311 lldb::SBAddress GetObjectFileHeaderAddress() const;
312 lldb::SBAddress GetObjectFileEntryPointAddress() const;
315 friend class SBAddress;
316 friend class SBFrame;
317 friend class SBSection;
318 friend class SBSymbolContext;
319 friend class SBTarget;
321 explicit SBModule(const lldb::ModuleSP &module_sp);
323 ModuleSP GetSP() const;
325 void SetSP(const ModuleSP &module_sp);
327 lldb::ModuleSP m_opaque_sp;
332 #endif // LLDB_SBModule_h_