diff options
Diffstat (limited to 'source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 187 |
1 files changed, 94 insertions, 93 deletions
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index c4ae5e36d9ad..64684c5963b3 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) { |