LLDB API Documentation

SBData.h
Go to the documentation of this file.
1 //===-- SBData.h -----------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_SBData_h_
11 #define LLDB_SBData_h_
12 
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 
17 class SBData
18 {
19 public:
20 
21  SBData ();
22 
23  SBData (const SBData &rhs);
24 
25  const SBData &
26  operator = (const SBData &rhs);
27 
28  ~SBData ();
29 
30  uint8_t
32 
33  void
34  SetAddressByteSize (uint8_t addr_byte_size);
35 
36  void
37  Clear ();
38 
39  bool
40  IsValid();
41 
42  size_t
43  GetByteSize ();
44 
45  lldb::ByteOrder
46  GetByteOrder();
47 
48  void
49  SetByteOrder (lldb::ByteOrder endian);
50 
51  float
52  GetFloat (lldb::SBError& error, lldb::offset_t offset);
53 
54  double
55  GetDouble (lldb::SBError& error, lldb::offset_t offset);
56 
57  long double
58  GetLongDouble (lldb::SBError& error, lldb::offset_t offset);
59 
60  lldb::addr_t
61  GetAddress (lldb::SBError& error, lldb::offset_t offset);
62 
63  uint8_t
64  GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset);
65 
66  uint16_t
67  GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset);
68 
69  uint32_t
70  GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset);
71 
72  uint64_t
73  GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset);
74 
75  int8_t
76  GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset);
77 
78  int16_t
79  GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset);
80 
81  int32_t
82  GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset);
83 
84  int64_t
85  GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset);
86 
87  const char*
88  GetString (lldb::SBError& error, lldb::offset_t offset);
89 
90  size_t
91  ReadRawData (lldb::SBError& error,
92  lldb::offset_t offset,
93  void *buf,
94  size_t size);
95 
96  bool
97  GetDescription (lldb::SBStream &description, lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
98 
99  // it would be nice to have SetData(SBError, const void*, size_t) when endianness and address size can be
100  // inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where
101  // the typemap isn't applied before resolving the overload, and thus the right function never gets called
102  void
103  SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
104 
105  // see SetData() for why we don't have Append(const void* buf, size_t size)
106  bool
107  Append (const SBData& rhs);
108 
109  static lldb::SBData
110  CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data);
111 
112  // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len
113  // should not be renamed or rearranged, because doing so will break the SWIG typemap
114  static lldb::SBData
115  CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len);
116 
117  static lldb::SBData
118  CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len);
119 
120  static lldb::SBData
121  CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len);
122 
123  static lldb::SBData
124  CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len);
125 
126  static lldb::SBData
127  CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len);
128 
129  bool
130  SetDataFromCString (const char* data);
131 
132  bool
133  SetDataFromUInt64Array (uint64_t* array, size_t array_len);
134 
135  bool
136  SetDataFromUInt32Array (uint32_t* array, size_t array_len);
137 
138  bool
139  SetDataFromSInt64Array (int64_t* array, size_t array_len);
140 
141  bool
142  SetDataFromSInt32Array (int32_t* array, size_t array_len);
143 
144  bool
145  SetDataFromDoubleArray (double* array, size_t array_len);
146 
147 
148 protected:
149 
150  // Mimic shared pointer...
151  lldb_private::DataExtractor *
152  get() const;
153 
154  lldb_private::DataExtractor *
155  operator->() const;
156 
157  lldb::DataExtractorSP &
158  operator*();
159 
160  const lldb::DataExtractorSP &
161  operator*() const;
162 
163  SBData (const lldb::DataExtractorSP &data_sp);
164 
165  void
166  SetOpaque (const lldb::DataExtractorSP &data_sp);
167 
168 private:
169  friend class SBInstruction;
170  friend class SBProcess;
171  friend class SBSection;
172  friend class SBValue;
173 
174  lldb::DataExtractorSP m_opaque_sp;
175 };
176 
177 
178 } // namespace lldb
179 
180 #endif // LLDB_SBData_h_