LLDB mainline
DWARFFormValue.h
Go to the documentation of this file.
1//===-- DWARFFormValue.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_DWARFFORMVALUE_H
10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
11
12#include "DWARFDataExtractor.h"
13#include <cstddef>
14#include <optional>
15
16class DWARFUnit;
17class SymbolFileDWARF;
18class DWARFDIE;
19
21public:
22 typedef struct ValueTypeTag {
23 ValueTypeTag() : value() { value.uval = 0; }
24
25 union {
26 uint64_t uval;
27 int64_t sval;
28 const char *cstr;
30 const uint8_t *data = nullptr;
32
33 enum {
39 };
40
41 DWARFFormValue() = default;
42 DWARFFormValue(const DWARFUnit *unit) : m_unit(unit) {}
44 : m_unit(unit), m_form(form) {}
45 const DWARFUnit *GetUnit() const { return m_unit; }
46 void SetUnit(const DWARFUnit *unit) { m_unit = unit; }
47 dw_form_t Form() const { return m_form; }
48 dw_form_t& FormRef() { return m_form; }
49 void SetForm(dw_form_t form) { m_form = form; }
50 const ValueType &Value() const { return m_value; }
51 ValueType &ValueRef() { return m_value; }
52 void SetValue(const ValueType &val) { m_value = val; }
53
54 void Dump(lldb_private::Stream &s) const;
56 lldb::offset_t *offset_ptr);
57 const uint8_t *BlockData() const;
58 static std::optional<uint8_t> GetFixedSize(dw_form_t form,
59 const DWARFUnit *u);
60 std::optional<uint8_t> GetFixedSize() const;
61 DWARFDIE Reference() const;
62 uint64_t Reference(dw_offset_t offset) const;
63 bool Boolean() const { return m_value.value.uval != 0; }
64 uint64_t Unsigned() const { return m_value.value.uval; }
65 void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
66 int64_t Signed() const { return m_value.value.sval; }
67 void SetSigned(int64_t sval) { m_value.value.sval = sval; }
68 const char *AsCString() const;
69 dw_addr_t Address() const;
70 bool IsValid() const { return m_form != 0; }
71 bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data,
72 lldb::offset_t *offset_ptr) const;
73 static bool SkipValue(const dw_form_t form,
74 const lldb_private::DWARFDataExtractor &debug_info_data,
75 lldb::offset_t *offset_ptr, const DWARFUnit *unit);
76 static bool IsBlockForm(const dw_form_t form);
77 static bool IsDataForm(const dw_form_t form);
78 static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
79 void Clear();
80 static bool FormIsSupported(dw_form_t form);
81
82protected:
83 // Compile unit where m_value was located.
84 // It may be different from compile unit where m_value refers to.
85 const DWARFUnit *m_unit = nullptr; // Unit for this form
86 dw_form_t m_form = 0; // Form for this value
87 ValueType m_value; // Contains all data for the form
88};
89
90#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
DWARFDIE Reference() const
DWARFFormValue()=default
static bool FormIsSupported(dw_form_t form)
bool IsValid() const
dw_form_t Form() const
const char * AsCString() const
void SetForm(dw_form_t form)
void SetSigned(int64_t sval)
uint64_t Unsigned() const
static bool IsDataForm(const dw_form_t form)
const uint8_t * BlockData() const
dw_form_t m_form
dw_addr_t Address() const
std::optional< uint8_t > GetFixedSize() const
void SetUnsigned(uint64_t uval)
struct DWARFFormValue::ValueTypeTag ValueType
ValueType m_value
const DWARFUnit * GetUnit() const
ValueType & ValueRef()
void SetUnit(const DWARFUnit *unit)
static bool IsBlockForm(const dw_form_t form)
void Dump(lldb_private::Stream &s) const
void SetValue(const ValueType &val)
DWARFFormValue(const DWARFUnit *unit, dw_form_t form)
DWARFFormValue(const DWARFUnit *unit)
static int Compare(const DWARFFormValue &a, const DWARFFormValue &b)
const DWARFUnit * m_unit
bool Boolean() const
int64_t Signed() const
dw_form_t & FormRef()
const ValueType & Value() const
bool ExtractValue(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
uint64_t dw_offset_t
Definition: dwarf.h:33
uint64_t dw_addr_t
Definition: dwarf.h:29
uint64_t offset_t
Definition: lldb-types.h:83
union DWARFFormValue::ValueTypeTag::@154 value