llvm.org GIT mirror llvm / 45e7e93
Move DIContext.h to common DebugInfo location. This will enable us to create a PDBContext so as to expose some amount of debug info functionality through a common interace. Differential Revision: http://reviews.llvm.org/D9205 Reviewed by: Alexey Samsonov git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235612 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 4 years ago
14 changed file(s) with 168 addition(s) and 183 deletion(s). Raw diff Collapse all Expand all
0 //===-- DIContext.h ---------------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines DIContext, an abstract data structure that holds
10 // debug information data.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_DEBUGINFO_DICONTEXT_H
15 #define LLVM_DEBUGINFO_DICONTEXT_H
16
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Object/ObjectFile.h"
20 #include "llvm/Object/RelocVisitor.h"
21 #include "llvm/Support/Casting.h"
22 #include "llvm/Support/DataTypes.h"
23 #include
24
25 namespace llvm {
26
27 class raw_ostream;
28
29 /// DILineInfo - a format-neutral container for source line information.
30 struct DILineInfo {
31 std::string FileName;
32 std::string FunctionName;
33 uint32_t Line;
34 uint32_t Column;
35
36 DILineInfo()
37 : FileName(""), FunctionName(""), Line(0), Column(0) {}
38
39 bool operator==(const DILineInfo &RHS) const {
40 return Line == RHS.Line && Column == RHS.Column &&
41 FileName == RHS.FileName && FunctionName == RHS.FunctionName;
42 }
43 bool operator!=(const DILineInfo &RHS) const {
44 return !(*this == RHS);
45 }
46 };
47
48 typedef SmallVector, 16> DILineInfoTable;
49
50 /// DIInliningInfo - a format-neutral container for inlined code description.
51 class DIInliningInfo {
52 SmallVector Frames;
53 public:
54 DIInliningInfo() {}
55 DILineInfo getFrame(unsigned Index) const {
56 assert(Index < Frames.size());
57 return Frames[Index];
58 }
59 uint32_t getNumberOfFrames() const {
60 return Frames.size();
61 }
62 void addFrame(const DILineInfo &Frame) {
63 Frames.push_back(Frame);
64 }
65 };
66
67 /// A DINameKind is passed to name search methods to specify a
68 /// preference regarding the type of name resolution the caller wants.
69 enum class DINameKind { None, ShortName, LinkageName };
70
71 /// DILineInfoSpecifier - controls which fields of DILineInfo container
72 /// should be filled with data.
73 struct DILineInfoSpecifier {
74 enum class FileLineInfoKind { None, Default, AbsoluteFilePath };
75 typedef DINameKind FunctionNameKind;
76
77 FileLineInfoKind FLIKind;
78 FunctionNameKind FNKind;
79
80 DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::Default,
81 FunctionNameKind FNKind = FunctionNameKind::None)
82 : FLIKind(FLIKind), FNKind(FNKind) {}
83 };
84
85 /// Selects which debug sections get dumped.
86 enum DIDumpType {
87 DIDT_Null,
88 DIDT_All,
89 DIDT_Abbrev,
90 DIDT_AbbrevDwo,
91 DIDT_Aranges,
92 DIDT_Frames,
93 DIDT_Info,
94 DIDT_InfoDwo,
95 DIDT_Types,
96 DIDT_TypesDwo,
97 DIDT_Line,
98 DIDT_LineDwo,
99 DIDT_Loc,
100 DIDT_LocDwo,
101 DIDT_Ranges,
102 DIDT_Pubnames,
103 DIDT_Pubtypes,
104 DIDT_GnuPubnames,
105 DIDT_GnuPubtypes,
106 DIDT_Str,
107 DIDT_StrDwo,
108 DIDT_StrOffsetsDwo,
109 DIDT_AppleNames,
110 DIDT_AppleTypes,
111 DIDT_AppleNamespaces,
112 DIDT_AppleObjC
113 };
114
115 class DIContext {
116 public:
117 enum DIContextKind {
118 CK_DWARF,
119 CK_PDB
120 };
121 DIContextKind getKind() const { return Kind; }
122
123 DIContext(DIContextKind K) : Kind(K) {}
124 virtual ~DIContext() {}
125
126 virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) = 0;
127
128 virtual DILineInfo getLineInfoForAddress(uint64_t Address,
129 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
130 virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,
131 uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
132 virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,
133 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
134 private:
135 const DIContextKind Kind;
136 };
137
138 }
139
140 #endif
+0
-150
include/llvm/DebugInfo/DWARF/DIContext.h less more
None //===-- DIContext.h ---------------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines DIContext, an abstract data structure that holds
10 // debug information data.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_DEBUGINFO_DICONTEXT_H
15 #define LLVM_DEBUGINFO_DICONTEXT_H
16
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Object/ObjectFile.h"
20 #include "llvm/Object/RelocVisitor.h"
21 #include "llvm/Support/Casting.h"
22 #include "llvm/Support/DataTypes.h"
23 #include
24
25 namespace llvm {
26
27 class raw_ostream;
28
29 /// DILineInfo - a format-neutral container for source line information.
30 struct DILineInfo {
31 std::string FileName;
32 std::string FunctionName;
33 uint32_t Line;
34 uint32_t Column;
35
36 DILineInfo()
37 : FileName(""), FunctionName(""), Line(0), Column(0) {}
38
39 bool operator==(const DILineInfo &RHS) const {
40 return Line == RHS.Line && Column == RHS.Column &&
41 FileName == RHS.FileName && FunctionName == RHS.FunctionName;
42 }
43 bool operator!=(const DILineInfo &RHS) const {
44 return !(*this == RHS);
45 }
46 };
47
48 typedef SmallVector, 16> DILineInfoTable;
49
50 /// DIInliningInfo - a format-neutral container for inlined code description.
51 class DIInliningInfo {
52 SmallVector Frames;
53 public:
54 DIInliningInfo() {}
55 DILineInfo getFrame(unsigned Index) const {
56 assert(Index < Frames.size());
57 return Frames[Index];
58 }
59 uint32_t getNumberOfFrames() const {
60 return Frames.size();
61 }
62 void addFrame(const DILineInfo &Frame) {
63 Frames.push_back(Frame);
64 }
65 };
66
67 /// A DINameKind is passed to name search methods to specify a
68 /// preference regarding the type of name resolution the caller wants.
69 enum class DINameKind { None, ShortName, LinkageName };
70
71 /// DILineInfoSpecifier - controls which fields of DILineInfo container
72 /// should be filled with data.
73 struct DILineInfoSpecifier {
74 enum class FileLineInfoKind { None, Default, AbsoluteFilePath };
75 typedef DINameKind FunctionNameKind;
76
77 FileLineInfoKind FLIKind;
78 FunctionNameKind FNKind;
79
80 DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::Default,
81 FunctionNameKind FNKind = FunctionNameKind::None)
82 : FLIKind(FLIKind), FNKind(FNKind) {}
83 };
84
85 /// Selects which debug sections get dumped.
86 enum DIDumpType {
87 DIDT_Null,
88 DIDT_All,
89 DIDT_Abbrev,
90 DIDT_AbbrevDwo,
91 DIDT_Aranges,
92 DIDT_Frames,
93 DIDT_Info,
94 DIDT_InfoDwo,
95 DIDT_Types,
96 DIDT_TypesDwo,
97 DIDT_Line,
98 DIDT_LineDwo,
99 DIDT_Loc,
100 DIDT_LocDwo,
101 DIDT_Ranges,
102 DIDT_Pubnames,
103 DIDT_Pubtypes,
104 DIDT_GnuPubnames,
105 DIDT_GnuPubtypes,
106 DIDT_Str,
107 DIDT_StrDwo,
108 DIDT_StrOffsetsDwo,
109 DIDT_AppleNames,
110 DIDT_AppleTypes,
111 DIDT_AppleNamespaces,
112 DIDT_AppleObjC
113 };
114
115 // In place of applying the relocations to the data we've read from disk we use
116 // a separate mapping table to the side and checking that at locations in the
117 // dwarf where we expect relocated values. This adds a bit of complexity to the
118 // dwarf parsing/extraction at the benefit of not allocating memory for the
119 // entire size of the debug info sections.
120 typedef DenseMap > RelocAddrMap;
121
122 class DIContext {
123 public:
124 enum DIContextKind {
125 CK_DWARF
126 };
127 DIContextKind getKind() const { return Kind; }
128
129 DIContext(DIContextKind K) : Kind(K) {}
130 virtual ~DIContext();
131
132 /// getDWARFContext - get a context for binary DWARF data.
133 static DIContext *getDWARFContext(const object::ObjectFile &Obj);
134
135 virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) = 0;
136
137 virtual DILineInfo getLineInfoForAddress(uint64_t Address,
138 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
139 virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,
140 uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
141 virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,
142 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
143 private:
144 const DIContextKind Kind;
145 };
146
147 }
148
149 #endif
1111
1212 #include "llvm/ADT/MapVector.h"
1313 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/DWARF/DIContext.h"
14 #include "llvm/DebugInfo/DIContext.h"
1515 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
1616 #include "llvm/DebugInfo/DWARF/DWARFDebugAranges.h"
1717 #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h"
2323 #include
2424
2525 namespace llvm {
26
27 // In place of applying the relocations to the data we've read from disk we use
28 // a separate mapping table to the side and checking that at locations in the
29 // dwarf where we expect relocated values. This adds a bit of complexity to the
30 // dwarf parsing/extraction at the benefit of not allocating memory for the
31 // entire size of the debug info sections.
32 typedef DenseMap > RelocAddrMap;
2633
2734 /// DWARFContext
2835 /// This data structure is the top level entity that deals with dwarf debug
1010 #define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
1111
1212 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/DebugInfo/DWARF/DIContext.h"
13 #include "llvm/DebugInfo/DIContext.h"
1414 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
1515 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
1616 #include "llvm/Support/DataTypes.h"
99 #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H
1010 #define LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H
1111
12 #include "llvm/DebugInfo/DWARF/DIContext.h"
12 #include "llvm/DebugInfo/DIContext.h"
1313 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
1414 #include "llvm/Support/DataExtractor.h"
1515 #include
0 add_llvm_library(LLVMDebugInfoDWARF
1 DIContext.cpp
21 DWARFAbbreviationDeclaration.cpp
32 DWARFAcceleratorTable.cpp
43 DWARFCompileUnit.cpp
1817
1918 ADDITIONAL_HEADER_DIRS
2019 ${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/DWARF
20 ${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo
2121 )
+0
-18
lib/DebugInfo/DWARF/DIContext.cpp less more
None //===-- DIContext.cpp -----------------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/DWARF/DIContext.h"
10 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
11 using namespace llvm;
12
13 DIContext::~DIContext() {}
14
15 DIContext *DIContext::getDWARFContext(const object::ObjectFile &Obj) {
16 return new DWARFContextInMemory(Obj);
17 }
255255 return;
256256 DWOFile = std::move(Obj.get());
257257 DWOContext.reset(
258 cast(DIContext::getDWARFContext(*DWOFile.getBinary())));
258 cast(new DWARFContextInMemory(*DWOFile.getBinary())));
259259 if (DWOContext->getNumDWOCompileUnits() > 0)
260260 DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
261261 }
1515 #include "IntelJITEventsWrapper.h"
1616 #include "llvm/ADT/DenseMap.h"
1717 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/DebugInfo/DWARF/DIContext.h"
18 #include "llvm/DebugInfo/DIContext.h"
19 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1920 #include "llvm/ExecutionEngine/JITEventListener.h"
2021 #include "llvm/IR/DebugInfo.h"
2122 #include "llvm/IR/Function.h"
101102
102103 // Get the address of the object image for use as a unique identifier
103104 const void* ObjData = DebugObj.getData().data();
104 DIContext* Context = DIContext::getDWARFContext(DebugObj);
105 DIContext* Context = new DWARFContextInMemory(DebugObj);
105106 MethodAddressVector Functions;
106107
107108 // Use symbol info to iterate functions in the object.
1212
1313 #include "llvm/ADT/STLExtras.h"
1414 #include "llvm/ADT/Triple.h"
15 #include "llvm/DebugInfo/DWARF/DIContext.h"
15 #include "llvm/DebugInfo/DIContext.h"
16 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1617 #include "llvm/Object/ObjectFile.h"
1718 #include "llvm/Object/RelocVisitor.h"
1819 #include "llvm/Support/CommandLine.h"
8586 }
8687 ObjectFile &Obj = *ObjOrErr.get();
8788
88 std::unique_ptr DICtx(DIContext::getDWARFContext(Obj));
89 std::unique_ptr DICtx(new DWARFContextInMemory(Obj));
8990
9091 outs() << Filename
9192 << ":\tfile format " << Obj.getFileFormatName() << "\n\n";
1616 #include "llvm/ADT/StringExtras.h"
1717 #include "llvm/ADT/Triple.h"
1818 #include "llvm/Config/config.h"
19 #include "llvm/DebugInfo/DWARF/DIContext.h"
19 #include "llvm/DebugInfo/DIContext.h"
20 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
2021 #include "llvm/MC/MCAsmInfo.h"
2122 #include "llvm/MC/MCContext.h"
2223 #include "llvm/MC/MCDisassembler.h"
61146115 }
61156116
61166117 // Setup the DIContext
6117 diContext.reset(DIContext::getDWARFContext(*DbgObj));
6118 diContext.reset(new DWARFContextInMemory(*DbgObj));
61186119 }
61196120
61206121 if (DumpSections.size() == 0)
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/ADT/StringMap.h"
14 #include "llvm/DebugInfo/DWARF/DIContext.h"
14 #include "llvm/DebugInfo/DIContext.h"
15 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1516 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
1617 #include "llvm/ExecutionEngine/RuntimeDyld.h"
1718 #include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
226227 OwningBinary DebugObj = LoadedObjInfo->getObjectForDebug(Obj);
227228
228229 std::unique_ptr Context(
229 DIContext::getDWARFContext(*DebugObj.getBinary()));
230 new DWARFContextInMemory(*DebugObj.getBinary()));
230231
231232 // Use symbol info to iterate functions in the object.
232233 for (object::symbol_iterator I = DebugObj.getBinary()->symbol_begin(),
1313 #include "LLVMSymbolize.h"
1414 #include "llvm/ADT/STLExtras.h"
1515 #include "llvm/Config/config.h"
16 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1617 #include "llvm/Object/ELFObjectFile.h"
1718 #include "llvm/Object/MachO.h"
1819 #include "llvm/Support/Casting.h"
459460 Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr));
460461 return nullptr;
461462 }
462 DIContext *Context = DIContext::getDWARFContext(*Objects.second);
463 DIContext *Context = new DWARFContextInMemory(*Objects.second);
463464 assert(Context);
464465 ModuleInfo *Info = new ModuleInfo(Objects.first, Context);
465466 Modules.insert(make_pair(ModuleName, Info));
1313 #define LLVM_TOOLS_LLVM_SYMBOLIZER_LLVMSYMBOLIZE_H
1414
1515 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/DebugInfo/DWARF/DIContext.h"
16 #include "llvm/DebugInfo/DIContext.h"
1717 #include "llvm/Object/MachOUniversal.h"
1818 #include "llvm/Object/ObjectFile.h"
1919 #include "llvm/Support/DataExtractor.h"