SBModule.h revision 7dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2
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    size_t
112    GetNumSymbols ();
113
114    lldb::SBSymbol
115    GetSymbolAtIndex (size_t idx);
116
117    size_t
118    GetNumSections ();
119
120    lldb::SBSection
121    GetSectionAtIndex (size_t idx);
122    //------------------------------------------------------------------
123    /// Find functions by name.
124    ///
125    /// @param[in] name
126    ///     The name of the function we are looking for.
127    ///
128    /// @param[in] name_type_mask
129    ///     A logical OR of one or more FunctionNameType enum bits that
130    ///     indicate what kind of names should be used when doing the
131    ///     lookup. Bits include fully qualified names, base names,
132    ///     C++ methods, or ObjC selectors.
133    ///     See FunctionNameType for more details.
134    ///
135    /// @return
136    ///     A lldb::SBSymbolContextList that gets filled in with all of
137    ///     the symbol contexts for all the matches.
138    //------------------------------------------------------------------
139    lldb::SBSymbolContextList
140    FindFunctions (const char *name,
141                   uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
142
143    //------------------------------------------------------------------
144    /// Find global and static variables by name.
145    ///
146    /// @param[in] target
147    ///     A valid SBTarget instance representing the debuggee.
148    ///
149    /// @param[in] name
150    ///     The name of the global or static variable we are looking
151    ///     for.
152    ///
153    /// @param[in] max_matches
154    ///     Allow the number of matches to be limited to \a max_matches.
155    ///
156    /// @return
157    ///     A list of matched variables in an SBValueList.
158    //------------------------------------------------------------------
159    lldb::SBValueList
160    FindGlobalVariables (lldb::SBTarget &target,
161                         const char *name,
162                         uint32_t max_matches);
163
164    lldb::SBType
165    FindFirstType (const char* name);
166
167    lldb::SBTypeList
168    FindTypes (const char* type);
169
170private:
171    friend class SBAddress;
172    friend class SBFrame;
173    friend class SBSection;
174    friend class SBSymbolContext;
175    friend class SBTarget;
176
177    explicit SBModule (const lldb::ModuleSP& module_sp);
178
179    ModuleSP
180    GetSP () const;
181
182    void
183    SetSP (const ModuleSP &module_sp);
184
185    lldb::ModuleSP m_opaque_sp;
186};
187
188
189} // namespace lldb
190
191#endif // LLDB_SBModule_h_
192