1 //===-- SBData.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 LLDB_SBData_h_
11 #define LLDB_SBData_h_
13 #include "lldb/API/SBDefines.h"
17 class LLDB_API SBData {
21 SBData(const SBData &rhs);
23 const SBData &operator=(const SBData &rhs);
27 uint8_t GetAddressByteSize();
29 void SetAddressByteSize(uint8_t addr_byte_size);
37 lldb::ByteOrder GetByteOrder();
39 void SetByteOrder(lldb::ByteOrder endian);
41 float GetFloat(lldb::SBError &error, lldb::offset_t offset);
43 double GetDouble(lldb::SBError &error, lldb::offset_t offset);
45 long double GetLongDouble(lldb::SBError &error, lldb::offset_t offset);
47 lldb::addr_t GetAddress(lldb::SBError &error, lldb::offset_t offset);
49 uint8_t GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset);
51 uint16_t GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset);
53 uint32_t GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset);
55 uint64_t GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset);
57 int8_t GetSignedInt8(lldb::SBError &error, lldb::offset_t offset);
59 int16_t GetSignedInt16(lldb::SBError &error, lldb::offset_t offset);
61 int32_t GetSignedInt32(lldb::SBError &error, lldb::offset_t offset);
63 int64_t GetSignedInt64(lldb::SBError &error, lldb::offset_t offset);
65 const char *GetString(lldb::SBError &error, lldb::offset_t offset);
67 size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf,
70 bool GetDescription(lldb::SBStream &description,
71 lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
73 // it would be nice to have SetData(SBError, const void*, size_t) when
74 // endianness and address size can be
75 // inferred from the existing DataExtractor, but having two SetData()
76 // signatures triggers a SWIG bug where
77 // the typemap isn't applied before resolving the overload, and thus the right
78 // function never gets called
79 void SetData(lldb::SBError &error, const void *buf, size_t size,
80 lldb::ByteOrder endian, uint8_t addr_size);
82 // see SetData() for why we don't have Append(const void* buf, size_t size)
83 bool Append(const SBData &rhs);
85 static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
86 uint32_t addr_byte_size,
89 // in the following CreateData*() and SetData*() prototypes, the two
90 // parameters array and array_len
91 // should not be renamed or rearranged, because doing so will break the SWIG
93 static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
94 uint32_t addr_byte_size,
98 static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
99 uint32_t addr_byte_size,
103 static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
104 uint32_t addr_byte_size,
108 static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
109 uint32_t addr_byte_size,
113 static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
114 uint32_t addr_byte_size,
118 bool SetDataFromCString(const char *data);
120 bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
122 bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
124 bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
126 bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
128 bool SetDataFromDoubleArray(double *array, size_t array_len);
131 // Mimic shared pointer...
132 lldb_private::DataExtractor *get() const;
134 lldb_private::DataExtractor *operator->() const;
136 lldb::DataExtractorSP &operator*();
138 const lldb::DataExtractorSP &operator*() const;
140 SBData(const lldb::DataExtractorSP &data_sp);
142 void SetOpaque(const lldb::DataExtractorSP &data_sp);
145 friend class SBInstruction;
146 friend class SBProcess;
147 friend class SBSection;
148 friend class SBTarget;
149 friend class SBValue;
151 lldb::DataExtractorSP m_opaque_sp;
156 #endif // LLDB_SBData_h_