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 inferred from the existing
75 // DataExtractor, but having two SetData() signatures triggers a SWIG bug
76 // where the typemap isn't applied before resolving the overload, and thus
77 // the right function never gets called
78 void SetData(lldb::SBError &error, const void *buf, size_t size,
79 lldb::ByteOrder endian, uint8_t addr_size);
81 // see SetData() for why we don't have Append(const void* buf, size_t size)
82 bool Append(const SBData &rhs);
84 static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
85 uint32_t addr_byte_size,
88 // in the following CreateData*() and SetData*() prototypes, the two
89 // parameters array and array_len should not be renamed or rearranged,
90 // because doing so will break the SWIG typemap
91 static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
92 uint32_t addr_byte_size,
96 static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
97 uint32_t addr_byte_size,
101 static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
102 uint32_t addr_byte_size,
106 static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
107 uint32_t addr_byte_size,
111 static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
112 uint32_t addr_byte_size,
116 bool SetDataFromCString(const char *data);
118 bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
120 bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
122 bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
124 bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
126 bool SetDataFromDoubleArray(double *array, size_t array_len);
129 // Mimic shared pointer...
130 lldb_private::DataExtractor *get() const;
132 lldb_private::DataExtractor *operator->() const;
134 lldb::DataExtractorSP &operator*();
136 const lldb::DataExtractorSP &operator*() const;
138 SBData(const lldb::DataExtractorSP &data_sp);
140 void SetOpaque(const lldb::DataExtractorSP &data_sp);
143 friend class SBInstruction;
144 friend class SBProcess;
145 friend class SBSection;
146 friend class SBTarget;
147 friend class SBValue;
149 lldb::DataExtractorSP m_opaque_sp;
154 #endif // LLDB_SBData_h_