[llvm] r344886 - [PDB] Extend IPDBSession's interface to retrieve frame data
Aleksandr Urakov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 22 00:18:08 PDT 2018
Author: aleksandr.urakov
Date: Mon Oct 22 00:18:08 2018
New Revision: 344886
URL: http://llvm.org/viewvc/llvm-project?rev=344886&view=rev
Log:
[PDB] Extend IPDBSession's interface to retrieve frame data
Summary:
This patch just extends the `IPDBSession` interface to allow retrieving
of frame data through it, and adds an implementation over DIA. It is needed
for an implementation (for now with DIA) of the conversion from FPO programs
to DWARF expressions mentioned in D53086.
Reviewers: zturner, asmith, rnk
Reviewed By: asmith
Subscribers: mgorny, aprantl, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D53324
Added:
llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h
llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h
llvm/trunk/include/llvm/DebugInfo/PDB/IPDBFrameData.h
llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp
llvm/trunk/lib/DebugInfo/PDB/DIA/DIAFrameData.cpp
Modified:
llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h
llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.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/DIASession.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/DIAEnumFrameData.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h?rev=344886&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h Mon Oct 22 00:18:08 2018
@@ -0,0 +1,40 @@
+//==- DIAEnumFrameData.h --------------------------------------- -*- 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_DIAENUMFRAMEDATA_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBFrameData.h"
+
+namespace llvm {
+namespace pdb {
+
+class DIASession;
+
+class DIAEnumFrameData : public IPDBEnumChildren<IPDBFrameData> {
+public:
+ explicit DIAEnumFrameData(const DIASession &PDBSession,
+ CComPtr<IDiaEnumFrameData> DiaEnumerator);
+
+ uint32_t getChildCount() const override;
+ ChildTypePtr getChildAtIndex(uint32_t Index) const override;
+ ChildTypePtr getNext() override;
+ void reset() override;
+
+private:
+ const DIASession &Session;
+ CComPtr<IDiaEnumFrameData> Enumerator;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif
Added: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h?rev=344886&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h Mon Oct 22 00:18:08 2018
@@ -0,0 +1,41 @@
+//===- DIAFrameData.h - DIA Impl. of IPDBFrameData ---------------- 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_DIAFRAMEDATA_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBFrameData.h"
+
+namespace llvm {
+namespace pdb {
+
+class DIASession;
+
+class DIAFrameData : public IPDBFrameData {
+public:
+ explicit DIAFrameData(const DIASession &PDBSession,
+ CComPtr<IDiaFrameData> DiaFrameData);
+
+ uint32_t getAddressOffset() const override;
+ uint32_t getAddressSection() const override;
+ uint32_t getLengthBlock() const override;
+ std::string getProgram() const override;
+ uint32_t getRelativeVirtualAddress() const override;
+ uint64_t getVirtualAddress() const override;
+
+private:
+ const DIASession &Session;
+ CComPtr<IDiaFrameData> FrameData;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif
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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h Mon Oct 22 00:18:08 2018
@@ -85,6 +85,7 @@ public:
std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override;
+ std::unique_ptr<IPDBEnumFrameData> getFrameData() const override;
private:
CComPtr<IDiaSession> Session;
};
Added: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBFrameData.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBFrameData.h?rev=344886&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBFrameData.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBFrameData.h Mon Oct 22 00:18:08 2018
@@ -0,0 +1,36 @@
+//===- IPDBFrameData.h - base interface for frame data ----------*- 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_IPDBFRAMEDATA_H
+#define LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H
+
+#include <cstdint>
+#include <string>
+
+namespace llvm {
+namespace pdb {
+
+/// IPDBFrameData defines an interface used to represent a frame data of some
+/// code block.
+class IPDBFrameData {
+public:
+ virtual ~IPDBFrameData();
+
+ virtual uint32_t getAddressOffset() const = 0;
+ virtual uint32_t getAddressSection() const = 0;
+ virtual uint32_t getLengthBlock() const = 0;
+ virtual std::string getProgram() const = 0;
+ virtual uint32_t getRelativeVirtualAddress() const = 0;
+ virtual uint64_t getVirtualAddress() const = 0;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif
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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h Mon Oct 22 00:18:08 2018
@@ -91,6 +91,9 @@ public:
virtual std::unique_ptr<IPDBEnumSectionContribs>
getSectionContribs() const = 0;
+
+ virtual std::unique_ptr<IPDBEnumFrameData>
+ getFrameData() const = 0;
};
} // namespace pdb
} // namespace llvm
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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h Mon Oct 22 00:18:08 2018
@@ -93,6 +93,8 @@ public:
std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override;
+ std::unique_ptr<IPDBEnumFrameData> getFrameData() 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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h Mon Oct 22 00:18:08 2018
@@ -12,6 +12,7 @@
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBFrameData.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include <cctype>
#include <cstddef>
@@ -71,6 +72,7 @@ using IPDBEnumLineNumbers = IPDBEnumChil
using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>;
using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>;
+using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>;
/// 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.
Modified: llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt?rev=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt Mon Oct 22 00:18:08 2018
@@ -14,6 +14,7 @@ if(LLVM_ENABLE_DIA_SDK)
add_pdb_impl_folder(DIA
DIA/DIADataStream.cpp
DIA/DIAEnumDebugStreams.cpp
+ DIA/DIAEnumFrameData.cpp
DIA/DIAEnumInjectedSources.cpp
DIA/DIAEnumLineNumbers.cpp
DIA/DIAEnumSectionContribs.cpp
@@ -21,6 +22,7 @@ if(LLVM_ENABLE_DIA_SDK)
DIA/DIAEnumSymbols.cpp
DIA/DIAEnumTables.cpp
DIA/DIAError.cpp
+ DIA/DIAFrameData.cpp
DIA/DIAInjectedSource.cpp
DIA/DIALineNumber.cpp
DIA/DIARawSymbol.cpp
Added: llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp?rev=344886&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp Mon Oct 22 00:18:08 2018
@@ -0,0 +1,43 @@
+//==- DIAEnumFrameData.cpp ---------------------------------------*- 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/DIAEnumFrameData.h"
+#include "llvm/DebugInfo/PDB/DIA/DIAFrameData.h"
+#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
+
+using namespace llvm::pdb;
+
+DIAEnumFrameData::DIAEnumFrameData(const DIASession &PDBSession,
+ CComPtr<IDiaEnumFrameData> DiaEnumerator)
+ : Session(PDBSession), Enumerator(DiaEnumerator) {}
+
+uint32_t DIAEnumFrameData::getChildCount() const {
+ LONG Count = 0;
+ return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
+}
+
+std::unique_ptr<IPDBFrameData>
+DIAEnumFrameData::getChildAtIndex(uint32_t Index) const {
+ CComPtr<IDiaFrameData> Item;
+ if (S_OK != Enumerator->Item(Index, &Item))
+ return nullptr;
+
+ return std::unique_ptr<IPDBFrameData>(new DIAFrameData(Session, Item));
+}
+
+std::unique_ptr<IPDBFrameData> DIAEnumFrameData::getNext() {
+ CComPtr<IDiaFrameData> Item;
+ ULONG NumFetched = 0;
+ if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
+ return nullptr;
+
+ return std::unique_ptr<IPDBFrameData>(new DIAFrameData(Session, Item));
+}
+
+void DIAEnumFrameData::reset() { Enumerator->Reset(); }
Added: llvm/trunk/lib/DebugInfo/PDB/DIA/DIAFrameData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIAFrameData.cpp?rev=344886&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIAFrameData.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIAFrameData.cpp Mon Oct 22 00:18:08 2018
@@ -0,0 +1,54 @@
+//===- DIAFrameData.cpp - DIA impl. of IPDBFrameData -------------- 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/DIAFrameData.h"
+#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
+#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
+
+using namespace llvm::pdb;
+
+DIAFrameData::DIAFrameData(const DIASession &PDBSession,
+ CComPtr<IDiaFrameData> DiaFrameData)
+ : Session(PDBSession), FrameData(DiaFrameData) {}
+
+template <typename ArgType>
+ArgType
+PrivateGetDIAValue(IDiaFrameData *FrameData,
+ HRESULT (__stdcall IDiaFrameData::*Method)(ArgType *)) {
+ ArgType Value;
+ if (S_OK == (FrameData->*Method)(&Value))
+ return static_cast<ArgType>(Value);
+
+ return ArgType();
+}
+
+uint32_t DIAFrameData::getAddressOffset() const {
+ return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_addressOffset);
+}
+
+uint32_t DIAFrameData::getAddressSection() const {
+ return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_addressSection);
+}
+
+uint32_t DIAFrameData::getLengthBlock() const {
+ return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_lengthBlock);
+}
+
+std::string DIAFrameData::getProgram() const {
+ return invokeBstrMethod(*FrameData, &IDiaFrameData::get_program);
+}
+
+uint32_t DIAFrameData::getRelativeVirtualAddress() const {
+ return PrivateGetDIAValue(FrameData,
+ &IDiaFrameData::get_relativeVirtualAddress);
+}
+
+uint64_t DIAFrameData::getVirtualAddress() const {
+ return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_virtualAddress);
+}
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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp Mon Oct 22 00:18:08 2018
@@ -9,6 +9,7 @@
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
+#include "llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h"
@@ -419,3 +420,13 @@ DIASession::getSectionContribs() const {
return llvm::make_unique<DIAEnumSectionContribs>(*this, Sections);
}
+
+std::unique_ptr<IPDBEnumFrameData>
+DIASession::getFrameData() const {
+ CComPtr<IDiaEnumFrameData> FD =
+ getTableEnumerator<IDiaEnumFrameData>(*Session);
+ if (!FD)
+ return nullptr;
+
+ return llvm::make_unique<DIAEnumFrameData>(*this, FD);
+}
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=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp Mon Oct 22 00:18:08 2018
@@ -200,6 +200,11 @@ NativeSession::getSectionContribs() cons
return nullptr;
}
+std::unique_ptr<IPDBEnumFrameData>
+NativeSession::getFrameData() const {
+ return nullptr;
+}
+
void NativeSession::initializeExeSymbol() {
if (ExeSymbol == 0)
ExeSymbol = Cache.createSymbol<NativeExeSymbol>();
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp?rev=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp Mon Oct 22 00:18:08 2018
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/IPDBDataStream.h"
+#include "llvm/DebugInfo/PDB/IPDBFrameData.h"
#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
@@ -35,3 +36,5 @@ IPDBTable::~IPDBTable() = default;
IPDBInjectedSource::~IPDBInjectedSource() = default;
IPDBSectionContrib::~IPDBSectionContrib() = default;
+
+IPDBFrameData::~IPDBFrameData() = default;
Modified: llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp?rev=344886&r1=344885&r2=344886&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/PDBApiTest.cpp Mon Oct 22 00:18:08 2018
@@ -159,6 +159,10 @@ class MockSession : public IPDBSession {
std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override {
return nullptr;
}
+
+ std::unique_ptr<IPDBEnumFrameData> getFrameData() const override {
+ return nullptr;
+ }
};
class MockRawSymbol : public IPDBRawSymbol {
More information about the llvm-commits
mailing list