LLDB mainline
NameToDIE.h
Go to the documentation of this file.
1//===-- NameToDIE.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_DWARF_NAMETODIE_H
10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
11
12#include <functional>
13
14#include "DIERef.h"
16#include "lldb/Core/dwarf.h"
17#include "lldb/lldb-defines.h"
18
19class DWARFUnit;
20
21class NameToDIE {
22public:
24
25 ~NameToDIE() = default;
26
28
29 void Insert(lldb_private::ConstString name, const DIERef &die_ref);
30
31 void Append(const NameToDIE &other);
32
33 void Finalize();
34
36 llvm::function_ref<bool(DIERef ref)> callback) const;
37
38 bool Find(const lldb_private::RegularExpression &regex,
39 llvm::function_ref<bool(DIERef ref)> callback) const;
40
41 /// \a unit must be the skeleton unit if possible, not GetNonSkeletonUnit().
42 void
44 llvm::function_ref<bool(DIERef ref)> callback) const;
45
46 void
47 ForEach(std::function<bool(lldb_private::ConstString name,
48 const DIERef &die_ref)> const
49 &callback) const;
50
51 /// Decode a serialized version of this object from data.
52 ///
53 /// \param data
54 /// The decoder object that references the serialized data.
55 ///
56 /// \param offset_ptr
57 /// A pointer that contains the offset from which the data will be decoded
58 /// from that gets updated as data gets decoded.
59 ///
60 /// \param strtab
61 /// All strings in cache files are put into string tables for efficiency
62 /// and cache file size reduction. Strings are stored as uint32_t string
63 /// table offsets in the cache data.
64 bool Decode(const lldb_private::DataExtractor &data,
65 lldb::offset_t *offset_ptr,
67
68 /// Encode this object into a data encoder object.
69 ///
70 /// This allows this object to be serialized to disk.
71 ///
72 /// \param encoder
73 /// A data encoder object that serialized bytes will be encoded into.
74 ///
75 /// \param strtab
76 /// All strings in cache files are put into string tables for efficiency
77 /// and cache file size reduction. Strings are stored as uint32_t string
78 /// table offsets in the cache data.
79 void Encode(lldb_private::DataEncoder &encoder,
80 lldb_private::ConstStringTable &strtab) const;
81
82 /// Used for unit testing the encoding and decoding.
83 bool operator==(const NameToDIE &rhs) const;
84
85 bool IsEmpty() const { return m_map.IsEmpty(); }
86
87 void Clear() { m_map.Clear(); }
88
89protected:
91};
92
93#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:26
lldb_private::UniqueCStringMap< DIERef > m_map
Definition: NameToDIE.h:90
void Append(const NameToDIE &other)
Definition: NameToDIE.cpp:87
~NameToDIE()=default
bool Find(lldb_private::ConstString name, llvm::function_ref< bool(DIERef ref)> callback) const
Definition: NameToDIE.cpp:33
bool IsEmpty() const
Definition: NameToDIE.h:85
void Finalize()
Definition: NameToDIE.cpp:24
bool Decode(const lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr, const lldb_private::StringTableReader &strtab)
Decode a serialized version of this object from data.
Definition: NameToDIE.cpp:97
void Insert(lldb_private::ConstString name, const DIERef &die_ref)
Definition: NameToDIE.cpp:29
NameToDIE()
Definition: NameToDIE.h:23
void FindAllEntriesForUnit(DWARFUnit &unit, llvm::function_ref< bool(DIERef ref)> callback) const
unit must be the skeleton unit if possible, not GetNonSkeletonUnit().
Definition: NameToDIE.cpp:51
void Encode(lldb_private::DataEncoder &encoder, lldb_private::ConstStringTable &strtab) const
Encode this object into a data encoder object.
Definition: NameToDIE.cpp:128
void Dump(lldb_private::Stream *s)
Definition: NameToDIE.cpp:68
bool operator==(const NameToDIE &rhs) const
Used for unit testing the encoding and decoding.
Definition: NameToDIE.cpp:139
void ForEach(std::function< bool(lldb_private::ConstString name, const DIERef &die_ref)> const &callback) const
Definition: NameToDIE.cpp:76
void Clear()
Definition: NameToDIE.h:87
Many cache files require string tables to store data efficiently.
A uniqued constant string class.
Definition: ConstString.h:39
An data extractor class.
Definition: DataExtractor.h:48
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Many cache files require string tables to store data efficiently.
uint64_t offset_t
Definition: lldb-types.h:87