xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIATable.cpp (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===- DIATable.cpp - DIA implementation of IPDBTable -----------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIATable.h"
10*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
11*0b57cec5SDimitry Andric 
12*0b57cec5SDimitry Andric using namespace llvm;
13*0b57cec5SDimitry Andric using namespace llvm::pdb;
14*0b57cec5SDimitry Andric 
DIATable(CComPtr<IDiaTable> DiaTable)15*0b57cec5SDimitry Andric DIATable::DIATable(CComPtr<IDiaTable> DiaTable) : Table(DiaTable) {}
16*0b57cec5SDimitry Andric 
getItemCount() const17*0b57cec5SDimitry Andric uint32_t DIATable::getItemCount() const {
18*0b57cec5SDimitry Andric   LONG Count = 0;
19*0b57cec5SDimitry Andric   return (S_OK == Table->get_Count(&Count)) ? Count : 0;
20*0b57cec5SDimitry Andric }
21*0b57cec5SDimitry Andric 
getName() const22*0b57cec5SDimitry Andric std::string DIATable::getName() const {
23*0b57cec5SDimitry Andric   return invokeBstrMethod(*Table, &IDiaTable::get_name);
24*0b57cec5SDimitry Andric }
25*0b57cec5SDimitry Andric 
getTableType() const26*0b57cec5SDimitry Andric PDB_TableType DIATable::getTableType() const {
27*0b57cec5SDimitry Andric   CComBSTR Name16;
28*0b57cec5SDimitry Andric   if (S_OK != Table->get_name(&Name16))
29*0b57cec5SDimitry Andric     return PDB_TableType::TableInvalid;
30*0b57cec5SDimitry Andric 
31*0b57cec5SDimitry Andric   if (Name16 == DiaTable_Symbols)
32*0b57cec5SDimitry Andric     return PDB_TableType::Symbols;
33*0b57cec5SDimitry Andric   if (Name16 == DiaTable_SrcFiles)
34*0b57cec5SDimitry Andric     return PDB_TableType::SourceFiles;
35*0b57cec5SDimitry Andric   if (Name16 == DiaTable_Sections)
36*0b57cec5SDimitry Andric     return PDB_TableType::SectionContribs;
37*0b57cec5SDimitry Andric   if (Name16 == DiaTable_LineNums)
38*0b57cec5SDimitry Andric     return PDB_TableType::LineNumbers;
39*0b57cec5SDimitry Andric   if (Name16 == DiaTable_SegMap)
40*0b57cec5SDimitry Andric     return PDB_TableType::Segments;
41*0b57cec5SDimitry Andric   if (Name16 == DiaTable_InjSrc)
42*0b57cec5SDimitry Andric     return PDB_TableType::InjectedSources;
43*0b57cec5SDimitry Andric   if (Name16 == DiaTable_FrameData)
44*0b57cec5SDimitry Andric     return PDB_TableType::FrameData;
45*0b57cec5SDimitry Andric   if (Name16 == DiaTable_InputAssemblyFiles)
46*0b57cec5SDimitry Andric     return PDB_TableType::InputAssemblyFiles;
47*0b57cec5SDimitry Andric   if (Name16 == DiaTable_Dbg)
48*0b57cec5SDimitry Andric     return PDB_TableType::Dbg;
49*0b57cec5SDimitry Andric   return PDB_TableType::TableInvalid;
50*0b57cec5SDimitry Andric }
51