llvm.org GIT mirror llvm / b5c7e2f
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344886 91177308-0d34-0410-b5e6-96231b3b80d8 Aleksandr Urakov 11 months ago
14 changed file(s) with 247 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //==- DIAEnumFrameData.h --------------------------------------- -*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H
10 #define LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H
11
12 #include "DIASupport.h"
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
15
16 namespace llvm {
17 namespace pdb {
18
19 class DIASession;
20
21 class DIAEnumFrameData : public IPDBEnumChildren {
22 public:
23 explicit DIAEnumFrameData(const DIASession &PDBSession,
24 CComPtr DiaEnumerator);
25
26 uint32_t getChildCount() const override;
27 ChildTypePtr getChildAtIndex(uint32_t Index) const override;
28 ChildTypePtr getNext() override;
29 void reset() override;
30
31 private:
32 const DIASession &Session;
33 CComPtr Enumerator;
34 };
35
36 } // namespace pdb
37 } // namespace llvm
38
39 #endif
0 //===- DIAFrameData.h - DIA Impl. of IPDBFrameData ---------------- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H
10 #define LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H
11
12 #include "DIASupport.h"
13 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
14
15 namespace llvm {
16 namespace pdb {
17
18 class DIASession;
19
20 class DIAFrameData : public IPDBFrameData {
21 public:
22 explicit DIAFrameData(const DIASession &PDBSession,
23 CComPtr DiaFrameData);
24
25 uint32_t getAddressOffset() const override;
26 uint32_t getAddressSection() const override;
27 uint32_t getLengthBlock() const override;
28 std::string getProgram() const override;
29 uint32_t getRelativeVirtualAddress() const override;
30 uint64_t getVirtualAddress() const override;
31
32 private:
33 const DIASession &Session;
34 CComPtr FrameData;
35 };
36
37 } // namespace pdb
38 } // namespace llvm
39
40 #endif
8484
8585 std::unique_ptr getSectionContribs() const override;
8686
87 std::unique_ptr getFrameData() const override;
8788 private:
8889 CComPtr Session;
8990 };
0 //===- IPDBFrameData.h - base interface for frame data ----------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H
10 #define LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H
11
12 #include
13 #include
14
15 namespace llvm {
16 namespace pdb {
17
18 /// IPDBFrameData defines an interface used to represent a frame data of some
19 /// code block.
20 class IPDBFrameData {
21 public:
22 virtual ~IPDBFrameData();
23
24 virtual uint32_t getAddressOffset() const = 0;
25 virtual uint32_t getAddressSection() const = 0;
26 virtual uint32_t getLengthBlock() const = 0;
27 virtual std::string getProgram() const = 0;
28 virtual uint32_t getRelativeVirtualAddress() const = 0;
29 virtual uint64_t getVirtualAddress() const = 0;
30 };
31
32 } // namespace pdb
33 } // namespace llvm
34
35 #endif
9090
9191 virtual std::unique_ptr
9292 getSectionContribs() const = 0;
93
94 virtual std::unique_ptr
95 getFrameData() const = 0;
9396 };
9497 } // namespace pdb
9598 } // namespace llvm
9292
9393 std::unique_ptr getSectionContribs() const override;
9494
95 std::unique_ptr getFrameData() const override;
96
9597 PDBFile &getPDBFile() { return *Pdb; }
9698 const PDBFile &getPDBFile() const { return *Pdb; }
9799
1111
1212 #include "llvm/DebugInfo/CodeView/CodeView.h"
1313 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
1415 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
1516 #include
1617 #include
7071 using IPDBEnumTables = IPDBEnumChildren;
7172 using IPDBEnumInjectedSources = IPDBEnumChildren;
7273 using IPDBEnumSectionContribs = IPDBEnumChildren;
74 using IPDBEnumFrameData = IPDBEnumChildren;
7375
7476 /// Specifies which PDB reader implementation is to be used. Only a value
7577 /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
1313 add_pdb_impl_folder(DIA
1414 DIA/DIADataStream.cpp
1515 DIA/DIAEnumDebugStreams.cpp
16 DIA/DIAEnumFrameData.cpp
1617 DIA/DIAEnumInjectedSources.cpp
1718 DIA/DIAEnumLineNumbers.cpp
1819 DIA/DIAEnumSectionContribs.cpp
2021 DIA/DIAEnumSymbols.cpp
2122 DIA/DIAEnumTables.cpp
2223 DIA/DIAError.cpp
24 DIA/DIAFrameData.cpp
2325 DIA/DIAInjectedSource.cpp
2426 DIA/DIALineNumber.cpp
2527 DIA/DIARawSymbol.cpp
0 //==- DIAEnumFrameData.cpp ---------------------------------------*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h"
10 #include "llvm/DebugInfo/PDB/DIA/DIAFrameData.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
12
13 using namespace llvm::pdb;
14
15 DIAEnumFrameData::DIAEnumFrameData(const DIASession &PDBSession,
16 CComPtr DiaEnumerator)
17 : Session(PDBSession), Enumerator(DiaEnumerator) {}
18
19 uint32_t DIAEnumFrameData::getChildCount() const {
20 LONG Count = 0;
21 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
22 }
23
24 std::unique_ptr
25 DIAEnumFrameData::getChildAtIndex(uint32_t Index) const {
26 CComPtr Item;
27 if (S_OK != Enumerator->Item(Index, &Item))
28 return nullptr;
29
30 return std::unique_ptr(new DIAFrameData(Session, Item));
31 }
32
33 std::unique_ptr DIAEnumFrameData::getNext() {
34 CComPtr Item;
35 ULONG NumFetched = 0;
36 if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
37 return nullptr;
38
39 return std::unique_ptr(new DIAFrameData(Session, Item));
40 }
41
42 void DIAEnumFrameData::reset() { Enumerator->Reset(); }
0 //===- DIAFrameData.cpp - DIA impl. of IPDBFrameData -------------- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/PDB/DIA/DIAFrameData.h"
10 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
12
13 using namespace llvm::pdb;
14
15 DIAFrameData::DIAFrameData(const DIASession &PDBSession,
16 CComPtr DiaFrameData)
17 : Session(PDBSession), FrameData(DiaFrameData) {}
18
19 template
20 ArgType
21 PrivateGetDIAValue(IDiaFrameData *FrameData,
22 HRESULT (__stdcall IDiaFrameData::*Method)(ArgType *)) {
23 ArgType Value;
24 if (S_OK == (FrameData->*Method)(&Value))
25 return static_cast(Value);
26
27 return ArgType();
28 }
29
30 uint32_t DIAFrameData::getAddressOffset() const {
31 return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_addressOffset);
32 }
33
34 uint32_t DIAFrameData::getAddressSection() const {
35 return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_addressSection);
36 }
37
38 uint32_t DIAFrameData::getLengthBlock() const {
39 return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_lengthBlock);
40 }
41
42 std::string DIAFrameData::getProgram() const {
43 return invokeBstrMethod(*FrameData, &IDiaFrameData::get_program);
44 }
45
46 uint32_t DIAFrameData::getRelativeVirtualAddress() const {
47 return PrivateGetDIAValue(FrameData,
48 &IDiaFrameData::get_relativeVirtualAddress);
49 }
50
51 uint64_t DIAFrameData::getVirtualAddress() const {
52 return PrivateGetDIAValue(FrameData, &IDiaFrameData::get_virtualAddress);
53 }
88 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
99 #include "llvm/ADT/STLExtras.h"
1010 #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h"
1112 #include "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h"
1213 #include "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
1314 #include "llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h"
418419
419420 return llvm::make_unique(*this, Sections);
420421 }
422
423 std::unique_ptr
424 DIASession::getFrameData() const {
425 CComPtr FD =
426 getTableEnumerator(*Session);
427 if (!FD)
428 return nullptr;
429
430 return llvm::make_unique(*this, FD);
431 }
199199 return nullptr;
200200 }
201201
202 std::unique_ptr
203 NativeSession::getFrameData() const {
204 return nullptr;
205 }
206
202207 void NativeSession::initializeExeSymbol() {
203208 if (ExeSymbol == 0)
204209 ExeSymbol = Cache.createSymbol();
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/DebugInfo/PDB/IPDBDataStream.h"
14 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
1415 #include "llvm/DebugInfo/PDB/IPDBInjectedSource.h"
1516 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
1617 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
3435 IPDBInjectedSource::~IPDBInjectedSource() = default;
3536
3637 IPDBSectionContrib::~IPDBSectionContrib() = default;
38
39 IPDBFrameData::~IPDBFrameData() = default;
156156 }
157157
158158 std::unique_ptr getSectionContribs() const override {
159 return nullptr;
160 }
161
162 std::unique_ptr getFrameData() const override {
159163 return nullptr;
160164 }
161165 };