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