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