LLDB mainline
SBData.h
Go to the documentation of this file.
1//===-- SBData.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 LLDB_API_SBDATA_H
10#define LLDB_API_SBDATA_H
11
12#include "lldb/API/SBDefines.h"
13
14namespace lldb_private {
15class ScriptInterpreter;
16} // namespace lldb_private
17
18namespace lldb {
19
21public:
22 SBData();
23
24 SBData(const SBData &rhs);
25
26 const SBData &operator=(const SBData &rhs);
27
29
30 uint8_t GetAddressByteSize();
31
32 void SetAddressByteSize(uint8_t addr_byte_size);
33
34 void Clear();
35
36 explicit operator bool() const;
37
38 bool IsValid();
39
40 size_t GetByteSize();
41
42 lldb::ByteOrder GetByteOrder();
43
44 void SetByteOrder(lldb::ByteOrder endian);
45
46 float GetFloat(lldb::SBError &error, lldb::offset_t offset);
47
48 double GetDouble(lldb::SBError &error, lldb::offset_t offset);
49
50 long double GetLongDouble(lldb::SBError &error, lldb::offset_t offset);
51
53
54 uint8_t GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset);
55
56 uint16_t GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset);
57
58 uint32_t GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset);
59
60 uint64_t GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset);
61
62 int8_t GetSignedInt8(lldb::SBError &error, lldb::offset_t offset);
63
64 int16_t GetSignedInt16(lldb::SBError &error, lldb::offset_t offset);
65
66 int32_t GetSignedInt32(lldb::SBError &error, lldb::offset_t offset);
67
68 int64_t GetSignedInt64(lldb::SBError &error, lldb::offset_t offset);
69
70 const char *GetString(lldb::SBError &error, lldb::offset_t offset);
71
72 size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf,
73 size_t size);
74
75 bool GetDescription(lldb::SBStream &description,
77
78 // it would be nice to have SetData(SBError, const void*, size_t) when
79 // endianness and address size can be inferred from the existing
80 // DataExtractor, but having two SetData() signatures triggers a SWIG bug
81 // where the typemap isn't applied before resolving the overload, and thus
82 // the right function never gets called
83 void SetData(lldb::SBError &error, const void *buf, size_t size,
84 lldb::ByteOrder endian, uint8_t addr_size);
85
86 void SetDataWithOwnership(lldb::SBError &error, const void *buf, size_t size,
87 lldb::ByteOrder endian, uint8_t addr_size);
88
89 // see SetData() for why we don't have Append(const void* buf, size_t size)
90 bool Append(const SBData &rhs);
91
92 static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
93 uint32_t addr_byte_size,
94 const char *data);
95
96 // in the following CreateData*() and SetData*() prototypes, the two
97 // parameters array and array_len should not be renamed or rearranged,
98 // because doing so will break the SWIG typemap
99 static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
100 uint32_t addr_byte_size,
101 uint64_t *array,
102 size_t array_len);
103
104 static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
105 uint32_t addr_byte_size,
106 uint32_t *array,
107 size_t array_len);
108
109 static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
110 uint32_t addr_byte_size,
111 int64_t *array,
112 size_t array_len);
113
114 static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
115 uint32_t addr_byte_size,
116 int32_t *array,
117 size_t array_len);
118
119 static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
120 uint32_t addr_byte_size,
121 double *array,
122 size_t array_len);
123
124 bool SetDataFromCString(const char *data);
125
126 bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
127
128 bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
129
130 bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
131
132 bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
133
134 bool SetDataFromDoubleArray(double *array, size_t array_len);
135
136protected:
137 // Mimic shared pointer...
138 lldb_private::DataExtractor *get() const;
139
140 lldb_private::DataExtractor *operator->() const;
141
142 lldb::DataExtractorSP &operator*();
143
144 const lldb::DataExtractorSP &operator*() const;
145
146 SBData(const lldb::DataExtractorSP &data_sp);
147
148 void SetOpaque(const lldb::DataExtractorSP &data_sp);
149
150private:
151 friend class SBInstruction;
152 friend class SBProcess;
153 friend class SBSection;
154 friend class SBTarget;
155 friend class SBValue;
156
158
160};
161
162} // namespace lldb
163
164#endif // LLDB_API_SBDATA_H
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_API
Definition: SBDefines.h:28
lldb::DataExtractorSP m_opaque_sp
Definition: SBData.h:159
An data extractor class.
Definition: DataExtractor.h:48
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
uint64_t offset_t
Definition: lldb-types.h:83
ByteOrder
Byte ordering definitions.
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
Definition: lldb-forward.h:330