LLDB API Documentation

SBModule.h
Go to the documentation of this file.
1 //===-- SBModule.h ----------------------------------------------*- 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 
10 #ifndef LLDB_SBModule_h_
11 #define LLDB_SBModule_h_
12 
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBError.h"
15 #include "lldb/API/SBSection.h"
17 #include "lldb/API/SBValueList.h"
18 
19 namespace lldb {
20 
21 class LLDB_API SBModule {
22 public:
23  SBModule();
24 
25  SBModule(const SBModule &rhs);
26 
27  SBModule(const SBModuleSpec &module_spec);
28 
29  const SBModule &operator=(const SBModule &rhs);
30 
31  SBModule(lldb::SBProcess &process, lldb::addr_t header_addr);
32 
33  ~SBModule();
34 
35  bool IsValid() const;
36 
37  void Clear();
38 
39  //------------------------------------------------------------------
40  /// Get const accessor for the module file specification.
41  ///
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.
45  ///
46  /// @return
47  /// A const reference to the file specification object.
48  //------------------------------------------------------------------
49  lldb::SBFileSpec GetFileSpec() const;
50 
51  //------------------------------------------------------------------
52  /// Get accessor for the module platform file specification.
53  ///
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.
62  ///
63  /// @return
64  /// A const reference to the file specification object.
65  //------------------------------------------------------------------
66  lldb::SBFileSpec GetPlatformFileSpec() const;
67 
68  bool SetPlatformFileSpec(const lldb::SBFileSpec &platform_file);
69 
70  //------------------------------------------------------------------
71  /// Get accessor for the remote install path for a module.
72  ///
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
77  /// to launching.
78  ///
79  /// @return
80  /// A file specification object.
81  //------------------------------------------------------------------
82  lldb::SBFileSpec GetRemoteInstallFileSpec();
83 
84  //------------------------------------------------------------------
85  /// Set accessor for the remote install path for a module.
86  ///
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
91  /// to launching.
92  ///
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.
98  ///
99  /// @param[in] file
100  /// A file specification object.
101  //------------------------------------------------------------------
102  bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file);
103 
104  lldb::ByteOrder GetByteOrder();
105 
106  uint32_t GetAddressByteSize();
107 
108  const char *GetTriple();
109 
110  const uint8_t *GetUUIDBytes() const;
111 
112  const char *GetUUIDString() const;
113 
114  bool operator==(const lldb::SBModule &rhs) const;
115 
116  bool operator!=(const lldb::SBModule &rhs) const;
117 
118  lldb::SBSection FindSection(const char *sect_name);
119 
120  lldb::SBAddress ResolveFileAddress(lldb::addr_t vm_addr);
121 
123  ResolveSymbolContextForAddress(const lldb::SBAddress &addr,
124  uint32_t resolve_scope);
125 
126  bool GetDescription(lldb::SBStream &description);
127 
128  uint32_t GetNumCompileUnits();
129 
130  lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t);
131 
132  size_t GetNumSymbols();
133 
134  lldb::SBSymbol GetSymbolAtIndex(size_t idx);
135 
136  lldb::SBSymbol FindSymbol(const char *name,
137  lldb::SymbolType type = eSymbolTypeAny);
138 
139  lldb::SBSymbolContextList FindSymbols(const char *name,
140  lldb::SymbolType type = eSymbolTypeAny);
141 
142  size_t GetNumSections();
143 
144  lldb::SBSection GetSectionAtIndex(size_t idx);
145  //------------------------------------------------------------------
146  /// Find functions by name.
147  ///
148  /// @param[in] name
149  /// The name of the function we are looking for.
150  ///
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.
157  ///
158  /// @return
159  /// A lldb::SBSymbolContextList that gets filled in with all of
160  /// the symbol contexts for all the matches.
161  //------------------------------------------------------------------
163  FindFunctions(const char *name,
164  uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
165 
166  //------------------------------------------------------------------
167  /// Find global and static variables by name.
168  ///
169  /// @param[in] target
170  /// A valid SBTarget instance representing the debuggee.
171  ///
172  /// @param[in] name
173  /// The name of the global or static variable we are looking
174  /// for.
175  ///
176  /// @param[in] max_matches
177  /// Allow the number of matches to be limited to \a max_matches.
178  ///
179  /// @return
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);
184 
185  //------------------------------------------------------------------
186  /// Find the first global (or static) variable by name.
187  ///
188  /// @param[in] target
189  /// A valid SBTarget instance representing the debuggee.
190  ///
191  /// @param[in] name
192  /// The name of the global or static variable we are looking
193  /// for.
194  ///
195  /// @return
196  /// An SBValue that gets filled in with the found variable (if any).
197  //------------------------------------------------------------------
198  lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
199  const char *name);
200 
201  lldb::SBType FindFirstType(const char *name);
202 
203  lldb::SBTypeList FindTypes(const char *type);
204 
205  //------------------------------------------------------------------
206  /// Get a type using its type ID.
207  ///
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.
211  ///
212  /// For DWARF debug info, the type ID is the DIE offset.
213  ///
214  /// @param[in] uid
215  /// The type user ID.
216  ///
217  /// @return
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);
222 
223  lldb::SBType GetBasicType(lldb::BasicType type);
224 
225  //------------------------------------------------------------------
226  /// Get all types matching \a type_mask from debug info in this
227  /// module.
228  ///
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.
235  ///
236  /// @return
237  /// A list of types in this module that match \a type_mask
238  //------------------------------------------------------------------
239  lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
240 
241  //------------------------------------------------------------------
242  /// Get the module version numbers.
243  ///
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.
248  ///
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.
254  ///
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.
265  ///
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).
275  ///
276  /// @return
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);
282 
283  //------------------------------------------------------------------
284  /// Get accessor for the symbol file specification.
285  ///
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/'.
290  ///
291  /// @return
292  /// A const reference to the file specification object.
293  //------------------------------------------------------------------
294  lldb::SBFileSpec GetSymbolFileSpec() const;
295 
296  lldb::SBAddress GetObjectFileHeaderAddress() const;
297 
298 private:
299  friend class SBAddress;
300  friend class SBFrame;
301  friend class SBSection;
302  friend class SBSymbolContext;
303  friend class SBTarget;
304 
305  explicit SBModule(const lldb::ModuleSP &module_sp);
306 
307  ModuleSP GetSP() const;
308 
309  void SetSP(const ModuleSP &module_sp);
310 
311  lldb::ModuleSP m_opaque_sp;
312 };
313 
314 } // namespace lldb
315 
316 #endif // LLDB_SBModule_h_
class LLDB_API SBModule
Definition: SBDefines.h:64