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 <stddef.h> // for NULL
14 #include "DWARFDataExtractor.h"
16 class DWARFCompileUnit;
21 typedef struct ValueTypeTag
43 m_fix_sizes(nullptr), m_size(0)
46 FixedFormSizes(const uint8_t* fix_sizes, size_t size) :
47 m_fix_sizes(fix_sizes), m_size(size)
51 GetSize(uint32_t index) const
53 return index < m_size ? m_fix_sizes[index] : 0;
63 const uint8_t* m_fix_sizes;
69 eValueTypeInvalid = 0,
77 DWARFFormValue(const DWARFCompileUnit* cu, dw_form_t form);
78 const DWARFCompileUnit* GetCompileUnit () const { return m_cu; }
79 void SetCompileUnit (const DWARFCompileUnit* cu) { m_cu = cu; }
80 dw_form_t Form() const { return m_form; }
81 void SetForm(dw_form_t form) { m_form = form; }
82 const ValueType& Value() const { return m_value; }
83 void Dump(lldb_private::Stream &s) const;
84 bool ExtractValue(const lldb_private::DWARFDataExtractor& data,
85 lldb::offset_t* offset_ptr);
86 const uint8_t* BlockData() const;
87 uint64_t Reference() const;
88 uint64_t Reference (dw_offset_t offset) const;
89 bool Boolean() const { return m_value.value.uval != 0; }
90 uint64_t Unsigned() const { return m_value.value.uval; }
91 void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
92 int64_t Signed() const { return m_value.value.sval; }
93 void SetSigned(int64_t sval) { m_value.value.sval = sval; }
94 const char* AsCString() const;
95 dw_addr_t Address() const;
96 bool IsValid() const { return m_form != 0; }
97 bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr) const;
98 static bool SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu);
99 static bool IsBlockForm(const dw_form_t form);
100 static bool IsDataForm(const dw_form_t form);
101 static FixedFormSizes GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
102 static int Compare (const DWARFFormValue& a,
103 const DWARFFormValue& b);
106 const DWARFCompileUnit* m_cu; // Compile unit for this form
107 dw_form_t m_form; // Form for this value
108 ValueType m_value; // Contains all data for the form
112 #endif // SymbolFileDWARF_DWARFFormValue_h_