DWARFFormValue.h revision 269024
1//===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef SymbolFileDWARF_DWARFFormValue_h_ 11#define SymbolFileDWARF_DWARFFormValue_h_ 12 13#include <stddef.h> // for NULL 14#include "DWARFDataExtractor.h" 15 16class DWARFCompileUnit; 17 18class DWARFFormValue 19{ 20public: 21 typedef struct ValueTypeTag 22 { 23 ValueTypeTag() : 24 value(), 25 data(NULL) 26 { 27 value.uval = 0; 28 } 29 30 union 31 { 32 uint64_t uval; 33 int64_t sval; 34 const char* cstr; 35 } value; 36 const uint8_t* data; 37 } ValueType; 38 39 enum 40 { 41 eValueTypeInvalid = 0, 42 eValueTypeUnsigned, 43 eValueTypeSigned, 44 eValueTypeCStr, 45 eValueTypeBlock 46 }; 47 48 DWARFFormValue(dw_form_t form = 0); 49 dw_form_t Form() const { return m_form; } 50 void SetForm(dw_form_t form) { m_form = form; } 51 const ValueType& Value() const { return m_value; } 52 void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor* debug_str_data, const DWARFCompileUnit* cu) const; 53 bool ExtractValue(const lldb_private::DWARFDataExtractor& data, 54 lldb::offset_t* offset_ptr, 55 const DWARFCompileUnit* cu); 56 bool IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (const uint8_t*)m_value.value.cstr; } 57 const uint8_t* BlockData() const; 58 uint64_t Reference(const DWARFCompileUnit* cu) const; 59 uint64_t Reference (dw_offset_t offset) const; 60 bool ResolveCompileUnitReferences(const DWARFCompileUnit* cu); 61 bool Boolean() const { return m_value.value.uval != 0; } 62 uint64_t Unsigned() const { return m_value.value.uval; } 63 void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; } 64 int64_t Signed() const { return m_value.value.sval; } 65 void SetSigned(int64_t sval) { m_value.value.sval = sval; } 66 const char* AsCString(const lldb_private::DWARFDataExtractor* debug_str_data_ptr) const; 67 bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu) const; 68 static bool SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu); 69// static bool TransferValue(dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu, BinaryStreamBuf& out_buff); 70// static bool TransferValue(const DWARFFormValue& formValue, const DWARFCompileUnit* cu, BinaryStreamBuf& out_buff); 71// static bool PutUnsigned(dw_form_t form, dw_offset_t offset, uint64_t value, BinaryStreamBuf& out_buff, const DWARFCompileUnit* cu, bool fixup_cu_relative_refs); 72 static bool IsBlockForm(const dw_form_t form); 73 static bool IsDataForm(const dw_form_t form); 74 static const uint8_t * GetFixedFormSizesForAddressSize (uint8_t addr_size); 75 static int Compare (const DWARFFormValue& a, const DWARFFormValue& b, const DWARFCompileUnit* a_cu, const DWARFCompileUnit* b_cu, const lldb_private::DWARFDataExtractor* debug_str_data_ptr); 76protected: 77 dw_form_t m_form; // Form for this value 78 ValueType m_value; // Contains all data for the form 79}; 80 81 82#endif // SymbolFileDWARF_DWARFFormValue_h_ 83