SBModule.h revision b5a8f1498e1ddaeed5187a878d57ea0b74af9c26
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#ifndef SWIG
30    const SBModule &
31    operator = (const SBModule &rhs);
32#endif
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#ifndef SWIG
89    const uint8_t *
90    GetUUIDBytes () const;
91#endif
92
93    const char *
94    GetUUIDString () const;
95
96#ifndef SWIG
97    bool
98    operator == (const lldb::SBModule &rhs) const;
99
100    bool
101    operator != (const lldb::SBModule &rhs) const;
102
103#endif
104    lldb::SBSection
105    FindSection (const char *sect_name);
106
107    lldb::SBAddress
108    ResolveFileAddress (lldb::addr_t vm_addr);
109
110    lldb::SBSymbolContext
111    ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
112                                    uint32_t resolve_scope);
113
114    bool
115    GetDescription (lldb::SBStream &description);
116
117    size_t
118    GetNumSymbols ();
119
120    lldb::SBSymbol
121    GetSymbolAtIndex (size_t idx);
122
123    size_t
124    GetNumSections ();
125
126    lldb::SBSection
127    GetSectionAtIndex (size_t idx);
128    //------------------------------------------------------------------
129    /// Find functions by name.
130    ///
131    /// @param[in] name
132    ///     The name of the function we are looking for.
133    ///
134    /// @param[in] name_type_mask
135    ///     A logical OR of one or more FunctionNameType enum bits that
136    ///     indicate what kind of names should be used when doing the
137    ///     lookup. Bits include fully qualified names, base names,
138    ///     C++ methods, or ObjC selectors.
139    ///     See FunctionNameType for more details.
140    ///
141    /// @param[in] append
142    ///     If true, any matches will be appended to \a sc_list, else
143    ///     matches replace the contents of \a sc_list.
144    ///
145    /// @param[out] sc_list
146    ///     A symbol context list that gets filled in with all of the
147    ///     matches.
148    ///
149    /// @return
150    ///     The number of matches added to \a sc_list.
151    //------------------------------------------------------------------
152    uint32_t
153    FindFunctions (const char *name,
154                   uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
155                   bool append,
156                   lldb::SBSymbolContextList& sc_list);
157
158    //------------------------------------------------------------------
159    /// Find global and static variables by name.
160    ///
161    /// @param[in] target
162    ///     A valid SBTarget instance representing the debuggee.
163    ///
164    /// @param[in] name
165    ///     The name of the global or static variable we are looking
166    ///     for.
167    ///
168    /// @param[in] max_matches
169    ///     Allow the number of matches to be limited to \a max_matches.
170    ///
171    /// @return
172    ///     A list of matched variables in an SBValueList.
173    //------------------------------------------------------------------
174    lldb::SBValueList
175    FindGlobalVariables (lldb::SBTarget &target,
176                         const char *name,
177                         uint32_t max_matches);
178
179    lldb::SBType
180    FindFirstType (const char* name);
181
182    lldb::SBTypeList
183    FindTypes (const char* type);
184
185private:
186    friend class SBAddress;
187    friend class SBFrame;
188    friend class SBSection;
189    friend class SBSymbolContext;
190    friend class SBTarget;
191
192    explicit SBModule (const lldb::ModuleSP& module_sp);
193
194    ModuleSP
195    GetSP () const;
196
197    void
198    SetSP (const ModuleSP &module_sp);
199
200    lldb::ModuleSP m_opaque_sp;
201};
202
203
204} // namespace lldb
205
206#endif // LLDB_SBModule_h_
207