]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
Merge OpenSSL 1.0.2f.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / SymbolFile / DWARF / DWARFFormValue.h
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
16 class DWARFCompileUnit;
17
18 class DWARFFormValue
19 {
20 public:
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();
49     DWARFFormValue(const DWARFCompileUnit* cu, dw_form_t form);
50     const DWARFCompileUnit* GetCompileUnit () const { return m_cu; }
51     void                SetCompileUnit (const DWARFCompileUnit* cu) { m_cu = cu; }
52     dw_form_t           Form()  const { return m_form; }
53     void                SetForm(dw_form_t form) { m_form = form; }
54     const ValueType&    Value() const { return m_value; }
55     void                Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor* debug_str_data) const;
56     bool                ExtractValue(const lldb_private::DWARFDataExtractor& data,
57                                      lldb::offset_t* offset_ptr);
58     bool                IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (const uint8_t*)m_value.value.cstr; }
59     const uint8_t*      BlockData() const;
60     uint64_t            Reference() const;
61     uint64_t            Reference (dw_offset_t offset) const;
62     bool                Boolean() const { return m_value.value.uval != 0; }
63     uint64_t            Unsigned() const { return m_value.value.uval; }
64     void                SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
65     int64_t             Signed() const { return m_value.value.sval; }
66     void                SetSigned(int64_t sval) { m_value.value.sval = sval; }
67     const char*         AsCString(const lldb_private::DWARFDataExtractor* debug_str_data_ptr) const;
68     bool                SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr) const;
69     static bool         SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu);
70     static bool         IsBlockForm(const dw_form_t form);
71     static bool         IsDataForm(const dw_form_t form);
72     static const uint8_t * GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
73     static int          Compare (const DWARFFormValue& a, const DWARFFormValue& b, const lldb_private::DWARFDataExtractor* debug_str_data_ptr);
74 protected:
75     const DWARFCompileUnit* m_cu; // Compile unit for this form
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_