[llvm] r318403 - [DebugInfo/PDB] Adding getUndecoratedNameEx and IPDB interfaces for IDiaEnumTables and IDiaTable.

Aaron Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 06:33:09 PST 2017


Author: asmith
Date: Thu Nov 16 06:33:09 2017
New Revision: 318403

URL: http://llvm.org/viewvc/llvm-project?rev=318403&view=rev
Log:
[DebugInfo/PDB] Adding getUndecoratedNameEx and IPDB interfaces for IDiaEnumTables and IDiaTable.

Initial changes to support debugging PE/COFF files with LLDB on Windows through DIA SDK.
There is another set of changes required on the LLDB side before this does anything.

Differential Revision: https://reviews.llvm.org/D39517

Added:
    llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h
    llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIATable.h
    llvm/trunk/include/llvm/DebugInfo/PDB/IPDBTable.h
    llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp
    llvm/trunk/lib/DebugInfo/PDB/DIA/DIATable.cpp
Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
    llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h
    llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
    llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h
    llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
    llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
    llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
    llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp
    llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp
    llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp

Added: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h?rev=318403&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h Thu Nov 16 06:33:09 2017
@@ -0,0 +1,37 @@
+//===- DIAEnumTables.h - DIA Tables Enumerator Impl -------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
+
+namespace llvm {
+namespace pdb {
+class IPDBTable;
+
+class DIAEnumTables : public IPDBEnumChildren<IPDBTable> {
+public:
+  explicit DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator);
+
+  uint32_t getChildCount() const override;
+  std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const override;
+  std::unique_ptr<IPDBTable> getNext() override;
+  void reset() override;
+  DIAEnumTables *clone() const override;
+
+private:
+  CComPtr<IDiaEnumTables> Enumerator;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h Thu Nov 16 06:33:09 2017
@@ -96,6 +96,7 @@ public:
   uint32_t getTypeId() const override;
   uint32_t getUavSlot() const override;
   std::string getUndecoratedName() const override;
+  std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override;
   uint32_t getUnmodifiedTypeId() const override;
   uint32_t getUpperBoundId() const override;
   Variant getValue() const override;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h Thu Nov 16 06:33:09 2017
@@ -64,6 +64,7 @@ public:
 
   std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
 
+  std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
 private:
   CComPtr<IDiaSession> Session;
 };

Added: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIATable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIATable.h?rev=318403&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIATable.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIATable.h Thu Nov 16 06:33:09 2017
@@ -0,0 +1,32 @@
+//===- DIATable.h - DIA implementation of IPDBTable -------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
+
+namespace llvm {
+namespace pdb {
+class DIATable : public IPDBTable {
+public:
+  explicit DIATable(CComPtr<IDiaTable> DiaTable);
+
+  uint32_t getItemCount() const override;
+  std::string getName() const override;
+  PDB_TableType getTableType() const override;
+
+private:
+  CComPtr<IDiaTable> Table;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h Thu Nov 16 06:33:09 2017
@@ -108,6 +108,7 @@ public:
   virtual uint32_t getTypeId() const = 0;
   virtual uint32_t getUavSlot() const = 0;
   virtual std::string getUndecoratedName() const = 0;
+  virtual std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const = 0;
   virtual uint32_t getUnmodifiedTypeId() const = 0;
   virtual uint32_t getUpperBoundId() const = 0;
   virtual Variant getValue() const = 0;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h Thu Nov 16 06:33:09 2017
@@ -67,6 +67,8 @@ public:
   getSourceFileById(uint32_t FileId) const = 0;
 
   virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0;
+
+  virtual std::unique_ptr<IPDBEnumTables> getEnumTables() const = 0;
 };
 }
 }

Added: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBTable.h?rev=318403&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBTable.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBTable.h Thu Nov 16 06:33:09 2017
@@ -0,0 +1,28 @@
+//===- IPDBTable.h - Base Interface for a PDB Symbol Context ----*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_IPDBTABLE_H
+#define LLVM_DEBUGINFO_PDB_IPDBTABLE_H
+
+#include "PDBTypes.h"
+
+namespace llvm {
+namespace pdb {
+class IPDBTable {
+public:
+  virtual ~IPDBTable();
+
+  virtual std::string getName() const = 0;
+  virtual uint32_t getItemCount() const = 0;
+  virtual PDB_TableType getTableType() const = 0;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_IPDBTABLE_H

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h Thu Nov 16 06:33:09 2017
@@ -101,6 +101,7 @@ public:
   uint32_t getTypeId() const override;
   uint32_t getUavSlot() const override;
   std::string getUndecoratedName() const override;
+  std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override;
   uint32_t getUnmodifiedTypeId() const override;
   uint32_t getUpperBoundId() const override;
   Variant getValue() const override;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h Thu Nov 16 06:33:09 2017
@@ -82,6 +82,8 @@ public:
 
   std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
 
+  std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
+
   PDBFile &getPDBFile() { return *Pdb; }
   const PDBFile &getPDBFile() const { return *Pdb; }
 

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h Thu Nov 16 06:33:09 2017
@@ -24,6 +24,7 @@ namespace pdb {
 class IPDBDataStream;
 class IPDBLineNumber;
 class IPDBSourceFile;
+class IPDBTable;
 class PDBSymDumper;
 class PDBSymbol;
 class PDBSymbolExe;
@@ -62,6 +63,7 @@ using IPDBEnumSymbols = IPDBEnumChildren
 using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
 using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
 using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
+using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
 
 /// Specifies which PDB reader implementation is to be used.  Only a value
 /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
@@ -72,13 +74,16 @@ enum class PDB_ReaderType {
 
 /// An enumeration indicating the type of data contained in this table.
 enum class PDB_TableType {
+  TableInvalid = 0,
   Symbols,
   SourceFiles,
   LineNumbers,
   SectionContribs,
   Segments,
   InjectedSources,
-  FrameData
+  FrameData,
+  InputAssemblyFiles,
+  Dbg
 };
 
 /// Defines flags used for enumerating child symbols.  This corresponds to the
@@ -241,6 +246,32 @@ enum class PDB_BuiltinType {
   HResult = 31
 };
 
+/// These values correspond to the flags that can be combined to control the
+/// return of an undecorated name for a C++ decorated name, and are documented
+/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
+enum PDB_UndnameFlags: uint32_t {
+  Undname_Complete = 0x0,
+  Undname_NoLeadingUnderscores = 0x1,
+  Undname_NoMsKeywords = 0x2,
+  Undname_NoFuncReturns = 0x4,
+  Undname_NoAllocModel = 0x8,
+  Undname_NoAllocLang = 0x10,
+  Undname_Reserved1 = 0x20,
+  Undname_Reserved2 = 0x40,
+  Undname_NoThisType = 0x60,
+  Undname_NoAccessSpec = 0x80,
+  Undname_NoThrowSig = 0x100,
+  Undname_NoMemberType = 0x200,
+  Undname_NoReturnUDTModel = 0x400,
+  Undname_32BitDecode = 0x800,
+  Undname_NameOnly = 0x1000,
+  Undname_TypeOnly = 0x2000,
+  Undname_HaveParams = 0x4000,
+  Undname_NoECSU = 0x8000,
+  Undname_NoIdentCharCheck = 0x10000,
+  Undname_NoPTR64 = 0x20000
+};
+
 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
 
 struct VersionInfo {

Modified: llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt Thu Nov 16 06:33:09 2017
@@ -17,11 +17,13 @@ if(LLVM_ENABLE_DIA_SDK)
     DIA/DIAEnumLineNumbers.cpp
     DIA/DIAEnumSourceFiles.cpp
     DIA/DIAEnumSymbols.cpp
+    DIA/DIAEnumTables.cpp
     DIA/DIAError.cpp
     DIA/DIALineNumber.cpp
     DIA/DIARawSymbol.cpp
     DIA/DIASession.cpp
     DIA/DIASourceFile.cpp
+    DIA/DIATable.cpp
     )
 
     set(LIBPDB_ADDITIONAL_HEADER_DIRS "${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/PDB/DIA")

Added: llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp?rev=318403&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp Thu Nov 16 06:33:09 2017
@@ -0,0 +1,53 @@
+//===- DIAEnumTables.cpp - DIA Table Enumerator Impl ------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/DIA/DIAEnumTables.h"
+#include "llvm/DebugInfo/PDB/DIA/DIATable.h"
+
+using namespace llvm;
+using namespace llvm::pdb;
+
+DIAEnumTables::DIAEnumTables(
+  CComPtr<IDiaEnumTables> DiaEnumerator)
+  : Enumerator(DiaEnumerator) {}
+
+uint32_t DIAEnumTables::getChildCount() const {
+  LONG Count = 0;
+  return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
+}
+
+std::unique_ptr<IPDBTable>
+DIAEnumTables::getChildAtIndex(uint32_t Index) const {
+  CComPtr<IDiaTable> Item;
+  VARIANT Var;
+  Var.vt = VT_UINT;
+  Var.uintVal = Index;
+  if (S_OK != Enumerator->Item(Var, &Item))
+    return nullptr;
+
+  return std::unique_ptr<IPDBTable>(new DIATable(Item));
+}
+
+std::unique_ptr<IPDBTable> DIAEnumTables::getNext() {
+  CComPtr<IDiaTable> Item;
+  ULONG CeltFetched = 0;
+  if (S_OK != Enumerator->Next(1, &Item, &CeltFetched))
+    return nullptr;
+
+  return std::unique_ptr<IPDBTable>(new DIATable(Item));
+}
+
+void DIAEnumTables::reset() { Enumerator->Reset(); }
+
+DIAEnumTables *DIAEnumTables::clone() const {
+  CComPtr<IDiaEnumTables> EnumeratorClone;
+  if (S_OK != Enumerator->Clone(&EnumeratorClone))
+    return nullptr;
+  return new DIAEnumTables(EnumeratorClone);
+}

Modified: llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp Thu Nov 16 06:33:09 2017
@@ -439,6 +439,20 @@ void DIARawSymbol::getDataBytes(llvm::Sm
   Symbol->get_dataBytes(DataSize, &DataSize, bytes.data());
 }
 
+std::string
+DIARawSymbol::getUndecoratedNameEx(PDB_UndnameFlags Flags) const {
+  CComBSTR Result16;
+  if (S_OK != Symbol->get_undecoratedNameEx((DWORD)Flags, &Result16))
+    return std::string();
+
+  const char *SrcBytes = reinterpret_cast<const char *>(Result16.m_str);
+  llvm::ArrayRef<char> SrcByteArray(SrcBytes, Result16.ByteLength());
+  std::string Result8;
+  if (!llvm::convertUTF16ToUTF8String(SrcByteArray, Result8))
+    return std::string();
+  return Result8;
+}
+
 PDB_MemberAccess DIARawSymbol::getAccess() const {
   return PrivateGetDIAValue<DWORD, PDB_MemberAccess>(Symbol,
                                                      &IDiaSymbol::get_access);

Modified: llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp Thu Nov 16 06:33:09 2017
@@ -11,6 +11,7 @@
 #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
 #include "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
 #include "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h"
+#include "llvm/DebugInfo/PDB/DIA/DIAEnumTables.h"
 #include "llvm/DebugInfo/PDB/DIA/DIAError.h"
 #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
 #include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
@@ -301,3 +302,11 @@ std::unique_ptr<IPDBEnumDataStreams> DIA
 
   return llvm::make_unique<DIAEnumDebugStreams>(DiaEnumerator);
 }
+
+std::unique_ptr<IPDBEnumTables> DIASession::getEnumTables() const {
+  CComPtr<IDiaEnumTables> DiaEnumerator;
+  if (S_OK != Session->getEnumTables(&DiaEnumerator))
+    return nullptr;
+
+  return llvm::make_unique<DIAEnumTables>(DiaEnumerator);
+}

Added: llvm/trunk/lib/DebugInfo/PDB/DIA/DIATable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIATable.cpp?rev=318403&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIATable.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIATable.cpp Thu Nov 16 06:33:09 2017
@@ -0,0 +1,61 @@
+//===- DIATable.cpp - DIA implementation of IPDBTable -----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/DIA/DIATable.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/ConvertUTF.h"
+
+using namespace llvm;
+using namespace llvm::pdb;
+
+DIATable::DIATable(CComPtr<IDiaTable> DiaTable)
+  : Table(DiaTable) {}
+
+uint32_t DIATable::getItemCount() const {
+  LONG Count = 0;
+  return (S_OK == Table->get_Count(&Count)) ? Count : 0;
+}
+
+std::string DIATable::getName() const {
+  CComBSTR Name16;
+  if (S_OK != Table->get_name(&Name16))
+    return std::string();
+
+  std::string Name8;
+  llvm::ArrayRef<char> Name16Bytes(reinterpret_cast<char *>(Name16.m_str),
+                                   Name16.ByteLength());
+  if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8))
+    return std::string();
+  return Name8;
+}
+
+PDB_TableType DIATable::getTableType() const {
+  CComBSTR Name16;
+  if (S_OK != Table->get_name(&Name16))
+    return PDB_TableType::TableInvalid;
+
+  if (Name16 == DiaTable_Symbols)
+    return PDB_TableType::Symbols;
+  if (Name16 == DiaTable_SrcFiles)
+    return PDB_TableType::SourceFiles;
+  if (Name16 == DiaTable_Sections)
+    return PDB_TableType::SectionContribs;
+  if (Name16 == DiaTable_LineNums)
+    return PDB_TableType::LineNumbers;
+  if (Name16 == DiaTable_SegMap)
+    return PDB_TableType::Segments;
+  if (Name16 == DiaTable_InjSrc)
+    return PDB_TableType::InjectedSources;
+  if (Name16 == DiaTable_FrameData)
+    return PDB_TableType::FrameData;
+  if (Name16 == DiaTable_InputAssemblyFiles)
+    return PDB_TableType::InputAssemblyFiles;
+  if (Name16 == DiaTable_Dbg)
+    return PDB_TableType::Dbg;
+}

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp Thu Nov 16 06:33:09 2017
@@ -286,6 +286,11 @@ std::string NativeRawSymbol::getUndecora
   return {};
 }
 
+std::string NativeRawSymbol::getUndecoratedNameEx(
+    PDB_UndnameFlags Flags) const {
+  return {};
+}
+
 uint32_t NativeRawSymbol::getUnmodifiedTypeId() const {
   return 0;
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp Thu Nov 16 06:33:09 2017
@@ -245,3 +245,7 @@ NativeSession::getSourceFileById(uint32_
 std::unique_ptr<IPDBEnumDataStreams> NativeSession::getDebugStreams() const {
   return nullptr;
 }
+
+std::unique_ptr<IPDBEnumTables> NativeSession::getEnumTables() const {
+  return nullptr;
+}

Modified: llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp Thu Nov 16 06:33:09 2017
@@ -15,6 +15,7 @@
 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
 #include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
 
 using namespace llvm;
 using namespace llvm::pdb;
@@ -26,3 +27,5 @@ IPDBDataStream::~IPDBDataStream() = defa
 IPDBRawSymbol::~IPDBRawSymbol() = default;
 
 IPDBLineNumber::~IPDBLineNumber() = default;
+
+IPDBTable::~IPDBTable() = default;

Modified: llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp?rev=318403&r1=318402&r2=318403&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp Thu Nov 16 06:33:09 2017
@@ -14,6 +14,7 @@
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
 #include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
@@ -118,6 +119,10 @@ class MockSession : public IPDBSession {
   std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override {
     return nullptr;
   }
+
+  std::unique_ptr<IPDBEnumTables> getEnumTables() const override {
+    return nullptr;
+  }
 };
 
 class MockRawSymbol : public IPDBRawSymbol {
@@ -152,6 +157,10 @@ public:
 
   PDB_SymType getSymTag() const override { return Type; }
 
+  std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override {
+    return {};
+  }
+
   MOCK_SYMBOL_ACCESSOR(getAccess)
   MOCK_SYMBOL_ACCESSOR(getAddressOffset)
   MOCK_SYMBOL_ACCESSOR(getAddressSection)




More information about the llvm-commits mailing list