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 
14 namespace lldb_private {
15 class ScriptInterpreter;
16 } // namespace lldb_private
17 
18 namespace lldb {
19 
21 public:
22  SBData();
23 
24  SBData(const SBData &rhs);
25 
26  const SBData &operator=(const SBData &rhs);
27 
28  ~SBData();
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 
52  lldb::addr_t GetAddress(lldb::SBError &error, lldb::offset_t offset);
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  // see SetData() for why we don't have Append(const void* buf, size_t size)
87  bool Append(const SBData &rhs);
88 
89  static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
90  uint32_t addr_byte_size,
91  const char *data);
92 
93  // in the following CreateData*() and SetData*() prototypes, the two
94  // parameters array and array_len should not be renamed or rearranged,
95  // because doing so will break the SWIG typemap
96  static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
97  uint32_t addr_byte_size,
98  uint64_t *array,
99  size_t array_len);
100 
101  static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
102  uint32_t addr_byte_size,
103  uint32_t *array,
104  size_t array_len);
105 
106  static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
107  uint32_t addr_byte_size,
108  int64_t *array,
109  size_t array_len);
110 
111  static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
112  uint32_t addr_byte_size,
113  int32_t *array,
114  size_t array_len);
115 
116  static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
117  uint32_t addr_byte_size,
118  double *array,
119  size_t array_len);
120 
121  bool SetDataFromCString(const char *data);
122 
123  bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
124 
125  bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
126 
127  bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
128 
129  bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
130 
131  bool SetDataFromDoubleArray(double *array, size_t array_len);
132 
133 protected:
134  // Mimic shared pointer...
135  lldb_private::DataExtractor *get() const;
136 
137  lldb_private::DataExtractor *operator->() const;
138 
139  lldb::DataExtractorSP &operator*();
140 
141  const lldb::DataExtractorSP &operator*() const;
142 
143  SBData(const lldb::DataExtractorSP &data_sp);
144 
145  void SetOpaque(const lldb::DataExtractorSP &data_sp);
146 
147 private:
148  friend class SBInstruction;
149  friend class SBProcess;
150  friend class SBSection;
151  friend class SBTarget;
152  friend class SBValue;
153 
155 
156  lldb::DataExtractorSP m_opaque_sp;
157 };
158 
159 } // namespace lldb
160 
161 #endif // LLDB_API_SBDATA_H
SBDefines.h
lldb::SBError
Definition: SBError.h:20
lldb::SBValue
Definition: SBValue.h:21
LLDB_API
#define LLDB_API
Definition: lldb-defines.h:23
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb::SBProcess
Definition: SBProcess.h:23
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb::SBTarget
Definition: SBTarget.h:29
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb::SBSection
Definition: SBSection.h:17
lldb::SBData
class LLDB_API SBData
Definition: SBDefines.h:36
lldb::SBData::m_opaque_sp
lldb::DataExtractorSP m_opaque_sp
Definition: SBData.h:156
uint32_t
lldb::SBData
Definition: SBData.h:20
uint16_t
lldb::SBInstruction
Definition: SBInstruction.h:24
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBStream
Definition: SBStream.h:18
lldb_private::operator*
const Scalar operator*(Scalar lhs, Scalar rhs)
Definition: Scalar.cpp:556
lldb
Definition: SBAddress.h:15
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138