本文整理汇总了C++中Error::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::Clear方法的具体用法?C++ Error::Clear怎么用?C++ Error::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Acceptor
std::unique_ptr<Acceptor>
Acceptor::Create(StringRef name, const bool child_processes_inherit, Error &error)
{
error.Clear();
LocalSocketIdFunc local_socket_id;
std::unique_ptr<Socket> listener_socket = nullptr;
std::string host_str;
std::string port_str;
int32_t port = INT32_MIN;
if (Socket::DecodeHostAndPort (name, host_str, port_str, port, &error))
{
auto tcp_socket = new TCPSocket(child_processes_inherit, error);
local_socket_id = [tcp_socket]() {
auto local_port = tcp_socket->GetLocalPortNumber();
return (local_port != 0) ? std::to_string(local_port) : "";
};
listener_socket.reset(tcp_socket);
}
else
{
const std::string socket_name = name;
local_socket_id = [socket_name](){
return socket_name;
};
listener_socket.reset(new DomainSocket(child_processes_inherit, error));
}
if (error.Success())
return std::unique_ptr<Acceptor>(
new Acceptor(std::move(listener_socket), name, local_socket_id));
return std::unique_ptr<Acceptor>();
}
示例2: process_sp
bool
lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::Update()
{
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
delete m_data_32;
m_data_32 = NULL;
delete m_data_64;
m_data_64 = NULL;
if (!valobj_sp)
return false;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Error error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
return false;
m_ptr_size = process_sp->GetAddressByteSize();
m_order = process_sp->GetByteOrder();
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
if (m_ptr_size == 4)
{
m_data_32 = new DataDescriptor_32();
process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
}
else
{
m_data_64 = new DataDescriptor_64();
process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
}
if (error.Fail())
return false;
return false;
}
示例3: WriteMemory
void
IRMemoryMap::WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Error &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;
}
示例4: GetPermissionsAsCString
addr_t
ProcessFreeBSD::DoAllocateMemory(size_t size, uint32_t permissions,
Error &error)
{
addr_t allocated_addr = LLDB_INVALID_ADDRESS;
unsigned prot = 0;
if (permissions & lldb::ePermissionsReadable)
prot |= eMmapProtRead;
if (permissions & lldb::ePermissionsWritable)
prot |= eMmapProtWrite;
if (permissions & lldb::ePermissionsExecutable)
prot |= eMmapProtExec;
if (InferiorCallMmap(this, allocated_addr, 0, size, prot,
eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) {
m_addr_to_mmap_size[allocated_addr] = size;
error.Clear();
} else {
allocated_addr = LLDB_INVALID_ADDRESS;
error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions));
}
return allocated_addr;
}
示例5: request_packet
bool
CommunicationKDP::SendRawRequest (uint8_t command_byte,
const void *src, // Raw packet payload bytes
uint32_t src_len, // Raw packet payload length
DataExtractor &reply_packet,
Error &error)
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + src_len;
const CommandType command = (CommandType)command_byte;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutRawBytes(src, src_len);
if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
{
uint32_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
if (kdp_error)
error.SetErrorStringWithFormat ("request packet 0x%8.8x failed (error %u)", command_byte, kdp_error);
else
{
error.Clear();
return true;
}
}
else
{
error.SetErrorString ("failed to send packet");
}
return false;
}
示例6: switch
std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol, bool child_processes_inherit, Error &error)
{
error.Clear();
std::unique_ptr<Socket> socket_up;
switch (protocol)
{
case ProtocolTcp:
socket_up.reset(new TCPSocket(child_processes_inherit, error));
break;
case ProtocolUdp:
socket_up.reset(new UDPSocket(child_processes_inherit, error));
break;
case ProtocolUnixDomain:
#ifndef LLDB_DISABLE_POSIX
socket_up.reset(new DomainSocket(child_processes_inherit, error));
#else
error.SetErrorString("Unix domain sockets are not supported on this platform.");
#endif
break;
case ProtocolUnixAbstract:
#ifdef __linux__
socket_up.reset(new AbstractSocket(child_processes_inherit, error));
#else
error.SetErrorString("Abstract domain sockets are not supported on this platform.");
#endif
break;
}
if (error.Fail())
socket_up.reset();
return socket_up;
}
示例7: WritePointerToMemory
void IRMemoryMap::WritePointerToMemory(lldb::addr_t process_address,
lldb::addr_t address, Error &error) {
error.Clear();
Scalar scalar(address);
WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);
}
示例8: name
OperatingSystemGo::Goroutine
OperatingSystemGo::CreateGoroutineAtIndex(uint64_t idx, Error &err)
{
err.Clear();
Goroutine result;
ValueObjectSP g = m_allg_sp->GetSyntheticArrayMember(idx, true)->Dereference(err);
if (err.Fail())
{
return result;
}
ConstString name("goid");
ValueObjectSP val = g->GetChildMemberWithName(name, true);
bool success = false;
result.m_goid = val->GetValueAsUnsigned(0, &success);
if (!success)
{
err.SetErrorToGenericError();
err.SetErrorString("unable to read goid");
return result;
}
name.SetCString("atomicstatus");
val = g->GetChildMemberWithName(name, true);
result.m_status = (uint32_t)val->GetValueAsUnsigned(0, &success);
if (!success)
{
err.SetErrorToGenericError();
err.SetErrorString("unable to read atomicstatus");
return result;
}
name.SetCString("sched");
val = g->GetChildMemberWithName(name, true);
result.m_gobuf = val->GetAddressOf(false);
name.SetCString("stack");
val = g->GetChildMemberWithName(name, true);
name.SetCString("lo");
ValueObjectSP child = val->GetChildMemberWithName(name, true);
result.m_lostack = child->GetValueAsUnsigned(0, &success);
if (!success)
{
err.SetErrorToGenericError();
err.SetErrorString("unable to read stack.lo");
return result;
}
name.SetCString("hi");
child = val->GetChildMemberWithName(name, true);
result.m_histack = child->GetValueAsUnsigned(0, &success);
if (!success)
{
err.SetErrorToGenericError();
err.SetErrorString("unable to read stack.hi");
return result;
}
return result;
}
示例9: ir_to_dwarf
Error
ClangExpressionParser::MakeDWARF ()
{
Error err;
llvm::Module *module = m_code_generator->GetModule();
if (!module)
{
err.SetErrorToGenericError();
err.SetErrorString("IR doesn't contain a module");
return err;
}
ClangExpressionVariableList *local_variables = m_expr.LocalVariables();
ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
if (!local_variables)
{
err.SetErrorToGenericError();
err.SetErrorString("Can't convert an expression without a VariableList to DWARF");
return err;
}
if (!decl_map)
{
err.SetErrorToGenericError();
err.SetErrorString("Can't convert an expression without a DeclMap to DWARF");
return err;
}
std::string function_name;
if (!FindFunctionInModule(function_name, module, m_expr.FunctionName()))
{
err.SetErrorToGenericError();
err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
return err;
}
IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream(), function_name.c_str());
if (!ir_to_dwarf.runOnModule(*module))
{
err.SetErrorToGenericError();
err.SetErrorString("Couldn't convert the expression to DWARF");
return err;
}
err.Clear();
return err;
}
示例10: Attach
lldb::ProcessSP PlatformRemoteGDBServer::Attach(
ProcessAttachInfo &attach_info, Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use
// existing one
Error &error) {
lldb::ProcessSP process_sp;
if (IsRemote()) {
if (IsConnected()) {
lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
std::string connect_url;
if (!LaunchGDBServer(debugserver_pid, connect_url)) {
error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
GetHostname());
} else {
if (target == NULL) {
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
debugger, NULL, NULL, false, NULL, new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
if (target && error.Success()) {
debugger.GetTargetList().SetSelectedTarget(target);
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
process_sp = target->CreateProcess(
attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
if (process_sp) {
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
if (error.Success()) {
ListenerSP listener_sp = attach_info.GetHijackListener();
if (listener_sp)
process_sp->HijackProcessEvents(listener_sp);
error = process_sp->Attach(attach_info);
}
if (error.Fail() && debugserver_pid != LLDB_INVALID_PROCESS_ID) {
KillSpawnedProcess(debugserver_pid);
}
}
}
}
} else {
error.SetErrorString("not connected to remote gdb server");
}
}
return process_sp;
}
示例11: Acceptor
std::unique_ptr<Acceptor> Acceptor::Create(StringRef name,
const bool child_processes_inherit,
Error &error) {
error.Clear();
Socket::SocketProtocol socket_protocol = Socket::ProtocolUnixDomain;
int port;
std::string scheme, host, path;
// Try to match socket name as URL - e.g., tcp://localhost:5555
if (UriParser::Parse(name.str(), scheme, host, port, path)) {
if (!FindProtocolByScheme(scheme.c_str(), socket_protocol))
error.SetErrorStringWithFormat("Unknown protocol scheme \"%s\"",
scheme.c_str());
else
name = name.drop_front(scheme.size() + strlen("://"));
} else {
std::string host_str;
std::string port_str;
int32_t port = INT32_MIN;
// Try to match socket name as $host:port - e.g., localhost:5555
if (Socket::DecodeHostAndPort(name, host_str, port_str, port, nullptr))
socket_protocol = Socket::ProtocolTcp;
}
if (error.Fail())
return std::unique_ptr<Acceptor>();
std::unique_ptr<Socket> listener_socket_up =
Socket::Create(socket_protocol, child_processes_inherit, error);
LocalSocketIdFunc local_socket_id;
if (error.Success()) {
if (listener_socket_up->GetSocketProtocol() == Socket::ProtocolTcp) {
TCPSocket *tcp_socket =
static_cast<TCPSocket *>(listener_socket_up.get());
local_socket_id = [tcp_socket]() {
auto local_port = tcp_socket->GetLocalPortNumber();
return (local_port != 0) ? llvm::to_string(local_port) : "";
};
} else {
const std::string socket_name = name;
local_socket_id = [socket_name]() { return socket_name; };
}
return std::unique_ptr<Acceptor>(
new Acceptor(std::move(listener_socket_up), name, local_socket_id));
}
return std::unique_ptr<Acceptor>();
}
示例12: switch
void
IRMemoryMap::Free (lldb::addr_t process_address, Error &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);
}
示例13: Connect
Error TCPSocket::Connect(llvm::StringRef name) {
if (m_socket == kInvalidSocketValue)
return Error("Invalid socket");
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf("TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
Error error;
std::string host_str;
std::string port_str;
int32_t port = INT32_MIN;
if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
return error;
struct sockaddr_in sa;
::memset(&sa, 0, sizeof(sa));
sa.sin_family = kDomain;
sa.sin_port = htons(port);
int inet_pton_result = ::inet_pton(kDomain, host_str.c_str(), &sa.sin_addr);
if (inet_pton_result <= 0) {
struct hostent *host_entry = gethostbyname(host_str.c_str());
if (host_entry)
host_str = ::inet_ntoa(*(struct in_addr *)*host_entry->h_addr_list);
inet_pton_result = ::inet_pton(kDomain, host_str.c_str(), &sa.sin_addr);
if (inet_pton_result <= 0) {
if (inet_pton_result == -1)
SetLastError(error);
else
error.SetErrorStringWithFormat("invalid host string: '%s'",
host_str.c_str());
return error;
}
}
if (-1 ==
::connect(GetNativeSocket(), (const struct sockaddr *)&sa, sizeof(sa))) {
SetLastError(error);
return error;
}
// Keep our TCP packets coming without any delays.
SetOptionNoDelay();
error.Clear();
return error;
}
示例14: Leak
void IRMemoryMap::Leak(lldb::addr_t process_address, Error &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;
}
示例15: ReadScalarFromMemory
void
IRMemoryMap::ReadPointerFromMemory (lldb::addr_t *address, lldb::addr_t process_address, Error &error)
{
error.Clear();
Scalar pointer_scalar;
ReadScalarFromMemory(pointer_scalar, process_address, GetAddressByteSize(), error);
if (!error.Success())
return;
*address = pointer_scalar.ULongLong();
return;
}