DIASectionContrib.cpp
4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
using namespace llvm;
using namespace llvm::pdb;
DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
CComPtr<IDiaSectionContrib> DiaSection)
: Session(PDBSession), Section(DiaSection) {}
std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const {
CComPtr<IDiaSymbol> Symbol;
if (FAILED(Section->get_compiland(&Symbol)))
return nullptr;
auto RawSymbol = std::make_unique<DIARawSymbol>(Session, Symbol);
return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol));
}
template <typename ArgType>
ArgType
PrivateGetDIAValue(IDiaSectionContrib *Section,
HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
ArgType Value;
if (S_OK == (Section->*Method)(&Value))
return static_cast<ArgType>(Value);
return ArgType();
}
uint32_t DIASectionContrib::getAddressSection() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
}
uint32_t DIASectionContrib::getAddressOffset() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
}
uint64_t DIASectionContrib::getVirtualAddress() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
}
uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
return PrivateGetDIAValue(Section,
&IDiaSectionContrib::get_relativeVirtualAddress);
}
uint32_t DIASectionContrib::getLength() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
}
bool DIASectionContrib::isNotPaged() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
}
bool DIASectionContrib::hasCode() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
}
bool DIASectionContrib::hasCode16Bit() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
}
bool DIASectionContrib::hasInitializedData() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
}
bool DIASectionContrib::hasUninitializedData() const {
return PrivateGetDIAValue(Section,
&IDiaSectionContrib::get_uninitializedData);
}
bool DIASectionContrib::isRemoved() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
}
bool DIASectionContrib::hasComdat() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
}
bool DIASectionContrib::isDiscardable() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
}
bool DIASectionContrib::isNotCached() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
}
bool DIASectionContrib::isShared() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
}
bool DIASectionContrib::isExecutable() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
}
bool DIASectionContrib::isReadable() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
}
bool DIASectionContrib::isWritable() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
}
uint32_t DIASectionContrib::getDataCrc32() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
}
uint32_t DIASectionContrib::getRelocationsCrc32() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
}
uint32_t DIASectionContrib::getCompilandId() const {
return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
}