diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
commit | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch) | |
tree | 27916256fdeeb57d10d2f3d6948be5d71a703215 /source/Plugins/Process/gdb-remote | |
parent | 76e0736e7fcfeb179779e49c05604464b1ccd704 (diff) |
Notes
Diffstat (limited to 'source/Plugins/Process/gdb-remote')
13 files changed, 225 insertions, 295 deletions
diff --git a/source/Plugins/Process/gdb-remote/CMakeLists.txt b/source/Plugins/Process/gdb-remote/CMakeLists.txt index 5e51feef1d3f8..7ae25f83c5f8a 100644 --- a/source/Plugins/Process/gdb-remote/CMakeLists.txt +++ b/source/Plugins/Process/gdb-remote/CMakeLists.txt @@ -7,6 +7,10 @@ set(LLDB_PLUGINS lldbPluginPlatformMacOSX ) +if(HAVE_LIBCOMPRESSION) + set(LIBCOMPRESSION compression) +endif() + add_lldb_library(lldbPluginProcessGDBRemote PLUGIN GDBRemoteClientBase.cpp GDBRemoteCommunication.cpp @@ -30,6 +34,7 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN lldbTarget lldbUtility ${LLDB_PLUGINS} + ${LIBCOMPRESSION} LINK_COMPONENTS Support ) diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 0c4df7e3f3065..949cf19db658a 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -600,10 +600,9 @@ bool GDBRemoteCommunication::DecompressPacket() { #if defined(HAVE_LIBCOMPRESSION) // libcompression is weak linked so check that compression_decode_buffer() is // available - if (compression_decode_buffer != NULL && - (m_compression_type == CompressionType::ZlibDeflate || - m_compression_type == CompressionType::LZFSE || - m_compression_type == CompressionType::LZ4)) { + if (m_compression_type == CompressionType::ZlibDeflate || + m_compression_type == CompressionType::LZFSE || + m_compression_type == CompressionType::LZ4) { compression_algorithm compression_type; if (m_compression_type == CompressionType::LZFSE) compression_type = COMPRESSION_LZFSE; @@ -815,7 +814,8 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, // checksum if (m_bytes[0] == '$' && total_length > 4) { for (size_t i = 0; !binary && i < total_length; ++i) { - if (isprint(m_bytes[i]) == 0 && isspace(m_bytes[i]) == 0) { + unsigned char c = m_bytes[i]; + if (isprint(c) == 0 && isspace(c) == 0) { binary = true; } } @@ -1375,3 +1375,39 @@ void GDBRemoteCommunication::AppendBytesToCache(const uint8_t *bytes, } } } + +void llvm::format_provider<GDBRemoteCommunication::PacketResult>::format( + const GDBRemoteCommunication::PacketResult &result, raw_ostream &Stream, + StringRef Style) { + using PacketResult = GDBRemoteCommunication::PacketResult; + + switch (result) { + case PacketResult::Success: + Stream << "Success"; + break; + case PacketResult::ErrorSendFailed: + Stream << "ErrorSendFailed"; + break; + case PacketResult::ErrorSendAck: + Stream << "ErrorSendAck"; + break; + case PacketResult::ErrorReplyFailed: + Stream << "ErrorReplyFailed"; + break; + case PacketResult::ErrorReplyTimeout: + Stream << "ErrorReplyTimeout"; + break; + case PacketResult::ErrorReplyInvalid: + Stream << "ErrorReplyInvalid"; + break; + case PacketResult::ErrorReplyAck: + Stream << "ErrorReplyAck"; + break; + case PacketResult::ErrorDisconnected: + Stream << "ErrorDisconnected"; + break; + case PacketResult::ErrorNoSequenceLock: + Stream << "ErrorNoSequenceLock"; + break; + } +} diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index ce90de3e8470e..ecc9386e49c7d 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -290,4 +290,14 @@ private: } // namespace process_gdb_remote } // namespace lldb_private +namespace llvm { +template <> +struct format_provider< + lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult> { + static void format(const lldb_private::process_gdb_remote:: + GDBRemoteCommunication::PacketResult &state, + raw_ostream &Stream, StringRef Style); +}; +} // namespace llvm + #endif // liblldb_GDBRemoteCommunication_h_ diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index e6fd386b903b8..867f57c475cec 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1022,10 +1022,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression( std::string avail_name; #if defined(HAVE_LIBCOMPRESSION) - // libcompression is weak linked so test if compression_decode_buffer() is - // available - if (compression_decode_buffer != NULL && - avail_type == CompressionType::None) { + if (avail_type == CompressionType::None) { for (auto compression : supported_compressions) { if (compression == "lzfse") { avail_type = CompressionType::LZFSE; @@ -1037,10 +1034,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression( #endif #if defined(HAVE_LIBCOMPRESSION) - // libcompression is weak linked so test if compression_decode_buffer() is - // available - if (compression_decode_buffer != NULL && - avail_type == CompressionType::None) { + if (avail_type == CompressionType::None) { for (auto compression : supported_compressions) { if (compression == "zlib-deflate") { avail_type = CompressionType::ZlibDeflate; @@ -1064,10 +1058,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression( #endif #if defined(HAVE_LIBCOMPRESSION) - // libcompression is weak linked so test if compression_decode_buffer() is - // available - if (compression_decode_buffer != NULL && - avail_type == CompressionType::None) { + if (avail_type == CompressionType::None) { for (auto compression : supported_compressions) { if (compression == "lz4") { avail_type = CompressionType::LZ4; @@ -1079,10 +1070,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression( #endif #if defined(HAVE_LIBCOMPRESSION) - // libcompression is weak linked so test if compression_decode_buffer() is - // available - if (compression_decode_buffer != NULL && - avail_type == CompressionType::None) { + if (avail_type == CompressionType::None) { for (auto compression : supported_compressions) { if (compression == "lzma") { avail_type = CompressionType::LZMA; @@ -1601,21 +1589,24 @@ GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction( // and we only want to override this behavior if we have explicitly // received a qHostInfo telling us otherwise if (m_qHostInfo_is_valid != eLazyBoolYes) { - // On targets like MIPS, watchpoint exceptions are always generated - // before the instruction is executed. The connected target may not - // support qHostInfo or qWatchpointSupportInfo packets. + // On targets like MIPS and ppc64le, watchpoint exceptions are always + // generated before the instruction is executed. The connected target + // may not support qHostInfo or qWatchpointSupportInfo packets. if (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel || - atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el) + atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el || + atype == llvm::Triple::ppc64le) after = false; else after = true; } else { - // For MIPS, set m_watchpoints_trigger_after_instruction to eLazyBoolNo - // if it is not calculated before. - if (m_watchpoints_trigger_after_instruction == eLazyBoolCalculate && - (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel || - atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el)) + // For MIPS and ppc64le, set m_watchpoints_trigger_after_instruction to + // eLazyBoolNo if it is not calculated before. + if ((m_watchpoints_trigger_after_instruction == eLazyBoolCalculate && + (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel || + atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el)) || + atype == llvm::Triple::ppc64le) { m_watchpoints_trigger_after_instruction = eLazyBoolNo; + } after = (m_watchpoints_trigger_after_instruction != eLazyBoolNo); } @@ -2624,8 +2615,8 @@ size_t GDBRemoteCommunicationClient::GetCurrentThreadIDs( * tid. * Assume pid=tid=1 in such cases. */ - if (response.IsUnsupportedResponse() && thread_ids.size() == 0 && - IsConnected()) { + if ((response.IsUnsupportedResponse() || response.IsNormalResponse()) && + thread_ids.size() == 0 && IsConnected()) { thread_ids.push_back(1); } } else { @@ -3451,7 +3442,9 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { if (!dict->GetValueForKeyAsString("uuid", string)) return llvm::None; - result.GetUUID().SetFromStringRef(string, string.size()); + if (result.GetUUID().SetFromStringRef(string, string.size() / 2) != + string.size()) + return llvm::None; if (!dict->GetValueForKeyAsInteger("file_offset", integer)) return llvm::None; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 712d85eed082e..ba67b82463987 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -20,10 +20,8 @@ #include <string> #include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/ArchSpec.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/StreamGDBRemote.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index f53db502be934..3cf6b8ac07b24 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -403,8 +403,8 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo( match_info.SetMatchAllUsers( Args::StringToBoolean(value, false, &success)); } else if (key.equals("triple")) { - match_info.GetProcessInfo().GetArchitecture().SetTriple( - value.str().c_str(), NULL); + match_info.GetProcessInfo().GetArchitecture() = + HostInfo::GetAugmentedArchSpec(value); } else { success = false; } @@ -973,8 +973,7 @@ GDBRemoteCommunicationServerCommon::Handle_QLaunchArch( const uint32_t bytes_left = packet.GetBytesLeft(); if (bytes_left > 0) { const char *arch_triple = packet.Peek(); - ArchSpec arch_spec(arch_triple, NULL); - m_process_launch_info.SetArchitecture(arch_spec); + m_process_launch_info.SetArchitecture(HostInfo::GetAugmentedArchSpec(arch_triple)); return SendOKResponse(); } return SendErrorResponse(13); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 9294359dbef1c..32741c2404e22 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -204,21 +204,8 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() { }); } -Status -GDBRemoteCommunicationServerLLGS::SetLaunchArguments(const char *const args[], - int argc) { - if ((argc < 1) || !args || !args[0] || !args[0][0]) - return Status("%s: no process command line specified to launch", - __FUNCTION__); - - m_process_launch_info.SetArguments(const_cast<const char **>(args), true); - return Status(); -} - -Status -GDBRemoteCommunicationServerLLGS::SetLaunchFlags(unsigned int launch_flags) { - m_process_launch_info.GetFlags().Set(launch_flags); - return Status(); +void GDBRemoteCommunicationServerLLGS::SetLaunchInfo(const ProcessLaunchInfo &info) { + m_process_launch_info = info; } Status GDBRemoteCommunicationServerLLGS::LaunchProcess() { @@ -244,13 +231,8 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() { "process but one already exists"); auto process_or = m_process_factory.Launch(m_process_launch_info, *this, m_mainloop); - if (!process_or) { - Status status(process_or.takeError()); - llvm::errs() << llvm::formatv( - "failed to launch executable `{0}`: {1}", - m_process_launch_info.GetArguments().GetArgumentAtIndex(0), status); - return status; - } + if (!process_or) + return Status(process_or.takeError()); m_debugged_process_up = std::move(*process_or); } @@ -396,12 +378,12 @@ static void AppendHexValue(StreamString &response, const uint8_t *buf, } static void WriteRegisterValueInHexFixedWidth( - StreamString &response, NativeRegisterContextSP ®_ctx_sp, + StreamString &response, NativeRegisterContext ®_ctx, const RegisterInfo ®_info, const RegisterValue *reg_value_p, lldb::ByteOrder byte_order) { RegisterValue reg_value; if (!reg_value_p) { - Status error = reg_ctx_sp->ReadRegister(®_info, reg_value); + Status error = reg_ctx.ReadRegister(®_info, reg_value); if (error.Success()) reg_value_p = ®_value; // else log. @@ -423,9 +405,7 @@ static void WriteRegisterValueInHexFixedWidth( static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD)); - NativeRegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return nullptr; + NativeRegisterContext& reg_ctx = thread.GetRegisterContext(); JSONObject::SP register_object_sp = std::make_shared<JSONObject>(); @@ -448,14 +428,14 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) { for (const uint32_t *generic_reg_p = k_expedited_registers; *generic_reg_p != LLDB_INVALID_REGNUM; ++generic_reg_p) { - uint32_t reg_num = reg_ctx_sp->ConvertRegisterKindToRegisterNumber( + uint32_t reg_num = reg_ctx.ConvertRegisterKindToRegisterNumber( eRegisterKindGeneric, *generic_reg_p); if (reg_num == LLDB_INVALID_REGNUM) continue; // Target does not support the given register. #endif const RegisterInfo *const reg_info_p = - reg_ctx_sp->GetRegisterInfoAtIndex(reg_num); + reg_ctx.GetRegisterInfoAtIndex(reg_num); if (reg_info_p == nullptr) { if (log) log->Printf( @@ -469,7 +449,7 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) { // registers. RegisterValue reg_value; - Status error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); + Status error = reg_ctx.ReadRegister(reg_info_p, reg_value); if (error.Fail()) { if (log) log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s", @@ -480,7 +460,7 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) { } StreamString stream; - WriteRegisterValueInHexFixedWidth(stream, reg_ctx_sp, *reg_info_p, + WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p, ®_value, lldb::eByteOrderBig); register_object_sp->SetObject( @@ -523,16 +503,16 @@ static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol &process, // Ensure we can get info on the given thread. uint32_t thread_idx = 0; - for (NativeThreadProtocolSP thread_sp; - (thread_sp = process.GetThreadAtIndex(thread_idx)) != nullptr; + for (NativeThreadProtocol *thread; + (thread = process.GetThreadAtIndex(thread_idx)) != nullptr; ++thread_idx) { - lldb::tid_t tid = thread_sp->GetID(); + lldb::tid_t tid = thread->GetID(); // Grab the reason this thread stopped. struct ThreadStopInfo tid_stop_info; std::string description; - if (!thread_sp->GetStopReason(tid_stop_info, description)) + if (!thread->GetStopReason(tid_stop_info, description)) return nullptr; const int signum = tid_stop_info.details.signal.signo; @@ -548,7 +528,7 @@ static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol &process, threads_array_sp->AppendObject(thread_obj_sp); if (!abridged) { - if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp)) + if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread)) thread_obj_sp->SetObject("registers", registers_sp); } @@ -556,7 +536,7 @@ static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol &process, if (signum != 0) thread_obj_sp->SetObject("signal", std::make_shared<JSONNumber>(signum)); - const std::string thread_name = thread_sp->GetName(); + const std::string thread_name = thread->GetName(); if (!thread_name.empty()) thread_obj_sp->SetObject("name", std::make_shared<JSONString>(thread_name)); @@ -604,14 +584,14 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( m_debugged_process_up->GetID(), tid); // Ensure we can get info on the given thread. - NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadByID(tid)); - if (!thread_sp) + NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + if (!thread) return SendErrorResponse(51); // Grab the reason this thread stopped. struct ThreadStopInfo tid_stop_info; std::string description; - if (!thread_sp->GetStopReason(tid_stop_info, description)) + if (!thread->GetStopReason(tid_stop_info, description)) return SendErrorResponse(52); // FIXME implement register handling for exec'd inferiors. @@ -638,7 +618,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( response.Printf("thread:%" PRIx64 ";", tid); // Include the thread name if there is one. - const std::string thread_name = thread_sp->GetName(); + const std::string thread_name = thread->GetName(); if (!thread_name.empty()) { size_t thread_name_len = thread_name.length(); @@ -665,15 +645,13 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( response.PutCString("threads:"); uint32_t thread_index = 0; - NativeThreadProtocolSP listed_thread_sp; - for (listed_thread_sp = - m_debugged_process_up->GetThreadAtIndex(thread_index); - listed_thread_sp; ++thread_index, - listed_thread_sp = m_debugged_process_up->GetThreadAtIndex( - thread_index)) { + NativeThreadProtocol *listed_thread; + for (listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index); + listed_thread; ++thread_index, + listed_thread = m_debugged_process_up->GetThreadAtIndex(thread_index)) { if (thread_index > 0) response.PutChar(','); - response.Printf("%" PRIx64, listed_thread_sp->GetID()); + response.Printf("%" PRIx64, listed_thread->GetID()); } response.PutChar(';'); @@ -701,20 +679,18 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( uint32_t i = 0; response.PutCString("thread-pcs"); char delimiter = ':'; - for (NativeThreadProtocolSP thread_sp; - (thread_sp = m_debugged_process_up->GetThreadAtIndex(i)) != nullptr; + for (NativeThreadProtocol *thread; + (thread = m_debugged_process_up->GetThreadAtIndex(i)) != nullptr; ++i) { - NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext(); - if (!reg_ctx_sp) - continue; + NativeRegisterContext& reg_ctx = thread->GetRegisterContext(); - uint32_t reg_to_read = reg_ctx_sp->ConvertRegisterKindToRegisterNumber( + uint32_t reg_to_read = reg_ctx.ConvertRegisterKindToRegisterNumber( eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); const RegisterInfo *const reg_info_p = - reg_ctx_sp->GetRegisterInfoAtIndex(reg_to_read); + reg_ctx.GetRegisterInfoAtIndex(reg_to_read); RegisterValue reg_value; - Status error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value); + Status error = reg_ctx.ReadRegister(reg_info_p, reg_value); if (error.Fail()) { if (log) log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s", @@ -727,7 +703,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( response.PutChar(delimiter); delimiter = ','; - WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p, + WriteRegisterValueInHexFixedWidth(response, reg_ctx, *reg_info_p, ®_value, endian::InlHostByteOrder()); } @@ -739,49 +715,48 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( // // Grab the register context. - NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext(); - if (reg_ctx_sp) { - // Expedite all registers in the first register set (i.e. should be GPRs) - // that are not contained in other registers. - const RegisterSet *reg_set_p; - if (reg_ctx_sp->GetRegisterSetCount() > 0 && - ((reg_set_p = reg_ctx_sp->GetRegisterSet(0)) != nullptr)) { - if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s expediting registers " - "from set '%s' (registers set count: %zu)", - __FUNCTION__, - reg_set_p->name ? reg_set_p->name : "<unnamed-set>", - reg_set_p->num_registers); - - for (const uint32_t *reg_num_p = reg_set_p->registers; - *reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) { - const RegisterInfo *const reg_info_p = - reg_ctx_sp->GetRegisterInfoAtIndex(*reg_num_p); - if (reg_info_p == nullptr) { + NativeRegisterContext& reg_ctx = thread->GetRegisterContext(); + // Expedite all registers in the first register set (i.e. should be GPRs) + // that are not contained in other registers. + const RegisterSet *reg_set_p; + if (reg_ctx.GetRegisterSetCount() > 0 && + ((reg_set_p = reg_ctx.GetRegisterSet(0)) != nullptr)) { + if (log) + log->Printf("GDBRemoteCommunicationServerLLGS::%s expediting registers " + "from set '%s' (registers set count: %zu)", + __FUNCTION__, + reg_set_p->name ? reg_set_p->name : "<unnamed-set>", + reg_set_p->num_registers); + + for (const uint32_t *reg_num_p = reg_set_p->registers; + *reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) { + const RegisterInfo *const reg_info_p = + reg_ctx.GetRegisterInfoAtIndex(*reg_num_p); + if (reg_info_p == nullptr) { + if (log) + log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get " + "register info for register set '%s', register index " + "%" PRIu32, + __FUNCTION__, + reg_set_p->name ? reg_set_p->name : "<unnamed-set>", + *reg_num_p); + } else if (reg_info_p->value_regs == nullptr) { + // Only expediate registers that are not contained in other registers. + RegisterValue reg_value; + Status error = reg_ctx.ReadRegister(reg_info_p, reg_value); + if (error.Success()) { + response.Printf("%.02x:", *reg_num_p); + WriteRegisterValueInHexFixedWidth(response, reg_ctx, *reg_info_p, + ®_value, lldb::eByteOrderBig); + response.PutChar(';'); + } else { if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get " - "register info for register set '%s', register index " - "%" PRIu32, + log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to read " + "register '%s' index %" PRIu32 ": %s", __FUNCTION__, - reg_set_p->name ? reg_set_p->name : "<unnamed-set>", - *reg_num_p); - } else if (reg_info_p->value_regs == nullptr) { - // Only expediate registers that are not contained in other registers. - RegisterValue 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, - ®_value, lldb::eByteOrderBig); - response.PutChar(';'); - } else { - if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to read " - "register '%s' index %" PRIu32 ": %s", - __FUNCTION__, reg_info_p->name ? reg_info_p->name - : "<unnamed-register>", - *reg_num_p, error.AsCString()); - } + reg_info_p->name ? reg_info_p->name + : "<unnamed-register>", + *reg_num_p, error.AsCString()); } } } @@ -837,6 +812,7 @@ void GDBRemoteCommunicationServerLLGS::HandleInferiorState_Exited( // We are ready to exit the debug monitor. m_exit_now = true; + m_mainloop.RequestTermination(); } void GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped( @@ -1316,12 +1292,12 @@ GDBRemoteCommunicationServerLLGS::Handle_qC(StringExtractorGDBRemote &packet) { lldb::tid_t tid = m_debugged_process_up->GetCurrentThreadID(); SetCurrentThreadID(tid); - NativeThreadProtocolSP thread_sp = m_debugged_process_up->GetCurrentThread(); - if (!thread_sp) + NativeThreadProtocol *thread = m_debugged_process_up->GetCurrentThread(); + if (!thread) return SendErrorResponse(69); StreamString response; - response.Printf("QC%" PRIx64, thread_sp->GetID()); + response.Printf("QC%" PRIx64, thread->GetID()); return SendPacketNoLock(response.GetString()); } @@ -1692,14 +1668,12 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo( return SendErrorResponse(68); // Ensure we have a thread. - NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadAtIndex(0)); - if (!thread_sp) + NativeThreadProtocol *thread = m_debugged_process_up->GetThreadAtIndex(0); + if (!thread) return SendErrorResponse(69); // Get the register context for the first thread. - NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext()); - if (!reg_context_sp) - return SendErrorResponse(69); + NativeRegisterContext ®_context = thread->GetRegisterContext(); // Parse out the register number from the request. packet.SetFilePos(strlen("qRegisterInfo")); @@ -1710,11 +1684,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo( // Return the end of registers response if we've iterated one past the end of // the register set. - if (reg_index >= reg_context_sp->GetUserRegisterCount()) + if (reg_index >= reg_context.GetUserRegisterCount()) return SendErrorResponse(69); - const RegisterInfo *reg_info = - reg_context_sp->GetRegisterInfoAtIndex(reg_index); + const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index); if (!reg_info) return SendErrorResponse(69); @@ -1796,7 +1769,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo( }; const char *const register_set_name = - reg_context_sp->GetRegisterSetNameForRegisterAtIndex(reg_index); + reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index); if (register_set_name) { response.PutCString("set:"); response.PutCString(register_set_name); @@ -1908,18 +1881,17 @@ GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo( response.PutChar('m'); LLDB_LOG(log, "starting thread iteration"); - NativeThreadProtocolSP thread_sp; + NativeThreadProtocol *thread; uint32_t thread_index; for (thread_index = 0, - thread_sp = m_debugged_process_up->GetThreadAtIndex(thread_index); - thread_sp; ++thread_index, - thread_sp = m_debugged_process_up->GetThreadAtIndex(thread_index)) { - LLDB_LOG(log, "iterated thread {0}({1}, tid={2})", thread_index, - thread_sp ? "is not null" : "null", - thread_sp ? thread_sp->GetID() : LLDB_INVALID_THREAD_ID); + thread = m_debugged_process_up->GetThreadAtIndex(thread_index); + thread; ++thread_index, + thread = m_debugged_process_up->GetThreadAtIndex(thread_index)) { + LLDB_LOG(log, "iterated thread {0}(tid={2})", thread_index, + thread->GetID()); if (thread_index > 0) response.PutChar(','); - response.Printf("%" PRIx64, thread_sp->GetID()); + response.Printf("%" PRIx64, thread->GetID()); } LLDB_LOG(log, "finished thread iteration"); @@ -1951,38 +1923,27 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) { } // Get the thread to use. - NativeThreadProtocolSP thread_sp = GetThreadFromSuffix(packet); - if (!thread_sp) { - if (log) - log->Printf( - "GDBRemoteCommunicationServerLLGS::%s failed, no thread available", - __FUNCTION__); + NativeThreadProtocol *thread = GetThreadFromSuffix(packet); + if (!thread) { + LLDB_LOG(log, "failed, no thread available"); return SendErrorResponse(0x15); } // Get the thread's register context. - NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext()); - if (!reg_context_sp) { - LLDB_LOG( - log, - "pid {0} tid {1} failed, no register context available for the thread", - m_debugged_process_up->GetID(), thread_sp->GetID()); - return SendErrorResponse(0x15); - } + NativeRegisterContext ®_context = thread->GetRegisterContext(); // Return the end of registers response if we've iterated one past the end of // the register set. - if (reg_index >= reg_context_sp->GetUserRegisterCount()) { + if (reg_index >= reg_context.GetUserRegisterCount()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested " "register %" PRIu32 " beyond register count %" PRIu32, __FUNCTION__, reg_index, - reg_context_sp->GetUserRegisterCount()); + reg_context.GetUserRegisterCount()); return SendErrorResponse(0x15); } - const RegisterInfo *reg_info = - reg_context_sp->GetRegisterInfoAtIndex(reg_index); + const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index); if (!reg_info) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested " @@ -1996,7 +1957,7 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) { // Retrieve the value RegisterValue reg_value; - Status error = reg_context_sp->ReadRegister(reg_info, reg_value); + Status error = reg_context.ReadRegister(reg_info, reg_value); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, read of " @@ -2047,24 +2008,13 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) { return SendIllFormedResponse( packet, "P packet missing '=' char after register number"); - // Get process architecture. - ArchSpec process_arch; - if (!m_debugged_process_up || - !m_debugged_process_up->GetArchitecture(process_arch)) { - if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to retrieve " - "inferior architecture", - __FUNCTION__); - return SendErrorResponse(0x49); - } - // Parse out the value. uint8_t reg_bytes[32]; // big enough to support up to 256 bit ymmN register size_t reg_size = packet.GetHexBytesAvail(reg_bytes); // Get the thread to use. - NativeThreadProtocolSP thread_sp = GetThreadFromSuffix(packet); - if (!thread_sp) { + NativeThreadProtocol *thread = GetThreadFromSuffix(packet); + if (!thread) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, no thread " "available (thread index 0)", @@ -2073,18 +2023,8 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) { } // Get the thread's register context. - NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext()); - if (!reg_context_sp) { - if (log) - log->Printf( - "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64 - " failed, no register context available for the thread", - __FUNCTION__, m_debugged_process_up->GetID(), thread_sp->GetID()); - return SendErrorResponse(0x15); - } - - const RegisterInfo *reg_info = - reg_context_sp->GetRegisterInfoAtIndex(reg_index); + NativeRegisterContext ®_context = thread->GetRegisterContext(); + const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index); if (!reg_info) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested " @@ -2095,12 +2035,11 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) { // Return the end of registers response if we've iterated one past the end of // the register set. - if (reg_index >= reg_context_sp->GetUserRegisterCount()) { + if (reg_index >= reg_context.GetUserRegisterCount()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested " "register %" PRIu32 " beyond register count %" PRIu32, - __FUNCTION__, reg_index, - reg_context_sp->GetUserRegisterCount()); + __FUNCTION__, reg_index, reg_context.GetUserRegisterCount()); return SendErrorResponse(0x47); } @@ -2115,8 +2054,10 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) { // Build the reginfos response. StreamGDBRemote response; - RegisterValue reg_value(reg_bytes, reg_size, process_arch.GetByteOrder()); - Status error = reg_context_sp->WriteRegister(reg_info, reg_value); + RegisterValue reg_value( + reg_bytes, reg_size, + m_debugged_process_up->GetArchitecture().GetByteOrder()); + Status error = reg_context.WriteRegister(reg_info, reg_value); if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, write of " @@ -2177,8 +2118,8 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) { // Ensure we have the given thread when not specifying -1 (all threads) or 0 // (any thread). if (tid != LLDB_INVALID_THREAD_ID && tid != 0) { - NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadByID(tid)); - if (!thread_sp) { + NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + if (!thread) { if (log) log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64 " not found", @@ -2739,8 +2680,8 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) { // Double check that we have such a thread. // TODO investigate: on MacOSX we might need to do an UpdateThreads () here. - NativeThreadProtocolSP thread_sp = m_debugged_process_up->GetThreadByID(tid); - if (!thread_sp || thread_sp->GetID() != tid) + NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid); + if (!thread) return SendErrorResponse(0x33); // Create the step action for the given thread. @@ -2865,8 +2806,8 @@ GDBRemoteCommunicationServerLLGS::Handle_QSaveRegisterState( packet.SetFilePos(strlen("QSaveRegisterState")); // Get the thread to use. - NativeThreadProtocolSP thread_sp = GetThreadFromSuffix(packet); - if (!thread_sp) { + NativeThreadProtocol *thread = GetThreadFromSuffix(packet); + if (!thread) { if (m_thread_suffix_supported) return SendIllFormedResponse( packet, "No thread specified in QSaveRegisterState packet"); @@ -2876,18 +2817,11 @@ GDBRemoteCommunicationServerLLGS::Handle_QSaveRegisterState( } // Grab the register context for the thread. - NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext()); - if (!reg_context_sp) { - LLDB_LOG( - log, - "pid {0} tid {1} failed, no register context available for the thread", - m_debugged_process_up->GetID(), thread_sp->GetID()); - return SendErrorResponse(0x15); - } + NativeRegisterContext& reg_context = thread->GetRegisterContext(); // Save registers to a buffer. DataBufferSP register_data_sp; - Status error = reg_context_sp->ReadAllRegisterValues(register_data_sp); + Status error = reg_context.ReadAllRegisterValues(register_data_sp); if (error.Fail()) { LLDB_LOG(log, "pid {0} failed to save all register values: {1}", m_debugged_process_up->GetID(), error); @@ -2930,8 +2864,8 @@ GDBRemoteCommunicationServerLLGS::Handle_QRestoreRegisterState( } // Get the thread to use. - NativeThreadProtocolSP thread_sp = GetThreadFromSuffix(packet); - if (!thread_sp) { + NativeThreadProtocol *thread = GetThreadFromSuffix(packet); + if (!thread) { if (m_thread_suffix_supported) return SendIllFormedResponse( packet, "No thread specified in QRestoreRegisterState packet"); @@ -2941,14 +2875,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QRestoreRegisterState( } // Grab the register context for the thread. - NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext()); - if (!reg_context_sp) { - LLDB_LOG( - log, - "pid {0} tid {1} failed, no register context available for the thread", - m_debugged_process_up->GetID(), thread_sp->GetID()); - return SendErrorResponse(0x15); - } + NativeRegisterContext ®_context = thread->GetRegisterContext(); // Retrieve register state buffer, then remove from the list. DataBufferSP register_data_sp; @@ -2969,7 +2896,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QRestoreRegisterState( m_saved_registers_map.erase(it); } - Status error = reg_context_sp->WriteAllRegisterValues(register_data_sp); + Status error = reg_context.WriteAllRegisterValues(register_data_sp); if (error.Fail()) { LLDB_LOG(log, "pid {0} failed to restore all register values: {1}", m_debugged_process_up->GetID(), error); @@ -3219,14 +3146,12 @@ void GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection() { } } -NativeThreadProtocolSP GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix( +NativeThreadProtocol *GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix( StringExtractorGDBRemote &packet) { - NativeThreadProtocolSP thread_sp; - // We have no thread if we don't have a process. if (!m_debugged_process_up || m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID) - return thread_sp; + return nullptr; // If the client hasn't asked for thread suffix support, there will not be a // thread suffix. @@ -3234,7 +3159,7 @@ NativeThreadProtocolSP GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix( if (!m_thread_suffix_supported) { const lldb::tid_t current_tid = GetCurrentThreadID(); if (current_tid == LLDB_INVALID_THREAD_ID) - return thread_sp; + return nullptr; else if (current_tid == 0) { // Pick a thread. return m_debugged_process_up->GetThreadAtIndex(0); @@ -3251,11 +3176,11 @@ NativeThreadProtocolSP GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix( "error: expected ';' prior to start of thread suffix: packet " "contents = '%s'", __FUNCTION__, packet.GetStringRef().c_str()); - return thread_sp; + return nullptr; } if (!packet.GetBytesLeft()) - return thread_sp; + return nullptr; // Parse out thread: portion. if (strncmp(packet.Peek(), "thread:", strlen("thread:")) != 0) { @@ -3264,14 +3189,14 @@ NativeThreadProtocolSP GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix( "error: expected 'thread:' but not found, packet contents = " "'%s'", __FUNCTION__, packet.GetStringRef().c_str()); - return thread_sp; + return nullptr; } packet.SetFilePos(packet.GetFilePos() + strlen("thread:")); const lldb::tid_t tid = packet.GetHexMaxU64(false, 0); if (tid != 0) return m_debugged_process_up->GetThreadByID(tid); - return thread_sp; + return nullptr; } lldb::tid_t GDBRemoteCommunicationServerLLGS::GetCurrentThreadID() const { diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index 71199473bb8ed..5a74d1acaa237 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -43,32 +43,7 @@ public: MainLoop &mainloop, const NativeProcessProtocol::Factory &process_factory); - //------------------------------------------------------------------ - /// Specify the program to launch and its arguments. - /// - /// @param[in] args - /// The command line to launch. - /// - /// @param[in] argc - /// The number of elements in the args array of cstring pointers. - /// - /// @return - /// An Status object indicating the success or failure of making - /// the setting. - //------------------------------------------------------------------ - Status SetLaunchArguments(const char *const args[], int argc); - - //------------------------------------------------------------------ - /// Specify the launch flags for the process. - /// - /// @param[in] launch_flags - /// The launch flags to use when launching this process. - /// - /// @return - /// An Status object indicating the success or failure of making - /// the setting. - //------------------------------------------------------------------ - Status SetLaunchFlags(unsigned int launch_flags); + void SetLaunchInfo(const ProcessLaunchInfo &info); //------------------------------------------------------------------ /// Launch a process with the current launch settings. @@ -234,7 +209,7 @@ private: void HandleInferiorState_Stopped(NativeProcessProtocol *process); - NativeThreadProtocolSP GetThreadFromSuffix(StringExtractorGDBRemote &packet); + NativeThreadProtocol *GetThreadFromSuffix(StringExtractorGDBRemote &packet); uint32_t GetNextSavedRegistersID(); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 977c34c2a69b3..04ed9d704e137 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -128,8 +128,9 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( llvm::StringRef platform_ip; int platform_port; llvm::StringRef platform_path; - bool ok = UriParser::Parse(GetConnection()->GetURI(), platform_scheme, - platform_ip, platform_port, platform_path); + std::string platform_uri = GetConnection()->GetURI(); + bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip, + platform_port, platform_path); UNUSED_IF_ASSERT_DISABLED(ok); assert(ok); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 612c7144451e0..e418deee01f3d 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -178,7 +178,7 @@ bool GDBRemoteRegisterContext::GetPrimordialRegister( const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm) { const uint32_t lldb_reg = reg_info->kinds[eRegisterKindLLDB]; const uint32_t remote_reg = reg_info->kinds[eRegisterKindProcessPlugin]; - StringExtractorGDBRemote response; + if (DataBufferSP buffer_sp = gdb_comm.ReadRegister(m_thread.GetProtocolID(), remote_reg)) return PrivateSetRegisterValue( diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index be11dd9bc7ec7..35d02c15ab85b 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -29,7 +29,6 @@ #include <sstream> #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -244,7 +243,7 @@ bool ProcessGDBRemote::CanDebug(lldb::TargetSP target_sp, //---------------------------------------------------------------------- ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, ListenerSP listener_sp) - : Process(target_sp, listener_sp), m_flags(0), m_gdb_comm(), + : Process(target_sp, listener_sp), m_debugserver_pid(LLDB_INVALID_PROCESS_ID), m_last_stop_packet_mutex(), m_register_info(), m_async_broadcaster(NULL, "lldb.process.gdb-remote.async-broadcaster"), @@ -818,7 +817,7 @@ Status ProcessGDBRemote::DoLaunch(Module *exe_module, if (object_file) { error = EstablishConnectionIfNeeded(launch_info); if (error.Success()) { - lldb_utility::PseudoTerminal pty; + PseudoTerminal pty; const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0; PlatformSP platform_sp(GetTarget().GetPlatform()); @@ -947,8 +946,7 @@ Status ProcessGDBRemote::DoLaunch(Module *exe_module, SetPrivateState(SetThreadStopInfo(response)); if (!disable_stdio) { - if (pty.GetMasterFileDescriptor() != - lldb_utility::PseudoTerminal::invalid_fd) + if (pty.GetMasterFileDescriptor() != PseudoTerminal::invalid_fd) SetSTDIOFileDescriptor(pty.ReleaseMasterFileDescriptor()); } } @@ -3255,7 +3253,6 @@ Status ProcessGDBRemote::DisableWatchpoint(Watchpoint *wp, bool notify) { } void ProcessGDBRemote::Clear() { - m_flags = 0; m_thread_list_real.Clear(); m_thread_list.Clear(); } @@ -3289,7 +3286,7 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { } return error; } -#if defined(__APPLE__) +#if !defined(_WIN32) #define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1 #endif @@ -3333,8 +3330,8 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver( lldb_utility::CleanUp<int, int> our_socket(-1, -1, close); lldb_utility::CleanUp<int, int> gdb_socket(-1, -1, close); - // Use a socketpair on Apple for now until other platforms can verify it - // works and is fast enough + // Use a socketpair on non-Windows systems for security and performance + // reasons. { int sockets[2]; /* the pair of socket descriptors */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == -1) { @@ -4168,7 +4165,6 @@ struct GdbServerTargetInfo { std::string osabi; stringVec includes; RegisterSetMap reg_set_map; - XMLNode feature_node; }; bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, @@ -4374,8 +4370,8 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { XMLNode target_node = xml_document.GetRootElement("target"); if (target_node) { - XMLNode feature_node; - target_node.ForEachChildElement([&target_info, &feature_node]( + std::vector<XMLNode> feature_nodes; + target_node.ForEachChildElement([&target_info, &feature_nodes]( const XMLNode &node) -> bool { llvm::StringRef name = node.GetName(); if (name == "architecture") { @@ -4387,7 +4383,7 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { if (!href.empty()) target_info.includes.push_back(href.str()); } else if (name == "feature") { - feature_node = node; + feature_nodes.push_back(node); } else if (name == "groups") { node.ForEachChildElementWithName( "group", [&target_info](const XMLNode &node) -> bool { @@ -4423,7 +4419,7 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { // set the Target's architecture yet, so the ABI is also potentially // incorrect. ABISP abi_to_use_sp = ABI::FindPlugin(shared_from_this(), arch_to_use); - if (feature_node) { + for (auto &feature_node : feature_nodes) { ParseRegisters(feature_node, target_info, this->m_register_info, abi_to_use_sp, cur_reg_num, reg_offset); } diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 54a472d7332e0..42d1c4ecd6663 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -18,9 +18,6 @@ #include <string> #include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/ArchSpec.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/ModuleSpec.h" @@ -28,6 +25,7 @@ #include "lldb/Host/HostThread.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamGDBRemote.h" @@ -263,7 +261,6 @@ protected: eBroadcastBitAsyncThreadDidExit = (1 << 2) }; - Flags m_flags; // Process specific flags (see eFlags enums) GDBRemoteCommunicationClient m_gdb_comm; std::atomic<lldb::pid_t> m_debugserver_pid; std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet @@ -324,10 +321,6 @@ protected: void Clear(); - Flags &GetFlags() { return m_flags; } - - const Flags &GetFlags() const { return m_flags; } - bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 5197e8f9adfcc..27dd03bfc7bc5 100644 --- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -10,7 +10,6 @@ #include "ThreadGDBRemote.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/ArchSpec.h" #include "lldb/Core/State.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" |