SBModule.h revision 392bd8d8356a35a0ad7a9990e1e05d0509971c4b
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"
16#include "lldb/API/SBSymbolContext.h"
17#include "lldb/API/SBValueList.h"
18
19namespace lldb {
20
21class SBModule
22{
23public:
24
25    SBModule ();
26
27    SBModule (const SBModule &rhs);
28
29    const SBModule &
30    operator = (const SBModule &rhs);
31
32    SBModule (lldb::SBProcess &process,
33              lldb::addr_t header_addr);
34
35    ~SBModule ();
36
37    bool
38    IsValid () const;
39
40    void
41    Clear();
42
43    //------------------------------------------------------------------
44    /// Get const accessor for the module file specification.
45    ///
46    /// This function returns the file for the module on the host system
47    /// that is running LLDB. This can differ from the path on the
48    /// platform since we might be doing remote debugging.
49    ///
50    /// @return
51    ///     A const reference to the file specification object.
52    //------------------------------------------------------------------
53    lldb::SBFileSpec
54    GetFileSpec () const;
55
56    //------------------------------------------------------------------
57    /// Get accessor for the module platform file specification.
58    ///
59    /// Platform file refers to the path of the module as it is known on
60    /// the remote system on which it is being debugged. For local
61    /// debugging this is always the same as Module::GetFileSpec(). But
62    /// remote debugging might mention a file '/usr/lib/liba.dylib'
63    /// which might be locally downloaded and cached. In this case the
64    /// platform file could be something like:
65    /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
66    /// The file could also be cached in a local developer kit directory.
67    ///
68    /// @return
69    ///     A const reference to the file specification object.
70    //------------------------------------------------------------------
71    lldb::SBFileSpec
72    GetPlatformFileSpec () const;
73
74    bool
75    SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
76
77    lldb::ByteOrder
78    GetByteOrder ();
79
80    uint32_t
81    GetAddressByteSize();
82
83    const char *
84    GetTriple ();
85
86    const uint8_t *
87    GetUUIDBytes () const;
88
89    const char *
90    GetUUIDString () const;
91
92    bool
93    operator == (const lldb::SBModule &rhs) const;
94
95    bool
96    operator != (const lldb::SBModule &rhs) const;
97
98    lldb::SBSection
99    FindSection (const char *sect_name);
100
101    lldb::SBAddress
102    ResolveFileAddress (lldb::addr_t vm_addr);
103
104    lldb::SBSymbolContext
105    ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
106                                    uint32_t resolve_scope);
107
108    bool
109    GetDescription (lldb::SBStream &description);
110
111    uint32_t
112    GetNumCompileUnits();
113
114    lldb::SBCompileUnit
115    GetCompileUnitAtIndex (uint32_t);
116
117    size_t
118    GetNumSymbols ();
119
120    lldb::SBSymbol
121    GetSymbolAtIndex (size_t idx);
122
123    lldb::SBSymbol
124    FindSymbol (const char *name,
125                lldb::SymbolType type = eSymbolTypeAny);
126
127    lldb::SBSymbolContextList
128    FindSymbols (const char *name,
129                 lldb::SymbolType type = eSymbolTypeAny);
130
131    size_t
132    GetNumSections ();
133
134    lldb::SBSection
135    GetSectionAtIndex (size_t idx);
136    //------------------------------------------------------------------
137    /// Find functions by name.
138    ///
139    /// @param[in] name
140    ///     The name of the function we are looking for.
141    ///
142    /// @param[in] name_type_mask
143    ///     A logical OR of one or more FunctionNameType enum bits that
144    ///     indicate what kind of names should be used when doing the
145    ///     lookup. Bits include fully qualified names, base names,
146    ///     C++ methods, or ObjC selectors.
147    ///     See FunctionNameType for more details.
148    ///
149    /// @return
150    ///     A lldb::SBSymbolContextList that gets filled in with all of
151    ///     the symbol contexts for all the matches.
152    //------------------------------------------------------------------
153    lldb::SBSymbolContextList
154    FindFunctions (const char *name,
155                   uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
156
157    //------------------------------------------------------------------
158    /// Find global and static variables by name.
159    ///
160    /// @param[in] target
161    ///     A valid SBTarget instance representing the debuggee.
162    ///
163    /// @param[in] name
164    ///     The name of the global or static variable we are looking
165    ///     for.
166    ///
167    /// @param[in] max_matches
168    ///     Allow the number of matches to be limited to \a max_matches.
169    ///
170    /// @return
171    ///     A list of matched variables in an SBValueList.
172    //------------------------------------------------------------------
173    lldb::SBValueList
174    FindGlobalVariables (lldb::SBTarget &target,
175                         const char *name,
176                         uint32_t max_matches);
177
178    //------------------------------------------------------------------
179    /// Find the first global (or static) variable by name.
180    ///
181    /// @param[in] target
182    ///     A valid SBTarget instance representing the debuggee.
183    ///
184    /// @param[in] name
185    ///     The name of the global or static variable we are looking
186    ///     for.
187    ///
188    /// @return
189    ///     An SBValue that gets filled in with the found variable (if any).
190    //------------------------------------------------------------------
191    lldb::SBValue
192    FindFirstGlobalVariable (lldb::SBTarget &target, const char *name);
193
194    lldb::SBType
195    FindFirstType (const char* name);
196
197    lldb::SBTypeList
198    FindTypes (const char* type);
199
200    lldb::SBType
201    GetBasicType(lldb::BasicType type);
202
203    //------------------------------------------------------------------
204    /// Get the module version numbers.
205    ///
206    /// Many object files have a set of version numbers that describe
207    /// the version of the executable or shared library. Typically there
208    /// are major, minor and build, but there may be more. This function
209    /// will extract the versions from object files if they are available.
210    ///
211    /// If \a versions is NULL, or if \a num_versions is 0, the return
212    /// value will indicate how many version numbers are available in
213    /// this object file. Then a subsequent call can be made to this
214    /// function with a value of \a versions and \a num_versions that
215    /// has enough storage to store some or all version numbers.
216    ///
217    /// @param[out] versions
218    ///     A pointer to an array of uint32_t types that is \a num_versions
219    ///     long. If this value is NULL, the return value will indicate
220    ///     how many version numbers are required for a subsequent call
221    ///     to this function so that all versions can be retrieved. If
222    ///     the value is non-NULL, then at most \a num_versions of the
223    ///     existing versions numbers will be filled into \a versions.
224    ///     If there is no version information available, \a versions
225    ///     will be filled with \a num_versions UINT32_MAX values
226    ///     and zero will be returned.
227    ///
228    /// @param[in] num_versions
229    ///     The maximum number of entries to fill into \a versions. If
230    ///     this value is zero, then the return value will indicate
231    ///     how many version numbers there are in total so another call
232    ///     to this function can be make with adequate storage in
233    ///     \a versions to get all of the version numbers. If \a
234    ///     num_versions is less than the actual number of version
235    ///     numbers in this object file, only \a num_versions will be
236    ///     filled into \a versions (if \a versions is non-NULL).
237    ///
238    /// @return
239    ///     This function always returns the number of version numbers
240    ///     that this object file has regardless of the number of
241    ///     version numbers that were copied into \a versions.
242    //------------------------------------------------------------------
243    uint32_t
244    GetVersion (uint32_t *versions,
245                uint32_t num_versions);
246
247private:
248    friend class SBAddress;
249    friend class SBFrame;
250    friend class SBSection;
251    friend class SBSymbolContext;
252    friend class SBTarget;
253
254    explicit SBModule (const lldb::ModuleSP& module_sp);
255
256    ModuleSP
257    GetSP () const;
258
259    void
260    SetSP (const ModuleSP &module_sp);
261
262    lldb::ModuleSP m_opaque_sp;
263};
264
265
266} // namespace lldb
267
268#endif // LLDB_SBModule_h_
269