本文整理汇总了C++中lldb_private::DataExtractor::SetData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::SetData方法的具体用法?C++ DataExtractor::SetData怎么用?C++ DataExtractor::SetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lldb_private::DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::SetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadFromMemory
bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx,
lldb::addr_t addr, AddressType address_type,
lldb_private::DataExtractor &data) {
if (!IsValid())
return false;
// Can't convert a file address to anything valid without more context (which
// Module it came from)
if (address_type == eAddressTypeFile)
return false;
if (!GetCompleteType())
return false;
auto byte_size =
GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (!byte_size)
return false;
if (data.GetByteSize() < *byte_size) {
lldb::DataBufferSP data_sp(new DataBufferHeap(*byte_size, '\0'));
data.SetData(data_sp);
}
uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, *byte_size));
if (dst != nullptr) {
if (address_type == eAddressTypeHost) {
if (addr == 0)
return false;
// The address is an address in this process, so just copy it
memcpy(dst, reinterpret_cast<uint8_t *>(addr), *byte_size);
return true;
} else {
Process *process = nullptr;
if (exe_ctx)
process = exe_ctx->GetProcessPtr();
if (process) {
Status error;
return process->ReadMemory(addr, dst, *byte_size, error) == *byte_size;
}
}
}
return false;
}
示例2: data_sp
size_t
ObjectFileJIT::ReadSectionData (const lldb_private::Section *section,
lldb_private::DataExtractor& section_data) const
{
if (section->GetFileSize())
{
const void *src = (void *)(uintptr_t)section->GetFileOffset();
DataBufferSP data_sp (new lldb_private::DataBufferHeap(src, section->GetFileSize()));
if (data_sp)
{
section_data.SetData (data_sp, 0, data_sp->GetByteSize());
section_data.SetByteOrder (GetByteOrder());
section_data.SetAddressByteSize (GetAddressByteSize());
return section_data.GetByteSize();
}
}
section_data.Clear();
return 0;
}