Home | History | Annotate | Download | only in DWARF
      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 
     15 class DWARFCompileUnit;
     16 
     17 class DWARFFormValue
     18 {
     19 public:
     20     typedef struct ValueTypeTag
     21     {
     22         ValueTypeTag() :
     23             value(),
     24             data(NULL)
     25         {
     26             value.uval = 0;
     27         }
     28 
     29         union
     30         {
     31             uint64_t uval;
     32             int64_t sval;
     33             const char* cstr;
     34         } value;
     35         const uint8_t* data;
     36     } ValueType;
     37 
     38     enum
     39     {
     40         eValueTypeInvalid = 0,
     41         eValueTypeUnsigned,
     42         eValueTypeSigned,
     43         eValueTypeCStr,
     44         eValueTypeBlock
     45     };
     46 
     47     DWARFFormValue(dw_form_t form = 0);
     48     dw_form_t           Form()  const { return m_form; }
     49     void                SetForm(dw_form_t form) { m_form = form; }
     50     const ValueType&    Value() const { return m_value; }
     51     void                Dump(lldb_private::Stream &s, const lldb_private::DataExtractor* debug_str_data, const DWARFCompileUnit* cu) const;
     52     bool                ExtractValue(const lldb_private::DataExtractor& data,
     53                                      lldb::offset_t* offset_ptr,
     54                                      const DWARFCompileUnit* cu);
     55     bool                IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (uint8_t*)m_value.value.cstr; }
     56     const uint8_t*      BlockData() const;
     57     uint64_t            Reference(const DWARFCompileUnit* cu) const;
     58     uint64_t            Reference (dw_offset_t offset) const;
     59     bool                ResolveCompileUnitReferences(const DWARFCompileUnit* cu);
     60     bool                Boolean() const { return m_value.value.uval != 0; }
     61     uint64_t            Unsigned() const { return m_value.value.uval; }
     62     void                SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
     63     int64_t             Signed() const { return m_value.value.sval; }
     64     void                SetSigned(int64_t sval) { m_value.value.sval = sval; }
     65     const char*         AsCString(const lldb_private::DataExtractor* debug_str_data_ptr) const;
     66     bool                SkipValue(const lldb_private::DataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu) const;
     67     static bool         SkipValue(const dw_form_t form, const lldb_private::DataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu);
     68 //  static bool         TransferValue(dw_form_t form, const lldb_private::DataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu, BinaryStreamBuf& out_buff);
     69 //  static bool         TransferValue(const DWARFFormValue& formValue, const DWARFCompileUnit* cu, BinaryStreamBuf& out_buff);
     70 //  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);
     71     static bool         IsBlockForm(const dw_form_t form);
     72     static bool         IsDataForm(const dw_form_t form);
     73     static const uint8_t * GetFixedFormSizesForAddressSize (uint8_t addr_size);
     74     static int          Compare (const DWARFFormValue& a, const DWARFFormValue& b, const DWARFCompileUnit* a_cu, const DWARFCompileUnit* b_cu, const lldb_private::DataExtractor* debug_str_data_ptr);
     75 protected:
     76     dw_form_t   m_form;     // Form for this value
     77     ValueType   m_value;    // Contains all data for the form
     78 };
     79 
     80 
     81 #endif  // SymbolFileDWARF_DWARFFormValue_h_
     82