本文整理汇总了C++中Status::Fail方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::Fail方法的具体用法?C++ Status::Fail怎么用?C++ Status::Fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::Fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PeekUserArea
uint32_t NativeRegisterContextLinux_s390x::SetHardwareWatchpoint(
lldb::addr_t addr, size_t size, uint32_t watch_flags) {
per_struct per_info;
if (watch_flags != 0x1)
return LLDB_INVALID_INDEX32;
if (m_watchpoint_addr != LLDB_INVALID_ADDRESS)
return LLDB_INVALID_INDEX32;
Status error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info,
sizeof(per_info));
if (error.Fail())
return LLDB_INVALID_INDEX32;
per_info.control_regs.bits.em_storage_alteration = 1;
per_info.control_regs.bits.storage_alt_space_ctl = 1;
per_info.starting_addr = addr;
per_info.ending_addr = addr + size - 1;
error = PokeUserArea(offsetof(user_regs_struct, per_info), &per_info,
sizeof(per_info));
if (error.Fail())
return LLDB_INVALID_INDEX32;
m_watchpoint_addr = addr;
return 0;
}
示例2: Recv
static void ServerCallbackv4(const void *baton, in_port_t port) {
auto child_pid = fork();
if (child_pid == 0) {
Socket *client_socket;
char addr_buffer[256];
sprintf(addr_buffer, "%s:%d", baton, port);
Status err = Socket::TcpConnect(addr_buffer, false, client_socket);
if (err.Fail())
abort();
char buffer[32];
size_t read_size = 32;
err = client_socket->Read((void *)&buffer[0], read_size);
if (err.Fail())
abort();
std::string Recv(&buffer[0], read_size);
if (Recv != hello)
abort();
size_t write_size = goodbye.length();
err = client_socket->Write(goodbye.c_str(), write_size);
if (err.Fail())
abort();
if (write_size != goodbye.length())
abort();
delete client_socket;
exit(0);
}
}
示例3: process_sp
bool lldb_private::formatters::NSError_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
ProcessSP process_sp(valobj.GetProcessSP());
if (!process_sp)
return false;
lldb::addr_t ptr_value = DerefToNSErrorPointer(valobj);
if (ptr_value == LLDB_INVALID_ADDRESS)
return false;
size_t ptr_size = process_sp->GetAddressByteSize();
lldb::addr_t code_location = ptr_value + 2 * ptr_size;
lldb::addr_t domain_location = ptr_value + 3 * ptr_size;
Status error;
uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location,
ptr_size, 0, error);
if (error.Fail())
return false;
lldb::addr_t domain_str_value =
process_sp->ReadPointerFromMemory(domain_location, error);
if (error.Fail() || domain_str_value == LLDB_INVALID_ADDRESS)
return false;
if (!domain_str_value) {
stream.Printf("domain: nil - code: %" PRIu64, code);
return true;
}
InferiorSizedWord isw(domain_str_value, *process_sp);
ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData(
"domain_str", isw.GetAsData(process_sp->GetByteOrder()),
valobj.GetExecutionContextRef(), process_sp->GetTarget()
.GetScratchClangASTContext()
->GetBasicType(lldb::eBasicTypeVoid)
.GetPointerType());
if (!domain_str_sp)
return false;
StreamString domain_str_summary;
if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) &&
!domain_str_summary.Empty()) {
stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(),
code);
return true;
} else {
stream.Printf("domain: nil - code: %" PRIu64, code);
return true;
}
}
示例4: UnixDomainAccept
Status Socket::UnixDomainAccept(llvm::StringRef name,
bool child_processes_inherit, Socket *&socket) {
Status error;
std::unique_ptr<Socket> listen_socket(
Create(ProtocolUnixDomain, child_processes_inherit, error));
if (error.Fail())
return error;
error = listen_socket->Listen(name, 5);
if (error.Fail())
return error;
error = listen_socket->Accept(socket);
return error;
}
示例5: Status
Status NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index,
bool &is_hit) {
per_lowcore_bits per_lowcore;
if (wp_index >= NumSupportedHardwareWatchpoints())
return Status("Watchpoint index out of range");
if (m_watchpoint_addr == LLDB_INVALID_ADDRESS) {
is_hit = false;
return Status();
}
Status error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore),
&per_lowcore, sizeof(per_lowcore));
if (error.Fail()) {
is_hit = false;
return error;
}
is_hit = (per_lowcore.perc_storage_alteration == 1 &&
per_lowcore.perc_store_real_address == 0);
if (is_hit) {
// Do not report this watchpoint again.
memset(&per_lowcore, 0, sizeof(per_lowcore));
PokeUserArea(offsetof(user_regs_struct, per_info.lowcore), &per_lowcore,
sizeof(per_lowcore));
}
return Status();
}
示例6: DoReadWatchPointRegisterValue
bool NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint(
uint32_t wp_index) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return false;
struct pt_watch_regs regs;
// First reading the current state of watch regs
DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(®s));
if (regs.style == pt_watch_style_mips32) {
regs.mips32.watchlo[wp_index] = default_watch_regs.mips32.watchlo[wp_index];
regs.mips32.watchhi[wp_index] = default_watch_regs.mips32.watchhi[wp_index];
regs.mips32.watch_masks[wp_index] =
default_watch_regs.mips32.watch_masks[wp_index];
} else // pt_watch_style_mips64
{
regs.mips64.watchlo[wp_index] = default_watch_regs.mips64.watchlo[wp_index];
regs.mips64.watchhi[wp_index] = default_watch_regs.mips64.watchhi[wp_index];
regs.mips64.watch_masks[wp_index] =
default_watch_regs.mips64.watch_masks[wp_index];
}
Status error = DoWriteWatchPointRegisterValue(m_thread.GetID(),
static_cast<void *>(®s));
if (!error.Fail()) {
hw_addr_map[wp_index] = LLDB_INVALID_ADDRESS;
return true;
}
return false;
}
示例7: MakeConnectURL
Status PlatformAndroidRemoteGDBServer::MakeConnectURL(
const lldb::pid_t pid, const uint16_t remote_port,
llvm::StringRef remote_socket_name, std::string &connect_url) {
static const int kAttempsNum = 5;
Status error;
// There is a race possibility that somebody will occupy a port while we're
// in between FindUnusedPort and ForwardPortWithAdb - adding the loop to
// mitigate such problem.
for (auto i = 0; i < kAttempsNum; ++i) {
uint16_t local_port = 0;
error = FindUnusedPort(local_port);
if (error.Fail())
return error;
error = ForwardPortWithAdb(local_port, remote_port, remote_socket_name,
m_socket_namespace, m_device_id);
if (error.Success()) {
m_port_forwards[pid] = local_port;
std::ostringstream url_str;
url_str << "connect://localhost:" << local_port;
connect_url = url_str.str();
break;
}
}
return error;
}
示例8: FindMetadata
bool DYLDRendezvous::FindMetadata(const char *name, PThreadField field,
uint32_t &value) {
Target &target = m_process->GetTarget();
SymbolContextList list;
if (!target.GetImages().FindSymbolsWithNameAndType(ConstString(name),
eSymbolTypeAny, list))
return false;
Address address = list[0].symbol->GetAddress();
addr_t addr = address.GetLoadAddress(&target);
if (addr == LLDB_INVALID_ADDRESS)
return false;
Status error;
value = (uint32_t)m_process->ReadUnsignedIntegerFromMemory(
addr + field * sizeof(uint32_t), sizeof(uint32_t), 0, error);
if (error.Fail())
return false;
if (field == eSize)
value /= 8; // convert bits to bytes
return true;
}
示例9: consumeObject
// Minidump string
llvm::Optional<std::string>
lldb_private::minidump::parseMinidumpString(llvm::ArrayRef<uint8_t> &data) {
std::string result;
const uint32_t *source_length;
Status error = consumeObject(data, source_length);
if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
return llvm::None;
auto source_start = reinterpret_cast<const llvm::UTF16 *>(data.data());
// source_length is the length of the string in bytes
// we need the length of the string in UTF-16 characters/code points (16 bits
// per char)
// that's why it's divided by 2
const auto source_end = source_start + (*source_length) / 2;
// resize to worst case length
result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
auto result_start = reinterpret_cast<llvm::UTF8 *>(&result[0]);
const auto result_end = result_start + result.size();
llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
llvm::strictConversion);
const auto result_size =
std::distance(reinterpret_cast<llvm::UTF8 *>(&result[0]), result_start);
result.resize(result_size); // shrink to actual length
return result;
}
示例10: Update
bool Update() override {
m_child_ptr = nullptr;
m_child_sp.reset();
ProcessSP process_sp(m_backend.GetProcessSP());
if (!process_sp)
return false;
lldb::addr_t userinfo_location = DerefToNSErrorPointer(m_backend);
if (userinfo_location == LLDB_INVALID_ADDRESS)
return false;
size_t ptr_size = process_sp->GetAddressByteSize();
userinfo_location += 4 * ptr_size;
Status error;
lldb::addr_t userinfo =
process_sp->ReadPointerFromMemory(userinfo_location, error);
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo, *process_sp);
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(
lldb::eBasicTypeObjCID));
return false;
}
示例11: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
StringList commands;
commands.AppendString("thread backtrace");
Thread *thread = m_exe_ctx.GetThreadPtr();
if (thread) {
char command_buffer[256];
uint32_t frame_count = thread->GetStackFrameCount();
for (uint32_t i = 0; i < frame_count; ++i) {
StackFrameSP frame = thread->GetStackFrameAtIndex(i);
lldb::addr_t pc = frame->GetStackID().GetPC();
snprintf(command_buffer, sizeof(command_buffer),
"disassemble --bytes --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
snprintf(command_buffer, sizeof(command_buffer),
"image show-unwind --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
}
}
const FileSpec &outfile_spec =
m_outfile_options.GetFile().GetCurrentValue();
if (outfile_spec) {
char path[PATH_MAX];
outfile_spec.GetPath(path, sizeof(path));
uint32_t open_options =
File::eOpenOptionWrite | File::eOpenOptionCanCreate |
File::eOpenOptionAppend | File::eOpenOptionCloseOnExec;
const bool append = m_outfile_options.GetAppend().GetCurrentValue();
if (!append)
open_options |= File::eOpenOptionTruncate;
StreamFileSP outfile_stream = std::make_shared<StreamFile>();
Status error = outfile_stream->GetFile().Open(path, open_options);
if (error.Fail()) {
result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n",
path, append ? "append" : "write",
error.AsCString());
result.SetStatus(eReturnStatusFailed);
return false;
}
result.SetImmediateOutputStream(outfile_stream);
}
CommandInterpreterRunOptions options;
options.SetStopOnError(false);
options.SetEchoCommands(true);
options.SetPrintResults(true);
options.SetAddToHistory(false);
m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result);
return result.Succeeded();
}
示例12: value_sp
lldb::OptionValueSP OptionValueUInt64::Create(llvm::StringRef value_str,
Status &error) {
lldb::OptionValueSP value_sp(new OptionValueUInt64());
error = value_sp->SetValueFromString(value_str);
if (error.Fail())
value_sp.reset();
return value_sp;
}
示例13: ReadPointer
addr_t DynamicLoader::ReadPointer(addr_t addr) {
Status error;
addr_t value = m_process->ReadPointerFromMemory(addr, error);
if (error.Fail())
return LLDB_INVALID_ADDRESS;
else
return value;
}
示例14: StartDebugger
bool TestClient::StartDebugger() {
const ArchSpec &arch_spec = HostInfo::GetArchitecture();
Args args;
args.AppendArgument(LLDB_SERVER);
args.AppendArgument("gdbserver");
args.AppendArgument("--log-channels=gdb-remote packets");
args.AppendArgument("--reverse-connect");
std::string log_file_name = GenerateLogFileName(arch_spec);
if (log_file_name.size()) {
args.AppendArgument("--log-file=" + log_file_name);
}
Status error;
TCPSocket listen_socket(true, false);
error = listen_socket.Listen("127.0.0.1:0", 5);
if (error.Fail()) {
GTEST_LOG_(ERROR) << "Unable to open listen socket.";
return false;
}
char connect_remote_address[64];
snprintf(connect_remote_address, sizeof(connect_remote_address),
"localhost:%u", listen_socket.GetLocalPortNumber());
args.AppendArgument(connect_remote_address);
m_server_process_info.SetArchitecture(arch_spec);
m_server_process_info.SetArguments(args, true);
Status status = Host::LaunchProcess(m_server_process_info);
if (status.Fail()) {
GTEST_LOG_(ERROR)
<< formatv("Failure to launch lldb server: {0}.", status).str();
return false;
}
char connect_remote_uri[64];
snprintf(connect_remote_uri, sizeof(connect_remote_uri), "connect://%s",
connect_remote_address);
Socket *accept_socket;
listen_socket.Accept(accept_socket);
SetConnection(new ConnectionFileDescriptor(accept_socket));
SendAck(); // Send this as a handshake.
return true;
}
示例15: ReadPointer
addr_t DYLDRendezvous::ReadPointer(addr_t addr, addr_t *dst) {
Status error;
*dst = m_process->ReadPointerFromMemory(addr, error);
if (error.Fail())
return 0;
return addr + m_process->GetAddressByteSize();
}