• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- DIATable.cpp - DIA implementation of IPDBTable -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/DebugInfo/PDB/DIA/DIATable.h"
11 #include "llvm/ADT/ArrayRef.h"
12 #include "llvm/Support/ConvertUTF.h"
13 
14 using namespace llvm;
15 using namespace llvm::pdb;
16 
DIATable(CComPtr<IDiaTable> DiaTable)17 DIATable::DIATable(CComPtr<IDiaTable> DiaTable)
18   : Table(DiaTable) {}
19 
getItemCount() const20 uint32_t DIATable::getItemCount() const {
21   LONG Count = 0;
22   return (S_OK == Table->get_Count(&Count)) ? Count : 0;
23 }
24 
getName() const25 std::string DIATable::getName() const {
26   CComBSTR Name16;
27   if (S_OK != Table->get_name(&Name16))
28     return std::string();
29 
30   std::string Name8;
31   llvm::ArrayRef<char> Name16Bytes(reinterpret_cast<char *>(Name16.m_str),
32                                    Name16.ByteLength());
33   if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8))
34     return std::string();
35   return Name8;
36 }
37 
getTableType() const38 PDB_TableType DIATable::getTableType() const {
39   CComBSTR Name16;
40   if (S_OK != Table->get_name(&Name16))
41     return PDB_TableType::TableInvalid;
42 
43   if (Name16 == DiaTable_Symbols)
44     return PDB_TableType::Symbols;
45   if (Name16 == DiaTable_SrcFiles)
46     return PDB_TableType::SourceFiles;
47   if (Name16 == DiaTable_Sections)
48     return PDB_TableType::SectionContribs;
49   if (Name16 == DiaTable_LineNums)
50     return PDB_TableType::LineNumbers;
51   if (Name16 == DiaTable_SegMap)
52     return PDB_TableType::Segments;
53   if (Name16 == DiaTable_InjSrc)
54     return PDB_TableType::InjectedSources;
55   if (Name16 == DiaTable_FrameData)
56     return PDB_TableType::FrameData;
57   if (Name16 == DiaTable_InputAssemblyFiles)
58     return PDB_TableType::InputAssemblyFiles;
59   if (Name16 == DiaTable_Dbg)
60     return PDB_TableType::Dbg;
61   return PDB_TableType::TableInvalid;
62 }
63