diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp | 157 |
1 files changed, 71 insertions, 86 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 58cb776..8ccab36 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -25,114 +25,99 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_gdb_remote; -GDBRemoteCommunicationServer::GDBRemoteCommunicationServer(const char *comm_name, - const char *listener_name) : - GDBRemoteCommunication (comm_name, listener_name), - m_exit_now (false) -{ -} +GDBRemoteCommunicationServer::GDBRemoteCommunicationServer( + const char *comm_name, const char *listener_name) + : GDBRemoteCommunication(comm_name, listener_name), m_exit_now(false) {} -GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer() -{ -} +GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer() {} void GDBRemoteCommunicationServer::RegisterPacketHandler( - StringExtractorGDBRemote::ServerPacketType packet_type, - PacketHandler handler) -{ - m_packet_handlers[packet_type] = std::move(handler); + StringExtractorGDBRemote::ServerPacketType packet_type, + PacketHandler handler) { + m_packet_handlers[packet_type] = std::move(handler); } GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServer::GetPacketAndSendResponse (uint32_t timeout_usec, - Error &error, - bool &interrupt, - bool &quit) -{ - StringExtractorGDBRemote packet; - - PacketResult packet_result = WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec, false); - if (packet_result == PacketResult::Success) - { - const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType (); - switch (packet_type) - { - case StringExtractorGDBRemote::eServerPacketType_nack: - case StringExtractorGDBRemote::eServerPacketType_ack: - break; - - case StringExtractorGDBRemote::eServerPacketType_invalid: - error.SetErrorString("invalid packet"); - quit = true; - break; - - case StringExtractorGDBRemote::eServerPacketType_unimplemented: - packet_result = SendUnimplementedResponse (packet.GetStringRef().c_str()); - break; - - default: - auto handler_it = m_packet_handlers.find(packet_type); - if (handler_it == m_packet_handlers.end()) - packet_result = SendUnimplementedResponse (packet.GetStringRef().c_str()); - else - packet_result = handler_it->second (packet, error, interrupt, quit); - break; - } +GDBRemoteCommunicationServer::GetPacketAndSendResponse(uint32_t timeout_usec, + Error &error, + bool &interrupt, + bool &quit) { + StringExtractorGDBRemote packet; + + PacketResult packet_result = + WaitForPacketWithTimeoutMicroSecondsNoLock(packet, timeout_usec, false); + if (packet_result == PacketResult::Success) { + const StringExtractorGDBRemote::ServerPacketType packet_type = + packet.GetServerPacketType(); + switch (packet_type) { + case StringExtractorGDBRemote::eServerPacketType_nack: + case StringExtractorGDBRemote::eServerPacketType_ack: + break; + + case StringExtractorGDBRemote::eServerPacketType_invalid: + error.SetErrorString("invalid packet"); + quit = true; + break; + + case StringExtractorGDBRemote::eServerPacketType_unimplemented: + packet_result = SendUnimplementedResponse(packet.GetStringRef().c_str()); + break; + + default: + auto handler_it = m_packet_handlers.find(packet_type); + if (handler_it == m_packet_handlers.end()) + packet_result = + SendUnimplementedResponse(packet.GetStringRef().c_str()); + else + packet_result = handler_it->second(packet, error, interrupt, quit); + break; } - else - { - if (!IsConnected()) - { - error.SetErrorString("lost connection"); - quit = true; - } - else - { - error.SetErrorString("timeout"); - } + } else { + if (!IsConnected()) { + error.SetErrorString("lost connection"); + quit = true; + } else { + error.SetErrorString("timeout"); } + } - // Check if anything occurred that would force us to want to exit. - if (m_exit_now) - quit = true; + // Check if anything occurred that would force us to want to exit. + if (m_exit_now) + quit = true; - return packet_result; + return packet_result; } GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServer::SendUnimplementedResponse (const char *) -{ - // TODO: Log the packet we aren't handling... - return SendPacketNoLock (""); +GDBRemoteCommunicationServer::SendUnimplementedResponse(const char *) { + // TODO: Log the packet we aren't handling... + return SendPacketNoLock(""); } - GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServer::SendErrorResponse (uint8_t err) -{ - char packet[16]; - int packet_len = ::snprintf (packet, sizeof(packet), "E%2.2x", err); - assert (packet_len < (int)sizeof(packet)); - return SendPacketNoLock (llvm::StringRef(packet, packet_len)); +GDBRemoteCommunicationServer::SendErrorResponse(uint8_t err) { + char packet[16]; + int packet_len = ::snprintf(packet, sizeof(packet), "E%2.2x", err); + assert(packet_len < (int)sizeof(packet)); + return SendPacketNoLock(llvm::StringRef(packet, packet_len)); } GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServer::SendIllFormedResponse (const StringExtractorGDBRemote &failed_packet, const char *message) -{ - Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); - if (log) - log->Printf ("GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)", __FUNCTION__, failed_packet.GetStringRef ().c_str (), message ? message : ""); - return SendErrorResponse (0x03); +GDBRemoteCommunicationServer::SendIllFormedResponse( + const StringExtractorGDBRemote &failed_packet, const char *message) { + Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + if (log) + log->Printf("GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)", + __FUNCTION__, failed_packet.GetStringRef().c_str(), + message ? message : ""); + return SendErrorResponse(0x03); } GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServer::SendOKResponse () -{ - return SendPacketNoLock ("OK"); +GDBRemoteCommunicationServer::SendOKResponse() { + return SendPacketNoLock("OK"); } -bool -GDBRemoteCommunicationServer::HandshakeWithClient() -{ - return GetAck() == PacketResult::Success; +bool GDBRemoteCommunicationServer::HandshakeWithClient() { + return GetAck() == PacketResult::Success; } |