xref: /freebsd-src/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIASectionContrib.cpp (revision 5b27928474e6a4103d65b347544705c40c9618fd)
10b57cec5SDimitry Andric //===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
100b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
110b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
120b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric using namespace llvm;
150b57cec5SDimitry Andric using namespace llvm::pdb;
160b57cec5SDimitry Andric 
DIASectionContrib(const DIASession & PDBSession,CComPtr<IDiaSectionContrib> DiaSection)170b57cec5SDimitry Andric DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
180b57cec5SDimitry Andric                                      CComPtr<IDiaSectionContrib> DiaSection)
190b57cec5SDimitry Andric   : Session(PDBSession), Section(DiaSection) {}
200b57cec5SDimitry Andric 
getCompiland() const210b57cec5SDimitry Andric std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const {
220b57cec5SDimitry Andric   CComPtr<IDiaSymbol> Symbol;
230b57cec5SDimitry Andric   if (FAILED(Section->get_compiland(&Symbol)))
240b57cec5SDimitry Andric     return nullptr;
250b57cec5SDimitry Andric 
26*8bcb0991SDimitry Andric   auto RawSymbol = std::make_unique<DIARawSymbol>(Session, Symbol);
270b57cec5SDimitry Andric   return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol));
280b57cec5SDimitry Andric }
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric template <typename ArgType>
310b57cec5SDimitry Andric ArgType
PrivateGetDIAValue(IDiaSectionContrib * Section,HRESULT (__stdcall IDiaSectionContrib::* Method)(ArgType *))320b57cec5SDimitry Andric PrivateGetDIAValue(IDiaSectionContrib *Section,
330b57cec5SDimitry Andric                    HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
340b57cec5SDimitry Andric   ArgType Value;
350b57cec5SDimitry Andric   if (S_OK == (Section->*Method)(&Value))
360b57cec5SDimitry Andric     return static_cast<ArgType>(Value);
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   return ArgType();
390b57cec5SDimitry Andric }
400b57cec5SDimitry Andric 
getAddressSection() const410b57cec5SDimitry Andric uint32_t DIASectionContrib::getAddressSection() const {
420b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
430b57cec5SDimitry Andric }
440b57cec5SDimitry Andric 
getAddressOffset() const450b57cec5SDimitry Andric uint32_t DIASectionContrib::getAddressOffset() const {
460b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
470b57cec5SDimitry Andric }
480b57cec5SDimitry Andric 
getVirtualAddress() const490b57cec5SDimitry Andric uint64_t DIASectionContrib::getVirtualAddress() const {
500b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
510b57cec5SDimitry Andric }
520b57cec5SDimitry Andric 
getRelativeVirtualAddress() const530b57cec5SDimitry Andric uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
540b57cec5SDimitry Andric   return PrivateGetDIAValue(Section,
550b57cec5SDimitry Andric                             &IDiaSectionContrib::get_relativeVirtualAddress);
560b57cec5SDimitry Andric }
570b57cec5SDimitry Andric 
getLength() const580b57cec5SDimitry Andric uint32_t DIASectionContrib::getLength() const {
590b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
600b57cec5SDimitry Andric }
610b57cec5SDimitry Andric 
isNotPaged() const620b57cec5SDimitry Andric bool DIASectionContrib::isNotPaged() const {
630b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
640b57cec5SDimitry Andric }
650b57cec5SDimitry Andric 
hasCode() const660b57cec5SDimitry Andric bool DIASectionContrib::hasCode() const {
670b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
680b57cec5SDimitry Andric }
690b57cec5SDimitry Andric 
hasCode16Bit() const700b57cec5SDimitry Andric bool DIASectionContrib::hasCode16Bit() const {
710b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
720b57cec5SDimitry Andric }
730b57cec5SDimitry Andric 
hasInitializedData() const740b57cec5SDimitry Andric bool DIASectionContrib::hasInitializedData() const {
750b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
760b57cec5SDimitry Andric }
770b57cec5SDimitry Andric 
hasUninitializedData() const780b57cec5SDimitry Andric bool DIASectionContrib::hasUninitializedData() const {
790b57cec5SDimitry Andric   return PrivateGetDIAValue(Section,
800b57cec5SDimitry Andric                             &IDiaSectionContrib::get_uninitializedData);
810b57cec5SDimitry Andric }
820b57cec5SDimitry Andric 
isRemoved() const830b57cec5SDimitry Andric bool DIASectionContrib::isRemoved() const {
840b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
850b57cec5SDimitry Andric }
860b57cec5SDimitry Andric 
hasComdat() const870b57cec5SDimitry Andric bool DIASectionContrib::hasComdat() const {
880b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
890b57cec5SDimitry Andric }
900b57cec5SDimitry Andric 
isDiscardable() const910b57cec5SDimitry Andric bool DIASectionContrib::isDiscardable() const {
920b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
930b57cec5SDimitry Andric }
940b57cec5SDimitry Andric 
isNotCached() const950b57cec5SDimitry Andric bool DIASectionContrib::isNotCached() const {
960b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
970b57cec5SDimitry Andric }
980b57cec5SDimitry Andric 
isShared() const990b57cec5SDimitry Andric bool DIASectionContrib::isShared() const {
1000b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
1010b57cec5SDimitry Andric }
1020b57cec5SDimitry Andric 
isExecutable() const1030b57cec5SDimitry Andric bool DIASectionContrib::isExecutable() const {
1040b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
1050b57cec5SDimitry Andric }
1060b57cec5SDimitry Andric 
isReadable() const1070b57cec5SDimitry Andric bool DIASectionContrib::isReadable() const {
1080b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
1090b57cec5SDimitry Andric }
1100b57cec5SDimitry Andric 
isWritable() const1110b57cec5SDimitry Andric bool DIASectionContrib::isWritable() const {
1120b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
1130b57cec5SDimitry Andric }
1140b57cec5SDimitry Andric 
getDataCrc32() const1150b57cec5SDimitry Andric uint32_t DIASectionContrib::getDataCrc32() const {
1160b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
1170b57cec5SDimitry Andric }
1180b57cec5SDimitry Andric 
getRelocationsCrc32() const1190b57cec5SDimitry Andric uint32_t DIASectionContrib::getRelocationsCrc32() const {
1200b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
1210b57cec5SDimitry Andric }
1220b57cec5SDimitry Andric 
getCompilandId() const1230b57cec5SDimitry Andric uint32_t DIASectionContrib::getCompilandId() const {
1240b57cec5SDimitry Andric   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
1250b57cec5SDimitry Andric }
126