LLDB  mainline
DWARFAbbreviationDeclaration.h
Go to the documentation of this file.
1 //===-- DWARFAbbreviationDeclaration.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_DWARFABBREVIATIONDECLARATION_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFABBREVIATIONDECLARATION_H
11 
12 #include "DWARFAttribute.h"
13 #include "DWARFDefines.h"
14 #include "SymbolFileDWARF.h"
15 #include "llvm/Support/Error.h"
16 
18 public:
19  enum { InvalidCode = 0 };
21 
22  // For hand crafting an abbreviation declaration
23  DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
24 
25  dw_uleb128_t Code() const { return m_code; }
26  void SetCode(dw_uleb128_t code) { m_code = code; }
27  dw_tag_t Tag() const { return m_tag; }
28  bool HasChildren() const { return m_has_children; }
29  size_t NumAttributes() const { return m_attributes.size(); }
31  return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0;
32  }
33 
34  // idx is assumed to be valid when calling GetAttrAndFormByIndex()
36  DWARFFormValue &form_value) const {
37  m_attributes[idx].get(attr, form_value.FormRef(), form_value.ValueRef());
38  }
40  return m_attributes[idx].get_form();
41  }
43 
44  /// Extract one abbreviation declaration and all of its associated attributes.
45  /// Possible return values:
46  /// DWARFEnumState::Complete - the extraction completed successfully. This
47  /// was the last abbrev decl in a sequence, and the user should not call
48  /// this function again.
49  /// DWARFEnumState::MoreItems - the extraction completed successfully. The
50  /// user should call this function again to retrieve the next decl.
51  /// llvm::Error - A parsing error occurred. The debug info is malformed.
52  llvm::Expected<lldb_private::DWARFEnumState>
54  lldb::offset_t *offset_ptr);
55  bool IsValid();
56 
57 protected:
59  dw_tag_t m_tag = llvm::dwarf::DW_TAG_null;
60  uint8_t m_has_children = 0;
62 };
63 
64 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFABBREVIATIONDECLARATION_H
DWARFAttribute.h
DWARFFormValue::ValueRef
ValueType & ValueRef()
Definition: DWARFFormValue.h:51
dw_tag_t
llvm::dwarf::Tag dw_tag_t
Definition: dwarf.h:25
DWARFAttribute::collection
std::vector< DWARFAttribute > collection
Definition: DWARFAttribute.h:34
DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration
DWARFAbbreviationDeclaration()
Definition: DWARFAbbreviationDeclaration.cpp:20
SymbolFileDWARF.h
DWARFFormValue::FormRef
dw_form_t & FormRef()
Definition: DWARFFormValue.h:48
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::DWARFDataExtractor
Definition: DWARFDataExtractor.h:18
DWARFDefines.h
DWARFAbbreviationDeclaration::m_has_children
uint8_t m_has_children
Definition: DWARFAbbreviationDeclaration.h:60
DWARFAbbreviationDeclaration::InvalidCode
@ InvalidCode
Definition: DWARFAbbreviationDeclaration.h:19
DWARFAbbreviationDeclaration::NumAttributes
size_t NumAttributes() const
Definition: DWARFAbbreviationDeclaration.h:29
DWARFAbbreviationDeclaration::Code
dw_uleb128_t Code() const
Definition: DWARFAbbreviationDeclaration.h:25
DWARFAbbreviationDeclaration::GetFormByIndexUnchecked
dw_form_t GetFormByIndexUnchecked(uint32_t idx) const
Definition: DWARFAbbreviationDeclaration.h:39
DWARFFormValue
Definition: DWARFFormValue.h:20
DWARFAbbreviationDeclaration::m_attributes
DWARFAttribute::collection m_attributes
Definition: DWARFAbbreviationDeclaration.h:61
DWARFAbbreviationDeclaration::extract
llvm::Expected< lldb_private::DWARFEnumState > extract(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
Extract one abbreviation declaration and all of its associated attributes.
Definition: DWARFAbbreviationDeclaration.cpp:28
DWARFAbbreviationDeclaration::m_code
dw_uleb128_t m_code
Definition: DWARFAbbreviationDeclaration.h:58
uint32_t
DWARFAbbreviationDeclaration::Tag
dw_tag_t Tag() const
Definition: DWARFAbbreviationDeclaration.h:27
DWARFAbbreviationDeclaration::m_tag
dw_tag_t m_tag
Definition: DWARFAbbreviationDeclaration.h:59
uint16_t
DWARFAbbreviationDeclaration
Definition: DWARFAbbreviationDeclaration.h:17
DWARFAbbreviationDeclaration::FindAttributeIndex
uint32_t FindAttributeIndex(dw_attr_t attr) const
Definition: DWARFAbbreviationDeclaration.cpp:74
DWARFAbbreviationDeclaration::GetFormByIndex
dw_form_t GetFormByIndex(uint32_t idx) const
Definition: DWARFAbbreviationDeclaration.h:30
DWARFAbbreviationDeclaration::SetCode
void SetCode(dw_uleb128_t code)
Definition: DWARFAbbreviationDeclaration.h:26
DWARFAbbreviationDeclaration::HasChildren
bool HasChildren() const
Definition: DWARFAbbreviationDeclaration.h:28
DWARFAbbreviationDeclaration::IsValid
bool IsValid()
Definition: DWARFAbbreviationDeclaration.cpp:69
DWARFAbbreviationDeclaration::GetAttrAndFormValueByIndex
void GetAttrAndFormValueByIndex(uint32_t idx, dw_attr_t &attr, DWARFFormValue &form_value) const
Definition: DWARFAbbreviationDeclaration.h:35