Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
//===-- GDBRemoteCommunication.h --------------------------------*- C++ -*-===// | //===-- GDBRemoteCommunication.h --------------------------------*- C++ -*-===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H | #ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H | ||||
#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H | #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H | ||||
#include "GDBRemoteCommunicationHistory.h" | #include "GDBRemoteCommunicationHistory.h" | ||||
#include <condition_variable> | #include <condition_variable> | ||||
#include <deque> | |||||
#include <future> | #include <future> | ||||
#include <mutex> | #include <mutex> | ||||
#include <queue> | #include <queue> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
#include "lldb/Core/Communication.h" | #include "lldb/Core/Communication.h" | ||||
#include "lldb/Host/Config.h" | #include "lldb/Host/Config.h" | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
public: | public: | ||||
enum { | enum { | ||||
eBroadcastBitRunPacketSent = kLoUserBroadcastBit, | eBroadcastBitRunPacketSent = kLoUserBroadcastBit, | ||||
}; | }; | ||||
enum class PacketType { Invalid = 0, Standard, Notify }; | enum class PacketType { Invalid = 0, Standard, Notify }; | ||||
enum class PacketResult { | enum class PacketResult { | ||||
Success = 0, // Success | Success = 0, // Success | ||||
ErrorSendFailed, // Status sending the packet | ErrorSendFailed, // Status sending the packet | ||||
ErrorSendAck, // Didn't get an ack back after sending a packet | ErrorSendAck, // Didn't get an ack back after sending a packet | ||||
ErrorReplyFailed, // Status getting the reply | ErrorReplyFailed, // Status getting the reply | ||||
ErrorReplyTimeout, // Timed out waiting for reply | ErrorReplyTimeout, // Timed out waiting for reply | ||||
ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that | ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that | ||||
// was sent | // was sent | ||||
ErrorReplyAck, // Sending reply ack failed | ErrorReplyAck, // Sending reply ack failed | ||||
ErrorDisconnected, // We were disconnected | ErrorDisconnected, // We were disconnected | ||||
ErrorNoSequenceLock // We couldn't get the sequence lock for a multi-packet | ErrorNoSequenceLock, // We couldn't get the sequence lock for a multi-packet | ||||
// request | // request | ||||
Notify, // Successfully gotten a notification packet | |||||
}; | }; | ||||
// Class to change the timeout for a given scope and restore it to the | // Class to change the timeout for a given scope and restore it to the | ||||
// original value when the | // original value when the | ||||
// created ScopedTimeout object got out of scope | // created ScopedTimeout object got out of scope | ||||
class ScopedTimeout { | class ScopedTimeout { | ||||
public: | public: | ||||
ScopedTimeout(GDBRemoteCommunication &gdb_comm, | ScopedTimeout(GDBRemoteCommunication &gdb_comm, | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | protected: | ||||
std::chrono::seconds m_packet_timeout; | std::chrono::seconds m_packet_timeout; | ||||
uint32_t m_echo_number; | uint32_t m_echo_number; | ||||
LazyBool m_supports_qEcho; | LazyBool m_supports_qEcho; | ||||
GDBRemoteCommunicationHistory m_history; | GDBRemoteCommunicationHistory m_history; | ||||
bool m_send_acks; | bool m_send_acks; | ||||
bool m_is_platform; // Set to true if this class represents a platform, | bool m_is_platform; // Set to true if this class represents a platform, | ||||
// false if this class represents a debug session for | // false if this class represents a debug session for | ||||
// a single process | // a single process | ||||
std::deque<std::string> m_notification_packet_queue; | |||||
CompressionType m_compression_type; | CompressionType m_compression_type; | ||||
PacketResult SendPacketNoLock(llvm::StringRef payload); | PacketResult SendPacketNoLock(llvm::StringRef payload); | ||||
PacketResult SendNotificationPacketNoLock(llvm::StringRef notify_type, | PacketResult SendNotificationPacketNoLock(llvm::StringRef notify_type, | ||||
std::deque<std::string>& queue, | std::deque<std::string>& queue, | ||||
llvm::StringRef payload); | llvm::StringRef payload); | ||||
PacketResult SendRawPacketNoLock(llvm::StringRef payload, | PacketResult SendRawPacketNoLock(llvm::StringRef payload, | ||||
bool skip_ack = false); | bool skip_ack = false); | ||||
PacketResult ReadPacket(StringExtractorGDBRemote &response, | PacketResult ReadPacket(StringExtractorGDBRemote &response, | ||||
Timeout<std::micro> timeout, bool sync_on_timeout); | Timeout<std::micro> timeout, bool sync_on_timeout, | ||||
bool allow_notification = false); | |||||
PacketResult ReadPacketWithOutputSupport( | PacketResult ReadPacketWithOutputSupport( | ||||
StringExtractorGDBRemote &response, Timeout<std::micro> timeout, | StringExtractorGDBRemote &response, Timeout<std::micro> timeout, | ||||
bool sync_on_timeout, | bool sync_on_timeout, | ||||
llvm::function_ref<void(llvm::StringRef)> output_callback); | llvm::function_ref<void(llvm::StringRef)> output_callback); | ||||
PacketResult WaitForPacketNoLock(StringExtractorGDBRemote &response, | PacketResult WaitForPacketNoLock(StringExtractorGDBRemote &response, | ||||
Timeout<std::micro> timeout, | Timeout<std::micro> timeout, | ||||
bool sync_on_timeout); | bool sync_on_timeout, | ||||
bool allow_notification = false); | |||||
bool CompressionIsEnabled() { | bool CompressionIsEnabled() { | ||||
return m_compression_type != CompressionType::None; | return m_compression_type != CompressionType::None; | ||||
} | } | ||||
// If compression is enabled, decompress the packet in m_bytes and update | // If compression is enabled, decompress the packet in m_bytes and update | ||||
// m_bytes with the uncompressed version. | // m_bytes with the uncompressed version. | ||||
// Returns 'true' packet was decompressed and m_bytes is the now-decompressed | // Returns 'true' packet was decompressed and m_bytes is the now-decompressed | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |