Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ObjectFilePDB.h --------------------------------------- -*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
10
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
11
12
#include "lldb/Symbol/ObjectFile.h"
13
#include "lldb/Utility/ArchSpec.h"
14
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
15
#include "llvm/DebugInfo/PDB/PDBTypes.h"
16
17
namespace lldb_private {
18
19
class ObjectFilePDB : public ObjectFile {
20
public:
21
  // Static Functions
22
  static void Initialize();
23
  static void Terminate();
24
25
3.44k
  static llvm::StringRef GetPluginNameStatic() { return "pdb"; }
26
3.44k
  static const char *GetPluginDescriptionStatic() {
27
3.44k
    return "PDB object file reader.";
28
3.44k
  }
29
30
  static std::unique_ptr<llvm::pdb::PDBFile>
31
  loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator);
32
33
  static ObjectFile *
34
  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
35
                 lldb::offset_t data_offset, const FileSpec *file,
36
                 lldb::offset_t file_offset, lldb::offset_t length);
37
38
  static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
39
                                          lldb::DataBufferSP &data_sp,
40
                                          const lldb::ProcessSP &process_sp,
41
                                          lldb::addr_t header_addr);
42
43
  static size_t GetModuleSpecifications(const FileSpec &file,
44
                                        lldb::DataBufferSP &data_sp,
45
                                        lldb::offset_t data_offset,
46
                                        lldb::offset_t file_offset,
47
                                        lldb::offset_t length,
48
                                        ModuleSpecList &specs);
49
50
  // PluginInterface protocol
51
1
  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
52
53
  // LLVM RTTI support
54
  static char ID;
55
6
  bool isA(const void *ClassID) const override {
56
6
    return ClassID == &ID || 
ObjectFile::isA(ClassID)4
;
57
6
  }
58
130k
  static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
59
60
  // ObjectFile Protocol.
61
0
  uint32_t GetAddressByteSize() const override { return 8; }
62
63
0
  lldb::ByteOrder GetByteOrder() const override {
64
0
    return lldb::eByteOrderLittle;
65
0
  }
66
67
0
  bool ParseHeader() override { return true; }
68
69
1
  bool IsExecutable() const override { return false; }
70
71
1
  void ParseSymtab(lldb_private::Symtab &symtab) override {}
72
73
2
  bool IsStripped() override { return false; }
74
75
  // No section in PDB file.
76
2
  void CreateSections(SectionList &unified_section_list) override {}
77
78
0
  void Dump(Stream *s) override {}
79
80
  ArchSpec GetArchitecture() override;
81
82
1
  UUID GetUUID() override { return m_uuid; }
83
84
0
  uint32_t GetDependentModules(FileSpecList &files) override { return 0; }
85
86
1
  Type CalculateType() override { return eTypeDebugInfo; }
87
88
1
  Strata CalculateStrata() override { return eStrataUser; }
89
90
1
  llvm::pdb::PDBFile &GetPDBFile() { return *m_file_up; }
91
92
  ObjectFilePDB(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
93
                lldb::offset_t data_offset, const FileSpec *file,
94
                lldb::offset_t offset, lldb::offset_t length);
95
96
private:
97
  UUID m_uuid;
98
  llvm::BumpPtrAllocator m_allocator;
99
  std::unique_ptr<llvm::pdb::PDBFile> m_file_up;
100
101
  bool initPDBFile();
102
};
103
104
} // namespace lldb_private
105
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H