• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- DWARFContext.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_DWARFCONTEXT_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
11 
12 #include "DWARFDataExtractor.h"
13 #include "lldb/Core/Section.h"
14 #include "llvm/ADT/Optional.h"
15 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
16 #include "llvm/Support/Threading.h"
17 #include <memory>
18 
19 namespace lldb_private {
20 class DWARFContext {
21 private:
22   SectionList *m_main_section_list;
23   SectionList *m_dwo_section_list;
24   mutable std::unique_ptr<llvm::DWARFContext> m_llvm_context;
25 
26   struct SectionData {
27     llvm::once_flag flag;
28     DWARFDataExtractor data;
29   };
30 
31   SectionData m_data_debug_abbrev;
32   SectionData m_data_debug_addr;
33   SectionData m_data_debug_aranges;
34   SectionData m_data_debug_cu_index;
35   SectionData m_data_debug_info;
36   SectionData m_data_debug_line;
37   SectionData m_data_debug_line_str;
38   SectionData m_data_debug_loc;
39   SectionData m_data_debug_loclists;
40   SectionData m_data_debug_macro;
41   SectionData m_data_debug_ranges;
42   SectionData m_data_debug_rnglists;
43   SectionData m_data_debug_str;
44   SectionData m_data_debug_str_offsets;
45   SectionData m_data_debug_tu_index;
46   SectionData m_data_debug_types;
47 
48   const DWARFDataExtractor &
49   LoadOrGetSection(llvm::Optional<lldb::SectionType> main_section_type,
50                    llvm::Optional<lldb::SectionType> dwo_section_type,
51                    SectionData &data);
52 
53   const DWARFDataExtractor &getOrLoadCuIndexData();
54   const DWARFDataExtractor &getOrLoadTuIndexData();
55 
56 public:
DWARFContext(SectionList * main_section_list,SectionList * dwo_section_list)57   explicit DWARFContext(SectionList *main_section_list,
58                         SectionList *dwo_section_list)
59       : m_main_section_list(main_section_list),
60         m_dwo_section_list(dwo_section_list) {}
61 
62   const DWARFDataExtractor &getOrLoadAbbrevData();
63   const DWARFDataExtractor &getOrLoadAddrData();
64   const DWARFDataExtractor &getOrLoadArangesData();
65   const DWARFDataExtractor &getOrLoadDebugInfoData();
66   const DWARFDataExtractor &getOrLoadLineData();
67   const DWARFDataExtractor &getOrLoadLineStrData();
68   const DWARFDataExtractor &getOrLoadLocData();
69   const DWARFDataExtractor &getOrLoadLocListsData();
70   const DWARFDataExtractor &getOrLoadMacroData();
71   const DWARFDataExtractor &getOrLoadRangesData();
72   const DWARFDataExtractor &getOrLoadRngListsData();
73   const DWARFDataExtractor &getOrLoadStrData();
74   const DWARFDataExtractor &getOrLoadStrOffsetsData();
75   const DWARFDataExtractor &getOrLoadDebugTypesData();
76 
isDwo()77   bool isDwo() { return m_dwo_section_list != nullptr; }
78 
79   llvm::DWARFContext &GetAsLLVM();
80 };
81 } // namespace lldb_private
82 
83 #endif
84