GetAddressByteSize ();
void
+ SetAddressByteSize (uint8_t addr_byte_size);
+
+ void
Clear ();
bool
lldb::ByteOrder
GetByteOrder();
+ void
+ SetByteOrder (lldb::ByteOrder endian);
+
float
GetFloat (lldb::SBError& error, uint32_t offset);
// inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where
// the typemap isn't applied before resolving the overload, and thus the right function never gets called
void
- SetData(lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
+ SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
// see SetData() for why we don't have Append(const void* buf, size_t size)
bool
- Append(const SBData& rhs);
+ Append (const SBData& rhs);
+
+ static lldb::SBData
+ CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data);
+
+ // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len
+ // should not be renamed or rearranged, because doing so will break the SWIG typemap
+ static lldb::SBData
+ CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len);
+
+ bool
+ SetDataFromCString (const char* data);
+
+ bool
+ SetDataFromUInt64Array (uint64_t* array, size_t array_len);
+
+ bool
+ SetDataFromUInt32Array (uint32_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt64Array (int64_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt32Array (int32_t* array, size_t array_len);
+
+ bool
+ SetDataFromDoubleArray (double* array, size_t array_len);
+
protected:
lldb::SBError
UnloadImage (uint32_t image_token);
- lldb::SBData
- GetDataFromCString(const char* data);
-
- lldb::SBData
- GetDataFromUnsignedInt64Array(uint64_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromUnsignedInt32Array(uint32_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromSignedInt64Array(int64_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromSignedInt32Array(int32_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromDoubleArray(double* array, size_t array_len);
-
protected:
friend class SBAddress;
friend class SBBreakpoint;
uint8_t
GetAddressByteSize ();
+
+ void
+ SetAddressByteSize (uint8_t addr_byte_size);
void
Clear ();
lldb::ByteOrder
GetByteOrder();
+
+ void
+ SetByteOrder (lldb::ByteOrder endian);
float
GetFloat (lldb::SBError& error, uint32_t offset);
size_t size);
void
- SetData(lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
+ SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
bool
- Append(const SBData& rhs);
-
+ Append (const SBData& rhs);
+
+ static lldb::SBData
+ CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data);
+
+ // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len
+ // should not be renamed or rearranged, because doing so will break the SWIG typemap
+ static lldb::SBData
+ CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len);
+
+ bool
+ SetDataFromCString (const char* data);
+
+ bool
+ SetDataFromUInt64Array (uint64_t* array, size_t array_len);
+
+ bool
+ SetDataFromUInt32Array (uint32_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt64Array (int64_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt32Array (int32_t* array, size_t array_len);
+
+ bool
+ SetDataFromDoubleArray (double* array, size_t array_len);
};
lldb::SBError
UnloadImage (uint32_t image_token);
- lldb::SBData
- GetDataFromCString(const char* data);
-
- lldb::SBData
- GetDataFromUnsignedInt64Array(uint64_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromUnsignedInt32Array(uint32_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromSignedInt64Array(int64_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromSignedInt32Array(int32_t* array, size_t array_len);
-
- lldb::SBData
- GetDataFromDoubleArray(double* array, size_t array_len);
-
};
} // namespace lldb
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
+#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
using namespace lldb;
using namespace lldb_private;
-SBData::SBData ()
+SBData::SBData () :
+ m_opaque_sp(new DataExtractor())
{
}
}
void
+SBData::SetAddressByteSize (uint8_t addr_byte_size)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (m_opaque_sp.get())
+ m_opaque_sp->SetAddressByteSize(addr_byte_size);
+ if (log)
+ log->Printf ("SBData::SetAddressByteSize (%i)", addr_byte_size);
+}
+
+void
SBData::Clear ()
{
if (m_opaque_sp.get())
return value;
}
+void
+SBData::SetByteOrder (lldb::ByteOrder endian)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (m_opaque_sp.get())
+ m_opaque_sp->SetByteOrder(endian);
+ if (log)
+ log->Printf ("SBData::GetByteOrder (%i)", endian);
+}
+
+
float
SBData::GetFloat (lldb::SBError& error, uint32_t offset)
{
}
void
-SBData::SetData(lldb::SBError& error,
- const void *buf,
- size_t size,
- lldb::ByteOrder endian,
- uint8_t addr_size)
+SBData::SetData (lldb::SBError& error,
+ const void *buf,
+ size_t size,
+ lldb::ByteOrder endian,
+ uint8_t addr_size)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (!m_opaque_sp.get())
}
bool
-SBData::Append(const SBData& rhs)
+SBData::Append (const SBData& rhs)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool value = false;
"(%s)", rhs.get(), value ? "true" : "false");
return value;
}
+
+lldb::SBData
+SBData::CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data)
+{
+ if (!data || !data[0])
+ return SBData();
+
+ uint32_t data_len = strlen(data);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(data, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+lldb::SBData
+SBData::CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len)
+{
+ if (!array || array_len == 0)
+ return SBData();
+
+ size_t data_len = array_len * sizeof(uint64_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+lldb::SBData
+SBData::CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len)
+{
+ if (!array || array_len == 0)
+ return SBData();
+
+ size_t data_len = array_len * sizeof(uint32_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+lldb::SBData
+SBData::CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len)
+{
+ if (!array || array_len == 0)
+ return SBData();
+
+ size_t data_len = array_len * sizeof(int64_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+lldb::SBData
+SBData::CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len)
+{
+ if (!array || array_len == 0)
+ return SBData();
+
+ size_t data_len = array_len * sizeof(int32_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+lldb::SBData
+SBData::CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len)
+{
+ if (!array || array_len == 0)
+ return SBData();
+
+ size_t data_len = array_len * sizeof(double);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+ lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, endian, addr_byte_size));
+
+ SBData ret(data_sp);
+
+ return ret;
+}
+
+bool
+SBData::SetDataFromCString (const char* data)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!data)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromCString (data=%p) => "
+ "false", data);
+ return false;
+ }
+
+ size_t data_len = strlen(data);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(data, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromCString (data=%p) => "
+ "true", data);
+
+ return true;
+}
+
+bool
+SBData::SetDataFromUInt64Array (uint64_t* array, size_t array_len)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!array || array_len == 0)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromUInt64Array (array=%p, array_len = %lu) => "
+ "false", array, array_len);
+ return false;
+ }
+
+ size_t data_len = array_len * sizeof(uint64_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromUInt64Array (array=%p, array_len = %lu) => "
+ "true", array, array_len);
+
+ return true;
+}
+
+bool
+SBData::SetDataFromUInt32Array (uint32_t* array, size_t array_len)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!array || array_len == 0)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromUInt32Array (array=%p, array_len = %lu) => "
+ "false", array, array_len);
+ return false;
+ }
+
+ size_t data_len = array_len * sizeof(uint32_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromUInt32Array (array=%p, array_len = %lu) => "
+ "true", array, array_len);
+
+ return true;
+}
+
+bool
+SBData::SetDataFromSInt64Array (int64_t* array, size_t array_len)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!array || array_len == 0)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromSInt64Array (array=%p, array_len = %lu) => "
+ "false", array, array_len);
+ return false;
+ }
+
+ size_t data_len = array_len * sizeof(int64_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromSInt64Array (array=%p, array_len = %lu) => "
+ "true", array, array_len);
+
+ return true;
+}
+
+bool
+SBData::SetDataFromSInt32Array (int32_t* array, size_t array_len)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!array || array_len == 0)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromSInt32Array (array=%p, array_len = %lu) => "
+ "false", array, array_len);
+ return false;
+ }
+
+ size_t data_len = array_len * sizeof(int32_t);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromSInt32Array (array=%p, array_len = %lu) => "
+ "true", array, array_len);
+
+ return true;
+}
+
+bool
+SBData::SetDataFromDoubleArray (double* array, size_t array_len)
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (!array || array_len == 0)
+ {
+ if (log)
+ log->Printf ("SBData::SetDataFromDoubleArray (array=%p, array_len = %lu) => "
+ "false", array, array_len);
+ return false;
+ }
+
+ size_t data_len = array_len * sizeof(double);
+
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
+
+ if (!m_opaque_sp.get())
+ m_opaque_sp.reset(new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ else
+ m_opaque_sp->SetData(buffer_sp);
+
+ if (log)
+ log->Printf ("SBData::SetDataFromDoubleArray (array=%p, array_len = %lu) => "
+ "true", array, array_len);
+
+ return true;
+}
#include "lldb/lldb-types.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
sb_error.SetErrorString("invalid process");
return sb_error;
}
-
-lldb::SBData
-SBProcess::GetDataFromCString(const char* data)
-{
- if (!IsValid())
- return SBData();
-
- if (!data || !data[0])
- return SBData();
-
- uint32_t data_len = strlen(data);
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(data, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
-lldb::SBData
-SBProcess::GetDataFromUnsignedInt64Array(uint64_t* array, size_t array_len)
-{
- if (!IsValid())
- return SBData();
-
- if (!array || array_len == 0)
- return SBData();
-
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
- size_t data_len = array_len * sizeof(uint64_t);
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
-lldb::SBData
-SBProcess::GetDataFromUnsignedInt32Array(uint32_t* array, size_t array_len)
-{
- if (!IsValid())
- return SBData();
-
- if (!array || array_len == 0)
- return SBData();
-
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
- size_t data_len = array_len * sizeof(uint32_t);
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
-lldb::SBData
-SBProcess::GetDataFromSignedInt64Array(int64_t* array, size_t array_len)
-{
- if (!IsValid())
- return SBData();
-
- if (!array || array_len == 0)
- return SBData();
-
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
- size_t data_len = array_len * sizeof(int64_t);
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
-lldb::SBData
-SBProcess::GetDataFromSignedInt32Array(int32_t* array, size_t array_len)
-{
- if (!IsValid())
- return SBData();
-
- if (!array || array_len == 0)
- return SBData();
-
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
- size_t data_len = array_len * sizeof(int32_t);
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
-lldb::SBData
-SBProcess::GetDataFromDoubleArray(double* array, size_t array_len)
-{
- if (!IsValid())
- return SBData();
-
- if (!array || array_len == 0)
- return SBData();
-
- lldb::ByteOrder byte_order = GetByteOrder();
- uint8_t addr_size = GetAddressByteSize();
- size_t data_len = array_len * sizeof(double);
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
- lldb::DataExtractorSP data_sp(new DataExtractor(buffer_sp, byte_order, addr_size));
-
- SBData ret(data_sp);
-
- return ret;
-}
-
# check the new API calls introduced per LLVM bugzilla enhancement request
# 11619 (Allow creating SBData values from arrays or primitives in Python)
- data2 = process.GetDataFromCString('hello!')
+ data2 = lldb.SBData.CreateDataFromCString(process.GetByteOrder(),process.GetAddressByteSize(),'hello!')
self.assertTrue(data2.GetUnsignedInt8(error,0) == 104, 'h == 104')
self.assertTrue(data2.GetUnsignedInt8(error,1) == 101, 'e == 101')
self.assertTrue(data2.GetUnsignedInt8(error,2) == 108, 'l == 108')
self.assertTrue(data2.GetUnsignedInt8(error,5) == 33, '! == 33')
self.assertTrue(data2.GetUnsignedInt8(error,6) == 0, 'binary 0 terminator')
- data2 = process.GetDataFromUnsignedInt64Array([1,2,3,4,5])
+ data2 = lldb.SBData.CreateDataFromUInt64Array(process.GetByteOrder(),process.GetAddressByteSize(),[1,2,3,4,5])
self.assertTrue(data2.GetUnsignedInt64(error,0) == 1, 'data2[0] = 1')
self.assertTrue(data2.GetUnsignedInt64(error,8) == 2, 'data2[1] = 2')
self.assertTrue(data2.GetUnsignedInt64(error,16) == 3, 'data2[2] = 3')
self.assertTrue(data2.GetUnsignedInt64(error,24) == 4, 'data2[3] = 4')
self.assertTrue(data2.GetUnsignedInt64(error,32) == 5, 'data2[4] = 5')
- data2 = process.GetDataFromSignedInt32Array([2, -2])
+ data2 = lldb.SBData.CreateDataFromSInt32Array(process.GetByteOrder(),process.GetAddressByteSize(),[2, -2])
self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'signed32 data2[0] = 2')
self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'signed32 data2[1] = -2')
- data2.Append(process.GetDataFromSignedInt64Array([2, -2]))
+ data2.Append(lldb.SBData.CreateDataFromSInt64Array(process.GetByteOrder(),process.GetAddressByteSize(),[2, -2]))
self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'signed32 data2[0] = 2')
self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'signed32 data2[1] = -2')
self.assertTrue(data2.GetSignedInt64(error,8) == 2, 'signed64 data2[0] = 2')
self.assertTrue(data2.GetSignedInt64(error,16) == -2, 'signed64 data2[1] = -2')
- data2 = process.GetDataFromUnsignedInt32Array([1,2,3,4,5])
+ data2 = lldb.SBData.CreateDataFromUInt32Array(process.GetByteOrder(),process.GetAddressByteSize(),[1,2,3,4,5])
self.assertTrue(data2.GetUnsignedInt32(error,0) == 1, '32-bit data2[0] = 1')
self.assertTrue(data2.GetUnsignedInt32(error,4) == 2, '32-bit data2[1] = 2')
self.assertTrue(data2.GetUnsignedInt32(error,8) == 3, '32-bit data2[2] = 3')
self.assertTrue(data2.GetUnsignedInt32(error,12) == 4, '32-bit data2[3] = 4')
self.assertTrue(data2.GetUnsignedInt32(error,16) == 5, '32-bit data2[4] = 5')
- data2 = process.GetDataFromDoubleArray([3.14,6.28,2.71])
+ data2 = lldb.SBData.CreateDataFromDoubleArray(process.GetByteOrder(),process.GetAddressByteSize(),[3.14,6.28,2.71])
self.assertTrue( fabs(data2.GetDouble(error,0) - 3.14) < 0.5, 'double data2[0] = 3.14')
self.assertTrue( fabs(data2.GetDouble(error,8) - 6.28) < 0.5, 'double data2[1] = 6.28')
self.assertTrue( fabs(data2.GetDouble(error,16) - 2.71) < 0.5, 'double data2[2] = 2.71')
+
+ data2 = lldb.SBData()
+
+ data2.SetDataFromCString('hello!')
+ self.assertTrue(data2.GetUnsignedInt8(error,0) == 104, 'set h == 104')
+ self.assertTrue(data2.GetUnsignedInt8(error,1) == 101, 'set e == 101')
+ self.assertTrue(data2.GetUnsignedInt8(error,2) == 108, 'set l == 108')
+ self.assertTrue(data2.GetUnsignedInt8(error,3) == 108, 'set l == 108')
+ self.assertTrue(data2.GetUnsignedInt8(error,4) == 111, 'set o == 111')
+ self.assertTrue(data2.GetUnsignedInt8(error,5) == 33, 'set ! == 33')
+ self.assertTrue(data2.GetUnsignedInt8(error,6) == 0, 'set binary 0 terminator')
+
+ data2.SetDataFromUInt64Array([1,2,3,4,5])
+ self.assertTrue(data2.GetUnsignedInt64(error,0) == 1, 'set data2[0] = 1')
+ self.assertTrue(data2.GetUnsignedInt64(error,8) == 2, 'set data2[1] = 2')
+ self.assertTrue(data2.GetUnsignedInt64(error,16) == 3, 'set data2[2] = 3')
+ self.assertTrue(data2.GetUnsignedInt64(error,24) == 4, 'set data2[3] = 4')
+ self.assertTrue(data2.GetUnsignedInt64(error,32) == 5, 'set data2[4] = 5')
+
+ data2.SetDataFromSInt32Array([2, -2])
+ self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'set signed32 data2[0] = 2')
+ self.assertTrue(data2.GetSignedInt32(error,4) == -2, 'set signed32 data2[1] = -2')
+
+ data2.SetDataFromSInt64Array([2, -2])
+ self.assertTrue(data2.GetSignedInt32(error,0) == 2, 'set signed64 data2[0] = 2')
+ self.assertTrue(data2.GetSignedInt32(error,8) == -2, 'set signed64 data2[1] = -2')
+
+ data2.SetDataFromUInt32Array([1,2,3,4,5])
+ self.assertTrue(data2.GetUnsignedInt32(error,0) == 1, 'set 32-bit data2[0] = 1')
+ self.assertTrue(data2.GetUnsignedInt32(error,4) == 2, 'set 32-bit data2[1] = 2')
+ self.assertTrue(data2.GetUnsignedInt32(error,8) == 3, 'set 32-bit data2[2] = 3')
+ self.assertTrue(data2.GetUnsignedInt32(error,12) == 4, 'set 32-bit data2[3] = 4')
+ self.assertTrue(data2.GetUnsignedInt32(error,16) == 5, 'set 32-bit data2[4] = 5')
+ data2.SetDataFromDoubleArray([3.14,6.28,2.71])
+ self.assertTrue( fabs(data2.GetDouble(error,0) - 3.14) < 0.5, 'set double data2[0] = 3.14')
+ self.assertTrue( fabs(data2.GetDouble(error,8) - 6.28) < 0.5, 'set double data2[1] = 6.28')
+ self.assertTrue( fabs(data2.GetDouble(error,16) - 2.71) < 0.5, 'set double data2[2] = 2.71')
if __name__ == '__main__':
import atexit