1 //===-- SymbolFileDWARFDwo.h ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
11 
12 #include "SymbolFileDWARF.h"
13 #include <optional>
14 
15 namespace lldb_private::plugin {
16 namespace dwarf {
17 class SymbolFileDWARFDwo : public SymbolFileDWARF {
18   /// LLVM RTTI support.
19   static char ID;
20 
21 public:
22   /// LLVM RTTI support.
23   /// \{
isA(const void * ClassID)24   bool isA(const void *ClassID) const override {
25     return ClassID == &ID || SymbolFileDWARF::isA(ClassID);
26   }
classof(const SymbolFile * obj)27   static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
28   /// \}
29 
30   SymbolFileDWARFDwo(SymbolFileDWARF &m_base_symbol_file,
31                      lldb::ObjectFileSP objfile, uint32_t id);
32 
33   ~SymbolFileDWARFDwo() override = default;
34 
35   DWARFCompileUnit *GetDWOCompileUnitForHash(uint64_t hash);
36 
37   void GetObjCMethods(ConstString class_name,
38                       llvm::function_ref<bool(DWARFDIE die)> callback) override;
39 
40   llvm::Expected<lldb::TypeSystemSP>
41   GetTypeSystemForLanguage(lldb::LanguageType language) override;
42 
43   DWARFDIE
44   GetDIE(const DIERef &die_ref) override;
45 
46   lldb::offset_t GetVendorDWARFOpcodeSize(const DataExtractor &data,
47                                           const lldb::offset_t data_offset,
48                                           const uint8_t op) const override;
49 
50   bool ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
51                               lldb::offset_t &offset,
52                               std::vector<Value> &stack) const override;
53 
54   void FindGlobalVariables(ConstString name,
55                            const CompilerDeclContext &parent_decl_ctx,
56                            uint32_t max_matches,
57                            VariableList &variables) override;
58 
59 protected:
60   DIEToTypePtr &GetDIEToType() override;
61 
62   DIEToVariableSP &GetDIEToVariable() override;
63 
64   DIEToCompilerType &GetForwardDeclDIEToCompilerType() override;
65 
66   CompilerTypeToDIE &GetForwardDeclCompilerTypeToDIE() override;
67 
68   UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() override;
69 
70   lldb::TypeSP
71   FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) override;
72 
73   lldb::TypeSP
74   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die,
75                                        ConstString type_name,
76                                        bool must_be_implementation) override;
77 
GetBaseSymbolFile()78   SymbolFileDWARF &GetBaseSymbolFile() const { return m_base_symbol_file; }
79 
80   /// If this file contains exactly one compile unit, this function will return
81   /// it. Otherwise it returns nullptr.
82   DWARFCompileUnit *FindSingleCompileUnit();
83 
84   SymbolFileDWARF &m_base_symbol_file;
85 };
86 } // namespace dwarf
87 } // namespace lldb_private::plugin
88 
89 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
90