Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
39645 views
//===-- DWARFBaseDIE.h -----------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H1011#include "lldb/Core/dwarf.h"12#include "lldb/lldb-types.h"1314#include "llvm/Support/Error.h"15#include <optional>1617namespace lldb_private::plugin {18namespace dwarf {19class DIERef;20class DWARFASTParser;21class DWARFAttributes;22class DWARFUnit;23class DWARFDebugInfoEntry;24class DWARFDeclContext;25class SymbolFileDWARF;2627class DWARFBaseDIE {28public:29DWARFBaseDIE() = default;3031DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)32: m_cu(cu), m_die(die) {}3334DWARFBaseDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)35: m_cu(const_cast<DWARFUnit *>(cu)), m_die(die) {}3637DWARFBaseDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)38: m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}3940DWARFBaseDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)41: m_cu(const_cast<DWARFUnit *>(cu)),42m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}4344// Tests45explicit operator bool() const { return IsValid(); }4647bool IsValid() const { return m_cu && m_die; }4849bool HasChildren() const;5051bool Supports_DW_AT_APPLE_objc_complete_type() const;5253// Accessors54SymbolFileDWARF *GetDWARF() const;5556DWARFUnit *GetCU() const { return m_cu; }5758DWARFDebugInfoEntry *GetDIE() const { return m_die; }5960std::optional<DIERef> GetDIERef() const;6162void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {63if (cu && die) {64m_cu = cu;65m_die = die;66} else {67Clear();68}69}7071void Clear() {72m_cu = nullptr;73m_die = nullptr;74}7576// Get the data that contains the attribute values for this DIE. Support77// for .debug_types means that any DIE can have its data either in the78// .debug_info or the .debug_types section; this method will return the79// correct section data.80//81// Clients must validate that this object is valid before calling this.82const DWARFDataExtractor &GetData() const;8384// Accessing information about a DIE85dw_tag_t Tag() const;8687dw_offset_t GetOffset() const;8889// Get the LLDB user ID for this DIE. This is often just the DIE offset,90// but it might have a SymbolFileDWARF::GetID() in the high 32 bits if91// we are doing Darwin DWARF in .o file, or DWARF stand alone debug92// info.93lldb::user_id_t GetID() const;9495const char *GetName() const;9697lldb::ModuleSP GetModule() const;9899// Getting attribute values from the DIE.100//101// GetAttributeValueAsXXX() functions should only be used if you are102// looking for one or two attributes on a DIE. If you are trying to103// parse all attributes, use GetAttributes (...) instead104const char *GetAttributeValueAsString(const dw_attr_t attr,105const char *fail_value) const;106107uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,108uint64_t fail_value) const;109110std::optional<uint64_t>111GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const;112113uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,114uint64_t fail_value) const;115116enum class Recurse : bool { no, yes };117DWARFAttributes GetAttributes(Recurse recurse = Recurse::yes) const;118119protected:120DWARFUnit *m_cu = nullptr;121DWARFDebugInfoEntry *m_die = nullptr;122};123124bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);125bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);126} // namespace dwarf127} // namespace lldb_private::plugin128129#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H130131132