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