Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
39642 views
//===-- CompileUnitIndex.h --------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H1011#include "lldb/Utility/RangeMap.h"12#include "llvm/ADT/DenseMap.h"13#include "llvm/ADT/DenseSet.h"14#include "llvm/ADT/IntervalMap.h"15#include "llvm/ADT/SmallString.h"16#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"17#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"18#include "llvm/DebugInfo/CodeView/SymbolRecord.h"19#include "llvm/DebugInfo/CodeView/TypeIndex.h"20#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"21#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"22#include "llvm/DebugInfo/PDB/PDBTypes.h"2324#include "PdbSymUid.h"2526#include <map>27#include <memory>28#include <optional>2930namespace lldb_private {3132namespace npdb {33class PdbIndex;3435/// Represents a single compile unit. This class is useful for collecting the36/// important accessors and information about a compile unit from disparate37/// parts of the PDB into a single place, simplifying acess to compile unit38/// information for the callers.39struct CompilandIndexItem {40CompilandIndexItem(PdbCompilandId m_id,41llvm::pdb::ModuleDebugStreamRef debug_stream,42llvm::pdb::DbiModuleDescriptor descriptor);4344// index of this compile unit.45PdbCompilandId m_id;4647// debug stream.48llvm::pdb::ModuleDebugStreamRef m_debug_stream;4950// dbi module descriptor.51llvm::pdb::DbiModuleDescriptor m_module_descriptor;5253llvm::codeview::StringsAndChecksumsRef m_strings;5455// List of files which contribute to this compiland.56std::vector<llvm::StringRef> m_file_list;5758// Maps virtual address to global symbol id, which can then be used to59// locate the exact compile unit and offset of the symbol. Note that this60// is intentionally an ordered map so that we can find all symbols up to a61// given starting address.62std::map<lldb::addr_t, PdbSymUid> m_symbols_by_va;6364// S_COMPILE3 sym describing compilation settings for the module.65std::optional<llvm::codeview::Compile3Sym> m_compile_opts;6667// S_OBJNAME sym describing object name.68std::optional<llvm::codeview::ObjNameSym> m_obj_name;6970// LF_BUILDINFO sym describing source file name, working directory,71// command line, etc. This usually contains exactly 5 items which72// are references to other strings.73llvm::SmallVector<llvm::codeview::TypeIndex, 5> m_build_info;7475// Inlinee lines table in this compile unit.76std::map<llvm::codeview::TypeIndex, llvm::codeview::InlineeSourceLine>77m_inline_map;7879// It's the line table parsed from DEBUG_S_LINES sections, mapping the file80// address range to file index and source line number.81using GlobalLineTable =82lldb_private::RangeDataVector<lldb::addr_t, uint32_t,83std::pair<uint32_t, uint32_t>>;84GlobalLineTable m_global_line_table;85};8687/// Indexes information about all compile units. This is really just a map of88/// global compile unit index to |CompilandIndexItem| structures.89class CompileUnitIndex {90PdbIndex &m_index;91llvm::DenseMap<uint16_t, std::unique_ptr<CompilandIndexItem>> m_comp_units;9293public:94explicit CompileUnitIndex(PdbIndex &index) : m_index(index) {}9596CompilandIndexItem &GetOrCreateCompiland(uint16_t modi);9798const CompilandIndexItem *GetCompiland(uint16_t modi) const;99100CompilandIndexItem *GetCompiland(uint16_t modi);101102llvm::SmallString<64> GetMainSourceFile(const CompilandIndexItem &item) const;103};104} // namespace npdb105} // namespace lldb_private106107#endif108109110