summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-07-04 01:02:43 +0000
committeremaste <emaste@FreeBSD.org>2015-07-04 01:02:43 +0000
commitcea4c167517a0678c7dbf92a0324088dcbac1035 (patch)
tree02de7f7c9d5a08ae1c4d3b4c98a565ff96cd52e6 /contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
parent1756896fd2b99ede7ebeb8019d4004bdfeed3bbe (diff)
parent8037fa4ee916fa20b3c63cbf531f4ee7e1c76138 (diff)
downloadFreeBSD-src-cea4c167517a0678c7dbf92a0324088dcbac1035.zip
FreeBSD-src-cea4c167517a0678c7dbf92a0324088dcbac1035.tar.gz
Update LLDB snapshot to upstream r241361
Notable upstream commits (upstream revision in parens): - Add a JSON producer to LLDB (228636) - Don't crash on bad DWARF expression (228729) - Add support of DWARFv3 DW_OP_form_tls_address (231342) - Assembly profiler for MIPS64 (232619) - Handle FreeBSD/arm64 core files (233273) - Read/Write register for MIPS64 (233685) - Rework LLDB system initialization (233758) - SysV ABI for aarch64 (236098) - MIPS software single stepping (236696) - FreeBSD/arm live debugging support (237303) - Assembly profiler for mips32 (237420) - Parse function name from DWARF DW_AT_abstract_origin (238307) - Improve LLDB prompt handling (238313) - Add real time signals support to FreeBSDSignals (238316) - Fix race in IOHandlerProcessSTDIO (238423) - MIPS64 Branch instruction emulation for SW single stepping (238820) - Improve OSType initialization in elf object file's arch_spec (239148) - Emulation of MIPS64 floating-point branch instructions (239996) - ABI Plugin for MIPS32 (239997) - ABI Plugin for MIPS64 (240123) - MIPS32 branch emulation and single stepping (240373) - Improve instruction emulation based stack unwinding on ARM (240533) - Add branch emulation to aarch64 instruction emulator (240769)
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h')
-rw-r--r--contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h137
1 files changed, 113 insertions, 24 deletions
diff --git a/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index ac203a6..7379bb3 100644
--- a/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -14,6 +14,7 @@
// C++ Includes
#include <list>
#include <string>
+#include <queue>
// Other libraries and framework includes
// Project includes
@@ -27,16 +28,46 @@
#include "Utility/StringExtractorGDBRemote.h"
+namespace lldb_private {
+namespace process_gdb_remote {
+
+typedef enum
+{
+ eStoppointInvalid = -1,
+ eBreakpointSoftware = 0,
+ eBreakpointHardware,
+ eWatchpointWrite,
+ eWatchpointRead,
+ eWatchpointReadWrite
+} GDBStoppointType;
+
+enum class CompressionType
+{
+ None = 0, // no compression
+ ZlibDeflate, // zlib's deflate compression scheme, requires zlib or Apple's libcompression
+ LZFSE, // an Apple compression scheme, requires Apple's libcompression
+ LZ4, // lz compression - called "lz4 raw" in libcompression terms, compat with https://code.google.com/p/lz4/
+ LZMA, // Lempel–Ziv–Markov chain algorithm
+};
+
class ProcessGDBRemote;
-class GDBRemoteCommunication : public lldb_private::Communication
+class GDBRemoteCommunication : public Communication
{
public:
enum
{
- eBroadcastBitRunPacketSent = kLoUserBroadcastBit
+ eBroadcastBitRunPacketSent = kLoUserBroadcastBit,
+ eBroadcastBitGdbReadThreadGotNotify = kLoUserBroadcastBit << 1 // Sent when we received a notify packet.
};
-
+
+ enum class PacketType
+ {
+ Invalid = 0,
+ Standard,
+ Notify
+ };
+
enum class PacketResult
{
Success = 0, // Success
@@ -49,12 +80,25 @@ public:
ErrorDisconnected, // We were disconnected
ErrorNoSequenceLock // We couldn't get the sequence lock for a multi-packet request
};
+
+ // Class to change the timeout for a given scope and restore it to the original value when the
+ // created ScopedTimeout object got out of scope
+ class ScopedTimeout
+ {
+ public:
+ ScopedTimeout (GDBRemoteCommunication& gdb_comm, uint32_t timeout);
+ ~ScopedTimeout ();
+
+ private:
+ GDBRemoteCommunication& m_gdb_comm;
+ uint32_t m_saved_timeout;
+ };
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
GDBRemoteCommunication(const char *comm_name,
- const char *listener_name,
- bool is_platform);
+ const char *listener_name);
virtual
~GDBRemoteCommunication();
@@ -73,9 +117,9 @@ public:
size_t payload_length);
bool
- GetSequenceMutex (lldb_private::Mutex::Locker& locker, const char *failure_message = NULL);
+ GetSequenceMutex (Mutex::Locker& locker, const char *failure_message = NULL);
- bool
+ PacketType
CheckForPacket (const uint8_t *src,
size_t src_len,
StringExtractorGDBRemote &packet);
@@ -116,20 +160,20 @@ public:
uint32_t
GetPacketTimeoutInMicroSeconds () const
{
- return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec;
+ return m_packet_timeout * TimeValue::MicroSecPerSec;
}
//------------------------------------------------------------------
// Start a debugserver instance on the current host using the
// supplied connection URL.
//------------------------------------------------------------------
- lldb_private::Error
+ Error
StartDebugserverProcess (const char *hostname,
uint16_t in_port, // If set to zero, then out_port will contain the bound port on exit
- lldb_private::ProcessLaunchInfo &launch_info,
+ ProcessLaunchInfo &launch_info,
uint16_t &out_port);
void
- DumpHistory(lldb_private::Stream &strm);
+ DumpHistory(Stream &strm);
protected:
@@ -186,10 +230,10 @@ protected:
uint32_t bytes_transmitted);
void
- Dump (lldb_private::Stream &strm) const;
+ Dump (Stream &strm) const;
void
- Dump (lldb_private::Log *log) const;
+ Dump (Log *log) const;
bool
DidDumpToLog () const
@@ -247,33 +291,59 @@ protected:
size_t payload_length);
PacketResult
+ ReadPacket (StringExtractorGDBRemote &response, uint32_t timeout_usec, bool sync_on_timeout);
+
+ // Pop a packet from the queue in a thread safe manner
+ PacketResult
+ PopPacketFromQueue (StringExtractorGDBRemote &response, uint32_t timeout_usec);
+
+ PacketResult
WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &response,
- uint32_t timeout_usec);
+ uint32_t timeout_usec,
+ bool sync_on_timeout);
bool
- WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr);
+ WaitForNotRunningPrivate (const TimeValue *timeout_ptr);
+
+ bool
+ CompressionIsEnabled ()
+ {
+ return m_compression_type != CompressionType::None;
+ }
+
+ // If compression is enabled, decompress the packet in m_bytes and update
+ // m_bytes with the uncompressed version.
+ // Returns 'true' packet was decompressed and m_bytes is the now-decompressed text.
+ // Returns 'false' if unable to decompress or if the checksum was invalid.
+ //
+ // NB: Once the packet has been decompressed, checksum cannot be computed based
+ // on m_bytes. The checksum was for the compressed packet.
+ bool
+ DecompressPacket ();
//------------------------------------------------------------------
// Classes that inherit from GDBRemoteCommunication can see and modify these
//------------------------------------------------------------------
uint32_t m_packet_timeout;
+ uint32_t m_echo_number;
+ LazyBool m_supports_qEcho;
#ifdef ENABLE_MUTEX_ERROR_CHECKING
- lldb_private::TrackingMutex m_sequence_mutex;
+ TrackingMutex m_sequence_mutex;
#else
- lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
+ Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
#endif
- lldb_private::Predicate<bool> m_public_is_running;
- lldb_private::Predicate<bool> m_private_is_running;
+ Predicate<bool> m_public_is_running;
+ Predicate<bool> m_private_is_running;
History m_history;
bool m_send_acks;
bool m_is_platform; // Set to true if this class represents a platform,
// false if this class represents a debug session for
// a single process
+ CompressionType m_compression_type;
- lldb_private::Error
- StartListenThread (const char *hostname = "127.0.0.1",
- uint16_t port = 0);
+ Error
+ StartListenThread (const char *hostname = "127.0.0.1", uint16_t port = 0);
bool
JoinListenThread ();
@@ -281,10 +351,26 @@ protected:
static lldb::thread_result_t
ListenThread (lldb::thread_arg_t arg);
+ // GDB-Remote read thread
+ // . this thread constantly tries to read from the communication
+ // class and stores all packets received in a queue. The usual
+ // threads read requests simply pop packets off the queue in the
+ // usual order.
+ // This setup allows us to intercept and handle async packets, such
+ // as the notify packet.
+
+ // This method is defined as part of communication.h
+ // when the read thread gets any bytes it will pass them on to this function
+ virtual void AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, lldb::ConnectionStatus status);
+
private:
- lldb_private::HostThread m_listen_thread;
+
+ std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue
+ lldb_private::Mutex m_packet_queue_mutex; // Mutex for accessing queue
+ Condition m_condition_queue_not_empty; // Condition variable to wait for packets
+
+ HostThread m_listen_thread;
std::string m_listen_url;
-
//------------------------------------------------------------------
// For GDBRemoteCommunication only
@@ -292,4 +378,7 @@ private:
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication);
};
+} // namespace process_gdb_remote
+} // namespace lldb_private
+
#endif // liblldb_GDBRemoteCommunication_h_
OpenPOWER on IntegriCloud