本文整理汇总了C++中Error::SetErrorStringWithFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::SetErrorStringWithFormat方法的具体用法?C++ Error::SetErrorStringWithFormat怎么用?C++ Error::SetErrorStringWithFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::SetErrorStringWithFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHostname
Error
PlatformRemoteGDBServer::ConnectRemote (Args& args)
{
Error error;
if (IsConnected())
{
error.SetErrorStringWithFormat ("the platform is already connected to '%s', execute 'platform disconnect' to close the current connection",
GetHostname());
}
else
{
if (args.GetArgumentCount() == 1)
{
const char *url = args.GetArgumentAtIndex(0);
m_gdb_client.SetConnection (new ConnectionFileDescriptor());
const ConnectionStatus status = m_gdb_client.Connect(url, &error);
if (status == eConnectionStatusSuccess)
{
if (m_gdb_client.HandshakeWithServer(&error))
{
m_gdb_client.GetHostInfo();
// If a working directory was set prior to connecting, send it down now
if (m_working_dir)
m_gdb_client.SetWorkingDir(m_working_dir.GetCString());
}
else
{
m_gdb_client.Disconnect();
if (error.Success())
error.SetErrorString("handshake failed");
}
}
}
else
{
error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
}
}
return error;
}
示例2: GetSDKsDirectory
Error
PlatformiOSSimulator::GetSymbolFile (const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file)
{
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
{
char resolved_path[PATH_MAX];
const char * sdk_dir = GetSDKsDirectory();
if (sdk_dir)
{
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/%s",
sdk_dir,
platform_file_path);
// First try in the SDK and see if the file is in there
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
return error;
// Else fall back to the actual path itself
local_file.SetFile(platform_file_path, true);
if (local_file.Exists())
return error;
}
error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
platform_file_path,
GetPluginName().GetCString());
}
else
{
error.SetErrorString ("invalid platform file argument");
}
return error;
}
示例3: switch
Error
OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationType op)
{
Error error;
switch (op)
{
case eVarSetOperationClear:
Clear ();
NotifyValueChanged();
break;
case eVarSetOperationReplace:
case eVarSetOperationAssign:
{
bool success = false;
uint64_t value = Args::StringToUInt64 (value_cstr, 0, 0, &success);
if (success)
{
m_value_was_set = true;
m_current_value = value;
NotifyValueChanged();
}
else
{
error.SetErrorStringWithFormat ("invalid uint64_t string value: '%s'", value_cstr);
}
}
break;
case eVarSetOperationInsertBefore:
case eVarSetOperationInsertAfter:
case eVarSetOperationRemove:
case eVarSetOperationAppend:
case eVarSetOperationInvalid:
error = OptionValue::SetValueFromCString (value_cstr, op);
break;
}
return error;
}
示例4: SetOptionValue
virtual Error
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
case 'c':
if (option_arg != NULL)
m_condition.assign (option_arg);
else
m_condition.clear();
m_condition_passed = true;
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
}
return error;
}
示例5: JoinPath
ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
Error &error) {
const auto lock_dir_spec = JoinPath(root_dir_spec, kLockDirName);
error = MakeDirectory(lock_dir_spec);
if (error.Fail())
return;
m_file_spec = JoinPath(lock_dir_spec, uuid.GetAsString().c_str());
m_file.Open(m_file_spec.GetCString(), File::eOpenOptionWrite |
File::eOpenOptionCanCreate |
File::eOpenOptionCloseOnExec);
if (!m_file) {
error.SetErrorToErrno();
return;
}
m_lock.reset(new lldb_private::LockFile(m_file.GetDescriptor()));
error = m_lock->WriteLock(0, 1);
if (error.Fail())
error.SetErrorStringWithFormat("Failed to lock file: %s",
error.AsCString());
}
示例6: value_sp
virtual Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
const char *option_value)
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 's':
{
OptionValueSP value_sp (OptionValueUInt64::Create (option_value, error));
if (value_sp)
set_indexes.AppendValue (value_sp);
}
break;
case 'a':
// When we don't use OptionValue::SetValueFromCString(const char *) to
// set an option value, it won't be marked as being set in the options
// so we make a call to let users know the value was set via option
dump_all_sets.SetCurrentValue (true);
dump_all_sets.SetOptionWasSet ();
break;
case 'A':
// When we don't use OptionValue::SetValueFromCString(const char *) to
// set an option value, it won't be marked as being set in the options
// so we make a call to let users know the value was set via option
alternate_name.SetCurrentValue (true);
dump_all_sets.SetOptionWasSet ();
break;
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
break;
}
return error;
}
示例7: debugger_sp
SBError
SBDebugger::SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name)
{
SBError sb_error;
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName (ConstString(debugger_instance_name)));
Error error;
if (debugger_sp)
{
ExecutionContext exe_ctx (debugger_sp->GetCommandInterpreter().GetExecutionContext());
error = debugger_sp->SetPropertyValue (&exe_ctx,
eVarSetOperationAssign,
var_name,
value);
}
else
{
error.SetErrorStringWithFormat ("invalid debugger instance name '%s'", debugger_instance_name);
}
if (error.Fail())
sb_error.SetError(error);
return sb_error;
}
示例8: switch
Error
OptionGroupUUID::SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
const char *option_arg)
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 'u':
error = m_uuid.SetValueFromString (option_arg);
if (error.Success())
m_uuid.SetOptionWasSet();
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
}
return error;
}
示例9: SetOptionValue
virtual Error
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
char short_option = (char) m_getopt_table[option_idx].val;
switch (short_option)
{
case 'f': log_file = option_arg; break;
case 't': log_options |= LLDB_LOG_OPTION_THREADSAFE; break;
case 'v': log_options |= LLDB_LOG_OPTION_VERBOSE; break;
case 'g': log_options |= LLDB_LOG_OPTION_DEBUG; break;
case 's': log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE; break;
case 'T': log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP; break;
case 'p': log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;break;
case 'n': log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME; break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
}
return error;
}
示例10: request_packet
uint32_t
CommunicationKDP::SendRequestWriteMemory (lldb::addr_t addr,
const void *src,
uint32_t src_len,
Error &error)
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
bool use_64 = (GetVersion() >= 11);
uint32_t command_addr_byte_size = use_64 ? 8 : 4;
const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutMaxHex64 (addr, command_addr_byte_size);
request_packet.PutHex32 (src_len);
request_packet.PutRawBytes(src, src_len);
DataExtractor reply_packet;
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 ("kdp write memory failed (error %u)", kdp_error);
else
{
error.Clear();
return src_len;
}
}
else
{
error.SetErrorString ("failed to send packet");
}
return 0;
}
示例11: GetPluginName
Error
PlatformFreeBSD::ConnectRemote (Args& args)
{
Error error;
if (IsHost())
{
error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString());
}
else
{
if (!m_remote_platform_sp)
m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
if (m_remote_platform_sp)
{
if (error.Success())
{
if (m_remote_platform_sp)
{
error = m_remote_platform_sp->ConnectRemote (args);
}
else
{
error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
}
}
}
else
error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
if (error.Fail())
m_remote_platform_sp.reset();
}
return error;
}
示例12: buf
void
IRMemoryMap::ReadScalarFromMemory (Scalar &scalar, lldb::addr_t process_address, size_t size, Error &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;
}
示例13: GetDefinitions
lldb_private::Error
OptionGroupPlatformSSH::SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
const char *option_arg)
{
Error error;
char short_option = (char) GetDefinitions()[option_idx].short_option;
switch (short_option)
{
case 's':
m_ssh = true;
break;
case 'S':
m_ssh_opts.assign(option_arg);
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
}
return error;
}
示例14:
size_t
ProcessMachCore::DoReadMemory (addr_t addr, void *buf, size_t size, Error &error)
{
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
if (core_objfile)
{
const VMRangeToFileOffset::Entry *core_memory_entry = m_core_aranges.FindEntryThatContains (addr);
if (core_memory_entry)
{
const addr_t offset = addr - core_memory_entry->GetRangeBase();
const addr_t bytes_left = core_memory_entry->GetRangeEnd() - addr;
size_t bytes_to_read = size;
if (bytes_to_read > bytes_left)
bytes_to_read = bytes_left;
return core_objfile->CopyData (core_memory_entry->data.GetRangeBase() + offset, bytes_to_read, buf);
}
else
{
error.SetErrorStringWithFormat ("core file does not contain 0x%" PRIx64, addr);
}
}
return 0;
}
示例15:
Error
FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse)
{
Error error;
std::wstring path_buffer;
if (!llvm::ConvertUTF8toWide(file_spec.GetPath(), path_buffer))
{
error.SetErrorString(PATH_CONVERSION_ERROR);
return error;
}
if (!recurse)
{
BOOL result = ::RemoveDirectoryW(path_buffer.c_str());
if (!result)
error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
}
else
{
// SHFileOperation() accepts a list of paths, and so must be double-null-terminated to
// indicate the end of the list. The first null terminator is there only in the backing
// store but not the actual vector contents, and so we need to push twice.
path_buffer.push_back(0);
path_buffer.push_back(0);
SHFILEOPSTRUCTW shfos = {0};
shfos.wFunc = FO_DELETE;
shfos.pFrom = (LPCWSTR)path_buffer.data();
shfos.fFlags = FOF_NO_UI;
int result = ::SHFileOperationW(&shfos);
// TODO(zturner): Correctly handle the intricacies of SHFileOperation return values.
if (result != 0)
error.SetErrorStringWithFormat("SHFileOperation failed");
}
return error;
}