LLDB  mainline
DWARFFormValue.h
Go to the documentation of this file.
1 //===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef SymbolFileDWARF_DWARFFormValue_h_
10 #define SymbolFileDWARF_DWARFFormValue_h_
11 
12 #include "DWARFDataExtractor.h"
13 #include <stddef.h>
14 
15 class DWARFUnit;
16 class SymbolFileDWARF;
17 
19 public:
20  typedef struct ValueTypeTag {
21  ValueTypeTag() : value(), data(NULL) { value.uval = 0; }
22 
23  union {
24  uint64_t uval;
25  int64_t sval;
26  const char *cstr;
27  } value;
28  const uint8_t *data;
29  } ValueType;
30 
32  public:
33  FixedFormSizes() : m_fix_sizes(nullptr), m_size(0) {}
34 
35  FixedFormSizes(const uint8_t *fix_sizes, size_t size)
36  : m_fix_sizes(fix_sizes), m_size(size) {}
37 
38  uint8_t GetSize(uint32_t index) const {
39  return index < m_size ? m_fix_sizes[index] : 0;
40  }
41 
42  bool Empty() const { return m_size == 0; }
43 
44  private:
45  const uint8_t *m_fix_sizes;
46  size_t m_size;
47  };
48 
49  enum {
55  };
56 
58  DWARFFormValue(const DWARFUnit *cu);
59  DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
60  const DWARFUnit *GetCompileUnit() const { return m_cu; }
61  void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
62  dw_form_t Form() const { return m_form; }
63  dw_form_t& FormRef() { return m_form; }
64  void SetForm(dw_form_t form) { m_form = form; }
65  const ValueType &Value() const { return m_value; }
66  ValueType &ValueRef() { return m_value; }
67  void SetValue(const ValueType &val) { m_value = val; }
68 
69  void Dump(lldb_private::Stream &s) const;
71  lldb::offset_t *offset_ptr);
72  const uint8_t *BlockData() const;
73  uint64_t Reference() const;
74  uint64_t Reference(dw_offset_t offset) const;
75  bool Boolean() const { return m_value.value.uval != 0; }
76  uint64_t Unsigned() const { return m_value.value.uval; }
77  void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
78  int64_t Signed() const { return m_value.value.sval; }
79  void SetSigned(int64_t sval) { m_value.value.sval = sval; }
80  const char *AsCString() const;
81  dw_addr_t Address() const;
82  bool IsValid() const { return m_form != 0; }
83  bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data,
84  lldb::offset_t *offset_ptr) const;
85  static bool SkipValue(const dw_form_t form,
86  const lldb_private::DWARFDataExtractor &debug_info_data,
87  lldb::offset_t *offset_ptr, const DWARFUnit *cu);
88  static bool IsBlockForm(const dw_form_t form);
89  static bool IsDataForm(const dw_form_t form);
90  static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size);
91  static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
92  void Clear();
93  static bool FormIsSupported(dw_form_t form);
94 
95 protected:
96  const DWARFUnit *m_cu; // Compile unit for this form
97  dw_form_t m_form; // Form for this value
98  ValueType m_value; // Contains all data for the form
99 };
100 
101 #endif // SymbolFileDWARF_DWARFFormValue_h_
static int Compare(const DWARFFormValue &a, const DWARFFormValue &b)
uint8_t GetSize(uint32_t index) const
void SetCompileUnit(const DWARFUnit *cu)
const char * AsCString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
dw_addr_t Address() const
static bool FormIsSupported(dw_form_t form)
dw_form_t Form() const
const ValueType & Value() const
uint64_t dw_addr_t
Definition: dwarf.h:26
void SetSigned(int64_t sval)
dw_form_t & FormRef()
static bool IsDataForm(const dw_form_t form)
bool Boolean() const
int64_t Signed() const
ValueType & ValueRef()
union DWARFFormValue::ValueTypeTag::@150 value
FixedFormSizes(const uint8_t *fix_sizes, size_t size)
bool ExtractValue(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
static bool IsBlockForm(const dw_form_t form)
uint64_t offset_t
Definition: lldb-types.h:87
void SetUnsigned(uint64_t uval)
void SetValue(const ValueType &val)
uint64_t Reference() const
uint64_t Unsigned() const
bool IsValid() const
const DWARFUnit * m_cu
ValueType m_value
static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size)
bool SkipValue(const lldb_private::DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const
dw_form_t m_form
const DWARFUnit * GetCompileUnit() const
void Dump(lldb_private::Stream &s) const
const uint8_t * BlockData() const
struct DWARFFormValue::ValueTypeTag ValueType
void SetForm(dw_form_t form)