LLVM 23.0.0git
DWARFDebugAbbrev.h
Go to the documentation of this file.
1//===- DWARFDebugAbbrev.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 LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H
10#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H
11
15#include <cstdint>
16#include <map>
17#include <optional>
18#include <vector>
19
20namespace llvm {
21
22class raw_ostream;
23
24/// Read the next (attribute, form) specification from an abbreviation
25/// declaration at \p Offset, advancing \p Offset past it. \p ImplicitConst is
26/// set to the inline value of a DW_FORM_implicit_const attribute and to
27/// std::nullopt otherwise. Returns false on the terminating (0, 0) pair.
28LLVM_ABI bool readAbbrevAttribute(const DataExtractor &AbbrevData,
29 uint64_t *Offset, dwarf::Attribute &Name,
30 dwarf::Form &Form,
31 std::optional<int64_t> &ImplicitConst);
32
34 uint64_t Offset;
35 /// Code of the first abbreviation, if all abbreviations in the set have
36 /// consecutive codes. UINT32_MAX otherwise.
37 uint32_t FirstAbbrCode;
38 std::vector<DWARFAbbreviationDeclaration> Decls;
39
40 using const_iterator =
41 std::vector<DWARFAbbreviationDeclaration>::const_iterator;
42
43public:
45
46 uint64_t getOffset() const { return Offset; }
47 LLVM_ABI void dump(raw_ostream &OS) const;
49
52
53 const_iterator begin() const {
54 return Decls.begin();
55 }
56
57 const_iterator end() const {
58 return Decls.end();
59 }
60
61 LLVM_ABI std::string getCodeRange() const;
62
63 uint32_t getFirstAbbrCode() const { return FirstAbbrCode; }
64
65private:
66 void clear();
67};
68
70 using DWARFAbbreviationDeclarationSetMap =
71 std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
72
73 mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
74 mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
75 mutable std::optional<DataExtractor> Data;
76
77public:
79
81 getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const;
82
83 LLVM_ABI void dump(raw_ostream &OS) const;
84 LLVM_ABI Error parse() const;
85
86 DWARFAbbreviationDeclarationSetMap::const_iterator begin() const {
87 assert(!Data && "Must call parse before iterating over DWARFDebugAbbrev");
88 return AbbrDeclSets.begin();
89 }
90
91 DWARFAbbreviationDeclarationSetMap::const_iterator end() const {
92 return AbbrDeclSets.end();
93 }
94};
95
96} // end namespace llvm
97
98#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:215
loop extract
LLVM_ABI void dump(raw_ostream &OS) const
LLVM_ABI const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const
LLVM_ABI std::string getCodeRange() const
LLVM_ABI Expected< const DWARFAbbreviationDeclarationSet * > getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const
LLVM_ABI Error parse() const
DWARFAbbreviationDeclarationSetMap::const_iterator end() const
LLVM_ABI DWARFDebugAbbrev(DataExtractor Data)
LLVM_ABI void dump(raw_ostream &OS) const
DWARFAbbreviationDeclarationSetMap::const_iterator begin() const
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Attribute
Attributes.
Definition Dwarf.h:125
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:573
LLVM_ABI bool readAbbrevAttribute(const DataExtractor &AbbrevData, uint64_t *Offset, dwarf::Attribute &Name, dwarf::Form &Form, std::optional< int64_t > &ImplicitConst)
Read the next (attribute, form) specification from an abbreviation declaration at Offset,...