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"
14 #include <stddef.h> // for NULL
16 class DWARFCompileUnit;
18 class DWARFFormValue {
20 typedef struct ValueTypeTag {
21 ValueTypeTag() : value(), data(NULL) { value.uval = 0; }
31 class FixedFormSizes {
33 FixedFormSizes() : m_fix_sizes(nullptr), m_size(0) {}
35 FixedFormSizes(const uint8_t *fix_sizes, size_t size)
36 : m_fix_sizes(fix_sizes), m_size(size) {}
38 uint8_t GetSize(uint32_t index) const {
39 return index < m_size ? m_fix_sizes[index] : 0;
42 bool Empty() const { return m_size == 0; }
45 const uint8_t *m_fix_sizes;
50 eValueTypeInvalid = 0,
58 DWARFFormValue(const DWARFCompileUnit *cu, dw_form_t form);
59 const DWARFCompileUnit *GetCompileUnit() const { return m_cu; }
60 void SetCompileUnit(const DWARFCompileUnit *cu) { m_cu = cu; }
61 dw_form_t Form() const { return m_form; }
62 void SetForm(dw_form_t form) { m_form = form; }
63 const ValueType &Value() const { return m_value; }
64 void Dump(lldb_private::Stream &s) const;
65 bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
66 lldb::offset_t *offset_ptr);
67 const uint8_t *BlockData() const;
68 uint64_t Reference() const;
69 uint64_t Reference(dw_offset_t offset) const;
70 bool Boolean() const { return m_value.value.uval != 0; }
71 uint64_t Unsigned() const { return m_value.value.uval; }
72 void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
73 int64_t Signed() const { return m_value.value.sval; }
74 void SetSigned(int64_t sval) { m_value.value.sval = sval; }
75 const char *AsCString() const;
76 dw_addr_t Address() const;
77 bool IsValid() const { return m_form != 0; }
78 bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data,
79 lldb::offset_t *offset_ptr) const;
80 static bool SkipValue(const dw_form_t form,
81 const lldb_private::DWARFDataExtractor &debug_info_data,
82 lldb::offset_t *offset_ptr, const DWARFCompileUnit *cu);
83 static bool IsBlockForm(const dw_form_t form);
84 static bool IsDataForm(const dw_form_t form);
85 static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size,
87 static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
91 const DWARFCompileUnit *m_cu; // Compile unit for this form
92 dw_form_t m_form; // Form for this value
93 ValueType m_value; // Contains all data for the form
96 #endif // SymbolFileDWARF_DWARFFormValue_h_