1254721Semaste//===-- SymbolFileDWARF.h --------------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef SymbolFileDWARF_SymbolFileDWARF_h_
11254721Semaste#define SymbolFileDWARF_SymbolFileDWARF_h_
12254721Semaste
13254721Semaste// C Includes
14254721Semaste// C++ Includes
15254721Semaste#include <list>
16254721Semaste#include <map>
17254721Semaste#include <set>
18254721Semaste#include <vector>
19254721Semaste
20254721Semaste// Other libraries and framework includes
21254721Semaste#include "clang/AST/CharUnits.h"
22254721Semaste#include "clang/AST/ExternalASTSource.h"
23254721Semaste#include "llvm/ADT/DenseMap.h"
24254721Semaste#include "llvm/ADT/SmallPtrSet.h"
25254721Semaste#include "llvm/ADT/SmallVector.h"
26254721Semaste
27254721Semaste#include "lldb/lldb-private.h"
28254721Semaste#include "lldb/Core/ClangForward.h"
29254721Semaste#include "lldb/Core/ConstString.h"
30254721Semaste#include "lldb/Core/dwarf.h"
31254721Semaste#include "lldb/Core/Flags.h"
32254721Semaste#include "lldb/Core/UniqueCStringMap.h"
33254721Semaste#include "lldb/Symbol/ClangASTContext.h"
34254721Semaste#include "lldb/Symbol/SymbolFile.h"
35254721Semaste#include "lldb/Symbol/SymbolContext.h"
36254721Semaste
37254721Semaste// Project includes
38254721Semaste#include "DWARFDefines.h"
39263363Semaste#include "DWARFDataExtractor.h"
40254721Semaste#include "HashedNameToDIE.h"
41254721Semaste#include "NameToDIE.h"
42254721Semaste#include "UniqueDWARFASTType.h"
43254721Semaste
44254721Semaste//----------------------------------------------------------------------
45254721Semaste// Forward Declarations for this DWARF plugin
46254721Semaste//----------------------------------------------------------------------
47254721Semasteclass DebugMapModule;
48254721Semasteclass DWARFAbbreviationDeclaration;
49254721Semasteclass DWARFAbbreviationDeclarationSet;
50254721Semasteclass DWARFileUnit;
51254721Semasteclass DWARFDebugAbbrev;
52254721Semasteclass DWARFDebugAranges;
53254721Semasteclass DWARFDebugInfo;
54254721Semasteclass DWARFDebugInfoEntry;
55254721Semasteclass DWARFDebugLine;
56254721Semasteclass DWARFDebugPubnames;
57254721Semasteclass DWARFDebugRanges;
58254721Semasteclass DWARFDeclContext;
59254721Semasteclass DWARFDIECollection;
60254721Semasteclass DWARFFormValue;
61254721Semasteclass SymbolFileDWARFDebugMap;
62254721Semaste
63254721Semasteclass SymbolFileDWARF : public lldb_private::SymbolFile, public lldb_private::UserID
64254721Semaste{
65254721Semastepublic:
66254721Semaste    friend class SymbolFileDWARFDebugMap;
67254721Semaste    friend class DebugMapModule;
68254721Semaste    friend class DWARFCompileUnit;
69254721Semaste    //------------------------------------------------------------------
70254721Semaste    // Static Functions
71254721Semaste    //------------------------------------------------------------------
72254721Semaste    static void
73254721Semaste    Initialize();
74254721Semaste
75254721Semaste    static void
76254721Semaste    Terminate();
77254721Semaste
78254721Semaste    static lldb_private::ConstString
79254721Semaste    GetPluginNameStatic();
80254721Semaste
81254721Semaste    static const char *
82254721Semaste    GetPluginDescriptionStatic();
83254721Semaste
84254721Semaste    static lldb_private::SymbolFile*
85254721Semaste    CreateInstance (lldb_private::ObjectFile* obj_file);
86254721Semaste    //------------------------------------------------------------------
87254721Semaste    // Constructors and Destructors
88254721Semaste    //------------------------------------------------------------------
89254721Semaste                            SymbolFileDWARF(lldb_private::ObjectFile* ofile);
90254721Semaste    virtual                 ~SymbolFileDWARF();
91254721Semaste
92254721Semaste    virtual uint32_t        CalculateAbilities ();
93254721Semaste    virtual void            InitializeObject();
94254721Semaste
95254721Semaste    //------------------------------------------------------------------
96254721Semaste    // Compile Unit function calls
97254721Semaste    //------------------------------------------------------------------
98254721Semaste    virtual uint32_t        GetNumCompileUnits();
99254721Semaste    virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index);
100254721Semaste
101254721Semaste    virtual lldb::LanguageType ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc);
102254721Semaste    virtual size_t          ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc);
103254721Semaste    virtual bool            ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc);
104254721Semaste    virtual bool            ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList& support_files);
105254721Semaste    virtual size_t          ParseFunctionBlocks (const lldb_private::SymbolContext& sc);
106254721Semaste    virtual size_t          ParseTypes (const lldb_private::SymbolContext& sc);
107254721Semaste    virtual size_t          ParseVariablesForContext (const lldb_private::SymbolContext& sc);
108254721Semaste
109254721Semaste    virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
110254721Semaste    virtual bool            ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_type);
111254721Semaste
112254721Semaste    virtual lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true);
113254721Semaste    virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid);
114254721Semaste    virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid);
115254721Semaste
116254721Semaste    virtual uint32_t        ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
117254721Semaste    virtual uint32_t        ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
118254721Semaste    virtual uint32_t        FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
119254721Semaste    virtual uint32_t        FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
120254721Semaste    virtual uint32_t        FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
121254721Semaste    virtual uint32_t        FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
122254721Semaste    virtual uint32_t        FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types);
123254721Semaste    virtual lldb_private::TypeList *
124254721Semaste                            GetTypeList ();
125254721Semaste    virtual size_t          GetTypes (lldb_private::SymbolContextScope *sc_scope,
126254721Semaste                                      uint32_t type_mask,
127254721Semaste                                      lldb_private::TypeList &type_list);
128254721Semaste
129254721Semaste    virtual lldb_private::ClangASTContext &
130254721Semaste                            GetClangASTContext ();
131254721Semaste
132254721Semaste    virtual lldb_private::ClangNamespaceDecl
133254721Semaste            FindNamespace (const lldb_private::SymbolContext& sc,
134254721Semaste                           const lldb_private::ConstString &name,
135254721Semaste                           const lldb_private::ClangNamespaceDecl *parent_namespace_decl);
136254721Semaste
137254721Semaste
138254721Semaste    //------------------------------------------------------------------
139254721Semaste    // ClangASTContext callbacks for external source lookups.
140254721Semaste    //------------------------------------------------------------------
141254721Semaste    static void
142254721Semaste    CompleteTagDecl (void *baton, clang::TagDecl *);
143254721Semaste
144254721Semaste    static void
145254721Semaste    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
146254721Semaste
147254721Semaste    static void
148254721Semaste    FindExternalVisibleDeclsByName (void *baton,
149254721Semaste                                    const clang::DeclContext *DC,
150254721Semaste                                    clang::DeclarationName Name,
151254721Semaste                                    llvm::SmallVectorImpl <clang::NamedDecl *> *results);
152254721Semaste
153254721Semaste    static bool
154254721Semaste    LayoutRecordType (void *baton,
155254721Semaste                      const clang::RecordDecl *record_decl,
156254721Semaste                      uint64_t &size,
157254721Semaste                      uint64_t &alignment,
158254721Semaste                      llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
159254721Semaste                      llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
160254721Semaste                      llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
161254721Semaste
162254721Semaste    bool
163254721Semaste    LayoutRecordType (const clang::RecordDecl *record_decl,
164254721Semaste                      uint64_t &size,
165254721Semaste                      uint64_t &alignment,
166254721Semaste                      llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
167254721Semaste                      llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
168254721Semaste                      llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
169254721Semaste
170254721Semaste    struct LayoutInfo
171254721Semaste    {
172254721Semaste        LayoutInfo () :
173254721Semaste            bit_size(0),
174254721Semaste            alignment(0),
175254721Semaste            field_offsets(),
176254721Semaste            base_offsets(),
177254721Semaste            vbase_offsets()
178254721Semaste        {
179254721Semaste        }
180254721Semaste        uint64_t bit_size;
181254721Semaste        uint64_t alignment;
182254721Semaste        llvm::DenseMap <const clang::FieldDecl *, uint64_t> field_offsets;
183254721Semaste        llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
184254721Semaste        llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets;
185254721Semaste    };
186254721Semaste    //------------------------------------------------------------------
187254721Semaste    // PluginInterface protocol
188254721Semaste    //------------------------------------------------------------------
189254721Semaste    virtual lldb_private::ConstString
190254721Semaste    GetPluginName();
191254721Semaste
192254721Semaste    virtual uint32_t
193254721Semaste    GetPluginVersion();
194254721Semaste
195254721Semaste    // Approach 2 - count + accessor
196254721Semaste    // Index compile units would scan the initial compile units and register
197254721Semaste    // them with the module. This would only be done on demand if and only if
198254721Semaste    // the compile units were needed.
199254721Semaste    //virtual size_t        GetCompUnitCount() = 0;
200254721Semaste    //virtual CompUnitSP    GetCompUnitAtIndex(size_t cu_idx) = 0;
201254721Semaste
202263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_abbrev_data ();
203263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_aranges_data ();
204263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_frame_data ();
205263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_info_data ();
206263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_line_data ();
207263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_loc_data ();
208263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_ranges_data ();
209263363Semaste    const lldb_private::DWARFDataExtractor&     get_debug_str_data ();
210263363Semaste    const lldb_private::DWARFDataExtractor&     get_apple_names_data ();
211263363Semaste    const lldb_private::DWARFDataExtractor&     get_apple_types_data ();
212263363Semaste    const lldb_private::DWARFDataExtractor&     get_apple_namespaces_data ();
213263363Semaste    const lldb_private::DWARFDataExtractor&     get_apple_objc_data ();
214254721Semaste
215254721Semaste
216254721Semaste    DWARFDebugAbbrev*       DebugAbbrev();
217254721Semaste    const DWARFDebugAbbrev* DebugAbbrev() const;
218254721Semaste
219254721Semaste    DWARFDebugInfo*         DebugInfo();
220254721Semaste    const DWARFDebugInfo*   DebugInfo() const;
221254721Semaste
222254721Semaste    DWARFDebugRanges*       DebugRanges();
223254721Semaste    const DWARFDebugRanges* DebugRanges() const;
224254721Semaste
225263363Semaste    const lldb_private::DWARFDataExtractor&
226254721Semaste    GetCachedSectionData (uint32_t got_flag,
227254721Semaste                          lldb::SectionType sect_type,
228263363Semaste                          lldb_private::DWARFDataExtractor &data);
229254721Semaste
230254721Semaste    static bool
231254721Semaste    SupportedVersion(uint16_t version);
232254721Semaste
233254721Semaste    clang::DeclContext *
234254721Semaste    GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die)
235254721Semaste    {
236254721Semaste        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die);
237254721Semaste        if (pos != m_die_to_decl_ctx.end())
238254721Semaste            return pos->second;
239254721Semaste        else
240254721Semaste            return NULL;
241254721Semaste    }
242254721Semaste
243254721Semaste    clang::DeclContext *
244254721Semaste    GetClangDeclContextForDIE (const lldb_private::SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
245254721Semaste
246254721Semaste    clang::DeclContext *
247254721Semaste    GetClangDeclContextForDIEOffset (const lldb_private::SymbolContext &sc, dw_offset_t die_offset);
248254721Semaste
249254721Semaste    clang::DeclContext *
250254721Semaste    GetClangDeclContextContainingDIE (DWARFCompileUnit *cu,
251254721Semaste                                      const DWARFDebugInfoEntry *die,
252254721Semaste                                      const DWARFDebugInfoEntry **decl_ctx_die);
253254721Semaste
254254721Semaste    clang::DeclContext *
255254721Semaste    GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset);
256254721Semaste
257254721Semaste    const DWARFDebugInfoEntry *
258254721Semaste    GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
259254721Semaste
260254721Semaste    void
261254721Semaste    SearchDeclContext (const clang::DeclContext *decl_context,
262254721Semaste                       const char *name,
263254721Semaste                       llvm::SmallVectorImpl <clang::NamedDecl *> *results);
264254721Semaste
265254721Semaste    lldb_private::Flags&
266254721Semaste    GetFlags ()
267254721Semaste    {
268254721Semaste        return m_flags;
269254721Semaste    }
270254721Semaste
271254721Semaste    const lldb_private::Flags&
272254721Semaste    GetFlags () const
273254721Semaste    {
274254721Semaste        return m_flags;
275254721Semaste    }
276254721Semaste
277254721Semaste    bool
278254721Semaste    HasForwardDeclForClangType (const lldb_private::ClangASTType &clang_type);
279254721Semaste
280254721Semasteprotected:
281254721Semaste
282254721Semaste    enum
283254721Semaste    {
284254721Semaste        flagsGotDebugAbbrevData     = (1 << 0),
285254721Semaste        flagsGotDebugArangesData    = (1 << 1),
286254721Semaste        flagsGotDebugFrameData      = (1 << 2),
287254721Semaste        flagsGotDebugInfoData       = (1 << 3),
288254721Semaste        flagsGotDebugLineData       = (1 << 4),
289254721Semaste        flagsGotDebugLocData        = (1 << 5),
290254721Semaste        flagsGotDebugMacInfoData    = (1 << 6),
291254721Semaste        flagsGotDebugPubNamesData   = (1 << 7),
292254721Semaste        flagsGotDebugPubTypesData   = (1 << 8),
293254721Semaste        flagsGotDebugRangesData     = (1 << 9),
294254721Semaste        flagsGotDebugStrData        = (1 << 10),
295254721Semaste        flagsGotAppleNamesData      = (1 << 11),
296254721Semaste        flagsGotAppleTypesData      = (1 << 12),
297254721Semaste        flagsGotAppleNamespacesData = (1 << 13),
298254721Semaste        flagsGotAppleObjCData       = (1 << 14)
299254721Semaste    };
300254721Semaste
301254721Semaste    bool                    NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl);
302254721Semaste
303254721Semaste    bool                    DIEIsInNamespace (const lldb_private::ClangNamespaceDecl *namespace_decl,
304254721Semaste                                              DWARFCompileUnit* dwarf_cu,
305254721Semaste                                              const DWARFDebugInfoEntry* die);
306254721Semaste
307254721Semaste    DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF);
308254721Semaste    lldb::CompUnitSP        ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx);
309254721Semaste    DWARFCompileUnit*       GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit);
310254721Semaste    DWARFCompileUnit*       GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu);
311254721Semaste    lldb_private::CompileUnit*      GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx = UINT32_MAX);
312254721Semaste    bool                    GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc);
313254721Semaste    lldb_private::Function *        ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die);
314254721Semaste    size_t                  ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
315254721Semaste                                                 lldb_private::Block *parent_block,
316254721Semaste                                                 DWARFCompileUnit* dwarf_cu,
317254721Semaste                                                 const DWARFDebugInfoEntry *die,
318254721Semaste                                                 lldb::addr_t subprogram_low_pc,
319254721Semaste                                                 uint32_t depth);
320254721Semaste    size_t                  ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children);
321254721Semaste    lldb::TypeSP            ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new);
322254721Semaste    lldb_private::Type*     ResolveTypeUID (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed);
323254721Semaste
324254721Semaste    lldb::VariableSP        ParseVariableDIE(
325254721Semaste                                const lldb_private::SymbolContext& sc,
326254721Semaste                                DWARFCompileUnit* dwarf_cu,
327254721Semaste                                const DWARFDebugInfoEntry *die,
328254721Semaste                                const lldb::addr_t func_low_pc);
329254721Semaste
330254721Semaste    size_t                  ParseVariables(
331254721Semaste                                const lldb_private::SymbolContext& sc,
332254721Semaste                                DWARFCompileUnit* dwarf_cu,
333254721Semaste                                const lldb::addr_t func_low_pc,
334254721Semaste                                const DWARFDebugInfoEntry *die,
335254721Semaste                                bool parse_siblings,
336254721Semaste                                bool parse_children,
337254721Semaste                                lldb_private::VariableList* cc_variable_list = NULL);
338254721Semaste
339254721Semaste    class DelayedAddObjCClassProperty;
340254721Semaste    typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList;
341254721Semaste
342254721Semaste    bool                    ClassOrStructIsVirtual (
343254721Semaste                                DWARFCompileUnit* dwarf_cu,
344254721Semaste                                const DWARFDebugInfoEntry *parent_die);
345254721Semaste
346254721Semaste    size_t                  ParseChildMembers(
347254721Semaste                                const lldb_private::SymbolContext& sc,
348254721Semaste                                DWARFCompileUnit* dwarf_cu,
349254721Semaste                                const DWARFDebugInfoEntry *die,
350254721Semaste                                lldb_private::ClangASTType &class_clang_type,
351254721Semaste                                const lldb::LanguageType class_language,
352254721Semaste                                std::vector<clang::CXXBaseSpecifier *>& base_classes,
353254721Semaste                                std::vector<int>& member_accessibilities,
354254721Semaste                                DWARFDIECollection& member_function_dies,
355254721Semaste                                DelayedPropertyList& delayed_properties,
356254721Semaste                                lldb::AccessType &default_accessibility,
357254721Semaste                                bool &is_a_class,
358254721Semaste                                LayoutInfo &layout_info);
359254721Semaste
360254721Semaste    size_t                  ParseChildParameters(
361254721Semaste                                const lldb_private::SymbolContext& sc,
362254721Semaste                                clang::DeclContext *containing_decl_ctx,
363254721Semaste                                DWARFCompileUnit* dwarf_cu,
364254721Semaste                                const DWARFDebugInfoEntry *parent_die,
365254721Semaste                                bool skip_artificial,
366254721Semaste                                bool &is_static,
367269024Semaste                                bool &is_variadic,
368254721Semaste                                lldb_private::TypeList* type_list,
369254721Semaste                                std::vector<lldb_private::ClangASTType>& function_args,
370254721Semaste                                std::vector<clang::ParmVarDecl*>& function_param_decls,
371254721Semaste                                unsigned &type_quals,
372254721Semaste                                lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
373254721Semaste
374254721Semaste    size_t                  ParseChildEnumerators(
375254721Semaste                                const lldb_private::SymbolContext& sc,
376254721Semaste                                lldb_private::ClangASTType &clang_type,
377254721Semaste                                bool is_signed,
378254721Semaste                                uint32_t enumerator_byte_size,
379254721Semaste                                DWARFCompileUnit* dwarf_cu,
380254721Semaste                                const DWARFDebugInfoEntry *enum_die);
381254721Semaste
382254721Semaste    void                    ParseChildArrayInfo(
383254721Semaste                                const lldb_private::SymbolContext& sc,
384254721Semaste                                DWARFCompileUnit* dwarf_cu,
385254721Semaste                                const DWARFDebugInfoEntry *parent_die,
386254721Semaste                                int64_t& first_index,
387254721Semaste                                std::vector<uint64_t>& element_orders,
388254721Semaste                                uint32_t& byte_stride,
389254721Semaste                                uint32_t& bit_stride);
390254721Semaste
391254721Semaste                            // Given a die_offset, figure out the symbol context representing that die.
392254721Semaste    bool                    ResolveFunction (dw_offset_t offset,
393254721Semaste                                             DWARFCompileUnit *&dwarf_cu,
394254721Semaste                                             lldb_private::SymbolContextList& sc_list);
395254721Semaste
396254721Semaste    bool                    ResolveFunction (DWARFCompileUnit *cu,
397254721Semaste                                             const DWARFDebugInfoEntry *die,
398254721Semaste                                             lldb_private::SymbolContextList& sc_list);
399254721Semaste
400254721Semaste    bool                    FunctionDieMatchesPartialName (
401254721Semaste                                const DWARFDebugInfoEntry* die,
402254721Semaste                                const DWARFCompileUnit *dwarf_cu,
403254721Semaste                                uint32_t name_type_mask,
404254721Semaste                                const char *partial_name,
405254721Semaste                                const char *base_name_start,
406254721Semaste                                const char *base_name_end);
407254721Semaste
408254721Semaste    void                    FindFunctions(
409254721Semaste                                const lldb_private::ConstString &name,
410254721Semaste                                const NameToDIE &name_to_die,
411254721Semaste                                lldb_private::SymbolContextList& sc_list);
412254721Semaste
413254721Semaste    void                    FindFunctions (
414254721Semaste                                const lldb_private::RegularExpression &regex,
415254721Semaste                                const NameToDIE &name_to_die,
416254721Semaste                                lldb_private::SymbolContextList& sc_list);
417254721Semaste
418254721Semaste    void                    FindFunctions (
419254721Semaste                                const lldb_private::RegularExpression &regex,
420254721Semaste                                const DWARFMappedHash::MemoryTable &memory_table,
421254721Semaste                                lldb_private::SymbolContextList& sc_list);
422254721Semaste
423254721Semaste    lldb::TypeSP            FindDefinitionTypeForDIE (
424254721Semaste                                DWARFCompileUnit* dwarf_cu,
425254721Semaste                                const DWARFDebugInfoEntry *die,
426254721Semaste                                const lldb_private::ConstString &type_name);
427254721Semaste
428254721Semaste    lldb::TypeSP            FindDefinitionTypeForDWARFDeclContext (
429254721Semaste                                const DWARFDeclContext &die_decl_ctx);
430254721Semaste
431254721Semaste    lldb::TypeSP            FindCompleteObjCDefinitionTypeForDIE (
432254721Semaste                                const DWARFDebugInfoEntry *die,
433254721Semaste                                const lldb_private::ConstString &type_name,
434254721Semaste                                bool must_be_implementation);
435254721Semaste
436254721Semaste    bool                    Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu);
437254721Semaste
438254721Semaste    lldb::TypeSP            FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name,
439254721Semaste                                                            bool header_definition_ok);
440254721Semaste
441254721Semaste    lldb_private::Symbol *  GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name);
442254721Semaste
443254721Semaste    void                    ParseFunctions (const DIEArray &die_offsets,
444254721Semaste                                            lldb_private::SymbolContextList& sc_list);
445254721Semaste    lldb::TypeSP            GetTypeForDIE (DWARFCompileUnit *cu,
446254721Semaste                                           const DWARFDebugInfoEntry* die);
447254721Semaste
448254721Semaste    uint32_t                FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types);
449254721Semaste
450254721Semaste    void                    Index();
451254721Semaste
452254721Semaste    void                    DumpIndexes();
453254721Semaste
454254721Semaste    void                    SetDebugMapModule (const lldb::ModuleSP &module_sp)
455254721Semaste                            {
456254721Semaste                                m_debug_map_module_wp = module_sp;
457254721Semaste                            }
458254721Semaste
459254721Semaste    SymbolFileDWARFDebugMap *
460254721Semaste                            GetDebugMapSymfile ();
461254721Semaste
462254721Semaste    const DWARFDebugInfoEntry *
463254721Semaste                            FindBlockContainingSpecification (dw_offset_t func_die_offset,
464254721Semaste                                                              dw_offset_t spec_block_die_offset,
465254721Semaste                                                              DWARFCompileUnit **dwarf_cu_handle);
466254721Semaste
467254721Semaste    const DWARFDebugInfoEntry *
468254721Semaste                            FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu,
469254721Semaste                                                              const DWARFDebugInfoEntry *die,
470254721Semaste                                                              dw_offset_t spec_block_die_offset,
471254721Semaste                                                              DWARFCompileUnit **dwarf_cu_handle);
472254721Semaste
473254721Semaste    clang::NamespaceDecl *
474254721Semaste    ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die);
475254721Semaste
476254721Semaste    UniqueDWARFASTTypeMap &
477254721Semaste    GetUniqueDWARFASTTypeMap ();
478254721Semaste
479254721Semaste    void                    LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
480254721Semaste                                                  const DWARFDebugInfoEntry *die)
481254721Semaste                            {
482254721Semaste                                m_die_to_decl_ctx[die] = decl_ctx;
483254721Semaste                                // There can be many DIEs for a single decl context
484254721Semaste                                m_decl_ctx_to_die[decl_ctx].insert(die);
485254721Semaste                            }
486254721Semaste
487254721Semaste    bool
488254721Semaste    UserIDMatches (lldb::user_id_t uid) const
489254721Semaste    {
490254721Semaste        const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull;
491254721Semaste        if (high_uid)
492254721Semaste            return high_uid == GetID();
493254721Semaste        return true;
494254721Semaste    }
495254721Semaste
496254721Semaste    lldb::user_id_t
497254721Semaste    MakeUserID (dw_offset_t die_offset) const
498254721Semaste    {
499254721Semaste        return GetID() | die_offset;
500254721Semaste    }
501254721Semaste
502254721Semaste    static bool
503254721Semaste    DeclKindIsCXXClass (clang::Decl::Kind decl_kind)
504254721Semaste    {
505254721Semaste        switch (decl_kind)
506254721Semaste        {
507254721Semaste            case clang::Decl::CXXRecord:
508254721Semaste            case clang::Decl::ClassTemplateSpecialization:
509254721Semaste                return true;
510254721Semaste            default:
511254721Semaste                break;
512254721Semaste        }
513254721Semaste        return false;
514254721Semaste    }
515254721Semaste
516254721Semaste    bool
517254721Semaste    ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu,
518254721Semaste                                 const DWARFDebugInfoEntry *parent_die,
519254721Semaste                                 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
520254721Semaste
521254721Semaste    bool
522254721Semaste    ParseTemplateDIE (DWARFCompileUnit* dwarf_cu,
523254721Semaste                      const DWARFDebugInfoEntry *die,
524254721Semaste                      lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
525254721Semaste
526254721Semaste    clang::ClassTemplateDecl *
527254721Semaste    ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
528254721Semaste                            lldb::AccessType access_type,
529254721Semaste                            const char *parent_name,
530254721Semaste                            int tag_decl_kind,
531254721Semaste                            const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
532254721Semaste
533254721Semaste    bool
534254721Semaste    DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1,
535254721Semaste                          DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2);
536254721Semaste
537254721Semaste    bool
538254721Semaste    ClassContainsSelector (DWARFCompileUnit *dwarf_cu,
539254721Semaste                           const DWARFDebugInfoEntry *class_die,
540254721Semaste                           const lldb_private::ConstString &selector);
541254721Semaste
542254721Semaste    bool
543254721Semaste    CopyUniqueClassMethodTypes (SymbolFileDWARF *class_symfile,
544254721Semaste                                lldb_private::Type *class_type,
545254721Semaste                                DWARFCompileUnit* src_cu,
546254721Semaste                                const DWARFDebugInfoEntry *src_class_die,
547254721Semaste                                DWARFCompileUnit* dst_cu,
548254721Semaste                                const DWARFDebugInfoEntry *dst_class_die,
549254721Semaste                                llvm::SmallVectorImpl <const DWARFDebugInfoEntry *> &failures);
550254721Semaste
551254721Semaste    bool
552254721Semaste    FixupAddress (lldb_private::Address &addr);
553254721Semaste
554254721Semaste    typedef std::set<lldb_private::Type *> TypeSet;
555254721Semaste
556254721Semaste    void
557254721Semaste    GetTypes (DWARFCompileUnit* dwarf_cu,
558254721Semaste              const DWARFDebugInfoEntry *die,
559254721Semaste              dw_offset_t min_die_offset,
560254721Semaste              dw_offset_t max_die_offset,
561254721Semaste              uint32_t type_mask,
562254721Semaste              TypeSet &type_set);
563254721Semaste
564263363Semaste    lldb::ModuleWP                        m_debug_map_module_wp;
565263363Semaste    SymbolFileDWARFDebugMap *             m_debug_map_symfile;
566263363Semaste    clang::TranslationUnitDecl *          m_clang_tu_decl;
567263363Semaste    lldb_private::Flags                   m_flags;
568263363Semaste    lldb_private::DWARFDataExtractor      m_dwarf_data;
569263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_abbrev;
570263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_aranges;
571263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_frame;
572263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_info;
573263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_line;
574263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_loc;
575263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_ranges;
576263363Semaste    lldb_private::DWARFDataExtractor      m_data_debug_str;
577263363Semaste    lldb_private::DWARFDataExtractor      m_data_apple_names;
578263363Semaste    lldb_private::DWARFDataExtractor      m_data_apple_types;
579263363Semaste    lldb_private::DWARFDataExtractor      m_data_apple_namespaces;
580263363Semaste    lldb_private::DWARFDataExtractor      m_data_apple_objc;
581254721Semaste
582254721Semaste    // The unique pointer items below are generated on demand if and when someone accesses
583254721Semaste    // them through a non const version of this class.
584254721Semaste    std::unique_ptr<DWARFDebugAbbrev>     m_abbr;
585254721Semaste    std::unique_ptr<DWARFDebugInfo>       m_info;
586254721Semaste    std::unique_ptr<DWARFDebugLine>       m_line;
587254721Semaste    std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_names_ap;
588254721Semaste    std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_types_ap;
589254721Semaste    std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_namespaces_ap;
590254721Semaste    std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_objc_ap;
591254721Semaste    NameToDIE                           m_function_basename_index;  // All concrete functions
592254721Semaste    NameToDIE                           m_function_fullname_index;  // All concrete functions
593254721Semaste    NameToDIE                           m_function_method_index;    // All inlined functions
594254721Semaste    NameToDIE                           m_function_selector_index;  // All method names for functions of classes
595254721Semaste    NameToDIE                           m_objc_class_selectors_index; // Given a class name, find all selectors for the class
596254721Semaste    NameToDIE                           m_global_index;             // Global and static variables
597254721Semaste    NameToDIE                           m_type_index;               // All type DIE offsets
598254721Semaste    NameToDIE                           m_namespace_index;          // All type DIE offsets
599254721Semaste    bool                                m_indexed:1,
600254721Semaste                                        m_is_external_ast_source:1,
601254721Semaste                                        m_using_apple_tables:1;
602254721Semaste    lldb_private::LazyBool              m_supports_DW_AT_APPLE_objc_complete_type;
603254721Semaste
604254721Semaste    std::unique_ptr<DWARFDebugRanges>     m_ranges;
605254721Semaste    UniqueDWARFASTTypeMap m_unique_ast_type_map;
606254721Semaste    typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
607254721Semaste    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
608254721Semaste    typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
609254721Semaste    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
610254721Semaste    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
611254721Semaste    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType;
612254721Semaste    typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE;
613254721Semaste    typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap;
614254721Semaste    DIEToDeclContextMap m_die_to_decl_ctx;
615254721Semaste    DeclContextToDIEMap m_decl_ctx_to_die;
616254721Semaste    DIEToTypePtr m_die_to_type;
617254721Semaste    DIEToVariableSP m_die_to_variable_sp;
618254721Semaste    DIEToClangType m_forward_decl_die_to_clang_type;
619254721Semaste    ClangTypeToDIE m_forward_decl_clang_type_to_die;
620254721Semaste    RecordDeclToLayoutMap m_record_decl_to_layout_map;
621254721Semaste};
622254721Semaste
623254721Semaste#endif  // SymbolFileDWARF_SymbolFileDWARF_h_
624