本文整理汇总了C++中Status::SetErrorToGenericError方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::SetErrorToGenericError方法的具体用法?C++ Status::SetErrorToGenericError怎么用?C++ Status::SetErrorToGenericError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::SetErrorToGenericError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteScalarToMemory
void IRMemoryMap::WriteScalarToMemory(lldb::addr_t process_address,
Scalar &scalar, size_t size,
Status &error) {
error.Clear();
if (size == UINT32_MAX)
size = scalar.GetByteSize();
if (size > 0) {
uint8_t buf[32];
const size_t mem_size =
scalar.GetAsMemoryData(buf, size, GetByteOrder(), error);
if (mem_size > 0) {
return WriteMemory(process_address, buf, mem_size, error);
} else {
error.SetErrorToGenericError();
error.SetErrorString(
"Couldn't write scalar: failed to get scalar as memory data");
}
} else {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't write scalar: its size was zero");
}
return;
}
示例2: ret
Materializer::DematerializerSP
Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
lldb::addr_t process_address, Status &error) {
ExecutionContextScope *exe_scope = frame_sp.get();
if (!exe_scope)
exe_scope = map.GetBestExecutionContextScope();
DematerializerSP dematerializer_sp = m_dematerializer_wp.lock();
if (dematerializer_sp) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't materialize: already materialized");
}
DematerializerSP ret(
new Dematerializer(*this, frame_sp, map, process_address));
if (!exe_scope) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't materialize: target doesn't exist");
}
for (EntityUP &entity_up : m_entities) {
entity_up->Materialize(frame_sp, map, process_address, error);
if (!error.Success())
return DematerializerSP();
}
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
log->Printf(
"Materializer::Materialize (frame_sp = %p, process_address = 0x%" PRIx64
") materialized:",
static_cast<void *>(frame_sp.get()), process_address);
for (EntityUP &entity_up : m_entities)
entity_up->DumpToLog(map, process_address, log);
}
m_dematerializer_wp = ret;
return ret;
}
示例3: ReadScalarFromMemory
void IRMemoryMap::ReadScalarFromMemory(Scalar &scalar,
lldb::addr_t process_address,
size_t size, Status &error) {
error.Clear();
if (size > 0) {
DataBufferHeap buf(size, 0);
ReadMemory(buf.GetBytes(), process_address, size, error);
if (!error.Success())
return;
DataExtractor extractor(buf.GetBytes(), buf.GetByteSize(), GetByteOrder(),
GetAddressByteSize());
lldb::offset_t offset = 0;
switch (size) {
default:
error.SetErrorToGenericError();
error.SetErrorStringWithFormat(
"Couldn't read scalar: unsupported size %" PRIu64, (uint64_t)size);
return;
case 1:
scalar = extractor.GetU8(&offset);
break;
case 2:
scalar = extractor.GetU16(&offset);
break;
case 4:
scalar = extractor.GetU32(&offset);
break;
case 8:
scalar = extractor.GetU64(&offset);
break;
}
} else {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read scalar: its size was zero");
}
return;
}
示例4: Wipe
void Materializer::Dematerializer::Dematerialize(Status &error,
lldb::addr_t frame_bottom,
lldb::addr_t frame_top) {
lldb::StackFrameSP frame_sp;
lldb::ThreadSP thread_sp = m_thread_wp.lock();
if (thread_sp)
frame_sp = thread_sp->GetFrameWithStackID(m_stack_id);
ExecutionContextScope *exe_scope = m_map->GetBestExecutionContextScope();
if (!IsValid()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't dematerialize: invalid dematerializer");
}
if (!exe_scope) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't dematerialize: target is gone");
} else {
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
log->Printf("Materializer::Dematerialize (frame_sp = %p, process_address "
"= 0x%" PRIx64 ") about to dematerialize:",
static_cast<void *>(frame_sp.get()), m_process_address);
for (EntityUP &entity_up : m_materializer->m_entities)
entity_up->DumpToLog(*m_map, m_process_address, log);
}
for (EntityUP &entity_up : m_materializer->m_entities) {
entity_up->Dematerialize(frame_sp, *m_map, m_process_address, frame_top,
frame_bottom, error);
if (!error.Success())
break;
}
}
Wipe();
}
示例5: Leak
void IRMemoryMap::Leak(lldb::addr_t process_address, Status &error) {
error.Clear();
AllocationMap::iterator iter = m_allocations.find(process_address);
if (iter == m_allocations.end()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't leak: allocation doesn't exist");
return;
}
Allocation &allocation = iter->second;
allocation.m_leak = true;
}
示例6: Free
void IRMemoryMap::Free(lldb::addr_t process_address, Status &error) {
error.Clear();
AllocationMap::iterator iter = m_allocations.find(process_address);
if (iter == m_allocations.end()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't free: allocation doesn't exist");
return;
}
Allocation &allocation = iter->second;
switch (allocation.m_policy) {
default:
case eAllocationPolicyHostOnly: {
lldb::ProcessSP process_sp = m_process_wp.lock();
if (process_sp) {
if (process_sp->CanJIT() && process_sp->IsAlive())
process_sp->DeallocateMemory(
allocation.m_process_alloc); // FindSpace allocated this for real
}
break;
}
case eAllocationPolicyMirror:
case eAllocationPolicyProcessOnly: {
lldb::ProcessSP process_sp = m_process_wp.lock();
if (process_sp)
process_sp->DeallocateMemory(allocation.m_process_alloc);
}
}
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
log->Printf("IRMemoryMap::Free (0x%" PRIx64 ") freed [0x%" PRIx64
"..0x%" PRIx64 ")",
(uint64_t)process_address, iter->second.m_process_start,
iter->second.m_process_start + iter->second.m_size);
}
m_allocations.erase(iter);
}
示例7: ResolveExecutable
Status PlatformRemoteDarwinDevice::ResolveExecutable(
const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr) {
Status error;
// Nothing special to do here, just use the actual file and architecture
ModuleSpec resolved_module_spec(ms);
// Resolve any executable within a bundle on MacOSX
// TODO: verify that this handles shallow bundles, if not then implement one
// ourselves
Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
if (resolved_module_spec.GetArchitecture().IsValid() ||
resolved_module_spec.GetUUID().IsValid()) {
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
NULL, NULL, NULL);
if (exe_module_sp && exe_module_sp->GetObjectFile())
return error;
exe_module_sp.reset();
}
// No valid architecture was specified or the exact ARM slice wasn't found
// so ask the platform for the architectures that we should be using (in
// the correct order) and see if we can find a match that way
StreamString arch_names;
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
idx, resolved_module_spec.GetArchitecture());
++idx) {
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
NULL, NULL, NULL);
// Did we find an executable using one of the
if (error.Success()) {
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
}
if (idx > 0)
arch_names.PutCString(", ");
arch_names.PutCString(
resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp) {
if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(), arch_names.GetData());
} else {
error.SetErrorStringWithFormat(
"'%s' is not readable",
resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
} else {
error.SetErrorStringWithFormat(
"'%s' does not exist",
resolved_module_spec.GetFileSpec().GetPath().c_str());
}
return error;
}
示例8: GetMemoryData
void IRMemoryMap::GetMemoryData(DataExtractor &extractor,
lldb::addr_t process_address, size_t size,
Status &error) {
error.Clear();
if (size > 0) {
AllocationMap::iterator iter = FindAllocation(process_address, size);
if (iter == m_allocations.end()) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat(
"Couldn't find an allocation containing [0x%" PRIx64 "..0x%" PRIx64
")",
process_address, process_address + size);
return;
}
Allocation &allocation = iter->second;
switch (allocation.m_policy) {
default:
error.SetErrorToGenericError();
error.SetErrorString(
"Couldn't get memory data: invalid allocation policy");
return;
case eAllocationPolicyProcessOnly:
error.SetErrorToGenericError();
error.SetErrorString(
"Couldn't get memory data: memory is only in the target");
return;
case eAllocationPolicyMirror: {
lldb::ProcessSP process_sp = m_process_wp.lock();
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't get memory data: data buffer is empty");
return;
}
if (process_sp) {
process_sp->ReadMemory(allocation.m_process_start,
allocation.m_data.GetBytes(),
allocation.m_data.GetByteSize(), error);
if (!error.Success())
return;
uint64_t offset = process_address - allocation.m_process_start;
extractor = DataExtractor(allocation.m_data.GetBytes() + offset, size,
GetByteOrder(), GetAddressByteSize());
return;
}
} break;
case eAllocationPolicyHostOnly:
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't get memory data: data buffer is empty");
return;
}
uint64_t offset = process_address - allocation.m_process_start;
extractor = DataExtractor(allocation.m_data.GetBytes() + offset, size,
GetByteOrder(), GetAddressByteSize());
return;
}
} else {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't get memory data: its size was zero");
return;
}
}
示例9: ReadMemory
void IRMemoryMap::ReadMemory(uint8_t *bytes, lldb::addr_t process_address,
size_t size, Status &error) {
error.Clear();
AllocationMap::iterator iter = FindAllocation(process_address, size);
if (iter == m_allocations.end()) {
lldb::ProcessSP process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->ReadMemory(process_address, bytes, size, error);
return;
}
lldb::TargetSP target_sp = m_target_wp.lock();
if (target_sp) {
Address absolute_address(process_address);
target_sp->ReadMemory(absolute_address, false, bytes, size, error);
return;
}
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: no allocation contains the target "
"range, and neither the process nor the target exist");
return;
}
Allocation &allocation = iter->second;
uint64_t offset = process_address - allocation.m_process_start;
if (offset > allocation.m_size) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: data is not in the allocation");
return;
}
lldb::ProcessSP process_sp;
switch (allocation.m_policy) {
default:
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: invalid allocation policy");
return;
case eAllocationPolicyHostOnly:
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: data buffer is empty");
return;
}
if (allocation.m_data.GetByteSize() < offset + size) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: not enough underlying data");
return;
}
::memcpy(bytes, allocation.m_data.GetBytes() + offset, size);
break;
case eAllocationPolicyMirror:
process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->ReadMemory(process_address, bytes, size, error);
if (!error.Success())
return;
} else {
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't read: data buffer is empty");
return;
}
::memcpy(bytes, allocation.m_data.GetBytes() + offset, size);
}
break;
case eAllocationPolicyProcessOnly:
process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->ReadMemory(process_address, bytes, size, error);
if (!error.Success())
return;
}
break;
}
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
log->Printf("IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64
", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
(uint64_t)allocation.m_process_start,
(uint64_t)allocation.m_process_start +
(uint64_t)allocation.m_size);
}
}
示例10: WriteMemory
void IRMemoryMap::WriteMemory(lldb::addr_t process_address,
const uint8_t *bytes, size_t size,
Status &error) {
error.Clear();
AllocationMap::iterator iter = FindAllocation(process_address, size);
if (iter == m_allocations.end()) {
lldb::ProcessSP process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->WriteMemory(process_address, bytes, size, error);
return;
}
error.SetErrorToGenericError();
error.SetErrorString("Couldn't write: no allocation contains the target "
"range and the process doesn't exist");
return;
}
Allocation &allocation = iter->second;
uint64_t offset = process_address - allocation.m_process_start;
lldb::ProcessSP process_sp;
switch (allocation.m_policy) {
default:
error.SetErrorToGenericError();
error.SetErrorString("Couldn't write: invalid allocation policy");
return;
case eAllocationPolicyHostOnly:
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't write: data buffer is empty");
return;
}
::memcpy(allocation.m_data.GetBytes() + offset, bytes, size);
break;
case eAllocationPolicyMirror:
if (!allocation.m_data.GetByteSize()) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't write: data buffer is empty");
return;
}
::memcpy(allocation.m_data.GetBytes() + offset, bytes, size);
process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->WriteMemory(process_address, bytes, size, error);
if (!error.Success())
return;
}
break;
case eAllocationPolicyProcessOnly:
process_sp = m_process_wp.lock();
if (process_sp) {
process_sp->WriteMemory(process_address, bytes, size, error);
if (!error.Success())
return;
}
break;
}
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
log->Printf("IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
(uint64_t)allocation.m_process_start,
(uint64_t)allocation.m_process_start +
(uint64_t)allocation.m_size);
}
}
示例11: Malloc
lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
uint32_t permissions, AllocationPolicy policy,
bool zero_memory, Status &error) {
lldb_private::Log *log(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
error.Clear();
lldb::ProcessSP process_sp;
lldb::addr_t allocation_address = LLDB_INVALID_ADDRESS;
lldb::addr_t aligned_address = LLDB_INVALID_ADDRESS;
size_t allocation_size;
if (size == 0) {
// FIXME: Malloc(0) should either return an invalid address or assert, in
// order to cut down on unnecessary allocations.
allocation_size = alignment;
} else {
// Round up the requested size to an aligned value.
allocation_size = llvm::alignTo(size, alignment);
// The process page cache does not see the requested alignment. We can't
// assume its result will be any more than 1-byte aligned. To work around
// this, request `alignment - 1` additional bytes.
allocation_size += alignment - 1;
}
switch (policy) {
default:
error.SetErrorToGenericError();
error.SetErrorString("Couldn't malloc: invalid allocation policy");
return LLDB_INVALID_ADDRESS;
case eAllocationPolicyHostOnly:
allocation_address = FindSpace(allocation_size);
if (allocation_address == LLDB_INVALID_ADDRESS) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't malloc: address space is full");
return LLDB_INVALID_ADDRESS;
}
break;
case eAllocationPolicyMirror:
process_sp = m_process_wp.lock();
if (log)
log->Printf("IRMemoryMap::%s process_sp=0x%" PRIx64
", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
__FUNCTION__, (lldb::addr_t)process_sp.get(),
process_sp && process_sp->CanJIT() ? "true" : "false",
process_sp && process_sp->IsAlive() ? "true" : "false");
if (process_sp && process_sp->CanJIT() && process_sp->IsAlive()) {
if (!zero_memory)
allocation_address =
process_sp->AllocateMemory(allocation_size, permissions, error);
else
allocation_address =
process_sp->CallocateMemory(allocation_size, permissions, error);
if (!error.Success())
return LLDB_INVALID_ADDRESS;
} else {
if (log)
log->Printf("IRMemoryMap::%s switching to eAllocationPolicyHostOnly "
"due to failed condition (see previous expr log message)",
__FUNCTION__);
policy = eAllocationPolicyHostOnly;
allocation_address = FindSpace(allocation_size);
if (allocation_address == LLDB_INVALID_ADDRESS) {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't malloc: address space is full");
return LLDB_INVALID_ADDRESS;
}
}
break;
case eAllocationPolicyProcessOnly:
process_sp = m_process_wp.lock();
if (process_sp) {
if (process_sp->CanJIT() && process_sp->IsAlive()) {
if (!zero_memory)
allocation_address =
process_sp->AllocateMemory(allocation_size, permissions, error);
else
allocation_address =
process_sp->CallocateMemory(allocation_size, permissions, error);
if (!error.Success())
return LLDB_INVALID_ADDRESS;
} else {
error.SetErrorToGenericError();
error.SetErrorString(
"Couldn't malloc: process doesn't support allocating memory");
return LLDB_INVALID_ADDRESS;
}
} else {
error.SetErrorToGenericError();
error.SetErrorString("Couldn't malloc: process doesn't exist, and this "
"memory must be in the process");
return LLDB_INVALID_ADDRESS;
}
break;
}
//.........这里部分代码省略.........