LLDB  mainline
CompileUnitIndex.h
Go to the documentation of this file.
1 //===-- CompileUnitIndex.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_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H
11 
12 #include "llvm/ADT/DenseMap.h"
13 #include "llvm/ADT/DenseSet.h"
14 #include "llvm/ADT/IntervalMap.h"
15 #include "llvm/ADT/Optional.h"
16 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
17 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
18 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
19 #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
20 #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
21 #include "llvm/DebugInfo/PDB/PDBTypes.h"
22 
23 #include "PdbSymUid.h"
24 
25 #include <map>
26 #include <memory>
27 
28 namespace lldb_private {
29 
30 namespace npdb {
31 class PdbIndex;
32 
33 /// Represents a single compile unit. This class is useful for collecting the
34 /// important accessors and information about a compile unit from disparate
35 /// parts of the PDB into a single place, simplifying acess to compile unit
36 /// information for the callers.
39  llvm::pdb::ModuleDebugStreamRef debug_stream,
40  llvm::pdb::DbiModuleDescriptor descriptor);
41 
42  // index of this compile unit.
44 
45  // debug stream.
46  llvm::pdb::ModuleDebugStreamRef m_debug_stream;
47 
48  // dbi module descriptor.
49  llvm::pdb::DbiModuleDescriptor m_module_descriptor;
50 
51  llvm::codeview::StringsAndChecksumsRef m_strings;
52 
53  // List of files which contribute to this compiland.
54  std::vector<llvm::StringRef> m_file_list;
55 
56  // Maps virtual address to global symbol id, which can then be used to
57  // locate the exact compile unit and offset of the symbol. Note that this
58  // is intentionally an ordered map so that we can find all symbols up to a
59  // given starting address.
60  std::map<lldb::addr_t, PdbSymUid> m_symbols_by_va;
61 
62  // S_COMPILE3 sym describing compilation settings for the module.
63  llvm::Optional<llvm::codeview::Compile3Sym> m_compile_opts;
64 
65  // S_OBJNAME sym describing object name.
66  llvm::Optional<llvm::codeview::ObjNameSym> m_obj_name;
67 
68  // LF_BUILDINFO sym describing source file name, working directory,
69  // command line, etc. This usually contains exactly 5 items which
70  // are references to other strings.
71  llvm::SmallVector<llvm::codeview::TypeIndex, 5> m_build_info;
72 };
73 
74 /// Indexes information about all compile units. This is really just a map of
75 /// global compile unit index to |CompilandIndexItem| structures.
78  llvm::DenseMap<uint16_t, std::unique_ptr<CompilandIndexItem>> m_comp_units;
79 
80 public:
81  explicit CompileUnitIndex(PdbIndex &index) : m_index(index) {}
82 
84 
85  const CompilandIndexItem *GetCompiland(uint16_t modi) const;
86 
88 
89  llvm::SmallString<64> GetMainSourceFile(const CompilandIndexItem &item) const;
90 };
91 } // namespace npdb
92 } // namespace lldb_private
93 
94 #endif
lldb_private::npdb::CompilandIndexItem::m_debug_stream
llvm::pdb::ModuleDebugStreamRef m_debug_stream
Definition: CompileUnitIndex.h:46
lldb_private::npdb::CompileUnitIndex::GetCompiland
const CompilandIndexItem * GetCompiland(uint16_t modi) const
Definition: CompileUnitIndex.cpp:175
lldb_private::npdb::CompileUnitIndex
Indexes information about all compile units.
Definition: CompileUnitIndex.h:76
lldb_private::npdb::CompilandIndexItem::m_obj_name
llvm::Optional< llvm::codeview::ObjNameSym > m_obj_name
Definition: CompileUnitIndex.h:66
lldb_private::npdb::PdbIndex
PdbIndex - Lazy access to the important parts of a PDB file.
Definition: PdbIndex.h:48
lldb_private::npdb::CompileUnitIndex::CompileUnitIndex
CompileUnitIndex(PdbIndex &index)
Definition: CompileUnitIndex.h:81
lldb_private::npdb::CompileUnitIndex::m_index
PdbIndex & m_index
Definition: CompileUnitIndex.h:77
lldb_private::npdb::CompilandIndexItem::m_compile_opts
llvm::Optional< llvm::codeview::Compile3Sym > m_compile_opts
Definition: CompileUnitIndex.h:63
lldb_private::npdb::CompilandIndexItem::CompilandIndexItem
CompilandIndexItem(PdbCompilandId m_id, llvm::pdb::ModuleDebugStreamRef debug_stream, llvm::pdb::DbiModuleDescriptor descriptor)
Definition: CompileUnitIndex.cpp:109
lldb_private::npdb::CompileUnitIndex::GetOrCreateCompiland
CompilandIndexItem & GetOrCreateCompiland(uint16_t modi)
Definition: CompileUnitIndex.cpp:115
lldb_private::npdb::CompilandIndexItem::m_file_list
std::vector< llvm::StringRef > m_file_list
Definition: CompileUnitIndex.h:54
lldb_private::npdb::CompilandIndexItem::m_module_descriptor
llvm::pdb::DbiModuleDescriptor m_module_descriptor
Definition: CompileUnitIndex.h:49
lldb_private::npdb::CompileUnitIndex::GetMainSourceFile
llvm::SmallString< 64 > GetMainSourceFile(const CompilandIndexItem &item) const
Definition: CompileUnitIndex.cpp:190
lldb_private::npdb::PdbCompilandId
Definition: PdbSymUid.h:39
lldb_private::npdb::CompilandIndexItem::m_strings
llvm::codeview::StringsAndChecksumsRef m_strings
Definition: CompileUnitIndex.h:51
lldb_private::npdb::CompilandIndexItem
Represents a single compile unit.
Definition: CompileUnitIndex.h:37
PdbSymUid.h
lldb_private::npdb::CompilandIndexItem::m_id
PdbCompilandId m_id
Definition: CompileUnitIndex.h:43
uint16_t
lldb_private::npdb::CompilandIndexItem::m_build_info
llvm::SmallVector< llvm::codeview::TypeIndex, 5 > m_build_info
Definition: CompileUnitIndex.h:71
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::npdb::CompilandIndexItem::m_symbols_by_va
std::map< lldb::addr_t, PdbSymUid > m_symbols_by_va
Definition: CompileUnitIndex.h:60
lldb_private::npdb::CompileUnitIndex::m_comp_units
llvm::DenseMap< uint16_t, std::unique_ptr< CompilandIndexItem > > m_comp_units
Definition: CompileUnitIndex.h:78