1 //===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SymbolFileDWARF_DWARFFormValue_h_
11 #define SymbolFileDWARF_DWARFFormValue_h_
13 #include "DWARFDataExtractor.h"
17 class SymbolFileDWARF;
19 class DWARFFormValue {
21 typedef struct ValueTypeTag {
22 ValueTypeTag() : value(), data(NULL) { value.uval = 0; }
32 class FixedFormSizes {
34 FixedFormSizes() : m_fix_sizes(nullptr), m_size(0) {}
36 FixedFormSizes(const uint8_t *fix_sizes, size_t size)
37 : m_fix_sizes(fix_sizes), m_size(size) {}
39 uint8_t GetSize(uint32_t index) const {
40 return index < m_size ? m_fix_sizes[index] : 0;
43 bool Empty() const { return m_size == 0; }
46 const uint8_t *m_fix_sizes;
51 eValueTypeInvalid = 0,
59 DWARFFormValue(const DWARFUnit *cu);
60 DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
61 const DWARFUnit *GetCompileUnit() const { return m_cu; }
62 void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
63 dw_form_t Form() const { return m_form; }
64 dw_form_t& FormRef() { return m_form; }
65 void SetForm(dw_form_t form) { m_form = form; }
66 const ValueType &Value() const { return m_value; }
67 ValueType &ValueRef() { return m_value; }
68 void SetValue(const ValueType &val) { m_value = val; }
70 void Dump(lldb_private::Stream &s) const;
71 bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
72 lldb::offset_t *offset_ptr);
73 const uint8_t *BlockData() const;
74 uint64_t Reference() const;
75 uint64_t Reference(dw_offset_t offset) const;
76 bool Boolean() const { return m_value.value.uval != 0; }
77 uint64_t Unsigned() const { return m_value.value.uval; }
78 void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
79 int64_t Signed() const { return m_value.value.sval; }
80 void SetSigned(int64_t sval) { m_value.value.sval = sval; }
81 const char *AsCString() const;
82 dw_addr_t Address() const;
83 bool IsValid() const { return m_form != 0; }
84 bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data,
85 lldb::offset_t *offset_ptr) const;
86 static bool SkipValue(const dw_form_t form,
87 const lldb_private::DWARFDataExtractor &debug_info_data,
88 lldb::offset_t *offset_ptr, const DWARFUnit *cu);
89 static bool IsBlockForm(const dw_form_t form);
90 static bool IsDataForm(const dw_form_t form);
91 static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size,
93 static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
95 static bool FormIsSupported(dw_form_t form);
98 const DWARFUnit *m_cu; // Compile unit for this form
99 dw_form_t m_form; // Form for this value
100 ValueType m_value; // Contains all data for the form
103 #endif // SymbolFileDWARF_DWARFFormValue_h_