Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:41

0001 //===-- SBData.h -----------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBDATA_H
0010 #define LLDB_API_SBDATA_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 
0014 namespace lldb_private {
0015 class ScriptInterpreter;
0016 } // namespace lldb_private
0017 
0018 namespace lldb {
0019 
0020 class LLDB_API SBData {
0021 public:
0022   SBData();
0023 
0024   SBData(const SBData &rhs);
0025 
0026   const SBData &operator=(const SBData &rhs);
0027 
0028   ~SBData();
0029 
0030   uint8_t GetAddressByteSize();
0031 
0032   void SetAddressByteSize(uint8_t addr_byte_size);
0033 
0034   void Clear();
0035 
0036   explicit operator bool() const;
0037 
0038   bool IsValid();
0039 
0040   size_t GetByteSize();
0041 
0042   lldb::ByteOrder GetByteOrder();
0043 
0044   void SetByteOrder(lldb::ByteOrder endian);
0045 
0046   float GetFloat(lldb::SBError &error, lldb::offset_t offset);
0047 
0048   double GetDouble(lldb::SBError &error, lldb::offset_t offset);
0049 
0050   long double GetLongDouble(lldb::SBError &error, lldb::offset_t offset);
0051 
0052   lldb::addr_t GetAddress(lldb::SBError &error, lldb::offset_t offset);
0053 
0054   uint8_t GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset);
0055 
0056   uint16_t GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset);
0057 
0058   uint32_t GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset);
0059 
0060   uint64_t GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset);
0061 
0062   int8_t GetSignedInt8(lldb::SBError &error, lldb::offset_t offset);
0063 
0064   int16_t GetSignedInt16(lldb::SBError &error, lldb::offset_t offset);
0065 
0066   int32_t GetSignedInt32(lldb::SBError &error, lldb::offset_t offset);
0067 
0068   int64_t GetSignedInt64(lldb::SBError &error, lldb::offset_t offset);
0069 
0070   const char *GetString(lldb::SBError &error, lldb::offset_t offset);
0071 
0072   size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf,
0073                      size_t size);
0074 
0075   bool GetDescription(lldb::SBStream &description,
0076                       lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
0077 
0078   // it would be nice to have SetData(SBError, const void*, size_t) when
0079   // endianness and address size can be inferred from the existing
0080   // DataExtractor, but having two SetData() signatures triggers a SWIG bug
0081   // where the typemap isn't applied before resolving the overload, and thus
0082   // the right function never gets called
0083   void SetData(lldb::SBError &error, const void *buf, size_t size,
0084                lldb::ByteOrder endian, uint8_t addr_size);
0085 
0086   void SetDataWithOwnership(lldb::SBError &error, const void *buf, size_t size,
0087                             lldb::ByteOrder endian, uint8_t addr_size);
0088 
0089   // see SetData() for why we don't have Append(const void* buf, size_t size)
0090   bool Append(const SBData &rhs);
0091 
0092   static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
0093                                             uint32_t addr_byte_size,
0094                                             const char *data);
0095 
0096   // in the following CreateData*() and SetData*() prototypes, the two
0097   // parameters array and array_len should not be renamed or rearranged,
0098   // because doing so will break the SWIG typemap
0099   static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
0100                                                 uint32_t addr_byte_size,
0101                                                 uint64_t *array,
0102                                                 size_t array_len);
0103 
0104   static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
0105                                                 uint32_t addr_byte_size,
0106                                                 uint32_t *array,
0107                                                 size_t array_len);
0108 
0109   static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
0110                                                 uint32_t addr_byte_size,
0111                                                 int64_t *array,
0112                                                 size_t array_len);
0113 
0114   static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
0115                                                 uint32_t addr_byte_size,
0116                                                 int32_t *array,
0117                                                 size_t array_len);
0118 
0119   static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
0120                                                 uint32_t addr_byte_size,
0121                                                 double *array,
0122                                                 size_t array_len);
0123 
0124   bool SetDataFromCString(const char *data);
0125 
0126   bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
0127 
0128   bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
0129 
0130   bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
0131 
0132   bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
0133 
0134   bool SetDataFromDoubleArray(double *array, size_t array_len);
0135 
0136 protected:
0137   // Mimic shared pointer...
0138   lldb_private::DataExtractor *get() const;
0139 
0140   lldb_private::DataExtractor *operator->() const;
0141 
0142   lldb::DataExtractorSP &operator*();
0143 
0144   const lldb::DataExtractorSP &operator*() const;
0145 
0146   SBData(const lldb::DataExtractorSP &data_sp);
0147 
0148   void SetOpaque(const lldb::DataExtractorSP &data_sp);
0149 
0150 private:
0151   friend class SBInstruction;
0152   friend class SBProcess;
0153   friend class SBSection;
0154   friend class SBTarget;
0155   friend class SBValue;
0156 
0157   friend class lldb_private::ScriptInterpreter;
0158 
0159   lldb::DataExtractorSP m_opaque_sp;
0160 };
0161 
0162 } // namespace lldb
0163 
0164 #endif // LLDB_API_SBDATA_H