Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
213845 views
//===-- NameToDIE.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_DWARF_NAMETODIE_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H1011#include <functional>1213#include "DIERef.h"14#include "lldb/Core/UniqueCStringMap.h"15#include "lldb/Core/dwarf.h"16#include "lldb/lldb-defines.h"1718namespace lldb_private::plugin {19namespace dwarf {20class DWARFUnit;2122class NameToDIE {23public:24NameToDIE() : m_map() {}2526~NameToDIE() = default;2728void Dump(Stream *s);2930void Insert(ConstString name, const DIERef &die_ref);3132void Append(const NameToDIE &other);3334void Finalize();3536bool Find(ConstString name,37llvm::function_ref<bool(DIERef ref)> callback) const;3839bool Find(const RegularExpression ®ex,40llvm::function_ref<bool(DIERef ref)> callback) const;4142/// \a unit must be the skeleton unit if possible, not GetNonSkeletonUnit().43void44FindAllEntriesForUnit(DWARFUnit &unit,45llvm::function_ref<bool(DIERef ref)> callback) const;4647void48ForEach(std::function<bool(ConstString name, const DIERef &die_ref)> const49&callback) const;5051/// Decode a serialized version of this object from data.52///53/// \param data54/// The decoder object that references the serialized data.55///56/// \param offset_ptr57/// A pointer that contains the offset from which the data will be decoded58/// from that gets updated as data gets decoded.59///60/// \param strtab61/// All strings in cache files are put into string tables for efficiency62/// and cache file size reduction. Strings are stored as uint32_t string63/// table offsets in the cache data.64bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr,65const StringTableReader &strtab);6667/// Encode this object into a data encoder object.68///69/// This allows this object to be serialized to disk.70///71/// \param encoder72/// A data encoder object that serialized bytes will be encoded into.73///74/// \param strtab75/// All strings in cache files are put into string tables for efficiency76/// and cache file size reduction. Strings are stored as uint32_t string77/// table offsets in the cache data.78void Encode(DataEncoder &encoder, ConstStringTable &strtab) const;7980/// Used for unit testing the encoding and decoding.81bool operator==(const NameToDIE &rhs) const;8283bool IsEmpty() const { return m_map.IsEmpty(); }8485void Clear() { m_map.Clear(); }8687protected:88UniqueCStringMap<DIERef> m_map;89};90} // namespace dwarf91} // namespace lldb_private::plugin9293#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H949596