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 size_t GetNumSymbols();
134 lldb::SBSymbol GetSymbolAtIndex(size_t idx);
136 lldb::SBSymbol FindSymbol(const char *name,
137 lldb::SymbolType type = eSymbolTypeAny);
139 lldb::SBSymbolContextList FindSymbols(const char *name,
140 lldb::SymbolType type = eSymbolTypeAny);
142 size_t GetNumSections();
144 lldb::SBSection GetSectionAtIndex(size_t idx);
145 //------------------------------------------------------------------
146 /// Find functions by name.
149 /// The name of the function we are looking for.
151 /// @param[in] name_type_mask
152 /// A logical OR of one or more FunctionNameType enum bits that
153 /// indicate what kind of names should be used when doing the
154 /// lookup. Bits include fully qualified names, base names,
155 /// C++ methods, or ObjC selectors.
156 /// See FunctionNameType for more details.
159 /// A lldb::SBSymbolContextList that gets filled in with all of
160 /// the symbol contexts for all the matches.
161 //------------------------------------------------------------------
162 lldb::SBSymbolContextList
163 FindFunctions(const char *name,
164 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
166 //------------------------------------------------------------------
167 /// Find global and static variables by name.
169 /// @param[in] target
170 /// A valid SBTarget instance representing the debuggee.
173 /// The name of the global or static variable we are looking
176 /// @param[in] max_matches
177 /// Allow the number of matches to be limited to \a max_matches.
180 /// A list of matched variables in an SBValueList.
181 //------------------------------------------------------------------
182 lldb::SBValueList FindGlobalVariables(lldb::SBTarget &target,
183 const char *name, uint32_t max_matches);
185 //------------------------------------------------------------------
186 /// Find the first global (or static) variable by name.
188 /// @param[in] target
189 /// A valid SBTarget instance representing the debuggee.
192 /// The name of the global or static variable we are looking
196 /// An SBValue that gets filled in with the found variable (if any).
197 //------------------------------------------------------------------
198 lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
201 lldb::SBType FindFirstType(const char *name);
203 lldb::SBTypeList FindTypes(const char *type);
205 //------------------------------------------------------------------
206 /// Get a type using its type ID.
208 /// Each symbol file reader will assign different user IDs to their
209 /// types, but it is sometimes useful when debugging type issues to
210 /// be able to grab a type using its type ID.
212 /// For DWARF debug info, the type ID is the DIE offset.
215 /// The type user ID.
218 /// An SBType for the given type ID, or an empty SBType if the
219 /// type was not found.
220 //------------------------------------------------------------------
221 lldb::SBType GetTypeByID(lldb::user_id_t uid);
223 lldb::SBType GetBasicType(lldb::BasicType type);
225 //------------------------------------------------------------------
226 /// Get all types matching \a type_mask from debug info in this
229 /// @param[in] type_mask
230 /// A bitfield that consists of one or more bits logically OR'ed
231 /// together from the lldb::TypeClass enumeration. This allows
232 /// you to request only structure types, or only class, struct
233 /// and union types. Passing in lldb::eTypeClassAny will return
234 /// all types found in the debug information for this module.
237 /// A list of types in this module that match \a type_mask
238 //------------------------------------------------------------------
239 lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
241 //------------------------------------------------------------------
242 /// Get the module version numbers.
244 /// Many object files have a set of version numbers that describe
245 /// the version of the executable or shared library. Typically there
246 /// are major, minor and build, but there may be more. This function
247 /// will extract the versions from object files if they are available.
249 /// If \a versions is NULL, or if \a num_versions is 0, the return
250 /// value will indicate how many version numbers are available in
251 /// this object file. Then a subsequent call can be made to this
252 /// function with a value of \a versions and \a num_versions that
253 /// has enough storage to store some or all version numbers.
255 /// @param[out] versions
256 /// A pointer to an array of uint32_t types that is \a num_versions
257 /// long. If this value is NULL, the return value will indicate
258 /// how many version numbers are required for a subsequent call
259 /// to this function so that all versions can be retrieved. If
260 /// the value is non-NULL, then at most \a num_versions of the
261 /// existing versions numbers will be filled into \a versions.
262 /// If there is no version information available, \a versions
263 /// will be filled with \a num_versions UINT32_MAX values
264 /// and zero will be returned.
266 /// @param[in] num_versions
267 /// The maximum number of entries to fill into \a versions. If
268 /// this value is zero, then the return value will indicate
269 /// how many version numbers there are in total so another call
270 /// to this function can be make with adequate storage in
271 /// \a versions to get all of the version numbers. If \a
272 /// num_versions is less than the actual number of version
273 /// numbers in this object file, only \a num_versions will be
274 /// filled into \a versions (if \a versions is non-NULL).
277 /// This function always returns the number of version numbers
278 /// that this object file has regardless of the number of
279 /// version numbers that were copied into \a versions.
280 //------------------------------------------------------------------
281 uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
283 //------------------------------------------------------------------
284 /// Get accessor for the symbol file specification.
286 /// When debugging an object file an additional debug information can
287 /// be provided in separate file. Therefore if you debugging something
288 /// like '/usr/lib/liba.dylib' then debug information can be located
289 /// in folder like '/usr/lib/liba.dylib.dSYM/'.
292 /// A const reference to the file specification object.
293 //------------------------------------------------------------------
294 lldb::SBFileSpec GetSymbolFileSpec() const;
296 lldb::SBAddress GetObjectFileHeaderAddress() const;
299 friend class SBAddress;
300 friend class SBFrame;
301 friend class SBSection;
302 friend class SBSymbolContext;
303 friend class SBTarget;
305 explicit SBModule(const lldb::ModuleSP &module_sp);
307 ModuleSP GetSP() const;
309 void SetSP(const ModuleSP &module_sp);
311 lldb::ModuleSP m_opaque_sp;
316 #endif // LLDB_SBModule_h_