diff options
Diffstat (limited to 'source/Plugins/Process/gdb-remote')
15 files changed, 327 insertions, 322 deletions
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index d527b4daaab93..0c4df7e3f3065 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -319,7 +319,7 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet, Timeout<std::micro> timeout, bool sync_on_timeout) { uint8_t buffer[8192]; - Error error; + Status error; Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); @@ -933,9 +933,9 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, return GDBRemoteCommunication::PacketType::Invalid; } -Error GDBRemoteCommunication::StartListenThread(const char *hostname, - uint16_t port) { - Error error; +Status GDBRemoteCommunication::StartListenThread(const char *hostname, + uint16_t port) { + Status error; if (m_listen_thread.IsJoinable()) { error.SetErrorString("listen thread already running"); } else { @@ -962,7 +962,7 @@ bool GDBRemoteCommunication::JoinListenThread() { lldb::thread_result_t GDBRemoteCommunication::ListenThread(lldb::thread_arg_t arg) { GDBRemoteCommunication *comm = (GDBRemoteCommunication *)arg; - Error error; + Status error; ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)comm->GetConnection(); @@ -975,7 +975,7 @@ GDBRemoteCommunication::ListenThread(lldb::thread_arg_t arg) { return NULL; } -Error GDBRemoteCommunication::StartDebugserverProcess( +Status GDBRemoteCommunication::StartDebugserverProcess( const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args, int pass_comm_fd) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); @@ -984,7 +984,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess( __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0)); - Error error; + Status error; // If we locate debugserver, keep that located version around static FileSpec g_debugserver_file_spec; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index b49e05e22d950..ce90de3e8470e 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -65,9 +65,9 @@ public: enum class PacketResult { Success = 0, // Success - ErrorSendFailed, // Error sending the packet + ErrorSendFailed, // Status sending the packet ErrorSendAck, // Didn't get an ack back after sending a packet - ErrorReplyFailed, // Error getting the reply + ErrorReplyFailed, // Status getting the reply ErrorReplyTimeout, // Timed out waiting for reply ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that // was sent @@ -131,7 +131,7 @@ public: // Start a debugserver instance on the current host using the // supplied connection URL. //------------------------------------------------------------------ - Error StartDebugserverProcess( + Status StartDebugserverProcess( const char *url, Platform *platform, // If non nullptr, then check with the platform for // the GDB server binary if it can't be located @@ -255,8 +255,8 @@ protected: // on m_bytes. The checksum was for the compressed packet. bool DecompressPacket(); - Error StartListenThread(const char *hostname = "127.0.0.1", - uint16_t port = 0); + Status StartListenThread(const char *hostname = "127.0.0.1", + uint16_t port = 0); bool JoinListenThread(); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 2e94fa94331d1..550ec0ea499a5 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -113,7 +113,7 @@ GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() { Disconnect(); } -bool GDBRemoteCommunicationClient::HandshakeWithServer(Error *error_ptr) { +bool GDBRemoteCommunicationClient::HandshakeWithServer(Status *error_ptr) { ResetDiscoverableSettings(false); // Start the read thread after we send the handshake ack since if we @@ -1394,8 +1394,8 @@ bool GDBRemoteCommunicationClient::DeallocateMemory(addr_t addr) { return false; } -Error GDBRemoteCommunicationClient::Detach(bool keep_stopped) { - Error error; +Status GDBRemoteCommunicationClient::Detach(bool keep_stopped) { + Status error; if (keep_stopped) { if (m_supports_detach_stay_stopped == eLazyBoolCalculate) { @@ -1434,9 +1434,9 @@ Error GDBRemoteCommunicationClient::Detach(bool keep_stopped) { return error; } -Error GDBRemoteCommunicationClient::GetMemoryRegionInfo( +Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( lldb::addr_t addr, lldb_private::MemoryRegionInfo ®ion_info) { - Error error; + Status error; region_info.Clear(); if (m_supports_memory_region_info != eLazyBoolNo) { @@ -1529,8 +1529,8 @@ Error GDBRemoteCommunicationClient::GetMemoryRegionInfo( return error; } -Error GDBRemoteCommunicationClient::GetWatchpointSupportInfo(uint32_t &num) { - Error error; +Status GDBRemoteCommunicationClient::GetWatchpointSupportInfo(uint32_t &num) { + Status error; if (m_supports_watchpoint_support_info == eLazyBoolYes) { num = m_num_supported_hardware_watchpoints; @@ -1568,18 +1568,18 @@ Error GDBRemoteCommunicationClient::GetWatchpointSupportInfo(uint32_t &num) { return error; } -lldb_private::Error GDBRemoteCommunicationClient::GetWatchpointSupportInfo( +lldb_private::Status GDBRemoteCommunicationClient::GetWatchpointSupportInfo( uint32_t &num, bool &after, const ArchSpec &arch) { - Error error(GetWatchpointSupportInfo(num)); + Status error(GetWatchpointSupportInfo(num)); if (error.Success()) error = GetWatchpointsTriggerAfterInstruction(after, arch); return error; } -lldb_private::Error +lldb_private::Status GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction( bool &after, const ArchSpec &arch) { - Error error; + Status error; llvm::Triple::ArchType atype = arch.GetMachine(); // we assume watchpoints will happen after running the relevant opcode @@ -2539,7 +2539,7 @@ uint8_t GDBRemoteCommunicationClient::SendGDBStoppointTypePacket( if (response.IsOKResponse()) return 0; - // Error while setting breakpoint, send back specific error + // Status while setting breakpoint, send back specific error if (response.IsErrorResponse()) return response.GetError(); @@ -2635,7 +2635,7 @@ lldb::addr_t GDBRemoteCommunicationClient::GetShlibInfoAddr() { return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); } -lldb_private::Error GDBRemoteCommunicationClient::RunShellCommand( +lldb_private::Status GDBRemoteCommunicationClient::RunShellCommand( const char *command, // Shouldn't be NULL const FileSpec & working_dir, // Pass empty FileSpec to use the current working directory @@ -2661,32 +2661,32 @@ lldb_private::Error GDBRemoteCommunicationClient::RunShellCommand( if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { if (response.GetChar() != 'F') - return Error("malformed reply"); + return Status("malformed reply"); if (response.GetChar() != ',') - return Error("malformed reply"); + return Status("malformed reply"); uint32_t exitcode = response.GetHexMaxU32(false, UINT32_MAX); if (exitcode == UINT32_MAX) - return Error("unable to run remote process"); + return Status("unable to run remote process"); else if (status_ptr) *status_ptr = exitcode; if (response.GetChar() != ',') - return Error("malformed reply"); + return Status("malformed reply"); uint32_t signo = response.GetHexMaxU32(false, UINT32_MAX); if (signo_ptr) *signo_ptr = signo; if (response.GetChar() != ',') - return Error("malformed reply"); + return Status("malformed reply"); std::string output; response.GetEscapedBinaryData(output); if (command_output) command_output->assign(output); - return Error(); + return Status(); } - return Error("unable to send packet"); + return Status("unable to send packet"); } -Error GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec, - uint32_t file_permissions) { +Status GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec, + uint32_t file_permissions) { std::string path{file_spec.GetPath(false)}; lldb_private::StreamString stream; stream.PutCString("qPlatform_mkdir:"); @@ -2698,16 +2698,17 @@ Error GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec, if (SendPacketAndWaitForResponse(packet, response, false) != PacketResult::Success) - return Error("failed to send '%s' packet", packet.str().c_str()); + return Status("failed to send '%s' packet", packet.str().c_str()); if (response.GetChar() != 'F') - return Error("invalid response to '%s' packet", packet.str().c_str()); + return Status("invalid response to '%s' packet", packet.str().c_str()); - return Error(response.GetU32(UINT32_MAX), eErrorTypePOSIX); + return Status(response.GetU32(UINT32_MAX), eErrorTypePOSIX); } -Error GDBRemoteCommunicationClient::SetFilePermissions( - const FileSpec &file_spec, uint32_t file_permissions) { +Status +GDBRemoteCommunicationClient::SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) { std::string path{file_spec.GetPath(false)}; lldb_private::StreamString stream; stream.PutCString("qPlatform_chmod:"); @@ -2719,16 +2720,16 @@ Error GDBRemoteCommunicationClient::SetFilePermissions( if (SendPacketAndWaitForResponse(packet, response, false) != PacketResult::Success) - return Error("failed to send '%s' packet", stream.GetData()); + return Status("failed to send '%s' packet", stream.GetData()); if (response.GetChar() != 'F') - return Error("invalid response to '%s' packet", stream.GetData()); + return Status("invalid response to '%s' packet", stream.GetData()); - return Error(response.GetU32(UINT32_MAX), eErrorTypePOSIX); + return Status(response.GetU32(UINT32_MAX), eErrorTypePOSIX); } static uint64_t ParseHostIOPacketResponse(StringExtractorGDBRemote &response, - uint64_t fail_result, Error &error) { + uint64_t fail_result, Status &error) { response.SetFilePos(0); if (response.GetChar() != 'F') return fail_result; @@ -2748,7 +2749,7 @@ static uint64_t ParseHostIOPacketResponse(StringExtractorGDBRemote &response, lldb::user_id_t GDBRemoteCommunicationClient::OpenFile(const lldb_private::FileSpec &file_spec, uint32_t flags, mode_t mode, - Error &error) { + Status &error) { std::string path(file_spec.GetPath(false)); lldb_private::StreamString stream; stream.PutCString("vFile:open:"); @@ -2767,7 +2768,8 @@ GDBRemoteCommunicationClient::OpenFile(const lldb_private::FileSpec &file_spec, return UINT64_MAX; } -bool GDBRemoteCommunicationClient::CloseFile(lldb::user_id_t fd, Error &error) { +bool GDBRemoteCommunicationClient::CloseFile(lldb::user_id_t fd, + Status &error) { lldb_private::StreamString stream; stream.Printf("vFile:close:%i", (int)fd); StringExtractorGDBRemote response; @@ -2796,10 +2798,11 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize( return UINT64_MAX; } -Error GDBRemoteCommunicationClient::GetFilePermissions( - const FileSpec &file_spec, uint32_t &file_permissions) { +Status +GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) { std::string path{file_spec.GetPath(false)}; - Error error; + Status error; lldb_private::StreamString stream; stream.PutCString("vFile:mode:"); stream.PutCStringAsRawHex8(path.c_str()); @@ -2834,7 +2837,7 @@ Error GDBRemoteCommunicationClient::GetFilePermissions( uint64_t GDBRemoteCommunicationClient::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, - Error &error) { + Status &error) { lldb_private::StreamString stream; stream.Printf("vFile:pread:%i,%" PRId64 ",%" PRId64, (int)fd, dst_len, offset); @@ -2868,7 +2871,7 @@ uint64_t GDBRemoteCommunicationClient::WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, - Error &error) { + Status &error) { lldb_private::StreamGDBRemote stream; stream.Printf("vFile:pwrite:%i,%" PRId64 ",", (int)fd, offset); stream.PutEscapedBytes(src, src_len); @@ -2896,10 +2899,10 @@ uint64_t GDBRemoteCommunicationClient::WriteFile(lldb::user_id_t fd, return 0; } -Error GDBRemoteCommunicationClient::CreateSymlink(const FileSpec &src, - const FileSpec &dst) { +Status GDBRemoteCommunicationClient::CreateSymlink(const FileSpec &src, + const FileSpec &dst) { std::string src_path{src.GetPath(false)}, dst_path{dst.GetPath(false)}; - Error error; + Status error; lldb_private::StreamGDBRemote stream; stream.PutCString("vFile:symlink:"); // the unix symlink() command reverses its parameters where the dst if first, @@ -2930,9 +2933,9 @@ Error GDBRemoteCommunicationClient::CreateSymlink(const FileSpec &src, return error; } -Error GDBRemoteCommunicationClient::Unlink(const FileSpec &file_spec) { +Status GDBRemoteCommunicationClient::Unlink(const FileSpec &file_spec) { std::string path{file_spec.GetPath(false)}; - Error error; + Status error; lldb_private::StreamGDBRemote stream; stream.PutCString("vFile:unlink:"); // the unix symlink() command reverses its parameters where the dst if first, @@ -3221,12 +3224,12 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { if (!dict) return llvm::None; - std::string string; + llvm::StringRef string; uint64_t integer; if (!dict->GetValueForKeyAsString("uuid", string)) return llvm::None; - result.GetUUID().SetFromCString(string.c_str(), string.size()); + result.GetUUID().SetFromStringRef(string, string.size()); if (!dict->GetValueForKeyAsInteger("file_offset", integer)) return llvm::None; @@ -3238,7 +3241,7 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { if (!dict->GetValueForKeyAsString("triple", string)) return llvm::None; - result.GetArchitecture().SetTriple(string.c_str()); + result.GetArchitecture().SetTriple(string); if (!dict->GetValueForKeyAsString("file_path", string)) return llvm::None; @@ -3311,7 +3314,7 @@ GDBRemoteCommunicationClient::GetModulesInfo( bool GDBRemoteCommunicationClient::ReadExtFeature( const lldb_private::ConstString object, const lldb_private::ConstString annex, std::string &out, - lldb_private::Error &err) { + lldb_private::Status &err) { std::stringstream output; StringExtractorGDBRemote chunk; @@ -3590,7 +3593,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() { : nullptr; } -Error GDBRemoteCommunicationClient::SendSignalsToIgnore( +Status GDBRemoteCommunicationClient::SendSignalsToIgnore( llvm::ArrayRef<int32_t> signals) { // Format packet: // QPassSignals:<hex_sig1>;<hex_sig2>...;<hex_sigN> @@ -3601,18 +3604,18 @@ Error GDBRemoteCommunicationClient::SendSignalsToIgnore( auto send_status = SendPacketAndWaitForResponse(packet, response, false); if (send_status != GDBRemoteCommunication::PacketResult::Success) - return Error("Sending QPassSignals packet failed"); + return Status("Sending QPassSignals packet failed"); if (response.IsOKResponse()) { - return Error(); + return Status(); } else { - return Error("Unknown error happened during sending QPassSignals packet."); + return Status("Unknown error happened during sending QPassSignals packet."); } } -Error GDBRemoteCommunicationClient::ConfigureRemoteStructuredData( +Status GDBRemoteCommunicationClient::ConfigureRemoteStructuredData( const ConstString &type_name, const StructuredData::ObjectSP &config_sp) { - Error error; + Status error; if (type_name.GetLength() == 0) { error.SetErrorString("invalid type_name argument"); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 63b9708cc9a0a..08d0bd5d690b6 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -41,7 +41,7 @@ public: // After connecting, send the handshake to the server to make sure // we are communicating with it. //------------------------------------------------------------------ - bool HandshakeWithServer(Error *error_ptr); + bool HandshakeWithServer(Status *error_ptr); // For packets which specify a range of output to be returned, // return all of the output via a series of request packets of the form @@ -230,17 +230,17 @@ public: bool DeallocateMemory(lldb::addr_t addr); - Error Detach(bool keep_stopped); + Status Detach(bool keep_stopped); - Error GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); + Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); - Error GetWatchpointSupportInfo(uint32_t &num); + Status GetWatchpointSupportInfo(uint32_t &num); - Error GetWatchpointSupportInfo(uint32_t &num, bool &after, - const ArchSpec &arch); + Status GetWatchpointSupportInfo(uint32_t &num, bool &after, + const ArchSpec &arch); - Error GetWatchpointsTriggerAfterInstruction(bool &after, - const ArchSpec &arch); + Status GetWatchpointsTriggerAfterInstruction(bool &after, + const ArchSpec &arch); const ArchSpec &GetHostArchitecture(); @@ -365,33 +365,33 @@ public: bool &sequence_mutex_unavailable); lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, - mode_t mode, Error &error); + mode_t mode, Status &error); - bool CloseFile(lldb::user_id_t fd, Error &error); + bool CloseFile(lldb::user_id_t fd, Status &error); lldb::user_id_t GetFileSize(const FileSpec &file_spec); - Error GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions); + Status GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions); - Error SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions); + Status SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions); uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, - uint64_t dst_len, Error &error); + uint64_t dst_len, Status &error); uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, - uint64_t src_len, Error &error); + uint64_t src_len, Status &error); - Error CreateSymlink(const FileSpec &src, const FileSpec &dst); + Status CreateSymlink(const FileSpec &src, const FileSpec &dst); - Error Unlink(const FileSpec &file_spec); + Status Unlink(const FileSpec &file_spec); - Error MakeDirectory(const FileSpec &file_spec, uint32_t mode); + Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); bool GetFileExists(const FileSpec &file_spec); - Error RunShellCommand( + Status RunShellCommand( const char *command, // Shouldn't be nullptr const FileSpec &working_dir, // Pass empty FileSpec to use the current // working directory @@ -448,12 +448,12 @@ public: bool ReadExtFeature(const lldb_private::ConstString object, const lldb_private::ConstString annex, std::string &out, - lldb_private::Error &err); + lldb_private::Status &err); void ServeSymbolLookups(lldb_private::Process *process); // Sends QPassSignals packet to the server with given signals to ignore. - Error SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); + Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); //------------------------------------------------------------------ /// Return the feature set supported by the gdb-remote server. @@ -495,7 +495,7 @@ public: /// /// @see \b Process::ConfigureStructuredData(...) for details. //------------------------------------------------------------------ - Error + Status ConfigureRemoteStructuredData(const ConstString &type_name, const StructuredData::ObjectSP &config_sp); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 934824e214dc5..dac675ee94323 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -39,7 +39,7 @@ void GDBRemoteCommunicationServer::RegisterPacketHandler( GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServer::GetPacketAndSendResponse( - Timeout<std::micro> timeout, Error &error, bool &interrupt, bool &quit) { + Timeout<std::micro> timeout, Status &error, bool &interrupt, bool &quit) { StringExtractorGDBRemote packet; PacketResult packet_result = WaitForPacketNoLock(packet, timeout, false); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h index 0c583e62d76bb..6eb25f8b9f98b 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h @@ -31,8 +31,8 @@ class GDBRemoteCommunicationServer : public GDBRemoteCommunication { public: using PortMap = std::map<uint16_t, lldb::pid_t>; using PacketHandler = - std::function<PacketResult(StringExtractorGDBRemote &packet, Error &error, - bool &interrupt, bool &quit)>; + std::function<PacketResult(StringExtractorGDBRemote &packet, + Status &error, bool &interrupt, bool &quit)>; GDBRemoteCommunicationServer(const char *comm_name, const char *listener_name); @@ -44,7 +44,7 @@ public: PacketHandler handler); PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout, - Error &error, bool &interrupt, + Status &error, bool &interrupt, bool &quit); // After connecting, do a little handshake with the client to make sure diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 66c1b15ff8572..de2400c51ba34 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -523,7 +523,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open( File::ConvertOpenOptionsForPOSIXOpen(packet.GetHexMaxU32(false, 0)); if (packet.GetChar() == ',') { mode_t mode = packet.GetHexMaxU32(false, 0600); - Error error; + Status error; const FileSpec path_spec{path, true}; int fd = ::open(path_spec.GetCString(), flags, mode); const int save_errno = fd == -1 ? errno : 0; @@ -544,7 +544,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Close( StringExtractorGDBRemote &packet) { packet.SetFilePos(::strlen("vFile:close:")); int fd = packet.GetS32(-1); - Error error; + Status error; int err = -1; int save_errno = 0; if (fd >= 0) { @@ -663,7 +663,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Mode( std::string path; packet.GetHexByteString(path); if (!path.empty()) { - Error error; + Status error; const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error); StreamString response; response.Printf("F%u", mode); @@ -702,7 +702,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_symlink( packet.GetHexByteStringTerminatedBy(dst, ','); packet.GetChar(); // Skip ',' char packet.GetHexByteString(src); - Error error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false}); + Status error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false}); StreamString response; response.Printf("F%u,%u", error.GetError(), error.GetError()); return SendPacketNoLock(response.GetString()); @@ -714,7 +714,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_unlink( packet.SetFilePos(::strlen("vFile:unlink:")); std::string path; packet.GetHexByteString(path); - Error error(llvm::sys::fs::remove(path)); + Status error(llvm::sys::fs::remove(path)); StreamString response; response.Printf("F%u,%u", error.GetError(), error.GetError()); return SendPacketNoLock(response.GetString()); @@ -736,7 +736,7 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell( packet.GetHexByteString(working_dir); int status, signo; std::string output; - Error err = + Status err = Host::RunShellCommand(path.c_str(), FileSpec{working_dir, true}, &status, &signo, &output, timeout); StreamGDBRemote response; @@ -794,7 +794,7 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_mkdir( if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); - Error error(llvm::sys::fs::create_directory(path, mode)); + Status error(llvm::sys::fs::create_directory(path, mode)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); @@ -814,7 +814,7 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod( if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); - Error error(llvm::sys::fs::setPermissions(path, perms)); + Status error(llvm::sys::fs::setPermissions(path, perms)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); @@ -1140,7 +1140,7 @@ GDBRemoteCommunicationServerCommon::Handle_jModulesInfo( packet_array->GetItemAtIndex(i)->GetAsDictionary(); if (!query) continue; - std::string file, triple; + llvm::StringRef file, triple; if (!query->GetValueForKeyAsString("file", file) || !query->GetValueForKeyAsString("triple", triple)) continue; @@ -1278,9 +1278,10 @@ FileSpec GDBRemoteCommunicationServerCommon::FindModuleFile( #endif } -ModuleSpec GDBRemoteCommunicationServerCommon::GetModuleInfo( - const std::string &module_path, const std::string &triple) { - ArchSpec arch(triple.c_str()); +ModuleSpec +GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path, + llvm::StringRef triple) { + ArchSpec arch(triple); const FileSpec req_module_path_spec(module_path, true); const FileSpec module_path_spec = diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h index 321a92266bddd..e9ab8f1a11deb 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h @@ -38,7 +38,7 @@ public: protected: ProcessLaunchInfo m_process_launch_info; - Error m_process_launch_error; + Status m_process_launch_error; ProcessInstanceInfoList m_proc_infos; uint32_t m_proc_infos_index; bool m_thread_suffix_supported; @@ -130,7 +130,7 @@ protected: PacketResult (T::*handler)(StringExtractorGDBRemote &packet)) { RegisterPacketHandler(packet_type, [this, handler](StringExtractorGDBRemote packet, - Error &error, bool &interrupt, + Status &error, bool &interrupt, bool &quit) { return (static_cast<T *>(this)->*handler)(packet); }); @@ -144,17 +144,16 @@ protected: /// with all the information for a child process to be launched. /// /// @return - /// An Error object indicating the success or failure of the + /// An Status object indicating the success or failure of the /// launch. //------------------------------------------------------------------ - virtual Error LaunchProcess() = 0; + virtual Status LaunchProcess() = 0; virtual FileSpec FindModuleFile(const std::string &module_path, const ArchSpec &arch); private: - ModuleSpec GetModuleInfo(const std::string &module_path, - const std::string &triple); + ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple); }; } // namespace process_gdb_remote diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 290889ec662ae..ec7c2f5330d73 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -184,35 +184,36 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() { &GDBRemoteCommunicationServerLLGS::Handle_QPassSignals); RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_k, - [this](StringExtractorGDBRemote packet, Error &error, + [this](StringExtractorGDBRemote packet, Status &error, bool &interrupt, bool &quit) { quit = true; return this->Handle_k(packet); }); } -Error GDBRemoteCommunicationServerLLGS::SetLaunchArguments( - const char *const args[], int argc) { +Status +GDBRemoteCommunicationServerLLGS::SetLaunchArguments(const char *const args[], + int argc) { if ((argc < 1) || !args || !args[0] || !args[0][0]) - return Error("%s: no process command line specified to launch", - __FUNCTION__); + return Status("%s: no process command line specified to launch", + __FUNCTION__); m_process_launch_info.SetArguments(const_cast<const char **>(args), true); - return Error(); + return Status(); } -Error GDBRemoteCommunicationServerLLGS::SetLaunchFlags( - unsigned int launch_flags) { +Status +GDBRemoteCommunicationServerLLGS::SetLaunchFlags(unsigned int launch_flags) { m_process_launch_info.GetFlags().Set(launch_flags); - return Error(); + return Status(); } -Error GDBRemoteCommunicationServerLLGS::LaunchProcess() { +Status GDBRemoteCommunicationServerLLGS::LaunchProcess() { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS)); if (!m_process_launch_info.GetArguments().GetArgumentCount()) - return Error("%s: no process command line specified to launch", - __FUNCTION__); + return Status("%s: no process command line specified to launch", + __FUNCTION__); const bool should_forward_stdio = m_process_launch_info.GetFileActionForFD(STDIN_FILENO) == nullptr || @@ -224,7 +225,7 @@ Error GDBRemoteCommunicationServerLLGS::LaunchProcess() { const bool default_to_use_pty = true; m_process_launch_info.FinalizeFileActions(nullptr, default_to_use_pty); - Error error; + Status error; { std::lock_guard<std::recursive_mutex> guard(m_debugged_process_mutex); assert(!m_debugged_process_sp && "lldb-server creating debugged " @@ -286,8 +287,8 @@ Error GDBRemoteCommunicationServerLLGS::LaunchProcess() { return error; } -Error GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) { - Error error; +Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) { + Status error; Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS)); if (log) @@ -298,10 +299,10 @@ Error GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) { // else. if (m_debugged_process_sp && m_debugged_process_sp->GetID() != LLDB_INVALID_PROCESS_ID) - return Error("cannot attach to a process %" PRIu64 - " when another process with pid %" PRIu64 - " is being debugged.", - pid, m_debugged_process_sp->GetID()); + return Status("cannot attach to a process %" PRIu64 + " when another process with pid %" PRIu64 + " is being debugged.", + pid, m_debugged_process_sp->GetID()); // Try to attach. error = NativeProcessProtocol::Attach(pid, *this, m_mainloop, @@ -420,7 +421,7 @@ static void WriteRegisterValueInHexFixedWidth( lldb::ByteOrder byte_order) { RegisterValue reg_value; if (!reg_value_p) { - Error error = reg_ctx_sp->ReadRegister(®_info, reg_value); + Status error = reg_ctx_sp->ReadRegister(®_info, reg_value); if (error.Success()) reg_value_p = ®_value; // else log. @@ -488,7 +489,7 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) { // registers. RegisterValue reg_value; - Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); + Status error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); if (error.Fail()) { if (log) log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s", @@ -739,7 +740,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( reg_ctx_sp->GetRegisterInfoAtIndex(reg_to_read); RegisterValue reg_value; - Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); + Status error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); if (error.Fail()) { if (log) log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s", @@ -793,7 +794,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( } else if (reg_info_p->value_regs == nullptr) { // Only expediate registers that are not contained in other registers. RegisterValue reg_value; - Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); + Status error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); if (error.Success()) { response.Printf("%.02x:", *reg_num_p); WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p, @@ -960,7 +961,7 @@ void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() { bool interrupt = false; bool done = false; - Error error; + Status error; while (true) { const PacketResult result = GetPacketAndSendResponse( std::chrono::microseconds(0), error, interrupt, done); @@ -978,12 +979,12 @@ void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() { } } -Error GDBRemoteCommunicationServerLLGS::InitializeConnection( +Status GDBRemoteCommunicationServerLLGS::InitializeConnection( std::unique_ptr<Connection> &&connection) { IOObjectSP read_object_sp = connection->GetReadObject(); GDBRemoteCommunicationServer::SetConnection(connection.release()); - Error error; + Status error; m_network_handle_up = m_mainloop.RegisterReadObject( read_object_sp, [this](MainLoopBase &) { DataAvailableCallback(); }, error); @@ -1005,8 +1006,8 @@ GDBRemoteCommunicationServerLLGS::SendONotification(const char *buffer, return SendPacketNoLock(response.GetString()); } -Error GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) { - Error error; +Status GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) { + Status error; // Set up the reading/handling of process I/O std::unique_ptr<ConnectionFileDescriptor> conn_up( @@ -1024,7 +1025,7 @@ Error GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) { return error; } - return Error(); + return Status(); } void GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding() { @@ -1032,7 +1033,7 @@ void GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding() { if (!m_stdio_communication.IsConnected()) return; - Error error; + Status error; lldbassert(!m_stdio_handle_up); m_stdio_handle_up = m_mainloop.RegisterReadObject( m_stdio_communication.GetConnection()->GetReadObject(), @@ -1055,7 +1056,7 @@ void GDBRemoteCommunicationServerLLGS::StopSTDIOForwarding() { void GDBRemoteCommunicationServerLLGS::SendProcessOutput() { char buffer[1024]; ConnectionStatus status; - Error error; + Status error; while (true) { size_t bytes_read = m_stdio_communication.Read( buffer, sizeof buffer, std::chrono::microseconds(0), status, &error); @@ -1140,7 +1141,7 @@ GDBRemoteCommunicationServerLLGS::Handle_k(StringExtractorGDBRemote &packet) { return PacketResult::Success; } - Error error = m_debugged_process_sp->Kill(); + Status error = m_debugged_process_sp->Kill(); if (error.Fail() && log) log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to kill debugged " "process %" PRIu64 ": %s", @@ -1223,7 +1224,7 @@ GDBRemoteCommunicationServerLLGS::Handle_C(StringExtractorGDBRemote &packet) { } ResumeActionList resume_actions(StateType::eStateRunning, 0); - Error error; + Status error; // We have two branches: what to do if a continue thread is specified (in // which case we target @@ -1304,7 +1305,7 @@ GDBRemoteCommunicationServerLLGS::Handle_c(StringExtractorGDBRemote &packet) { // Build the ResumeActionList ResumeActionList actions(StateType::eStateRunning, 0); - Error error = m_debugged_process_sp->Resume(actions); + Status error = m_debugged_process_sp->Resume(actions); if (error.Fail()) { if (log) { log->Printf( @@ -1428,7 +1429,7 @@ GDBRemoteCommunicationServerLLGS::Handle_vCont( thread_actions.Append(thread_action); } - Error error = m_debugged_process_sp->Resume(thread_actions); + Status error = m_debugged_process_sp->Resume(thread_actions); if (error.Fail()) { if (log) { log->Printf("GDBRemoteCommunicationServerLLGS::%s vCont failed for " @@ -1853,7 +1854,7 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) { // Retrieve the value RegisterValue reg_value; - Error error = reg_context_sp->ReadRegister(reg_info, reg_value); + Status error = reg_context_sp->ReadRegister(reg_info, reg_value); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, read of " @@ -1973,7 +1974,7 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) { StreamGDBRemote response; RegisterValue reg_value(reg_bytes, reg_size, process_arch.GetByteOrder()); - Error error = reg_context_sp->WriteRegister(reg_info, reg_value); + Status error = reg_context_sp->WriteRegister(reg_info, reg_value); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, write of " @@ -2088,7 +2089,7 @@ GDBRemoteCommunicationServerLLGS::Handle_I(StringExtractorGDBRemote &packet) { // TODO: enqueue this block in circular buffer and send window size to // remote host ConnectionStatus status; - Error error; + Status error; m_stdio_communication.Write(tmp, read, status, &error); if (error.Fail()) { return SendErrorResponse(0x15); @@ -2114,7 +2115,7 @@ GDBRemoteCommunicationServerLLGS::Handle_interrupt( } // Interrupt the process. - Error error = m_debugged_process_sp->Interrupt(); + Status error = m_debugged_process_sp->Interrupt(); if (error.Fail()) { if (log) { log->Printf( @@ -2181,7 +2182,7 @@ GDBRemoteCommunicationServerLLGS::Handle_memory_read( // Retrieve the process memory. size_t bytes_read = 0; - Error error = m_debugged_process_sp->ReadMemoryWithoutTrap( + Status error = m_debugged_process_sp->ReadMemoryWithoutTrap( read_addr, &buf[0], byte_count, bytes_read); if (error.Fail()) { if (log) @@ -2282,8 +2283,8 @@ GDBRemoteCommunicationServerLLGS::Handle_M(StringExtractorGDBRemote &packet) { // Write the process memory. size_t bytes_written = 0; - Error error = m_debugged_process_sp->WriteMemory(write_addr, &buf[0], - byte_count, bytes_written); + Status error = m_debugged_process_sp->WriteMemory(write_addr, &buf[0], + byte_count, bytes_written); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 @@ -2329,7 +2330,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfoSupported( // Test if we can get any region back when asking for the region around NULL. MemoryRegionInfo region_info; - const Error error = + const Status error = m_debugged_process_sp->GetMemoryRegionInfo(0, region_info); if (error.Fail()) { // We don't support memory region info collection for this @@ -2367,7 +2368,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo( // Get the memory region info for the target address. MemoryRegionInfo region_info; - const Error error = + const Status error = m_debugged_process_sp->GetMemoryRegionInfo(read_addr, region_info); if (error.Fail()) { // Return the error message. @@ -2485,7 +2486,7 @@ GDBRemoteCommunicationServerLLGS::Handle_Z(StringExtractorGDBRemote &packet) { if (want_breakpoint) { // Try to set the breakpoint. - const Error error = + const Status error = m_debugged_process_sp->SetBreakpoint(addr, size, want_hardware); if (error.Success()) return SendOKResponse(); @@ -2498,7 +2499,7 @@ GDBRemoteCommunicationServerLLGS::Handle_Z(StringExtractorGDBRemote &packet) { return SendErrorResponse(0x09); } else { // Try to set the watchpoint. - const Error error = m_debugged_process_sp->SetWatchpoint( + const Status error = m_debugged_process_sp->SetWatchpoint( addr, size, watch_flags, want_hardware); if (error.Success()) return SendOKResponse(); @@ -2582,7 +2583,7 @@ GDBRemoteCommunicationServerLLGS::Handle_z(StringExtractorGDBRemote &packet) { if (want_breakpoint) { // Try to clear the breakpoint. - const Error error = + const Status error = m_debugged_process_sp->RemoveBreakpoint(addr, want_hardware); if (error.Success()) return SendOKResponse(); @@ -2595,7 +2596,7 @@ GDBRemoteCommunicationServerLLGS::Handle_z(StringExtractorGDBRemote &packet) { return SendErrorResponse(0x09); } else { // Try to clear the watchpoint. - const Error error = m_debugged_process_sp->RemoveWatchpoint(addr); + const Status error = m_debugged_process_sp->RemoveWatchpoint(addr); if (error.Success()) return SendOKResponse(); Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS)); @@ -2646,7 +2647,7 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) { // All other threads stop while we're single stepping a thread. actions.SetDefaultThreadActionIfNeeded(eStateStopped, 0); - Error error = m_debugged_process_sp->Resume(actions); + Status error = m_debugged_process_sp->Resume(actions); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 @@ -2782,7 +2783,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QSaveRegisterState( // Save registers to a buffer. DataBufferSP register_data_sp; - Error error = reg_context_sp->ReadAllRegisterValues(register_data_sp); + Status error = reg_context_sp->ReadAllRegisterValues(register_data_sp); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 @@ -2871,7 +2872,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QRestoreRegisterState( m_saved_registers_map.erase(it); } - Error error = reg_context_sp->WriteAllRegisterValues(register_data_sp); + Status error = reg_context_sp->WriteAllRegisterValues(register_data_sp); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 @@ -2906,7 +2907,7 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttach( "pid %" PRIu64, __FUNCTION__, pid); - Error error = AttachToProcess(pid); + Status error = AttachToProcess(pid); if (error.Fail()) { if (log) @@ -2954,7 +2955,7 @@ GDBRemoteCommunicationServerLLGS::Handle_D(StringExtractorGDBRemote &packet) { return SendIllFormedResponse(packet, "Invalid pid"); } - const Error error = m_debugged_process_sp->Detach(); + const Status error = m_debugged_process_sp->Detach(); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to detach from " @@ -3058,7 +3059,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qFileLoadAddress( packet.GetHexByteString(file_name); lldb::addr_t file_load_address = LLDB_INVALID_ADDRESS; - Error error = + Status error = m_debugged_process_sp->GetFileLoadAddress(file_name, file_load_address); if (error.Fail()) return SendErrorResponse(69); @@ -3098,7 +3099,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QPassSignals( if (!m_debugged_process_sp) return SendErrorResponse(68); - Error error = m_debugged_process_sp->IgnoreSignals(signals); + Status error = m_debugged_process_sp->IgnoreSignals(signals); if (error.Fail()) return SendErrorResponse(69); @@ -3112,7 +3113,7 @@ void GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection() { if (m_stdio_communication.IsConnected()) { auto connection = m_stdio_communication.GetConnection(); if (connection) { - Error error; + Status error; connection->Disconnect(&error); if (error.Success()) { diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index a47927e1c6408..ebda9a911d3c1 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -51,10 +51,10 @@ public: /// The number of elements in the args array of cstring pointers. /// /// @return - /// An Error object indicating the success or failure of making + /// An Status object indicating the success or failure of making /// the setting. //------------------------------------------------------------------ - Error SetLaunchArguments(const char *const args[], int argc); + Status SetLaunchArguments(const char *const args[], int argc); //------------------------------------------------------------------ /// Specify the launch flags for the process. @@ -63,10 +63,10 @@ public: /// The launch flags to use when launching this process. /// /// @return - /// An Error object indicating the success or failure of making + /// An Status object indicating the success or failure of making /// the setting. //------------------------------------------------------------------ - Error SetLaunchFlags(unsigned int launch_flags); + Status SetLaunchFlags(unsigned int launch_flags); //------------------------------------------------------------------ /// Launch a process with the current launch settings. @@ -76,10 +76,10 @@ public: /// with all the information for a child process to be launched. /// /// @return - /// An Error object indicating the success or failure of the + /// An Status object indicating the success or failure of the /// launch. //------------------------------------------------------------------ - Error LaunchProcess() override; + Status LaunchProcess() override; //------------------------------------------------------------------ /// Attach to a process. @@ -88,10 +88,10 @@ public: /// configured Platform. /// /// @return - /// An Error object indicating the success or failure of the + /// An Status object indicating the success or failure of the /// attach operation. //------------------------------------------------------------------ - Error AttachToProcess(lldb::pid_t pid); + Status AttachToProcess(lldb::pid_t pid); //------------------------------------------------------------------ // NativeProcessProtocol::NativeDelegate overrides @@ -103,7 +103,7 @@ public: void DidExec(NativeProcessProtocol *process) override; - Error InitializeConnection(std::unique_ptr<Connection> &&connection); + Status InitializeConnection(std::unique_ptr<Connection> &&connection); protected: MainLoop &m_mainloop; @@ -213,7 +213,7 @@ protected: lldb::tid_t GetContinueThreadID() const { return m_continue_tid; } - Error SetSTDIOFileDescriptor(int fd); + Status SetSTDIOFileDescriptor(int fd); FileSpec FindModuleFile(const std::string &module_path, const ArchSpec &arch) override; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index ae1c1adb5b458..73e3732df3efa 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -82,7 +82,7 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform( &GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo); RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_interrupt, - [](StringExtractorGDBRemote packet, Error &error, + [](StringExtractorGDBRemote packet, Status &error, bool &interrupt, bool &quit) { error.SetErrorString("interrupt received"); interrupt = true; @@ -95,7 +95,7 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform( //---------------------------------------------------------------------- GDBRemoteCommunicationServerPlatform::~GDBRemoteCommunicationServerPlatform() {} -Error GDBRemoteCommunicationServerPlatform::LaunchGDBServer( +Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( const lldb_private::Args &args, std::string hostname, lldb::pid_t &pid, uint16_t &port, std::string &socket_name) { if (port == UINT16_MAX) @@ -147,7 +147,7 @@ Error GDBRemoteCommunicationServerPlatform::LaunchGDBServer( port_ptr = nullptr; } - Error error = StartDebugserverProcess( + Status error = StartDebugserverProcess( url.str().c_str(), nullptr, debugserver_launch_info, port_ptr, &args, -1); pid = debugserver_launch_info.GetProcessID(); @@ -192,7 +192,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID; std::string socket_name; - Error error = + Status error = LaunchGDBServer(Args(), hostname, debugserver_pid, port, socket_name); if (error.Fail()) { if (log) @@ -439,10 +439,10 @@ bool GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped( return true; } -Error GDBRemoteCommunicationServerPlatform::LaunchProcess() { +Status GDBRemoteCommunicationServerPlatform::LaunchProcess() { if (!m_process_launch_info.GetArguments().GetArgumentCount()) - return Error("%s: no process command line specified to launch", - __FUNCTION__); + return Status("%s: no process command line specified to launch", + __FUNCTION__); // specify the process monitor if not already set. This should // generally be what happens since we need to reap started @@ -454,7 +454,7 @@ Error GDBRemoteCommunicationServerPlatform::LaunchProcess() { this, std::placeholders::_1), false); - Error error = Host::LaunchProcess(m_process_launch_info); + Status error = Host::LaunchProcess(m_process_launch_info); if (!error.Success()) { fprintf(stderr, "%s: failed to launch executable %s", __FUNCTION__, m_process_launch_info.GetArguments().GetArgumentAtIndex(0)); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h index 472d86e3a15c1..aed5106272d1b 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -34,7 +34,7 @@ public: ~GDBRemoteCommunicationServerPlatform() override; - Error LaunchProcess() override; + Status LaunchProcess() override; // Set both ports to zero to let the platform automatically bind to // a port chosen by the OS. @@ -61,9 +61,9 @@ public: void SetInferiorArguments(const lldb_private::Args &args); - Error LaunchGDBServer(const lldb_private::Args &args, std::string hostname, - lldb::pid_t &pid, uint16_t &port, - std::string &socket_name); + Status LaunchGDBServer(const lldb_private::Args &args, std::string hostname, + lldb::pid_t &pid, uint16_t &port, + std::string &socket_name); void SetPendingGdbServer(lldb::pid_t pid, uint16_t port, const std::string &socket_name); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index ea4acc74893a1..612c7144451e0 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -95,8 +95,8 @@ bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info, // Read the register if (ReadRegisterBytes(reg_info, m_reg_data)) { const bool partial_data_ok = false; - Error error(value.SetValueFromData(reg_info, m_reg_data, - reg_info->byte_offset, partial_data_ok)); + Status error(value.SetValueFromData( + reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok)); return error.Success(); } return false; diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index c4ae5e36d9ad3..64684c5963b3e 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -97,8 +97,8 @@ namespace lldb { // function and get the packet history dumped to a file. void DumpProcessGDBRemotePacketHistory(void *p, const char *path) { StreamFile strm; - Error error(strm.GetFile().Open(path, File::eOpenOptionWrite | - File::eOpenOptionCanCreate)); + Status error(strm.GetFile().Open(path, File::eOpenOptionWrite | + File::eOpenOptionCanCreate)); if (error.Success()) ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory(strm); } @@ -324,7 +324,7 @@ bool ProcessGDBRemote::ParsePythonTargetDefinition( const FileSpec &target_definition_fspec) { ScriptInterpreter *interpreter = GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); - Error error; + Status error; StructuredData::ObjectSP module_object_sp( interpreter->LoadPluginModule(target_definition_fspec, error)); if (module_object_sp) { @@ -639,23 +639,23 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { m_register_info.Finalize(GetTarget().GetArchitecture()); } -Error ProcessGDBRemote::WillLaunch(Module *module) { +Status ProcessGDBRemote::WillLaunch(Module *module) { return WillLaunchOrAttach(); } -Error ProcessGDBRemote::WillAttachToProcessWithID(lldb::pid_t pid) { +Status ProcessGDBRemote::WillAttachToProcessWithID(lldb::pid_t pid) { return WillLaunchOrAttach(); } -Error ProcessGDBRemote::WillAttachToProcessWithName(const char *process_name, - bool wait_for_launch) { +Status ProcessGDBRemote::WillAttachToProcessWithName(const char *process_name, + bool wait_for_launch) { return WillLaunchOrAttach(); } -Error ProcessGDBRemote::DoConnectRemote(Stream *strm, - llvm::StringRef remote_url) { +Status ProcessGDBRemote::DoConnectRemote(Stream *strm, + llvm::StringRef remote_url) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); - Error error(WillLaunchOrAttach()); + Status error(WillLaunchOrAttach()); if (error.Fail()) return error; @@ -744,8 +744,8 @@ Error ProcessGDBRemote::DoConnectRemote(Stream *strm, return error; } -Error ProcessGDBRemote::WillLaunchOrAttach() { - Error error; +Status ProcessGDBRemote::WillLaunchOrAttach() { + Status error; m_stdio_communication.Clear(); return error; } @@ -753,10 +753,10 @@ Error ProcessGDBRemote::WillLaunchOrAttach() { //---------------------------------------------------------------------- // Process Control //---------------------------------------------------------------------- -Error ProcessGDBRemote::DoLaunch(Module *exe_module, - ProcessLaunchInfo &launch_info) { +Status ProcessGDBRemote::DoLaunch(Module *exe_module, + ProcessLaunchInfo &launch_info) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); - Error error; + Status error; if (log) log->Printf("ProcessGDBRemote::%s() entered", __FUNCTION__); @@ -965,8 +965,8 @@ Error ProcessGDBRemote::DoLaunch(Module *exe_module, return error; } -Error ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) { - Error error; +Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) { + Status error; // Only connect if we have a valid connect URL Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); @@ -1169,10 +1169,10 @@ void ProcessGDBRemote::DidLaunch() { DidLaunchOrAttach(process_arch); } -Error ProcessGDBRemote::DoAttachToProcessWithID( +Status ProcessGDBRemote::DoAttachToProcessWithID( lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); - Error error; + Status error; if (log) log->Printf("ProcessGDBRemote::%s()", __FUNCTION__); @@ -1197,9 +1197,9 @@ Error ProcessGDBRemote::DoAttachToProcessWithID( return error; } -Error ProcessGDBRemote::DoAttachToProcessWithName( +Status ProcessGDBRemote::DoAttachToProcessWithName( const char *process_name, const ProcessAttachInfo &attach_info) { - Error error; + Status error; // Clear out and clean up from any current state Clear(); @@ -1247,18 +1247,18 @@ void ProcessGDBRemote::DidAttach(ArchSpec &process_arch) { DidLaunchOrAttach(process_arch); } -Error ProcessGDBRemote::WillResume() { +Status ProcessGDBRemote::WillResume() { m_continue_c_tids.clear(); m_continue_C_tids.clear(); m_continue_s_tids.clear(); m_continue_S_tids.clear(); m_jstopinfo_sp.reset(); m_jthreadsinfo_sp.reset(); - return Error(); + return Status(); } -Error ProcessGDBRemote::DoResume() { - Error error; +Status ProcessGDBRemote::DoResume() { + Status error; Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf("ProcessGDBRemote::Resume()"); @@ -2113,9 +2113,9 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) { if (mem_cache_dict->GetValueForKeyAsInteger<lldb::addr_t>( "address", mem_cache_addr)) { if (mem_cache_addr != LLDB_INVALID_ADDRESS) { - StringExtractor bytes; - if (mem_cache_dict->GetValueForKeyAsString( - "bytes", bytes.GetStringRef())) { + llvm::StringRef str; + if (mem_cache_dict->GetValueForKeyAsString("bytes", str)) { + StringExtractor bytes(str); bytes.SetFilePos(0); const size_t byte_size = bytes.GetStringRef().size() / 2; @@ -2400,8 +2400,8 @@ void ProcessGDBRemote::RefreshStateAfterStop() { m_thread_list_real.RefreshStateAfterStop(); } -Error ProcessGDBRemote::DoHalt(bool &caused_stop) { - Error error; +Status ProcessGDBRemote::DoHalt(bool &caused_stop) { + Status error; if (m_public_state.GetValue() == eStateAttaching) { // We are being asked to halt during an attach. We need to just close @@ -2412,8 +2412,8 @@ Error ProcessGDBRemote::DoHalt(bool &caused_stop) { return error; } -Error ProcessGDBRemote::DoDetach(bool keep_stopped) { - Error error; +Status ProcessGDBRemote::DoDetach(bool keep_stopped) { + Status error; Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf("ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped); @@ -2441,8 +2441,8 @@ Error ProcessGDBRemote::DoDetach(bool keep_stopped) { return error; } -Error ProcessGDBRemote::DoDestroy() { - Error error; +Status ProcessGDBRemote::DoDestroy() { + Status error; Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf("ProcessGDBRemote::DoDestroy()"); @@ -2722,7 +2722,7 @@ void ProcessGDBRemote::WillPublicStop() { // Process Memory //------------------------------------------------------------------ size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size, - Error &error) { + Status &error) { GetMaxMemorySize(); bool binary_memory_read = m_gdb_comm.GetxPacketSupported(); // M and m packets take 2 bytes for 1 byte of memory @@ -2781,7 +2781,7 @@ size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size, } size_t ProcessGDBRemote::DoWriteMemory(addr_t addr, const void *buf, - size_t size, Error &error) { + size_t size, Status &error) { GetMaxMemorySize(); // M and m packets take 2 bytes for 1 byte of memory size_t max_memory_size = m_max_memory_size / 2; @@ -2822,7 +2822,7 @@ size_t ProcessGDBRemote::DoWriteMemory(addr_t addr, const void *buf, lldb::addr_t ProcessGDBRemote::DoAllocateMemory(size_t size, uint32_t permissions, - Error &error) { + Status &error) { Log *log( GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_EXPRESSIONS)); addr_t allocated_addr = LLDB_INVALID_ADDRESS; @@ -2866,27 +2866,27 @@ lldb::addr_t ProcessGDBRemote::DoAllocateMemory(size_t size, return allocated_addr; } -Error ProcessGDBRemote::GetMemoryRegionInfo(addr_t load_addr, - MemoryRegionInfo ®ion_info) { +Status ProcessGDBRemote::GetMemoryRegionInfo(addr_t load_addr, + MemoryRegionInfo ®ion_info) { - Error error(m_gdb_comm.GetMemoryRegionInfo(load_addr, region_info)); + Status error(m_gdb_comm.GetMemoryRegionInfo(load_addr, region_info)); return error; } -Error ProcessGDBRemote::GetWatchpointSupportInfo(uint32_t &num) { +Status ProcessGDBRemote::GetWatchpointSupportInfo(uint32_t &num) { - Error error(m_gdb_comm.GetWatchpointSupportInfo(num)); + Status error(m_gdb_comm.GetWatchpointSupportInfo(num)); return error; } -Error ProcessGDBRemote::GetWatchpointSupportInfo(uint32_t &num, bool &after) { - Error error(m_gdb_comm.GetWatchpointSupportInfo( +Status ProcessGDBRemote::GetWatchpointSupportInfo(uint32_t &num, bool &after) { + Status error(m_gdb_comm.GetWatchpointSupportInfo( num, after, GetTarget().GetArchitecture())); return error; } -Error ProcessGDBRemote::DoDeallocateMemory(lldb::addr_t addr) { - Error error; +Status ProcessGDBRemote::DoDeallocateMemory(lldb::addr_t addr) { + Status error; LazyBool supported = m_gdb_comm.SupportsAllocDeallocMemory(); switch (supported) { @@ -2924,7 +2924,7 @@ Error ProcessGDBRemote::DoDeallocateMemory(lldb::addr_t addr) { // Process STDIO //------------------------------------------------------------------ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len, - Error &error) { + Status &error) { if (m_stdio_communication.IsConnected()) { ConnectionStatus status; m_stdio_communication.Write(src, src_len, status, NULL); @@ -2934,8 +2934,8 @@ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len, return 0; } -Error ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) { - Error error; +Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) { + Status error; assert(bp_site != NULL); // Get logging info @@ -3072,8 +3072,8 @@ Error ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) { return EnableSoftwareBreakpoint(bp_site); } -Error ProcessGDBRemote::DisableBreakpointSite(BreakpointSite *bp_site) { - Error error; +Status ProcessGDBRemote::DisableBreakpointSite(BreakpointSite *bp_site) { + Status error; assert(bp_site != NULL); addr_t addr = bp_site->GetLoadAddress(); user_id_t site_id = bp_site->GetID(); @@ -3141,8 +3141,8 @@ static GDBStoppointType GetGDBStoppointType(Watchpoint *wp) { return eWatchpointWrite; } -Error ProcessGDBRemote::EnableWatchpoint(Watchpoint *wp, bool notify) { - Error error; +Status ProcessGDBRemote::EnableWatchpoint(Watchpoint *wp, bool notify) { + Status error; if (wp) { user_id_t watchID = wp->GetID(); addr_t addr = wp->GetLoadAddress(); @@ -3178,8 +3178,8 @@ Error ProcessGDBRemote::EnableWatchpoint(Watchpoint *wp, bool notify) { return error; } -Error ProcessGDBRemote::DisableWatchpoint(Watchpoint *wp, bool notify) { - Error error; +Status ProcessGDBRemote::DisableWatchpoint(Watchpoint *wp, bool notify) { + Status error; if (wp) { user_id_t watchID = wp->GetID(); @@ -3231,8 +3231,8 @@ void ProcessGDBRemote::Clear() { m_thread_list.Clear(); } -Error ProcessGDBRemote::DoSignal(int signo) { - Error error; +Status ProcessGDBRemote::DoSignal(int signo) { + Status error; Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf("ProcessGDBRemote::DoSignal (signal = %d)", signo); @@ -3242,15 +3242,15 @@ Error ProcessGDBRemote::DoSignal(int signo) { return error; } -Error ProcessGDBRemote::EstablishConnectionIfNeeded( - const ProcessInfo &process_info) { +Status +ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { // Make sure we aren't already connected? if (m_gdb_comm.IsConnected()) - return Error(); + return Status(); PlatformSP platform_sp(GetTarget().GetPlatform()); if (platform_sp && !platform_sp->IsHost()) - return Error("Lost debug server connection"); + return Status("Lost debug server connection"); auto error = LaunchAndConnectToDebugserver(process_info); if (error.Fail()) { @@ -3277,11 +3277,11 @@ static bool SetCloexecFlag(int fd) { } #endif -Error ProcessGDBRemote::LaunchAndConnectToDebugserver( +Status ProcessGDBRemote::LaunchAndConnectToDebugserver( const ProcessInfo &process_info) { using namespace std::placeholders; // For _1, _2, etc. - Error error; + Status error; if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID) { // If we locate debugserver, keep that located version around static FileSpec g_debugserver_file_spec; @@ -3739,30 +3739,30 @@ bool ProcessGDBRemote::NewThreadNotifyBreakpointHit( return false; } -Error ProcessGDBRemote::UpdateAutomaticSignalFiltering() { +Status ProcessGDBRemote::UpdateAutomaticSignalFiltering() { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); LLDB_LOG(log, "Check if need to update ignored signals"); // QPassSignals package is not supported by the server, // there is no way we can ignore any signals on server side. if (!m_gdb_comm.GetQPassSignalsSupported()) - return Error(); + return Status(); // No signals, nothing to send. if (m_unix_signals_sp == nullptr) - return Error(); + return Status(); // Signals' version hasn't changed, no need to send anything. uint64_t new_signals_version = m_unix_signals_sp->GetVersion(); if (new_signals_version == m_last_signals_version) { LLDB_LOG(log, "Signals' version hasn't changed. version={0}", m_last_signals_version); - return Error(); + return Status(); } auto signals_to_ignore = m_unix_signals_sp->GetFilteredSignals(false, false, false); - Error error = m_gdb_comm.SendSignalsToIgnore(signals_to_ignore); + Status error = m_gdb_comm.SendSignalsToIgnore(signals_to_ignore); LLDB_LOG(log, "Signals' version changed. old version={0}, new version={1}, " @@ -3820,11 +3820,11 @@ DynamicLoader *ProcessGDBRemote::GetDynamicLoader() { return m_dyld_ap.get(); } -Error ProcessGDBRemote::SendEventData(const char *data) { +Status ProcessGDBRemote::SendEventData(const char *data) { int return_value; bool was_supported; - Error error; + Status error; return_value = m_gdb_comm.SendLaunchEventDataPacket(data, &was_supported); if (return_value != 0) { @@ -3995,7 +3995,7 @@ StructuredData::ObjectSP ProcessGDBRemote::GetSharedCacheInfo() { return object_sp; } -Error ProcessGDBRemote::ConfigureStructuredData( +Status ProcessGDBRemote::ConfigureStructuredData( const ConstString &type_name, const StructuredData::ObjectSP &config_sp) { return m_gdb_comm.ConfigureRemoteStructuredData(type_name, config_sp); } @@ -4332,7 +4332,7 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { // request the target xml file std::string raw; - lldb_private::Error lldberr; + lldb_private::Status lldberr; if (!comm.ReadExtFeature(ConstString("features"), ConstString("target.xml"), raw, lldberr)) { return false; @@ -4424,10 +4424,10 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { return m_register_info.GetNumRegisters() > 0; } -Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { +Status ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { // Make sure LLDB has an XML parser it can use first if (!XMLDocument::XMLEnabled()) - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS); if (log) @@ -4441,11 +4441,11 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { // request the loaded library list std::string raw; - lldb_private::Error lldberr; + lldb_private::Status lldberr; if (!comm.ReadExtFeature(ConstString("libraries-svr4"), ConstString(""), raw, lldberr)) - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); // parse the xml file in memory if (log) @@ -4453,11 +4453,11 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { XMLDocument doc; if (!doc.ParseMemory(raw.c_str(), raw.size(), "noname.xml")) - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); XMLNode root_element = doc.GetRootElement("library-list-svr4"); if (!root_element) - return Error(); + return Status(); // main link map structure llvm::StringRef main_lm = root_element.GetAttributeValue("main-lm"); @@ -4528,22 +4528,22 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { // request the loaded library list std::string raw; - lldb_private::Error lldberr; + lldb_private::Status lldberr; if (!comm.ReadExtFeature(ConstString("libraries"), ConstString(""), raw, lldberr)) - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); if (log) log->Printf("parsing: %s", raw.c_str()); XMLDocument doc; if (!doc.ParseMemory(raw.c_str(), raw.size(), "noname.xml")) - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); XMLNode root_element = doc.GetRootElement("library-list"); if (!root_element) - return Error(); + return Status(); root_element.ForEachChildElementWithName( "library", [log, &list](const XMLNode &library) -> bool { @@ -4584,10 +4584,10 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { log->Printf("found %" PRId32 " modules in total", (int)list.m_list.size()); } else { - return Error(0, ErrorType::eErrorTypeGeneric); + return Status(0, ErrorType::eErrorTypeGeneric); } - return Error(); + return Status(); } lldb::ModuleSP ProcessGDBRemote::LoadModuleAtAddress(const FileSpec &file, @@ -4686,15 +4686,15 @@ size_t ProcessGDBRemote::LoadModules() { return LoadModules(module_list); } -Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, - bool &is_loaded, - lldb::addr_t &load_addr) { +Status ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, + bool &is_loaded, + lldb::addr_t &load_addr) { is_loaded = false; load_addr = LLDB_INVALID_ADDRESS; std::string file_path = file.GetPath(false); if (file_path.empty()) - return Error("Empty file name specified"); + return Status("Empty file name specified"); StreamString packet; packet.PutCString("qFileLoadAddress:"); @@ -4704,27 +4704,28 @@ Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetString(), response, false) != GDBRemoteCommunication::PacketResult::Success) - return Error("Sending qFileLoadAddress packet failed"); + return Status("Sending qFileLoadAddress packet failed"); if (response.IsErrorResponse()) { if (response.GetError() == 1) { // The file is not loaded into the inferior is_loaded = false; load_addr = LLDB_INVALID_ADDRESS; - return Error(); + return Status(); } - return Error( + return Status( "Fetching file load address from remote server returned an error"); } if (response.IsNormalResponse()) { is_loaded = true; load_addr = response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); - return Error(); + return Status(); } - return Error("Unknown error happened during sending the load address packet"); + return Status( + "Unknown error happened during sending the load address packet"); } void ProcessGDBRemote::ModulesDidLoad(ModuleList &module_list) { diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index a1794d0f50508..60f0464f86bb5 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -30,7 +30,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringExtractor.h" #include "lldb/Utility/StringList.h" @@ -78,25 +78,25 @@ public: //------------------------------------------------------------------ // Creating a new process, or attaching to an existing one //------------------------------------------------------------------ - Error WillLaunch(Module *module) override; + Status WillLaunch(Module *module) override; - Error DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override; + Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override; void DidLaunch() override; - Error WillAttachToProcessWithID(lldb::pid_t pid) override; + Status WillAttachToProcessWithID(lldb::pid_t pid) override; - Error WillAttachToProcessWithName(const char *process_name, - bool wait_for_launch) override; + Status WillAttachToProcessWithName(const char *process_name, + bool wait_for_launch) override; - Error DoConnectRemote(Stream *strm, llvm::StringRef remote_url) override; + Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) override; - Error WillLaunchOrAttach(); + Status WillLaunchOrAttach(); - Error DoAttachToProcessWithID(lldb::pid_t pid, - const ProcessAttachInfo &attach_info) override; + Status DoAttachToProcessWithID(lldb::pid_t pid, + const ProcessAttachInfo &attach_info) override; - Error + Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) override; @@ -112,19 +112,19 @@ public: //------------------------------------------------------------------ // Process Control //------------------------------------------------------------------ - Error WillResume() override; + Status WillResume() override; - Error DoResume() override; + Status DoResume() override; - Error DoHalt(bool &caused_stop) override; + Status DoHalt(bool &caused_stop) override; - Error DoDetach(bool keep_stopped) override; + Status DoDetach(bool keep_stopped) override; bool DetachRequiresHalt() override { return true; } - Error DoSignal(int signal) override; + Status DoSignal(int signal) override; - Error DoDestroy() override; + Status DoDestroy() override; void RefreshStateAfterStop() override; @@ -143,41 +143,41 @@ public: // Process Memory //------------------------------------------------------------------ size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, - Error &error) override; + Status &error) override; size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, - Error &error) override; + Status &error) override; lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, - Error &error) override; + Status &error) override; - Error GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo ®ion_info) override; + Status GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo ®ion_info) override; - Error DoDeallocateMemory(lldb::addr_t ptr) override; + Status DoDeallocateMemory(lldb::addr_t ptr) override; //------------------------------------------------------------------ // Process STDIO //------------------------------------------------------------------ - size_t PutSTDIN(const char *buf, size_t buf_size, Error &error) override; + size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override; //---------------------------------------------------------------------- // Process Breakpoints //---------------------------------------------------------------------- - Error EnableBreakpointSite(BreakpointSite *bp_site) override; + Status EnableBreakpointSite(BreakpointSite *bp_site) override; - Error DisableBreakpointSite(BreakpointSite *bp_site) override; + Status DisableBreakpointSite(BreakpointSite *bp_site) override; //---------------------------------------------------------------------- // Process Watchpoints //---------------------------------------------------------------------- - Error EnableWatchpoint(Watchpoint *wp, bool notify = true) override; + Status EnableWatchpoint(Watchpoint *wp, bool notify = true) override; - Error DisableWatchpoint(Watchpoint *wp, bool notify = true) override; + Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override; - Error GetWatchpointSupportInfo(uint32_t &num) override; + Status GetWatchpointSupportInfo(uint32_t &num) override; - Error GetWatchpointSupportInfo(uint32_t &num, bool &after) override; + Status GetWatchpointSupportInfo(uint32_t &num, bool &after) override; bool StartNoticingNewThreads() override; @@ -185,7 +185,7 @@ public: GDBRemoteCommunicationClient &GetGDBRemote() { return m_gdb_comm; } - Error SendEventData(const char *data) override; + Status SendEventData(const char *data) override; //---------------------------------------------------------------------- // Override DidExit so we can disconnect from the remote GDB server @@ -207,8 +207,8 @@ public: size_t LoadModules() override; - Error GetFileLoadAddress(const FileSpec &file, bool &is_loaded, - lldb::addr_t &load_addr) override; + Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, + lldb::addr_t &load_addr) override; void ModulesDidLoad(ModuleList &module_list) override; @@ -216,7 +216,7 @@ public: GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count) override; - Error + Status ConfigureStructuredData(const ConstString &type_name, const StructuredData::ObjectSP &config_sp) override; @@ -315,9 +315,9 @@ protected: bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; - Error EstablishConnectionIfNeeded(const ProcessInfo &process_info); + Status EstablishConnectionIfNeeded(const ProcessInfo &process_info); - Error LaunchAndConnectToDebugserver(const ProcessInfo &process_info); + Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info); void KillDebugserverProcess(); @@ -379,7 +379,7 @@ protected: void DidLaunchOrAttach(ArchSpec &process_arch); - Error ConnectToDebugserver(llvm::StringRef host_port); + Status ConnectToDebugserver(llvm::StringRef host_port); const char *GetDispatchQueueNameForThread(lldb::addr_t thread_dispatch_qaddr, std::string &dispatch_queue_name); @@ -390,14 +390,14 @@ protected: bool GetGDBServerRegisterInfo(ArchSpec &arch); // Query remote GDBServer for a detailed loaded library list - Error GetLoadedModuleList(LoadedModuleInfoList &); + Status GetLoadedModuleList(LoadedModuleInfoList &); lldb::ModuleSP LoadModuleAtAddress(const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr, bool value_is_offset); - Error UpdateAutomaticSignalFiltering() override; + Status UpdateAutomaticSignalFiltering() override; private: //------------------------------------------------------------------ |