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