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"
19
20namespace lldb_private::plugin {
21namespace dwarf {
22class DWARFUnit;
23
24class NameToDIE {
25public:
27
28 ~NameToDIE() = default;
29
30 void Dump(Stream *s);
31
32 void Insert(ConstString name, const DIERef &die_ref);
33
34 void Append(const NameToDIE &other);
35
36 void Finalize();
37
38 bool Find(ConstString name,
39 llvm::function_ref<IterationAction(DIERef ref)> callback) const;
40
41 bool Find(const RegularExpression &regex,
42 llvm::function_ref<IterationAction(DIERef ref)> callback) const;
43
44 /// \a unit must be the skeleton unit if possible, not GetNonSkeletonUnit().
46 DWARFUnit &unit,
47 llvm::function_ref<IterationAction(DIERef ref)> callback) const;
48
49 void
50 ForEach(std::function<bool(ConstString name, const DIERef &die_ref)> const
51 &callback) const;
52
53 /// Decode a serialized version of this object from data.
54 ///
55 /// \param data
56 /// The decoder object that references the serialized data.
57 ///
58 /// \param offset_ptr
59 /// A pointer that contains the offset from which the data will be decoded
60 /// from that gets updated as data gets decoded.
61 ///
62 /// \param strtab
63 /// All strings in cache files are put into string tables for efficiency
64 /// and cache file size reduction. Strings are stored as uint32_t string
65 /// table offsets in the cache data.
66 bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr,
67 const StringTableReader &strtab);
68
69 /// Encode this object into a data encoder object.
70 ///
71 /// This allows this object to be serialized to disk.
72 ///
73 /// \param encoder
74 /// A data encoder object that serialized bytes will be encoded into.
75 ///
76 /// \param strtab
77 /// All strings in cache files are put into string tables for efficiency
78 /// and cache file size reduction. Strings are stored as uint32_t string
79 /// table offsets in the cache data.
80 void Encode(DataEncoder &encoder, 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} // namespace dwarf
93} // namespace lldb_private::plugin
94
95#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.
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:31
void Append(const NameToDIE &other)
Definition NameToDIE.cpp:91
bool Find(ConstString name, llvm::function_ref< IterationAction(DIERef ref)> callback) const
Definition NameToDIE.cpp:35
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, const StringTableReader &strtab)
Decode a serialized version of this object from data.
void Insert(ConstString name, const DIERef &die_ref)
Definition NameToDIE.cpp:31
bool operator==(const NameToDIE &rhs) const
Used for unit testing the encoding and decoding.
void Encode(DataEncoder &encoder, ConstStringTable &strtab) const
Encode this object into a data encoder object.
void ForEach(std::function< bool(ConstString name, const DIERef &die_ref)> const &callback) const
Definition NameToDIE.cpp:80
UniqueCStringMap< DIERef > m_map
Definition NameToDIE.h:90
void FindAllEntriesForUnit(DWARFUnit &unit, llvm::function_ref< IterationAction(DIERef ref)> callback) const
unit must be the skeleton unit if possible, not GetNonSkeletonUnit().
Definition NameToDIE.cpp:55
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
uint64_t offset_t
Definition lldb-types.h:85